/* ============================================================
   /display comparison component — "About Time — Who does what".
   Dropped in from the standalone design. ALL tokens are scoped to
   .at-compare (never :root) so they can't clobber the scroll's own
   variables, and the light overrides hang off the scroll's
   data-mode toggle (dark is the default; [data-mode="light"] flips).
   ============================================================ */

/* ----- TOKENS (dark default) ----- */
.at-compare {
  --font-display: "omnes-pro", "Fraunces", "Inter", system-ui, -apple-system, sans-serif;
  --font-body:    "Inter", system-ui, -apple-system, sans-serif;

  --bg:        #0c0a11;
  --bg-2:      #100d16;
  --panel:     #14111c;
  --panel-2:   #1a1624;
  --edge:      rgba(238,235,247,0.08);
  --edge-soft: rgba(238,235,247,0.05);

  --ink:       #f0eef6;
  --ink-soft:  #b4afc1;
  --ink-mute:  #807a90;

  --sublabel:  #8A7AB8;   /* col sub-labels — distinctly below ink-soft */
  --part-ph:   #C4AFFF;   /* AA+ phrase text on dark partial cells */
  --no-bg:     rgba(169,154,201,0.028);  /* deliberate dim void */
  --no-edge:   rgba(169,154,201,0.07);

  --yes:       #ff63b0;
  --yes-bg:    rgba(255,90,176,0.11);
  --yes-edge:  rgba(255,90,176,0.22);

  --part:      #b59cff;
  --part-bg:   rgba(165,135,250,0.10);
  --part-edge: rgba(165,135,250,0.22);

  --no-ink:    #6c6780;

  --spine-ink:  #ffa6d4;
  --spine-bg:   rgba(255,90,176,0.14);
  --spine-bg-2: rgba(255,90,176,0.20);
  --spine-edge: rgba(255,110,190,0.48);
  --spine-glow: rgba(255,80,180,0.32);

  --radius: 16px;
  --shadow: 0 40px 120px -50px rgba(0,0,0,0.7);
}

/* ----- TOKENS (light — tracks the scroll's data-mode) ----- */
[data-mode="light"] .at-compare {
  --bg:        #f2eff7;
  --bg-2:      #ece8f3;
  --panel:     #ffffff;
  --panel-2:   #f5f2fa;
  --edge:      rgba(28,22,40,0.11);
  --edge-soft: rgba(28,22,40,0.06);

  --ink:       #1b1626;
  --ink-soft:  #5c5668;
  --ink-mute:  #8d8799;

  --sublabel:  #7A65A8;
  --part-ph:   #4A34A6;   /* AA on white partial cells */
  --no-bg:     rgba(24,16,46,0.025);
  --no-edge:   rgba(24,16,46,0.07);

  --yes:       #ce2f88;
  --yes-bg:    rgba(206,47,136,0.10);
  --yes-edge:  rgba(206,47,136,0.24);

  --part:      #6d4fd0;
  --part-bg:   rgba(109,79,208,0.10);
  --part-edge: rgba(109,79,208,0.20);

  --no-ink:    #a39db1;

  --spine-ink:  #ac1f6e;
  --spine-bg:   rgba(206,47,136,0.10);
  --spine-bg-2: rgba(206,47,136,0.17);
  --spine-edge: rgba(206,47,136,0.46);
  --spine-glow: rgba(206,47,136,0.18);

  --shadow: 0 40px 110px -55px rgba(40,30,60,0.28);
}

/* ============================== BASE ============================== */
.at-compare, .at-compare * { box-sizing: border-box; }

.at-compare {
  --pad: clamp(20px, 5vw, 88px);
  font-family: var(--font-body);
  background: transparent;
  color: var(--ink);
  padding: clamp(56px, 9vw, 132px) var(--pad) clamp(48px, 8vw, 104px);
  position: relative;
  overflow: hidden;
  transition: color .5s ease;
}
.at-compare::selection { background: var(--spine-bg-2); }

.at-inner { max-width: 1240px; margin: 0 auto; position: relative; }

