/* ==========================================================================
   02 · Ronin Nightgrid — variant token overrides (ui-designer)
   Dark-first (<html data-default-theme="dark">). Light = "daylight console":
   cool-warm paper + charcoal ink; the hero portal stays dark in both themes.
   Existing token names only (see shared/css/design-system.css).

   WCAG contrast (WCAG 2.x relative luminance, computed):
   DARK
     text-primary   #F2EEEA on #120F0D 16.54 | #1B1714 15.43 | #221C18 14.59
     text-secondary #ADA197 on #120F0D  7.57 | #1B1714  7.06 | #221C18  6.67 | #2A2420 6.07
     secondary (almond) #D9BAA1 on #120F0D 10.45 | #221C18 9.21
     primary (teal) #2FB7C2 as text on #120F0D 7.89 | #1B1714 7.35 | #221C18 6.95
     btn primary    #0B1214 on #2FB7C2  7.81 (hover #5FD3DC: 10.66)
     btn secondary  #120F0D on #D9BAA1 10.45 (almond fill) / almond outline text 10.45
     accent (magenta) #F0479E on #120F0D 5.55 | #1B1714 5.17
     focus ring     #5FD3DC on #120F0D 10.76 (>= 3:1 non-text)
   LIGHT
     text-primary   #211C19 on #F3F1EE 14.96 | #E7E2DC 13.10 | #FCFBF9 16.31
     text-secondary #574D46 on #F3F1EE  7.29 | #E7E2DC  6.38 | #FCFBF9  7.95
     primary (teal) #136B74 as text on #F3F1EE 5.51 | #E7E2DC 4.82 | #FCFBF9 6.00
     btn primary    #FFFFFF on #136B74  6.21 (hover #0F5A62: 7.90)
     btn secondary  #2A2420 on #D9BAA1  8.38 (almond is a FILL in light, never text)
     accent (magenta) #B0156F on #F3F1EE 5.85 | #E7E2DC 5.12
     focus ring     #136B74 on #F3F1EE 5.51
   Portal (always dark): uses the DARK pairs above.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces & ink (light: daylight console) */
  --bg-primary: #F3F1EE;      /* cool-warm paper */
  --bg-secondary: #E7E2DC;    /* status strip, alt sections */
  --bg-elevated: #FCFBF9;     /* tiles, quote cards */
  --text-primary: #211C19;    /* charcoal ink */
  --text-secondary: #574D46;
  --border-color: #D3CAC2;    /* hairlines, grid lines (decorative) */

  /* Brand */
  --primary-color: #136B74;   /* teal deepened for AA on paper */
  --primary-contrast: #FFFFFF;
  --secondary-color: #D9BAA1; /* almond: fill only in light (btn, selection, meter) */
  --accent-color: #B0156F;    /* magenta: live / alert only */
  --glow-color: #2FB7C2;      /* raw teal: lines, dots, glow; never body text */
  --focus-ring: #136B74;

  /* Shadow (light: soft, charcoal-tinted) */
  --shadow-sm: 0 1px 2px rgb(33 28 25 / 0.08);
  --shadow-md: 0 8px 24px -10px rgb(33 28 25 / 0.22);
  --shadow-lg: 0 28px 56px -20px rgb(33 28 25 / 0.35);
  --shadow-glow: 0 0 0 1px rgb(47 183 194 / 0.45), 0 0 20px -4px rgb(47 183 194 / 0.30);

  /* Art placeholder (portal is dark in both themes) */
  --art-placeholder-from: #1B1714;
  --art-placeholder-to: #22333A;
  --art-silhouette: rgb(47 183 194 / 0.14);
}

