:root {
  /* Surfaces */
  --sa-bg:          #fdfaf7;
  --sa-bg-wash:     #fdf1ea;
  --sa-bg-soft:     #f7f1ea;
  --sa-bg-dark:     #0e1116;
  --sa-surface:     #ffffff;

  /* Ink */
  --sa-ink:            #0e1116;
  --sa-ink-soft:       #454b54;
  --sa-ink-faint:      #7e8894;
  --sa-ink-on-dark:    #eef3f9;
  --sa-ink-soft-on-dark: #9aa6b4;

  /* Rules */
  --sa-rule:       #e9ded4;
  --sa-rule-soft:  #f1e8de;
  --sa-rule-dark:  #1f242d;

  /* Brand + tones */
  --sa-brand:      #ff5b4a;
  --sa-brand-dark: #d83f2e;
  --sa-brand-soft: #ffd9d2;
  --sa-bad:        #e4412f;
  --sa-warn:       #e89a3a;
  --sa-good:       #3aa76b;

  /* Tone tints */
  --sa-bad-tint:   #e4412f14;
  --sa-bad-border: #e4412f30;
  --sa-warn-tint:  #e89a3a14;
  --sa-warn-border:#e89a3a30;
  --sa-partial:        #d97706;
  --sa-partial-tint:   #d9770614;
  --sa-partial-border: #d9770630;
  --sa-good-tint:  #3aa76b14;
  --sa-good-border:#3aa76b30;

  /* Typography */
  --sa-font-sans:    'Inter', system-ui, sans-serif;
  --sa-font-serif:   'Instrument Serif', Georgia, serif;
  --sa-font-mono:    ui-monospace, 'SF Mono', 'Menlo', monospace;

  /* Radii */
  --sa-radius-sm: 6px;
  --sa-radius-md: 10px;
  --sa-radius-lg: 14px;
  --sa-radius-xl: 18px;

  /* Shadows */
  --sa-shadow-hairline:    0 0 0 1px rgba(0,0,0,0.04);
  --sa-shadow-card:        0 40px 80px -30px rgba(20,10,0,0.25), 0 0 0 1px rgba(20,10,0,0.04);
  --sa-shadow-score:       0 50px 100px -40px rgba(20,10,0,0.3),  0 0 0 1px rgba(20,10,0,0.04);
  /* Block — the E v2 signature offset shadow on primary surface cards.
     Warm cocoa undertone (RGB 60/30/15) tuned to the cream palette;
     5% on `block` for primary surfaces, 3% on `block-soft` for secondary
     overlays (e.g. the section-nav jump dropdown) so the relative
     emphasis between primary and secondary holds. */
  --sa-shadow-block:       5px 5px 1px rgba(60,30,15,0.05);
  --sa-shadow-block-soft:  5px 5px 1px rgba(60,30,15,0.03);
}

/* ── Interactive chrome ───────────────────────────────────────── */

/* Nav section anchors — underline sweeps in from left on hover */
.sa-nav-anchor {
  position: relative;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: var(--sa-font-sans);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sa-ink-soft);
  transition: color 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sa-nav-anchor::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 12px;
  right: 12px;
  height: 1px;
  background: var(--sa-brand);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sa-nav-anchor:hover { color: var(--sa-brand); }
.sa-nav-anchor:hover::after { transform: scaleX(1); }
.sa-nav-anchor--active { color: var(--sa-ink); background: var(--sa-rule-soft); }

/* Run scan nav button */
.sa-run-scan-btn {
  display: inline-block;
  text-decoration: none;
  background: var(--sa-brand);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 2px 8px -3px rgba(255, 91, 74, 0.45);
  margin-left: 6px;
  transition: background 200ms, box-shadow 200ms;
}
.sa-run-scan-btn:hover {
  background: var(--sa-brand-dark);
  box-shadow: 0 8px 18px -8px rgba(255, 91, 74, 0.66);
}

/* Log in pill */
.sa-login-btn {
  display: inline-block;
  text-decoration: none;
  border: 1px solid var(--sa-rule);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--sa-ink-soft);
  transition: background 180ms, border-color 180ms, color 180ms;
}
.sa-login-btn:hover {
  background: var(--sa-bg-wash);
  border-color: var(--sa-brand);
  color: var(--sa-brand);
}

/* Footer nav links */
.sa-footer-link {
  text-decoration: none;
  color: var(--sa-ink-faint);
  transition: color 180ms;
}
.sa-footer-link:hover { color: var(--sa-brand); }

@media (prefers-reduced-motion: reduce) {
  .sa-nav-anchor,
  .sa-nav-anchor::after,
  .sa-login-btn,
  .sa-footer-link { transition: none; }
}

/* Nav container — matches .lp-section horizontal padding at each breakpoint */
.sa-nav-container { padding-left: 64px; padding-right: 64px; }
@media (max-width: 900px) {
  .sa-nav-container { padding-left: 24px; padding-right: 24px; }
}
@media (max-width: 600px) {
  .sa-nav-container { padding-left: 20px; padding-right: 20px; }
}

