:root {
  --blue: #2B5CA5;
  --blue-ink: #204a87;
  --charcoal: #2F3941;
  --charcoal-70: rgba(47, 57, 65, 0.70);
  --charcoal-50: rgba(47, 57, 65, 0.50);
  --charcoal-30: rgba(47, 57, 65, 0.30);
  --charcoal-12: rgba(47, 57, 65, 0.12);
  --charcoal-08: rgba(47, 57, 65, 0.08);
  --off-white: #F0F0F0;
  --white: #FFFFFF;

  --good:    #6B8E7F;
  --caution: #C9A961;
  --poor:    #B4756E;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 40rem;
  --page-x: clamp(1.25rem, 4vw, 2.5rem);
}

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

html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--off-white);
  color: var(--charcoal);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { display: block; max-width: 100%; }

a {
  color: var(--blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}
a:hover { border-bottom-color: var(--blue); }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------------- header ---------------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem var(--page-x);
  border-bottom: 1px solid var(--charcoal-08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--charcoal);
  border-bottom: none;
}
.brand-wordmark {
  height: 30px;
  width: auto;
  display: block;
  /* the png has a light background that blends into off-white via multiply */
  mix-blend-mode: multiply;
}

.quiet-link {
  font-size: 0.875rem;
  color: var(--charcoal-70);
}
.quiet-link:hover { color: var(--charcoal); }

/* contact dropdown */
.contact-menu {
  position: relative;
}
.contact-menu > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  padding: 0.35rem 0.55rem;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: border-color 120ms ease, background 120ms ease;
}
.contact-menu > summary::-webkit-details-marker { display: none; }
.contact-menu > summary:hover {
  border-color: var(--charcoal-12);
  background: var(--white);
}
.contact-caret {
  width: 9px;
  height: 6px;
  color: currentColor;
  transition: transform 160ms ease;
}
.contact-menu[open] > summary .contact-caret {
  transform: rotate(180deg);
}
.contact-menu[open] > summary {
  border-color: var(--charcoal-12);
  background: var(--white);
  color: var(--charcoal);
}
.contact-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 12rem;
  background: var(--white);
  border: 1px solid var(--charcoal-12);
  border-radius: 3px;
  padding: 0.75rem 0.9rem;
  box-shadow: 0 8px 24px -12px rgba(47, 57, 65, 0.18), 0 1px 0 var(--charcoal-08);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 20;
  animation: contactPanel 140ms ease;
}
@keyframes contactPanel {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.contact-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--charcoal-50);
}
.contact-panel a {
  font-size: 0.9rem;
  color: var(--blue);
  word-break: break-all;
}

/* ---------------- hero ---------------- */

.hero {
  max-width: 82rem;
  margin: 0 auto;
  padding: clamp(4.5rem, 13vh, 9rem) var(--page-x) clamp(3.5rem, 9vh, 5.5rem);
}

h1 {
  font-size: clamp(1.85rem, 4.6vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 600;
  margin: 0 0 2rem;
  color: var(--charcoal);
  max-width: 68rem;
}

.lede {
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  line-height: 1.7;
  color: var(--charcoal-70);
  max-width: 72rem;
  margin: 0 0 2rem;
}

.hero-research {
  margin: 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--charcoal-08);
  max-width: 72rem;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--charcoal-50);
}
.hero-research a { color: var(--blue); }

/* ---------------- diagram section ---------------- */

.diagram-section {
  position: relative;
  height: 320vh;
  border-top: 1px solid var(--charcoal-08);
  border-bottom: 1px solid var(--charcoal-08);
}

.diagram-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--off-white);
}

.diagram-frame {
  position: relative;
  width: 100%;
  height: 100%;
  padding: clamp(5.5rem, 14vh, 8rem) clamp(1.5rem, 4vw, 3rem) clamp(2rem, 6vh, 4rem);
}

/* diagram section title, sits at top of the pinned frame */
.diagram-title {
  position: absolute;
  left: 50%;
  top: clamp(1.5rem, 4vh, 2.5rem);
  transform: translateX(-50%);
  text-align: center;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}
.diagram-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.diagram-eyebrow::before,
.diagram-eyebrow::after {
  content: "";
  width: 1.5rem;
  height: 1px;
  background: var(--blue);
  opacity: 0.5;
}
.diagram-heading {
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  font-weight: 500;
  color: var(--charcoal);
  margin: 0;
  letter-spacing: -0.005em;
  line-height: 1.3;
  max-width: 32rem;
}

/* svg fills the frame absolutely, sits behind the cards */
.arrow-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.arrow-svg-mobile { display: none; }

.arrow-path {
  stroke: var(--blue);
  fill: none;
  stroke-linecap: round;
}

.arrow-tip {
  opacity: 0;
  transition: opacity 200ms ease;
}
.arrow-tip.on { opacity: 1; }