/* Dark values: the designed state. Identical in both blocks. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #120F0D;      /* near-black warm charcoal */
  --bg-secondary: #1B1714;    /* raised bands: status strip, step rail */
  --bg-elevated: #221C18;     /* tiles, cards, CTA panel */
  --text-primary: #F2EEEA;
  --text-secondary: #ADA197;
  --border-color: #2A2420;    /* charcoal hairlines */
  --primary-color: #2FB7C2;   /* slate-teal: the light source */
  --primary-contrast: #0B1214;
  --secondary-color: #D9BAA1; /* almond: heading accents, secondary buttons */
  --accent-color: #F0479E;    /* magenta: live / alert only */
  --glow-color: #2FB7C2;
  --focus-ring: #5FD3DC;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.5);
  --shadow-md: 0 8px 24px -10px rgb(0 0 0 / 0.7);
  --shadow-lg: 0 28px 56px -20px rgb(0 0 0 / 0.8);
  --shadow-glow: 0 0 0 1px rgb(47 183 194 / 0.35), 0 0 32px -6px rgb(47 183 194 / 0.28);
  --art-placeholder-from: #1B1714;
  --art-placeholder-to: #22333A;
  --art-silhouette: rgb(47 183 194 / 0.14);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg-primary: #120F0D;
    --bg-secondary: #1B1714;
    --bg-elevated: #221C18;
    --text-primary: #F2EEEA;
    --text-secondary: #ADA197;
    --border-color: #2A2420;
    --primary-color: #2FB7C2;
    --primary-contrast: #0B1214;
    --secondary-color: #D9BAA1;
    --accent-color: #F0479E;
    --glow-color: #2FB7C2;
    --focus-ring: #5FD3DC;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.5);
    --shadow-md: 0 8px 24px -10px rgb(0 0 0 / 0.7);
    --shadow-lg: 0 28px 56px -20px rgb(0 0 0 / 0.8);
    --shadow-glow: 0 0 0 1px rgb(47 183 194 / 0.35), 0 0 32px -6px rgb(47 183 194 / 0.28);
    --art-placeholder-from: #1B1714;
    --art-placeholder-to: #22333A;
    --art-silhouette: rgb(47 183 194 / 0.14);
  }
}

/* === Variant layout (builder) === */

/* Portal is a display: always dark, whatever the page theme */
.portal {
  --bg-primary: #120F0D; --bg-secondary: #1B1714; --bg-elevated: #221C18;
  --text-primary: #F2EEEA; --text-secondary: #ADA197; --border-color: #2A2420;
  --art-placeholder-from: #1B1714; --art-placeholder-to: #22333A;
  --art-silhouette: rgb(47 183 194 / 0.14);
  color-scheme: dark;
}

/* Panel border that stays visible in both themes */
body { --panel-border: color-mix(in srgb, var(--text-secondary) 22%, var(--bg-elevated)); }

/* ---------- Shared bits ---------- */
.tag { color: var(--primary-color); letter-spacing: 0.12em; display: inline-flex; align-items: center; gap: var(--space-2); }
.tag::before { content: ""; width: 6px; height: 6px; background: var(--glow-color); }

/* Almond secondary button: outline in dark, fill in light */
.btn--almond { border-color: var(--secondary-color); color: var(--secondary-color); background: transparent; }
.btn--almond:hover { background: var(--secondary-color); color: var(--bg-primary); }
.btn--primary:hover { background: #5FD3DC; }
:root[data-theme="light"] .btn--almond { background: var(--secondary-color); color: #2A2420; }
:root[data-theme="light"] .btn--almond:hover { border-color: #2A2420; }
:root[data-theme="light"] .btn--primary:hover { background: #0F5A62; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .btn--almond { background: var(--secondary-color); color: #2A2420; }
  :root:not([data-theme]) .btn--almond:hover { border-color: #2A2420; }
  :root:not([data-theme]) .btn--primary:hover { background: #0F5A62; }
}

.grid-bg { position: relative; isolation: isolate; }
.grid-bg::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(var(--border-color) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, var(--border-color) 1px, transparent 1px) 0 0 / 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at 70% 40%, #000 30%, transparent 75%);
          mask-image: radial-gradient(ellipse at 70% 40%, #000 30%, transparent 75%);
  opacity: 0.6;
  pointer-events: none;
}

.section-head { display: grid; gap: var(--space-3); justify-items: start; margin-bottom: var(--space-10); max-width: 46rem; }
.section-head h2 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem); letter-spacing: -0.015em; }

/* ---------- Hero ---------- */
.hero { padding-block: var(--space-12) var(--space-16); }
.hero__inner { display: grid; gap: var(--space-12); align-items: center; }
.hero__copy { display: grid; gap: var(--space-6); justify-items: start; }
.hero h1 { max-width: 14ch; }
.hero .lead { max-width: 52ch; color: var(--text-secondary); font-size: var(--text-lg); }
.hl { color: var(--secondary-color); }
:root[data-theme="light"] .hl { color: inherit; background: linear-gradient(transparent 62%, var(--secondary-color) 62%); }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .hl { color: inherit; background: linear-gradient(transparent 62%, var(--secondary-color) 62%); }
}
.hero__ctas { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.hero__facts { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-6); font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: var(--tracking-mono); text-transform: uppercase; color: var(--text-secondary); }
.hero__facts li { display: inline-flex; align-items: center; gap: var(--space-2); }
.hero__facts li::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--glow-color); }

