@import url("./fonts.css");

/* ---- Design tokens, lifted verbatim from the Afippi design-system bundle ---- */
:root {
  --background: #fafbfc;
  --foreground: #0a0a0a;
  --card: #fff;
  --card-foreground: #0a0a0a;
  --primary: #171717;
  --primary-foreground: #fafafa;
  --secondary: #f5f5f5;
  --secondary-foreground: #171717;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --accent: #f5f5f5;
  --accent-foreground: #171717;
  --destructive: #ef4444;
  /* #ef4444 is 3.6:1 on the background: fine for dots and rules, too light for text. */
  --destructive-ink: #b91c1c;
  --border: #e5e5e5;
  --ring: #0a0a0a;
  --radius: .5rem;
  --brand-primary: #2563eb;
  --brand-primary-foreground: #f8fafc;
  --brand-secondary: #9455d3;

  /* The one darkened grey for small labels and secondary prose. The raw
     --muted-foreground (#737373) misses AA below 16px, and every page had
     independently darkened it to a slightly different value. */
  --quiet: #5c5c5c;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Geist Variable', system-ui, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary); text-underline-offset: 3px; }
a:hover { color: var(--brand-secondary); }

img { max-width: 100%; }

:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: 0.75rem; top: -3rem; z-index: 50;
  background: var(--card); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.5rem 0.875rem; text-decoration: none;
  transition: top 140ms ease;
}
.skip-link:focus { top: 0.75rem; }

/* ---- shadcn-shaped primitives the design imports from the DS bundle ---- */
.ui-card {
  background: var(--card); color: var(--card-foreground);
  display: flex; flex-direction: column; gap: 1.5rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + .25rem);
  padding-block: 1.5rem;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05);
}
.ui-card-header { display: grid; gap: 0.375rem; padding-inline: 1.5rem; }
.ui-card-title { font-weight: 600; line-height: 1; }
.ui-card-description { color: var(--muted-foreground); font-size: 0.875rem; }
.ui-card-content { padding-inline: 1.5rem; }

.ui-separator {
  display: block; width: 100%; height: 1px;
  background: var(--border); border: 0; flex: none;
}

.ui-avatar {
  position: relative; display: flex; flex: none;
  width: 2rem; height: 2rem; overflow: hidden; border-radius: 50%;
}
.ui-avatar-fallback {
  background: var(--muted); display: flex; width: 100%; height: 100%;
  align-items: center; justify-content: center;
  border-radius: 50%; font-size: 0.8125rem; font-weight: 500;
}

.ui-button {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.375rem; white-space: nowrap;
  height: 2rem; padding-inline: 0.75rem;
  border-radius: calc(var(--radius) - .125rem);
  font: inherit; font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.ui-button-ghost { border: 1px solid transparent; background: transparent; color: var(--foreground); }
.ui-button-outline { border: 1px solid var(--border); background: var(--background); color: var(--foreground); box-shadow: 0 1px 2px rgb(0 0 0 / 0.04); }
.ui-button-ghost:hover, .ui-button-outline:hover { background: var(--accent); color: var(--accent-foreground); }

.ui-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: fit-content; gap: 0.25rem; white-space: nowrap;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - .125rem);
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem; font-weight: 500;
}
.ui-badge-default { background: var(--primary); color: var(--primary-foreground); }
.ui-badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }

.ui-tabs-list {
  display: inline-flex; width: fit-content; height: 2.25rem;
  align-items: center; justify-content: center;
  background: var(--muted); color: var(--muted-foreground);
  border-radius: calc(var(--radius) + .125rem); padding: 3px;
}
.ui-tabs-trigger {
  display: inline-flex; flex: 1 1 auto;
  align-items: center; justify-content: center; gap: 0.375rem;
  height: calc(100% - 1px); padding: 0.25rem 0.75rem;
  border: 1px solid transparent; border-radius: calc(var(--radius) - .125rem);
  background: transparent; color: inherit;
  font: inherit; font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.ui-tabs-trigger[aria-selected="true"] {
  background: var(--background); color: var(--foreground);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}
[role="tabpanel"][hidden] { display: none; }

/* ---- Site chrome ---- */
.site-nav { position: sticky; top: 0; z-index: 20; }
.site-nav__bar { position: relative; isolation: isolate; border-bottom: 1px solid var(--border); }
/* The blur lives on a pseudo-element: backdrop-filter on an ancestor would
   become the containing block of the fixed scrim and the mobile sheet. */
.site-nav__bar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
}
/* 1fr | auto | 1fr keeps the menu on the page's centre line whatever the
   logo and the controls weigh. */