/* ── Sticky nav ──────────────────────────────────────────────── */
.sa-sticky-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 0;
  background: var(--sa-bg-wash);
  border-bottom: 1px solid var(--sa-rule-soft);
  box-shadow: none;
  transition:
    background    220ms cubic-bezier(.2,.8,.2,1),
    border-color  220ms cubic-bezier(.2,.8,.2,1),
    box-shadow    220ms cubic-bezier(.2,.8,.2,1),
    padding       220ms cubic-bezier(.2,.8,.2,1),
    transform     200ms cubic-bezier(.2,.8,.2,1);
}

/* Results page: when the user scrolls past the hero, the main sticky nav
   slides off-screen so the compact section-nav pill takes the top slot.
   The body class is toggled by tier_pill_nav_controller. */
body.results-nav-swapped .sa-sticky-nav {
  transform: translateY(-100%);
  pointer-events: none;
}

/* ── Full-bleed section bands ────────────────────────────────
   Match phase4 FRSection (concept-e-v2.jsx · fr-atoms.jsx#FRSection):
   tinted/washed band that spans edge-to-edge of the viewport, breaking
   out of the article's max-w-[1120px] constraint, with top + bottom
   borders. Used on brand-probe, query-deep-dive, description-rewrites,
   and the Full AI Audit upsell.
   Implementation: a ::before pseudo-element extends the bg/borders
   beyond the section's flow box without touching the section's own
   width or its children's layout. The article wrapper carries
   `relative` (its own stacking context); the pseudo with `z-index: -1`
   lands above the body's bg-cream and behind the section's content. */
.sa-section-band { position: relative; isolation: isolate; }
.sa-section-band::before {
  content: "";
  position: absolute;
  left: calc(50% - 50vw);
  right: calc(50% - 50vw);
  top: 0;
  bottom: 0;
  z-index: -1;
  border-top: 1px solid var(--sa-rule-soft);
  border-bottom: 1px solid var(--sa-rule-soft);
}
.sa-section-band-tint::before { background: var(--sa-bg-soft); }
.sa-section-band-wash::before { background: var(--sa-bg-wash); }

/* Paid results sections are composed by the parent view so optional partials
   can disappear without breaking the tinted/light alternation. */
.sa-paid-result-section {
  margin-bottom: 2.5rem;
}

.sa-paid-result-section.sa-section-band {
  padding-top: 2.5rem;
  padding-bottom: 2.5rem;
}

.sa-paid-result-section > section {
  margin-bottom: 0;
}

.sa-paid-result-section > .sa-section-band {
  padding-top: 0;
  padding-bottom: 0;
}

.sa-paid-result-section > .sa-section-band::before {
  content: none;
}

.sa-paid-result-section[data-section-has-group-sibling="false"] > [data-testid="sa-categories"] {
  border-bottom: 0;
  padding-bottom: 0;
}

.sa-paid-result-section-stack {
  display: grid;
  gap: 1.5rem;
}

.sa-paid-result-section-stack > section {
  margin-bottom: 0;
}

@media (min-width: 80rem) {
  .sa-paid-result-section {
    margin-bottom: 3.5rem;
  }

  .sa-paid-result-section.sa-section-band {
    padding-top: 3.5rem;
    padding-bottom: 3.5rem;
  }
}

/* Full-bleed horizontal rule. Used to separate the hero from the
   utility bar without anchoring the line to the article's content
   width — the rule extends to the viewport edges. */