.portal {
  position: relative;
  width: 100%;
  max-width: 20rem;
  margin-inline: auto;
  padding: var(--space-3);
  background: #120F0D;
  border: 1px solid #2A2420;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow);
  overflow: hidden;
}
.portal .art-frame { border-radius: var(--radius-md); background: radial-gradient(ellipse at 50% 35%, #1E2A2C, #120F0D 70%); }
.portal::before, .portal::after,
.portal__hud::before, .portal__hud::after {
  content: ""; position: absolute; width: 20px; height: 20px; border: 0 solid var(--glow-color); opacity: 0.9; z-index: 2;
}
.portal::before { top: 10px; left: 10px; border-top-width: 2px; border-left-width: 2px; }
.portal::after { top: 10px; right: 10px; border-top-width: 2px; border-right-width: 2px; }
.portal__hud::before { bottom: 10px; left: 10px; border-bottom-width: 2px; border-left-width: 2px; }
.portal__hud::after { bottom: 10px; right: 10px; border-bottom-width: 2px; border-right-width: 2px; }
.portal__hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.hud {
  position: absolute;
  font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: var(--tracking-mono); text-transform: uppercase;
  color: #ADA197; font-variant-numeric: tabular-nums;
}
.hud--tl { top: 34px; left: 22px; }
.hud--tr { top: 34px; right: 22px; color: #F2EEEA; }
.hud--bl { bottom: 30px; left: 22px; display: grid; gap: 6px; color: #F2EEEA; }
.meter { display: flex; gap: 3px; }
.meter i { width: 18px; height: 4px; background: rgb(47 183 194 / 0.2); }
.meter i.on { background: var(--glow-color); }
.portal__scan {
  position: absolute; left: 0; right: 0; top: 0; height: 24px; z-index: 1;
  background: linear-gradient(to top, var(--glow-color) 0 1px, rgb(47 183 194 / 0.18) 1px, transparent);
  opacity: 0;
  animation: scan 1.8s var(--ease-out) 400ms 1 forwards;
}
@keyframes scan {
  0% { top: 0; opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* ---------- Status strip ---------- */
.status { background: var(--bg-secondary); border-block: 1px solid var(--border-color); }
.status__scroll { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: thin; }
.status__list {
  display: flex; align-items: center; min-height: 56px; width: max-content; min-width: 100%;
  font-family: var(--font-mono); font-size: var(--text-sm); text-transform: uppercase; letter-spacing: var(--tracking-mono);
  font-variant-numeric: tabular-nums;
}
.status__list li { scroll-snap-align: start; display: flex; align-items: center; gap: var(--space-2); padding-inline: var(--space-5); white-space: nowrap; position: relative; }
.status__list li + li::before { content: ""; position: absolute; left: 0; top: 50%; height: 24px; width: 1px; background: var(--border-color); transform: translateY(-50%); }
.status__list li:first-child { padding-left: 0; }
.status__label { color: var(--text-secondary); font-size: var(--text-xs); }
.status__value { color: var(--text-primary); }
.status__live { color: var(--text-primary); font-weight: 500; }
.dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-color); flex: none; }
.status__live .dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent-color); animation: ring 2s ease-out infinite; }
@keyframes ring { from { transform: scale(1); opacity: 0.5; } to { transform: scale(1.8); opacity: 0; } }

/* ---------- Bento ---------- */
.bento { display: grid; gap: var(--space-4); }
.tile {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-6);
  background: var(--bg-elevated);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast) ease;
  min-width: 0;
}
.tile:hover { border-color: var(--glow-color); }
.tile h3 { font-size: var(--text-xl); }
.tile p { color: var(--text-secondary); }
.tile__label { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary-color); }
.tile__metric { font-family: var(--font-mono); font-size: var(--text-2xl); color: var(--text-primary); }
.tile__link { margin-top: auto; font-weight: 500; text-decoration: none; display: inline-flex; min-height: 44px; align-items: center; gap: var(--space-1); align-self: flex-start; }
.tile__link:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.tile--triage { box-shadow: inset 0 2px 0 var(--glow-color), var(--shadow-sm); }