/* center N mark inside the arrow loop */
.center-mark {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(96px, 12vw, 148px);
  height: clamp(96px, 12vw, 148px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  pointer-events: none;
}
.center-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* start desaturated and low opacity, fill in with color as the arrow travels */
  filter: saturate(calc(var(--flow-progress, 0)));
  opacity: calc(0.35 + 0.65 * var(--flow-progress, 0));
  transition: filter 180ms ease, opacity 180ms ease;
}

/* ---------------- stages (desktop absolute layout) ---------------- */

.stage {
  position: absolute;
  z-index: 2;
  max-width: 24rem;
  opacity: 0.55; /* softly visible on load so the layout reads as a whole */
  transform: none;
  transition: opacity 350ms ease;
}
.stage.active { opacity: 1; }
.stage.stage-note { opacity: 1; }

.stage-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}
.stage-tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--blue);
  letter-spacing: 0.04em;
  padding: 0.18rem 0.45rem;
  border: 1px solid rgba(43, 92, 165, 0.35);
  border-radius: 2px;
  background: rgba(43, 92, 165, 0.06);
  line-height: 1;
}
.stage.active .stage-tag {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}
.stage-tag-invert { }
.stage h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--charcoal);
  text-transform: lowercase;
}
.stage-caption {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  color: var(--charcoal-50);
  max-width: 22rem;
  line-height: 1.5;
}

/* stage positions (desktop) */
/* frame is ~ diagram viewport; we place cards near the four points the svg loop reaches. */
.stage-note    { left: clamp(1.5rem, 4vw, 3rem); top: clamp(2.5rem, 8vh, 4.5rem); }
.stage-extract { right: clamp(1.5rem, 4vw, 3rem); top: clamp(2.5rem, 8vh, 4.5rem); text-align: right; }
.stage-extract .stage-head { justify-content: flex-end; }
.stage-extract .stage-caption { margin-left: auto; }
.stage-engine  { right: clamp(1.5rem, 4vw, 3rem); bottom: clamp(2.5rem, 8vh, 4.5rem); text-align: right; }
.stage-engine .stage-head { justify-content: flex-end; }
.stage-engine .stage-caption { margin-left: auto; }
.stage-score   { left: clamp(1.5rem, 4vw, 3rem); bottom: clamp(2.5rem, 8vh, 4.5rem); }
.stage-return  {
  /* a11y-only text near the note for screen readers; visual return is the note update */
  left: 50%;
  bottom: 1rem;
  transform: translate(-50%, 0);
  text-align: center;
  max-width: 18rem;
  opacity: 0;
}
.stage-return.active { opacity: 1; }
.stage-return .stage-head { justify-content: center; }
.stage-return h3 { color: var(--charcoal-50); }

/* ---------------- note card ---------------- */

.note-card {
  background: var(--white);
  border: 1px solid var(--charcoal-12);
  padding: 1rem 1.1rem 1.1rem;
  max-width: 22rem;
  border-radius: 2px;
  box-shadow: 0 1px 0 var(--charcoal-08);
}
.note-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--charcoal-50);
  letter-spacing: 0.04em;
  padding-bottom: 0.5rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--charcoal-08);
}
.note-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.65;
  margin: 0;
  color: var(--charcoal);
  transition: color 300ms ease;
}
.note-card.dim .note-text { color: var(--charcoal-50); }

.hl {
  color: var(--charcoal);
  background: transparent;
  padding: 0 2px;
  border-radius: 1px;
  transition: background 300ms ease, color 300ms ease;
}
.note-card.hl-on .hl {
  background: rgba(43, 92, 165, 0.10);
  color: var(--blue-ink);
}

.note-attached {
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--charcoal-08);
  display: none;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--charcoal-70);
}
.note-attached .attached-value {
  color: var(--poor);
  font-size: 1rem;
  font-weight: 500;
}
.note-card.returned .note-attached { display: flex; }

/* ---------------- chips ---------------- */

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  max-width: 24rem;
}
.chip {
  background: var(--white);
  border: 1px solid var(--charcoal-12);
  padding: 0.35rem 0.6rem;
  display: inline-flex;
  gap: 0.5rem;
  align-items: baseline;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  border-radius: 2px;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 260ms ease, transform 260ms ease;
  max-width: 100%;
}
.chip-label {
  color: var(--blue);
  letter-spacing: 0.04em;
}
.chip-text {
  color: var(--charcoal-70);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18rem;
}
.stage-extract.active .chip { opacity: 1; transform: none; }
.stage-extract.active .chip:nth-child(1) { transition-delay: 0ms; }
.stage-extract.active .chip:nth-child(2) { transition-delay: 90ms; }
.stage-extract.active .chip:nth-child(3) { transition-delay: 180ms; }

/* ---------------- engine ---------------- */