.sa-rule-fullbleed {
  border-top: 1px solid var(--sa-rule-soft);
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

/* Section-progress pill: hidden until the user scrolls past the hero.
   tier_pill_nav_controller toggles `body.results-nav-swapped` based on
   the hero's IntersectionObserver; before that flips, the pill stays
   out of the document flow so it doesn't reserve vertical space at
   the top of the page. */
.sa-section-nav { display: none; }
body.results-nav-swapped .sa-section-nav { display: block; }

/* Smooth-scroll for native anchor jumps (e.g. the Jump-to menu in the
   section-progress pill). Plain CSS replaces the Stimulus action that
   used to handle this — anchor click → browser scroll, no controller
   round-trip. `scroll-mt-24` on each section anchor compensates for
   the sticky nav. */
html { scroll-behavior: smooth; }

/* Landing page: blends with hero at top (same bg), frosts when scrolled */
.sa-sticky-nav.sa-nav-hero {
  padding: 20px 0;
  background: var(--sa-bg-wash);
  border-bottom-color: transparent;
  box-shadow: none;
}
.sa-sticky-nav.sa-nav-hero.is-scrolled {
  padding: 14px 0;
  background: rgba(253, 241, 234, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--sa-rule-soft);
  box-shadow: 0 1px 0 rgba(20,10,0,0.02), 0 8px 20px -16px rgba(20,10,0,0.18);
}

@media (prefers-reduced-motion: reduce) {
  .sa-sticky-nav { transition: none; }
}

/* Italic-accent phrase inside headings */
.sa-ital {
  font-family: var(--sa-font-serif);
  font-style: italic;
  font-weight: 400;
  color: var(--sa-brand);
  letter-spacing: 0;
}

/* Mono uppercase eyebrow label above every section heading */
.sa-eyebrow {
  font-family: var(--sa-font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--sa-ink-faint);
}
@media (max-width: 600px) {
  .sa-eyebrow { font-size: 10px; }
}

/* Scoreboard strip in compact-sticky mode. The base scoreboard styling
   lives inline in the partial; only the morph-to-sticky styles live here
   so they're easy to find when print/reduced-motion need updating. */
[data-sticky-strip] {
  transition: padding 200ms ease, background 200ms ease;
}
[data-sticky-strip][data-compact="true"] {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(253, 250, 247, 0.88);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
  backdrop-filter: blur(10px) saturate(1.05);
  border-bottom: 1px solid var(--sa-rule-soft);
  box-shadow: 0 6px 16px -8px rgba(14, 17, 22, 0.18);
  padding-block: 8px;
}

/* Drawer fragments: only the active fragment is visible on screen. The
   print rule below reveals every fragment so the printed audit captures
   all category/query detail, not just whatever was active when printed. */
[data-drawer-fragment] { display: none; }
[data-drawer-fragment][data-active="true"] { display: block; }

/* Hide the drawer first-paint placeholder once any fragment is active. */
[data-testid="sa-categories-drawer"]:has([data-drawer-fragment][data-active="true"]) > [data-categories-placeholder] {
  display: none;
}

@media print {
  [data-sticky-strip] {
    position: static !important;
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border-bottom: none !important;
  }
  [data-drawer-fragment] { display: block !important; }
  [data-drawer-fragment] + [data-drawer-fragment] {
    margin-top: 1.5rem;
    border-top: 1px dashed var(--sa-rule-soft);
    padding-top: 1.5rem;
  }
}

/* Terminal cursor blink — used in terminal player on the landing page */
@keyframes sa-blink {
  50% { opacity: 0; }
}
.sa-cursor {
  display: inline-block;
  width: 8px;
  height: 14px;
  background: var(--sa-good);
  vertical-align: middle;
  animation: sa-blink 0.8s infinite;
}
@media (prefers-reduced-motion: reduce) {
  .sa-cursor { animation: none; }
}

/* ============================================================
   Paid results · sticky scoreboard + inline drawer pattern
   Used by Category Breakdown and Query Deep Dive sections.
   ============================================================ */

/* Scoreboard strip in compact-sticky mode. The base scoreboard styling
   lives inline in the partial; only the morph-to-sticky styles live here
   so they're easy to find when print/reduced-motion need updating. */
[data-sticky-strip] {
  transition: padding 200ms ease, background 200ms ease;
}
[data-sticky-strip][data-compact="true"] {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(253, 250, 247, 0.88);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
  backdrop-filter: blur(10px) saturate(1.05);
  border-bottom: 1px solid var(--sa-rule-soft);
  box-shadow: 0 6px 16px -8px rgba(14, 17, 22, 0.18);
  padding-block: 8px;
}

/* Drawer fragments: only the active fragment is visible on screen. The
   print rule below reveals every fragment so the printed audit captures
   all category/query detail, not just whatever was active when printed. */
[data-drawer-fragment] { display: none; }
[data-drawer-fragment][data-active="true"] { display: block; }

/* Hide the drawer first-paint placeholder once any fragment is active. */
[data-testid="sa-categories-drawer"]:has([data-drawer-fragment][data-active="true"]) > [data-categories-placeholder] {
  display: none;
}

@media print {
  [data-sticky-strip] {
    position: static !important;
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
    border-bottom: none !important;
  }
  [data-drawer-fragment] { display: block !important; }
  [data-drawer-fragment] + [data-drawer-fragment] {
    margin-top: 1.5rem;
    border-top: 1px dashed var(--sa-rule-soft);
    padding-top: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-sticky-strip] { transition: none; }
}

/* Action-plan deep-link arrival highlight. Brief 2-second ring on the
   targeted row when a merchant clicks "In action plan · NN" from a
   category drawer. */
[id^="smart-action-row-SA-"]:target {
  animation: sa-target-ring 2s ease-out;
}
@keyframes sa-target-ring {
  0%   { box-shadow: 0 0 0 3px rgba(58, 167, 107, 0.55); }
  100% { box-shadow: 0 0 0 3px rgba(58, 167, 107, 0); }
}
@media (prefers-reduced-motion: reduce) {
  [id^="smart-action-row-SA-"]:target { animation: none; }
}

/* Capped-scroll panel — edge fades toggled by scroll_panel_controller */
.sa-scroll-panel::before,
.sa-scroll-panel::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 28px;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.2s;
}
.sa-scroll-panel::before {
  top: 0;
  background: linear-gradient(to bottom, var(--sa-bg-soft), transparent);
  opacity: 0;
}
.sa-scroll-panel::after {
  bottom: 0;
  background: linear-gradient(to top, var(--sa-bg-soft), transparent);
  opacity: 1;
}
.sa-scroll-panel.scrolled-from-top::before { opacity: 1; }
.sa-scroll-panel.scrolled-to-bottom::after { opacity: 0; }

@media print {
  .sa-scroll-panel::before,
  .sa-scroll-panel::after { display: none; }
  .sa-scroll-panel { overflow: visible !important; }
}