/* ----- header band ----- */
.at-top {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 28px; flex-wrap: wrap;
  margin-bottom: clamp(32px, 5vw, 60px);
}
.at-head { max-width: 760px; }
.at-eyebrow {
  font-size: 12px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--sublabel); font-weight: 600; margin: 0 0 18px;
}
.at-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.04;
  letter-spacing: -0.012em;
  margin: 0;
  text-wrap: balance;
  color: var(--ink);
}
.at-title em { font-style: italic; color: var(--yes); }

/* ============================== TABLE ============================== */
.at-scroll { overflow-x: auto; margin: 0 -4px; padding: 4px 4px 0; }
.at-scroll::-webkit-scrollbar { height: 8px; }
.at-scroll::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 99px; }

/* Flatten bottom corners when the callout band follows — one unified shape */
.at-scroll:has(+ .at-callout) table.cmp {
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
}

table.cmp {
  width: 100%;
  min-width: 940px;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: none;
  overflow: hidden;
}

.cmp th, .cmp td {
  text-align: center;
  vertical-align: middle;
  padding: 18px 14px;
  border-bottom: 1px solid var(--edge-soft);
  position: relative;
}
.cmp tbody tr:last-child td { border-bottom: 0; }

/* needs column */
.cmp .need {
  text-align: left;
  width: 26%;
  min-width: 250px;
  position: sticky; left: 0; z-index: 3;
  background: transparent;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.38;
  color: var(--ink);
  padding-left: clamp(20px, 3vw, 34px);
  hyphens: auto;
  -webkit-hyphens: auto;
  word-break: break-word;
}
thead .need { z-index: 5; }

/* header cells */
.cmp thead th {
  padding-top: 26px; padding-bottom: 22px;
  vertical-align: top;
  border-bottom: 1px solid var(--edge);
  background: transparent;
}
.col-name {
  font-family: var(--font-display);
  font-weight: 600; font-size: 17px; line-height: 1.12;
  letter-spacing: -0.005em; color: var(--ink);
  display: block; text-wrap: balance;
}
.col-sub {
  display: block; margin-top: 9px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .19em; text-transform: uppercase;
  color: var(--sublabel);
}
.need .col-name {
  font-style: italic; font-size: clamp(17px, 2.2vw, 22px);
  color: var(--ink); line-height: 1.1;
}

/* cell value blocks */
.v { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; line-height: 1.2; }
.v .g {
  font-size: 17px; font-weight: 600; line-height: 1;
  font-family: var(--font-body);
}
.v .ph {
  font-size: 12.5px; font-weight: 500; letter-spacing: .005em;
  text-wrap: balance; max-width: 15ch;
}

/* ---- state: YES ---- */
td.yes { background: var(--yes-bg); box-shadow: inset 0 0 0 1px var(--yes-edge); }
td.yes .g  { color: var(--yes); }
td.yes .ph { color: color-mix(in oklab, var(--yes) 78%, var(--ink)); }

/* ---- state: PARTIAL ---- */
td.part { background: var(--part-bg); box-shadow: inset 0 0 0 1px var(--part-edge); }
td.part .g  { color: var(--part); font-size: 19px; }
td.part .ph { color: var(--part-ph); }

/* ---- state: ABSENT (deliberate dim void, never alarmist) ---- */
td.no {
  background: var(--no-bg);
  box-shadow: inset 0 0 0 1px var(--no-edge);
}
td.no .g { color: var(--no-ink); font-size: 16px; font-weight: 400; }
td.no .lbl { font-size: 12.5px; color: var(--no-ink); font-weight: 500; }

/* ============================== THE SPINE ============================== */
/* Glow biased LEFT (negative x-offset) so it glows toward the needs column,
   not onto the next tool column. */