.site-nav__inner {
  max-width: 74rem; margin: 0 auto;
  padding: 0 clamp(1.25rem, 5vw, 3rem);
  height: 3.5rem;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
}
.site-nav__logo { display: flex; align-items: center; justify-self: start; width: 5.75rem; min-height: 2.75rem; color: var(--foreground); }
.site-nav__menu { display: flex; align-items: stretch; height: 100%; gap: 1.75rem; }
.site-nav__end { grid-column: 3; justify-self: end; display: flex; align-items: center; margin-right: -0.625rem; }
.site-nav__trigger {
  display: inline-flex; align-items: center; gap: 0.375rem; height: 100%;
  cursor: pointer; font: inherit; font-size: 0.875rem; font-weight: 500;
  padding: 0; border: 0; background: transparent; text-decoration: none;
  color: var(--foreground);
  transition: color 140ms ease, box-shadow 140ms ease;
}
.site-nav__trigger:hover,
.site-nav__trigger[aria-expanded="true"] { color: var(--brand-primary); }
/* The section the reader is in carries a bar on the header's rule. */
.site-nav__trigger[data-here="true"] { box-shadow: inset 0 -2px 0 var(--foreground); }
.site-nav__caret { color: var(--quiet); transition: transform 160ms ease; }
.site-nav__trigger[aria-expanded="true"] .site-nav__caret { transform: rotate(180deg); color: currentColor; }
.site-nav__menu-button {
  display: none; place-items: center; width: 2.75rem; height: 2.75rem;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--foreground); cursor: pointer;
}
.site-nav__menu-button:hover { background: var(--muted); }
@media (max-width: 47.99rem) {
  .site-nav__menu { display: none; }
  .site-nav__menu-button { display: grid; }
}
.site-nav__panel {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--background); border-bottom: 1px solid var(--border);
  box-shadow: 0 24px 48px rgb(0 0 0 / 0.10);
}
.site-nav__panel[hidden] { display: none; }
.site-nav__panel-inner { max-width: 74rem; margin: 0 auto; padding: 2rem clamp(1.25rem, 5vw, 3rem) 2.5rem; }
.site-nav__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
  gap: 1.25rem;
}
.site-nav__card {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.site-nav__card:hover { color: inherit; border-color: var(--brand-primary); box-shadow: 0 8px 20px rgb(0 0 0 / 0.06); }
.site-nav__scrim { position: fixed; inset: 3.5rem 0 0; z-index: -1; background: rgb(0 0 0 / 0.02); }
.site-nav__scrim[hidden] { display: none; }

/* ---- Mobile sheet ---- */
.site-sheet { position: fixed; inset: 0; z-index: 30; }
.site-sheet[hidden] { display: none; }
.site-sheet__backdrop { position: absolute; inset: 0; background: rgb(10 10 10 / 0.32); animation: sheet-fade 200ms ease; }
.site-sheet__panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(22rem, 88vw);
  display: flex; flex-direction: column;
  background: var(--background); border-left: 1px solid var(--border);
  box-shadow: -24px 0 48px rgb(0 0 0 / 0.12);
  animation: sheet-in 260ms cubic-bezier(0.32, 0.72, 0, 1);
}
.site-sheet__top {
  display: flex; align-items: center; justify-content: space-between;
  height: 3.5rem; padding: 0 0.625rem 0 1.25rem; border-bottom: 1px solid var(--border); flex: none;
}
.site-sheet__home { color: var(--foreground); }
.site-sheet__body { overflow-y: auto; overscroll-behavior: contain; padding: 0.5rem 1.25rem 2rem; }
.site-sheet__group { padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.site-sheet__heading {
  margin: 0 0 0.5rem; font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--quiet);
}
.site-sheet__list { list-style: none; margin: 0; padding: 0; }
.site-sheet__link {
  display: block; padding: 0.5rem 0; text-decoration: none; color: var(--foreground);
  font-family: Poppins, sans-serif; font-weight: 600; font-size: 1.125rem; letter-spacing: -0.02em; line-height: 1.3;
}
.site-sheet__blurb {
  display: block; margin-top: 0.125rem;
  font-family: 'Geist Variable', system-ui, sans-serif; font-weight: 400; font-size: 0.8125rem; letter-spacing: 0; color: var(--quiet);
}
.site-sheet__link[aria-current="page"] { color: var(--brand-primary); }
@keyframes sheet-in { from { transform: translateX(100%); } }
@keyframes sheet-fade { from { opacity: 0; } }
html.sheet-open { overflow: hidden; }