.queue { border-top: 1px solid var(--panel-border); font-family: var(--font-mono); font-size: var(--text-sm); margin-top: var(--space-2); }
.queue li { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); min-height: 40px; border-bottom: 1px solid var(--panel-border); }
.queue__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue__state { color: var(--text-secondary); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-mono); }
.chip { justify-self: start; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 0.6875rem; text-transform: uppercase; letter-spacing: var(--tracking-mono); color: var(--primary-color); background: color-mix(in srgb, var(--glow-color) 12%, transparent); }
.chip--high { color: var(--accent-color); background: color-mix(in srgb, var(--accent-color) 14%, transparent); }

.tile__split { display: grid; gap: var(--space-6); align-items: center; }
.tile__split > div { display: grid; gap: var(--space-3); }
.lattice { width: 100%; max-width: 280px; color: var(--glow-color); }
.lattice__hit { fill: var(--accent-color); }

/* ---------- Steps ---------- */
ol.steps { display: grid; gap: var(--space-8); position: relative; padding-left: var(--space-16); }
.steps::before { content: ""; position: absolute; left: 20px; top: 20px; bottom: 20px; width: 1px; background: var(--glow-color); opacity: 0.4; }
.step { position: relative; display: grid; gap: var(--space-2); }
.step__node {
  position: absolute; left: calc(-1 * var(--space-16)); top: 0;
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--glow-color); background: var(--bg-secondary);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--primary-color);
}
.step__label { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-secondary); line-height: 40px; }
.step p { color: var(--text-secondary); max-width: 36ch; }

/* ---------- Proof ---------- */
.proof__stat em { font-style: normal; color: var(--secondary-color); }
:root[data-theme="light"] .proof__stat em { color: var(--primary-color); }
@media (prefers-color-scheme: light) { :root:not([data-theme]) .proof__stat em { color: var(--primary-color); } }
.quotes { display: grid; gap: var(--space-4); }
.quote {
  display: grid; gap: var(--space-4); padding: var(--space-6);
  background: var(--bg-elevated); border: 1px solid var(--panel-border); border-left: 3px solid var(--secondary-color);
  border-radius: var(--radius-lg);
}
.quote blockquote { font-size: var(--text-lg); }
.quote figcaption { color: var(--text-secondary); font-size: var(--text-sm); }
.quote figcaption strong { color: var(--text-primary); font-weight: 600; }
.logos { display: flex; flex-wrap: wrap; gap: var(--space-4) var(--space-10); margin-top: var(--space-10); font-family: var(--font-display); font-weight: 700; font-size: var(--text-lg); letter-spacing: 0.02em; color: var(--text-secondary); }
.logos li { opacity: 0.7; transition: opacity var(--duration-fast) ease; }
.logos li:hover { opacity: 1; }