.cmp .spine {
  background: linear-gradient(180deg, var(--spine-bg-2), var(--spine-bg) 14%, var(--spine-bg) 86%, var(--spine-bg-2));
  box-shadow:
    inset 1px 0 0 var(--spine-edge),
    inset -1px 0 0 var(--spine-edge),
    -10px 0 22px -10px var(--spine-glow);
  border-bottom-color: color-mix(in oklab, var(--spine-edge) 35%, transparent);
  z-index: 1;
}
.cmp thead .spine {
  background: linear-gradient(180deg, color-mix(in oklab, var(--spine-bg-2) 140%, transparent), var(--spine-bg-2));
  box-shadow:
    inset 1px 0 0 var(--spine-edge),
    inset -1px 0 0 var(--spine-edge),
    inset 0 1px 0 var(--spine-edge),
    -10px 0 26px -10px var(--spine-glow);
  border-bottom-color: var(--spine-edge);
}
.cmp tbody tr:last-child .spine {
  box-shadow:
    inset 1px 0 0 var(--spine-edge),
    inset -1px 0 0 var(--spine-edge),
    inset 0 -1px 0 var(--spine-edge),
    -10px 0 22px -10px var(--spine-glow);
}
.cmp .spine .col-name { color: var(--ink); font-weight: 600; }
.cmp .spine .col-sub  { color: var(--spine-ink); }
.cmp td.spine .g  { color: var(--spine-ink); }
.cmp td.spine .ph { color: color-mix(in oklab, var(--spine-ink) 60%, var(--ink)); }

/* travelling ignite highlight (one-time, motion only) */
.spine-sweep {
  position: absolute; pointer-events: none; z-index: 4;
  top: 0; height: 0; opacity: 0;
  background: linear-gradient(180deg, transparent, color-mix(in oklab, var(--spine-edge) 70%, transparent), transparent);
  filter: blur(4px);
}

/* ============================== LEGEND ============================== */
/* Pill anchored top-right of .at-inner — seen before scanning starts */
.at-legend {
  position: absolute; top: 0; right: 0;
  display: inline-flex; gap: 16px; flex-wrap: nowrap; align-items: center;
  padding: 8px 16px;
  background: rgba(169,154,201,0.07);
  border: 1px solid var(--edge);
  border-radius: 99px;
  font-size: 11.5px;
  color: var(--ink-soft);
}
[data-mode="light"] .at-legend {
  background: rgba(24,16,46,0.05);
}
.at-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.at-legend b { font-weight: 700; font-size: 13px; line-height: 1; }
.lg-yes b  { color: var(--yes); }
.lg-part b { color: var(--part); }
.lg-no b   { color: var(--no-ink); }

/* ============================== CALLOUT BAND ============================== */
/* Integrated bottom of the table — two-tier: headline (prominent) + sub (muted). */
.at-callout {
  border: 1px solid var(--edge);
  border-top: 2px solid var(--yes);
  border-radius: 0 0 var(--radius) var(--radius);
  margin: 0 4px;
  padding: clamp(20px, 3.5vw, 36px) clamp(22px, 4.5vw, 44px);
  background: color-mix(in oklab, var(--yes-bg) 50%, transparent);
}
.at-callout-headline {
  font-family: var(--font-display);
  font-size: clamp(15px, 1.7vw, 20px);
  font-weight: 600; line-height: 1.44;
  color: var(--ink);
  margin: 0 0 10px;
  text-wrap: balance; max-width: 78ch;
}
.at-callout-headline em { font-style: italic; color: var(--yes); }
.at-callout-sub {
  font-size: clamp(12px, 1.2vw, 13.5px);
  line-height: 1.68;
  color: var(--ink-soft);
  margin: 0; max-width: 74ch;
}

/* ============================== CAPTION (vs-Numa section) ============================== */
.at-caption {
  font-family: var(--font-display);
  font-style: italic; font-weight: 400;
  font-size: clamp(16px, 2.1vw, 21px);
  line-height: 1.5; color: var(--ink-soft);
  text-align: center; max-width: 760px;
  margin: clamp(36px, 5vw, 56px) auto 0;
  text-wrap: balance;
}
.at-caption strong { color: var(--ink); font-weight: 500; font-style: normal; }

/* ============================== REVEAL (graceful) ==============================
   Visibility never depends on the animation timeline. Rows are visible by default;
   compare.js adds [data-animate] to hide-then-reveal, and ALWAYS removes it after,
   so the settled state is plain opacity:1 (safe in paused / headless / print). */