/* ---- Footer ---- */
.site-footer {
  margin-top: 2rem;
  font-family: 'Geist Variable', system-ui, sans-serif;
  font-size: 0.9375rem; line-height: 1.6; color: var(--foreground);
}
.site-footer a { text-decoration: none; transition: color 140ms ease; }
.site-footer__label, .site-footer__heading {
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: 0.6875rem; line-height: 1.45; letter-spacing: 0.1em; text-transform: uppercase; color: var(--quiet);
}
.site-footer__source-band { border-top: 1px solid var(--border); }
.site-footer__source { display: flex; flex-wrap: wrap; gap: 0.75rem 3.5rem; padding-block: 2.5rem; }
.site-footer__source .site-footer__label { flex: 0 0 13rem; padding-top: 0.25rem; }
.site-footer__source p { flex: 1 1 22rem; max-width: 42rem; margin: 0; color: var(--quiet); text-wrap: pretty; }
.site-footer__body { border-top: 1px solid var(--border); background: var(--card); }
.site-footer__grid {
  display: grid; gap: 2.5rem 3rem; padding-block: 3rem 3.5rem;
  grid-template-columns: minmax(0, 1.4fr) repeat(3, minmax(0, 1fr));
}
@media (max-width: 47.99rem) {
  .site-footer__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-block: 2.5rem; }
  .site-footer__brand { grid-column: 1 / -1; }
}
.site-footer__home { display: inline-block; padding-block: 0.25rem; color: var(--foreground); }
.site-footer__name { margin: 1rem 0 0; font-family: Poppins, sans-serif; font-weight: 600; font-size: 1.0625rem; letter-spacing: -0.02em; }
.site-footer__blurb { margin: 0.375rem 0 0; font-size: 0.875rem; color: var(--quiet); max-width: 20rem; text-wrap: pretty; }
.site-footer__heading { margin: 0 0 0.75rem; }
.site-footer__list { list-style: none; margin: 0; padding: 0; }
.site-footer__link {
  color: var(--foreground); font-size: 0.875rem;
  /* Touch floor: the rest of the site engineers every control to 2.75rem. */
  display: inline-flex; align-items: center; min-height: 2.75rem; min-width: 2.75rem;
}
@media (min-width: 48rem) { .site-footer__link { min-height: 2.25rem; } }
.site-footer__link:hover { color: var(--brand-primary); }
/* The page you are on stays in the list but reads as visited, not as a link. */
.site-footer__link[aria-current="page"] { color: var(--quiet); }
.site-footer__base { border-top: 1px solid var(--border); background: var(--card); }
.site-footer__base-inner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 2rem;
  padding-block: 1rem; font-size: 0.8125rem; color: var(--quiet);
}
.site-footer__base-inner p { margin: 0; }
.site-footer__base-inner a { color: var(--foreground); display: inline-flex; align-items: center; min-height: 2.75rem; }
.site-footer__base-inner a:hover { color: var(--brand-primary); }

/* ---- Hover states the design expresses as `style-hover` ---- */
.hover-muted:hover { background: var(--muted); }
.hover-brand-border:hover { border-color: var(--brand-primary); }
.hover-brand-card:hover { border-color: var(--brand-primary); box-shadow: 0 8px 20px rgb(0 0 0 / 0.06); }

/* ---- Layout helpers ---- */
.wrap { max-width: 74rem; margin: 0 auto; padding-inline: clamp(1.25rem, 5vw, 3rem); }

.split {
  display: grid;
  grid-template-columns: minmax(21rem, 24rem) minmax(0, 1fr);
  gap: 3.5rem; align-items: start;
}
/* 3.75rem of sticky nav, plus 1.25rem of air. */
.split__rail { position: sticky; top: 5rem; }
@media (max-width: 60rem) {
  .split { grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
  .split__rail { position: static; }
}

/* Wide content never forces the page to scroll sideways. */
/* A horizontal scroller needs to say so: without a cue the last column is
   simply invisible on a phone. The fade only paints while there is more to
   reach, because it is anchored to the scroller's own background. */
.scroll-x {
  overflow-x: auto;
  scrollbar-width: thin;
  background:
    linear-gradient(to right, var(--background) 30%, transparent) left center / 3rem 100% no-repeat,
    linear-gradient(to left, var(--background) 30%, transparent) right center / 3rem 100% no-repeat,
    radial-gradient(farthest-side at 0 50%, rgb(0 0 0 / 0.10), transparent) left center / 1.25rem 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, rgb(0 0 0 / 0.10), transparent) right center / 1.25rem 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}