.engine-panel {
  background: var(--charcoal);
  color: var(--off-white);
  padding: 1rem 1.1rem;
  border-radius: 2px;
  min-width: 14rem;
  max-width: 20rem;
  margin-left: auto;
  border: 1px solid var(--charcoal);
}
.engine-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 0.7rem;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid rgba(240,240,240,0.12);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.engine-name { color: var(--off-white); letter-spacing: 0.04em; }
.engine-loc { color: rgba(240,240,240,0.55); }
.engine-readout { display: flex; flex-direction: column; gap: 0.35rem; }
.engine-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: rgba(240,240,240,0.7);
}
.engine-line .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(240,240,240,0.2);
  transition: background 220ms ease;
}
.stage-engine.active .engine-line .dot { background: var(--blue); }
.stage-engine.active .engine-line:nth-child(1) .dot { transition-delay: 0ms; }
.stage-engine.active .engine-line:nth-child(2) .dot { transition-delay: 120ms; }
.stage-engine.active .engine-line:nth-child(3) .dot { transition-delay: 240ms; }

/* ---------------- score ---------------- */

.score-card {
  background: var(--white);
  border: 1px solid var(--charcoal-12);
  padding: 1rem 1.1rem 1.1rem;
  border-radius: 2px;
  min-width: 16rem;
  max-width: 22rem;
}
.score-index {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--charcoal-08);
}
.score-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--charcoal-50);
  letter-spacing: 0.04em;
}
.score-value {
  font-size: 2.25rem;
  font-weight: 500;
  color: var(--poor);
  line-height: 1;
  letter-spacing: -0.02em;
}
.bubbles {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.75rem;
}
.bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--charcoal-70);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 220ms ease, transform 220ms ease;
}
.bubble-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--charcoal-30);
  flex-shrink: 0;
}
.bubble[data-status="good"] .bubble-dot { background: var(--good); }
.bubble[data-status="caution"] .bubble-dot { background: var(--caution); }
.bubble[data-status="poor"] .bubble-dot { background: var(--poor); }
.stage-score.active .bubble { opacity: 1; transform: none; }
.stage-score.active .bubble:nth-child(1) { transition-delay: 60ms; }
.stage-score.active .bubble:nth-child(2) { transition-delay: 140ms; }
.stage-score.active .bubble:nth-child(3) { transition-delay: 220ms; }
.stage-score.active .bubble:nth-child(4) { transition-delay: 300ms; }

.score-card .score-value {
  opacity: 0;
  transition: opacity 300ms ease 40ms;
}
.stage-score.active .score-value { opacity: 1; }

/* ---------------- context ---------------- */

.context {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(4rem, 10vh, 6rem) var(--page-x);
}
.context-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.context-list li {
  padding: 1.1rem 0;
  border-top: 1px solid var(--charcoal-08);
  font-size: clamp(1rem, 1.4vw, 1.125rem);
  color: var(--charcoal);
  line-height: 1.5;
}
.context-list li:last-child { border-bottom: 1px solid var(--charcoal-08); }

/* ---------------- footer ---------------- */

.site-footer {
  padding: clamp(3rem, 8vh, 5rem) var(--page-x) clamp(2rem, 6vh, 3rem);
}
.footer-inner {
  max-width: var(--measure);
  margin: 0 auto;
  display: grid;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--charcoal-70);
}
.footer-name {
  margin: 0;
  color: var(--charcoal);
  font-weight: 500;
  font-size: 0.9rem;
}
.footer-research { margin: 0; max-width: 34rem; line-height: 1.55; }
.footer-contact { margin: 0; }
.footer-status { margin: 0; color: var(--charcoal-50); font-size: 0.8rem; }

/* ---------------- mobile ---------------- */

@media (max-width: 768px) {
  .center-mark { display: none; } /* only meaningful inside the desktop loop */

  .diagram-section {
    height: auto;
    padding: 2rem 0;
  }
  .diagram-sticky {
    position: static;
    height: auto;
    background: transparent;
  }
  .diagram-frame {
    position: relative;
    padding: 1rem var(--page-x);
    min-height: 1200px;
  }

  .arrow-svg-desktop { display: none; }
  .arrow-svg-mobile {
    display: block;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }

  .stage {
    position: relative;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    bottom: auto !important;
    transform: none;
    max-width: none;
    width: 100%;
    margin: 0 auto 2.5rem;
    padding-left: 3rem;
    text-align: left !important;
  }
  .stage .stage-head { justify-content: flex-start !important; }
  .stage .stage-caption { margin-left: 0 !important; }
  .stage .chips { align-items: flex-start; }
  .stage .engine-panel { margin-left: 0; }
  .stage-return {
    display: none; /* the note card update carries the return visually on mobile too */
  }
  .stage-note { margin-top: 1rem; }
}

/* ---------------- reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
  .stage { opacity: 1; transform: none; }
  .chip, .bubble, .score-value { opacity: 1; transform: none; }
  .note-card .note-attached { display: flex; }
  .note-card.hl-static .hl {
    background: rgba(43, 92, 165, 0.10);
    color: var(--blue-ink);
  }
  .engine-line .dot { background: var(--blue); }
  .arrow-tip { opacity: 1; }
}