@media (prefers-reduced-motion: no-preference) {
  .at-compare[data-animate] tbody tr:not(.in) > * {
    opacity: 0;
    transform: translateY(10px);
  }
  .at-compare[data-animate] tbody tr > * {
    transition: opacity .5s ease, transform .55s cubic-bezier(.2,.7,.2,1);
  }
  .at-compare[data-animate] tbody tr.in td.spine { transition-delay: .08s; }
  .at-compare[data-animate] .spine-sweep.go {
    animation: at-cmp-sweep 1.5s cubic-bezier(.45,0,.2,1) .35s 1;
  }
  @keyframes at-cmp-sweep {
    0%   { opacity: 0; }
    12%  { opacity: .9; }
    100% { opacity: 0; top: 100%; }
  }
}

/* desktop: shrink the table to fit its container so the last column is never clipped */
@media (min-width: 721px) {
  table.cmp { table-layout: fixed; min-width: 0; }
  .cmp th, .cmp td { padding: 14px 9px; }
  .cmp .need { width: 24%; min-width: 0; padding-left: clamp(16px, 2vw, 26px); }
  .v .ph { max-width: 14ch; }
  /* Stagger competitor headers up/down so long names don't crowd each other.
     Padding totals stay equal (28px) so row height is unchanged; only the
     vertical position of each header's content shifts. */
  .cmp thead th:nth-child(n+3):nth-child(odd)  { padding-top:  4px; padding-bottom: 24px; }
  .cmp thead th:nth-child(n+3):nth-child(even) { padding-top: 24px; padding-bottom:  4px; }
}

@media (max-width: 720px) {
  .cmp .need { min-width: 200px; }
  .v .ph { font-size: 12px; }
}

@media print {
  .at-compare { background: #fff; color: #111; }
  .spine-sweep { display: none; }
  table.cmp { box-shadow: none; min-width: 0; }
}

/* screen-reader-only utility (scoped names used only by this component) */
.sr-only, .at-compare .sr {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ==============================
   2-COLUMN TABLE — no forced min-width
   Applied to the vs-Numa spotlight and mobile picker panels.
   ============================== */
table.cmp.cmp--2col {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}
table.cmp.cmp--2col .need { min-width: 0; width: 42%; }
table.cmp.cmp--2col .v .ph { max-width: 12ch; }

/* ==============================
   MOBILE VS-PICKER
   Chip row + 2-column panels built by compare.js from the 9-col table.
   Shown below 768px; hidden (display:none) by default.
   ============================== */
.at-picker { display: none; }

.at-chips {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 18px;
  padding: 0 2px;
}

.at-chip {
  padding: 6px 13px;
  border-radius: 99px;
  border: 1px solid var(--edge);
  background: var(--panel);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.3;
  -webkit-tap-highlight-color: transparent;
  transition: background .16s, color .16s, border-color .16s;
  white-space: nowrap;
}
.at-chip.is-on {
  background: var(--spine-bg-2);
  border-color: var(--spine-edge);
  color: var(--spine-ink);
}
.at-chip:focus-visible {
  outline: 2px solid var(--spine-ink);
  outline-offset: 2px;
}

.at-ppanel { display: none; }
.at-ppanel.is-on { display: block; }

/* Picker panel tables: no x-overflow needed */
.at-ppanel .at-scroll { overflow-x: visible; margin: 0; padding: 0; }

/* ──────────────────────────────────────────────────────────
   < 768px — flex-order the #compare section so that:
     0  heading (.at-top)
     1  vs picker (.at-picker)
     2  legend (position:static on mobile)
     3  callout band (.at-callout)
     4  CTA button row
   The 9-col table scroll wrapper is hidden; picker replaces it.
   ────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  #compare > .at-inner > .at-scroll { display: none; }
  .at-picker { display: block; }

  #compare > .at-inner {
    display: flex;
    flex-direction: column;
  }
  #compare > .at-inner > .at-top     { order: 0; }
  #compare > .at-inner > .at-picker  { order: 1; }
  #compare > .at-inner > .at-legend  { order: 2; }
  #compare > .at-inner > .at-callout { order: 3; }
  #compare > .at-inner > .at-btn-row { order: 4; }

  /* legend reflows into normal block on narrow screens */
  .at-legend {
    position: static;
    display: flex; flex-wrap: wrap;
    margin-bottom: 18px;
    border-radius: 10px; padding: 10px 14px;
  }

  /* callout doesn't need the merged corner radii on mobile */
  .at-callout {
    border-radius: var(--radius);
    margin: 0;
  }
}