.scroll-x > * { min-width: 34rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Levels of agency: the staircase rail ---- */
.level-rail { display: flex; flex-direction: column; gap: 0.5rem; }
.level-rail__btn {
  display: grid; grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1rem; align-items: stretch; width: 100%;
  cursor: pointer; font: inherit;
  font-family: 'Geist Variable', system-ui, sans-serif;
  padding: 0.5rem 0.875rem; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--muted-foreground);
  transition: background 180ms ease, color 180ms ease;
}
.level-rail__btn[data-reached="true"] { color: var(--foreground); }
.level-rail__btn[aria-selected="true"] {
  background: color-mix(in oklab, var(--brand-primary) 9%, transparent);
  color: var(--brand-primary);
}
.level-rail__btn:hover { background: var(--muted); }
.level-rail__fig {
  display: flex; align-items: flex-end; justify-content: center;
  border-bottom: 2px solid var(--border);
}
/* The PNGs carry real alpha, so plain opacity is safe for the un-reached dim. */
.level-rail__fig img { width: auto; display: block; opacity: 0.3; transition: opacity 220ms ease; }
.level-rail__btn[data-reached="true"] .level-rail__fig img { opacity: 1; }
.level-rail__name { display: flex; align-items: center; font-weight: 600; font-size: 1rem; letter-spacing: -0.01em; }

/* ---- Pyramid principle: the tiered rail ---- */
.pyr__btn {
  display: block; width: 100%; text-align: left;
  cursor: pointer; font: inherit;
  font-family: 'Geist Variable', system-ui, sans-serif;
  padding: 0.875rem 1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease;
}
.pyr__btn:hover { background: var(--muted); }
.pyr__btn--reason { text-align: center; padding: 0.75rem 0.5rem; }
.pyr__btn[aria-selected="true"] {
  border-color: transparent;
  background: color-mix(in oklab, var(--brand-primary) 12%, transparent);
  color: var(--brand-primary);
}
.pyr__btn--answer[aria-selected="true"] {
  background: var(--brand-primary); color: var(--brand-primary-foreground);
}
.pyr__stem { display: block; width: 2px; height: 1.25rem; background: var(--border); }

/* ---- Chip filters (hub) and pill tabs (MECE) ---- */
.chip {
  cursor: pointer; font: inherit;
  font-family: 'Geist Variable', system-ui, sans-serif;
  font-size: 0.9375rem; font-weight: 500;
  padding: 0.5rem 0.875rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.chip:hover { border-color: var(--brand-primary); }
.chip[aria-pressed="true"], .chip[aria-selected="true"] {
  border-color: transparent;
  background: var(--brand-primary); color: var(--brand-primary-foreground);
}
.fits-tag { visibility: hidden; }
.fits-tag[data-on="true"] { visibility: visible; }

/* ---- List-and-detail pattern (issue trees, MECE, by monkeys) ---- */
.pick {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font: inherit; font-family: 'Geist Variable', system-ui, sans-serif;
  line-height: 1.45; letter-spacing: -0.01em;
  padding: 0.75rem 0.875rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card); color: var(--foreground);
  transition: background 160ms ease, border-color 160ms ease;
}
.pick:hover { border-color: var(--brand-primary); }
.pick[aria-selected="true"], .pick[aria-expanded="true"] {
  border-color: transparent;
  background: color-mix(in oklab, var(--brand-primary) 9%, transparent);
}
.pick--branch { font-size: 1.0625rem; font-weight: 600; }
.pick--branch[aria-selected="true"] {
  background: var(--brand-primary); color: var(--brand-primary-foreground);
}
/* The indent has to come out of the width, or the row overhangs the page on mobile. */
.pick--leaf { margin-left: 1.5rem; width: calc(100% - 1.5rem); }
.pick__bar { display: block; width: 100%; height: 3px; margin-top: 0.5rem; border-radius: 2px; background: var(--border); }
.pick__fill { display: block; height: 3px; border-radius: 2px; background: var(--brand-primary); }
.pick__fill[data-unknown="true"] { background: var(--muted-foreground); opacity: 0.45; }
.pick--branch[aria-selected="true"] .pick__bar { background: color-mix(in oklab, var(--brand-primary-foreground) 28%, transparent); }
.pick--branch[aria-selected="true"] .pick__fill { background: var(--brand-primary-foreground); }

/* ---- RAG status: outlined colour tabs ---- */
.rag-tab {
  display: inline-flex; align-items: center; gap: 0.5rem;
  cursor: pointer; font: inherit;
  font-family: 'Geist Variable', system-ui, sans-serif;
  font-size: 0.9375rem; font-weight: 500;
  padding: 0.5rem 0.875rem; border-radius: var(--radius);
  /* Outlined rather than filled, so the three dots stay the only things carrying the colour. */
  border: 2px solid var(--border); background: var(--card); color: var(--foreground);
  transition: border-color 160ms ease;
}
.rag-tab[aria-selected="true"] { border-color: var(--hue); }
