/* Qumbra — site styles
   Palette is the brand palette, unchanged. See qumbra-design/brand/README.md:
     #0B0E15 void    ground, dark
     #E6EAF0 signal  the mark, on dark
     #10131C umbra   the mark, on light
     #EFF1F2 paper   ground, light
   Register: astronomical, not gothic. Eclipse geometry, not horror-movie darkness. */

:root {
  --void:   #0B0E15;
  --signal: #E6EAF0;
  --umbra:  #10131C;
  --paper:  #EFF1F2;

  --bg:      var(--void);
  --bg-alt:  #0E121B;
  --fg:      var(--signal);
  --fg-mute: #8C97AB;
  --rule:    #1D2331;
  --card:    #11162010;
  --card-bg: #121724;
  --accent:  #7FD4C1;   /* annular ring: the one bright edge around the shadow */
  --green:   #5BC98F;
  --amber:   #E0B252;
  --red:     #E0666B;

  --measure: 68ch;
  --wrap: 1080px;
  --radius: 10px;
}

html[data-theme="light"] {
  --bg:      var(--paper);
  --bg-alt:  #E4E7EA;
  --fg:      var(--umbra);
  --fg-mute: #5A6473;
  --rule:    #CDD3D9;
  --card-bg: #FFFFFF;
  --accent:  #157F6A;
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    --bg:      var(--paper);
    --bg-alt:  #E4E7EA;
    --fg:      var(--umbra);
    --fg-mute: #5A6473;
    --rule:    #CDD3D9;
    --card-bg: #FFFFFF;
    --accent:  #157F6A;
  }
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 17px/1.65 ui-sans-serif, -apple-system, "Segoe UI", "Helvetica Neue",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ── bilingual switch ─────────────────────────────────────────────
   Both languages ship in the HTML; the inactive one is removed from
   the accessibility tree as well as the layout. Mirrors the design
   repo's own EN/ZH pairing convention. */
body [lang="en"] { display: none; }
body [lang="zh"] { display: none; }
html[data-lang="en"] body [lang="en"] { display: revert; }
html[data-lang="zh"] body [lang="zh"] { display: revert; }

html[data-lang="zh"] body { line-height: 1.8; }

code {
  font: 0.88em/1.4 ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  padding: 0.12em 0.36em;
  border-radius: 4px;
}

a { color: inherit; }

.skip {
  position: absolute; left: -9999px;
  background: var(--accent); color: var(--void);
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 var(--radius) 0;
}
.skip:focus { left: 0; top: 0; }

.wrap { width: min(100% - 3rem, var(--wrap)); margin-inline: auto; }

/* ── top bar ─────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .85rem max(1.5rem, calc((100% - var(--wrap)) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.mark { width: 26px; height: 26px; color: var(--fg); flex: none; }
.wordmark { font-weight: 600; letter-spacing: .06em; font-size: 1.02rem; }

.nav { display: flex; gap: 1.35rem; margin-left: auto; font-size: .92rem; }
.nav a { color: var(--fg-mute); text-decoration: none; padding: .2rem 0; border-bottom: 1px solid transparent; }
.nav a:hover, .nav a:focus-visible { color: var(--fg); border-bottom-color: var(--accent); }

.controls { display: flex; gap: .5rem; }
.pill {
  font: inherit; font-size: .82rem; line-height: 1;
  padding: .48rem .7rem; min-width: 3rem;
  color: var(--fg-mute); background: transparent;
  border: 1px solid var(--rule); border-radius: 999px;
  cursor: pointer;
}
.pill:hover, .pill:focus-visible { color: var(--fg); border-color: var(--accent); }
html[data-theme="light"] .t-light, .t-dark { display: none; }
html[data-theme="light"] .t-dark { display: inline; }
html:not([data-theme="light"]) .t-light { display: inline; }

@media (max-width: 860px) {
  .nav { display: none; }
  .controls { margin-left: auto; }
}

/* ── hero ────────────────────────────────────────────────────── */
.hero {
  padding: clamp(3.5rem, 9vw, 7rem) 0 clamp(3rem, 6vw, 5rem);
  /* the umbra: a soft dark core against the surrounding ground */
  background:
    radial-gradient(ellipse 70% 55% at 50% -10%,
      color-mix(in srgb, var(--accent) 11%, transparent), transparent 70%);
  border-bottom: 1px solid var(--rule);
}

.eyebrow {
  margin: 0 0 1.4rem;
  font-size: .82rem; letter-spacing: .11em; text-transform: uppercase;
  color: var(--fg-mute);
}
html[data-lang="zh"] .eyebrow { text-transform: none; letter-spacing: .05em; font-size: .86rem; }

h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(2.05rem, 5.2vw, 3.5rem);
  line-height: 1.12; letter-spacing: -0.022em; font-weight: 600;
  max-width: 26ch;
}
/* `ch` is the width of "0" in the Latin face, but a CJK glyph is about twice that,
   so the Latin measure orphans the last character or two. Wider measure, slightly
   smaller face — 20 CJK characters then fit the line the <br> intends. */
html[data-lang="zh"] h1 {
  line-height: 1.32; letter-spacing: normal;
  font-size: clamp(1.8rem, 4.3vw, 2.9rem);
  max-width: 30ch;
}

.lede { max-width: var(--measure); font-size: 1.1rem; color: var(--fg-mute); margin: 0 0 2rem; }
.lede em { color: var(--fg); font-style: italic; }
html[data-lang="zh"] .lede em { font-style: normal; font-weight: 600; }