/* ---------- CTA ---------- */
.cta-wrap { padding-top: 0; }
.cta-panel {
  position: relative; display: grid; gap: var(--space-5); justify-items: start;
  padding: var(--space-12) var(--space-6);
  background: var(--bg-elevated);
  border: 1px solid rgb(47 183 194 / 0.5);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glow);
}
.cta-panel::before, .cta-panel::after { content: ""; position: absolute; width: 20px; height: 20px; border: 0 solid var(--glow-color); }
.cta-panel::before { top: 10px; left: 10px; border-top-width: 2px; border-left-width: 2px; }
.cta-panel::after { bottom: 10px; right: 10px; border-bottom-width: 2px; border-right-width: 2px; }
.cta-panel .lead { color: var(--text-secondary); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border-color); padding-block: var(--space-12) var(--space-8); font-size: var(--text-sm); }
.footer__grid { display: grid; gap: var(--space-8); grid-template-columns: repeat(2, 1fr); }
.footer__brand { grid-column: 1 / -1; display: grid; gap: var(--space-3); justify-items: start; }
.footer__h { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-secondary); font-weight: 500; margin-bottom: var(--space-2); }
.site-footer ul a { display: inline-flex; min-height: 44px; align-items: center; color: var(--text-primary); text-decoration: none; }
.site-footer ul a:hover { color: var(--primary-color); }
.footer__status { display: flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: var(--tracking-mono); }
.dot--ok { background: var(--glow-color); }
.footer__legal { margin-top: var(--space-10); padding-top: var(--space-6); border-top: 1px solid var(--border-color); color: var(--text-secondary); }

/* ---------- Breakpoints ---------- */
@media (min-width: 640px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .tile--triage, .tile--graph { grid-column: 1 / -1; }
  .tile__split { grid-template-columns: 1.2fr 1fr; }
  .portal { max-width: 24rem; }
}
@media (min-width: 768px) {
  ol.steps { grid-template-columns: repeat(3, 1fr); padding-left: 0; padding-top: var(--space-16); }
  .steps::before { left: 20px; right: 20px; top: 20px; bottom: auto; width: auto; height: 1px; }
  .step__node { left: 0; top: calc(-1 * var(--space-16)); }
  .quotes { grid-template-columns: repeat(2, 1fr); }
  .cta-panel { padding: var(--space-16); }
  .footer__grid { grid-template-columns: 2fr repeat(4, 1fr); }
  .footer__brand { grid-column: auto; align-content: start; }
}
@media (min-width: 1024px) {
  .hero { padding-block: 0; }
  .hero__inner { grid-template-columns: 7fr 5fr; min-height: min(calc(100svh - var(--header-h) - 58px), 52rem); padding-block: var(--space-12); }
  .portal { max-width: 26rem; margin-right: 0; }
  .status__list { justify-content: space-between; width: auto; }
  .bento { grid-template-columns: repeat(4, 1fr); grid-template-areas: "triage triage identity identity" "triage triage cloud blade" "graph graph ledger ledger"; }
  .tile { padding: var(--space-8); }
  .tile--triage { grid-area: triage; }
  .tile--identity { grid-area: identity; }
  .tile--cloud { grid-area: cloud; }
  .tile--blade { grid-area: blade; }
  .tile--graph { grid-area: graph; }
  .tile--ledger { grid-area: ledger; }
}
@media (min-width: 1280px) {
  .hero__inner { grid-template-columns: 6fr 5fr; gap: var(--space-16); }
  .portal { max-width: 30rem; }
}

@media (prefers-reduced-motion: reduce) {
  .portal__scan, .status__live .dot::after { animation: none; display: none; }
}

/* Keep the placeholder label clear of the HUD readouts */
.portal .art-frame.is-missing::after { left: auto; right: var(--space-6); bottom: var(--space-6); }

.ledger { display: grid; gap: var(--space-2); font-family: var(--font-mono); font-size: var(--text-sm); }
.ledger li { display: flex; justify-content: space-between; gap: var(--space-4); padding-block: var(--space-2); border-bottom: 1px solid var(--panel-border); }
.ledger li span:last-child { color: var(--primary-color); font-size: var(--text-xs); letter-spacing: var(--tracking-mono); text-transform: uppercase; }

@media (max-width: 399px) { .hud--tr { display: none; } }