.cta { display: flex; flex-wrap: wrap; gap: .7rem; margin: 0 0 2.6rem; }
.btn {
  display: inline-block; text-decoration: none;
  padding: .62rem 1.15rem; font-size: .93rem; font-weight: 500;
  border: 1px solid var(--rule); border-radius: 999px; color: var(--fg);
}
.btn:hover, .btn:focus-visible { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--void); }
.btn.primary:hover, .btn.primary:focus-visible {
  background: transparent; color: var(--accent);
}
html[data-theme="light"] .btn.primary { color: var(--paper); }
html[data-theme="light"] .btn.primary:hover { color: var(--accent); }

.disclaimer {
  max-width: var(--measure);
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--card-bg);
  font-size: .95rem; color: var(--fg-mute);
}
/* strong carries no lang attribute, so the bilingual display rules never touch it —
   each language is one <div lang> wrapper instead. Keep it that way: a lang-tagged
   element whose display an author rule also sets is a specificity coin-flip. */
.disclaimer strong { color: var(--fg); display: block; margin-bottom: .4rem; }
.disclaimer em { color: var(--fg); }

/* ── bands ───────────────────────────────────────────────────── */
.band { padding: clamp(3rem, 7vw, 5.5rem) 0; border-bottom: 1px solid var(--rule); }
.band.alt { background: var(--bg-alt); }

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 3.2vw, 2.1rem);
  line-height: 1.25; letter-spacing: -0.015em; font-weight: 600;
  max-width: 26ch;
}
html[data-lang="zh"] h2 { letter-spacing: normal; line-height: 1.45; }

.section-lede { max-width: var(--measure); color: var(--fg-mute); margin: 0 0 2.4rem; }

.footnote {
  max-width: var(--measure); margin: 2.2rem 0 0;
  font-size: .92rem; color: var(--fg-mute);
  padding-top: 1.2rem; border-top: 1px solid var(--rule);
}

.muted { color: var(--fg-mute); font-size: .95rem; }

/* ── cards ───────────────────────────────────────────────────── */
.grid { display: grid; gap: 1.1rem; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); }
/* min() keeps this at two columns at full width instead of collapsing to three
   and orphaning the fourth status card, while still going single-column on narrow. */
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); }

.card {
  padding: 1.4rem 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.card h3 {
  margin: 0 0 .7rem; font-size: 1.03rem; font-weight: 600;
  display: flex; align-items: flex-start; gap: .55rem;
}
.card p { margin: 0; color: var(--fg-mute); font-size: .95rem; }
.card strong { color: var(--fg); }
.card em { color: var(--fg); }

a.card.link { text-decoration: none; display: block; transition: border-color .15s ease; }
a.card.link h3 { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: -0.01em; }
a.card.link:hover, a.card.link:focus-visible { border-color: var(--accent); }
a.card.link:hover h3, a.card.link:focus-visible h3 { color: var(--accent); }

.card.ok   { border-left: 3px solid var(--green); }
.card.warn { border-left: 3px solid var(--amber); }
.card.stop { border-left: 3px solid var(--red); }

/* margin-top optically centres the dot on the FIRST line of the heading; centring
   on the flex box instead drifts it to the middle when the title wraps. */
.dot { width: .55rem; height: .55rem; border-radius: 50%; flex: none; margin-top: .42em; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red   { background: var(--red); }

/* ── the mark section ────────────────────────────────────────── */
.mark-layout {
  display: grid; gap: clamp(2rem, 5vw, 4rem);
  grid-template-columns: minmax(160px, 260px) 1fr;
  align-items: start;
}
@media (max-width: 780px) {
  .mark-layout { grid-template-columns: 1fr; }
  .mark-art { max-width: 180px; }
}
.mark-art svg { width: 100%; height: auto; color: var(--fg); }
.mark-copy h2 { max-width: 30ch; }
.mark-copy p { max-width: var(--measure); }
.mark-copy p:first-of-type { color: var(--fg-mute); }
.mark-copy strong, .mark-copy em { color: var(--fg); }

/* ── stats ───────────────────────────────────────────────────── */
.stats {
  display: grid; gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat { background: var(--bg); padding: 1.35rem 1.4rem; }
.band.alt .stat { background: var(--bg-alt); }
.stat .v {
  font-size: 1.75rem; font-weight: 600; line-height: 1.1;
  letter-spacing: -0.02em; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.stat .v .u { font-size: .95rem; font-weight: 500; color: var(--fg-mute); letter-spacing: 0; }
.stat .k { margin-top: .5rem; font-size: .86rem; color: var(--fg-mute); line-height: 1.5; }

/* ── stack list ──────────────────────────────────────────────── */
.stack { list-style: none; counter-reset: layer; margin: 0; padding: 0; }
.stack li {
  counter-increment: layer;
  display: grid; grid-template-columns: 2.2rem minmax(160px, 15rem) 1fr;
  gap: 1.2rem; align-items: baseline;
  padding: 1.1rem 0;
  border-top: 1px solid var(--rule);
}
.stack li:last-child { border-bottom: 1px solid var(--rule); }
.stack li::before {
  content: counter(layer, decimal-leading-zero);
  font: 500 .8rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent);
}
.stack .layer { font-weight: 600; font-size: .98rem; }
.stack .detail { color: var(--fg-mute); font-size: .94rem; }

@media (max-width: 780px) {
  .stack li { grid-template-columns: 2.2rem 1fr; }
  .stack .detail { grid-column: 2; }
}

/* ── footer ──────────────────────────────────────────────────── */
.footer { padding: 3rem 0 4rem; color: var(--fg-mute); font-size: .92rem; }
.footer .reg { max-width: var(--measure); margin: 0 0 1.4rem; }
.footer strong { color: var(--fg); }
.footer .fine { font-size: .85rem; opacity: .8; margin: 0; }

/* ── focus ───────────────────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
