/* Self-hosted (CSP is same-origin only). Rebuild subsets with tools/build_fonts.py. */
@font-face {
  font-family: "DL Grotesk";
  src: url("fonts/grotesk.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: "DL Serif";
  src: url("fonts/newsreader-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 380;
  font-display: swap;
}
/* 楷体 is the Chinese counterpart of an italic: a calligraphic face, never a slanted Song/Hei. */
@font-face {
  font-family: "DL Kai";
  src: url("fonts/wenkai.woff2") format("woff2");
  font-display: swap;
}

:root {
  --bg: #f3f0e9;
  --ink: #161514;
  --muted: #6f6c64;
  --soft: rgba(22, 21, 20, 0.06);
  --line: rgba(22, 21, 20, 0.14);
  --stage: #df4219;
  --stage-ink: #fcf1e4;
  --stage-dark: #1b0d07;
  --sans: "DL Grotesk", ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --italic: "DL Serif", "Iowan Old Style", Georgia, serif;
  --kai: "DL Kai", "Kaiti SC", "STKaiti", "KaiTi", "AR PL UKai CN", serif;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --gutter: clamp(10px, 1.2vw, 16px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f0e;
    --ink: #efebe2;
    --muted: #8f8b82;
    --soft: rgba(239, 235, 226, 0.07);
    --line: rgba(239, 235, 226, 0.14);
    --stage: #d23c15;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Never fake an italic or bold: a slanted ideograph looks broken. */
  font-synthesis: none;
}
::selection { background: var(--stage-dark); color: var(--stage-ink); }
a { color: inherit; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 10px; }

/* top bar, on paper */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px calc(var(--gutter) + clamp(14px, 2.6vw, 40px));
}
.mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 650; font-size: 1.2rem; letter-spacing: -0.02em; text-decoration: none;
}
.glyph { width: 26px; height: 26px; border-radius: 8px; background: var(--stage); position: relative; }
.glyph::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: 10.5px; height: 5px;
  border-radius: 3px; background: var(--stage-ink);
  animation: blink 6s var(--ease) 2.4s infinite;
}
@keyframes blink { 0%, 92%, 100% { transform: scaleX(1); } 96% { transform: scaleX(0.2); } }

.lang { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--soft); }
.lang button {
  appearance: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 0.85rem; padding: 5px 12px; border-radius: 9px;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
.lang button:hover { color: var(--ink); }
.lang button[aria-pressed="true"] { background: var(--bg); color: var(--ink); box-shadow: 0 1px 0 var(--line); }

/* the orange field: copy on the left, curves on the right, one surface */
.stage {
  --pad: clamp(24px, 4vw, 64px);
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 40px;
  margin: 0 var(--gutter) var(--gutter);
  padding: var(--pad);
  min-height: 600px;
  border-radius: 30px;
  overflow: hidden;
  isolation: isolate;
  background: var(--stage);
  color: var(--stage-ink);
}
.ridges { position: absolute; inset: 0; width: 100%; height: 100%; display: block; z-index: -1; }

.tag {
  position: absolute; top: 18px; right: 18px;
  padding: 6px 12px; border-radius: 10px; font-size: 0.78rem; letter-spacing: 0.02em;
  background: color-mix(in srgb, var(--stage-ink) 14%, transparent);
}
.clock { display: flex; gap: 14px; font-variant-numeric: tabular-nums; }
.zone { display: inline-flex; gap: 6px; }
.zone span { opacity: 0.7; }
.zone b { font-weight: 560; }

.copy { max-width: 640px; }

.chip {
  display: inline-flex; align-items: center; flex-wrap: wrap;
  margin: 0 0 26px; padding: 6px 14px 6px 12px; border-radius: 11px;
  background: color-mix(in srgb, var(--stage-ink) 14%, transparent); font-size: 0.9rem;
}
.chip::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--stage-ink); margin-right: 10px;
  animation: ping 2.8s var(--ease) infinite;
}
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--stage-ink) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }

.bar {
  display: inline-block; width: var(--w); height: 0.95em; border-radius: 4px;
  margin: 0 0.4em; background: var(--stage-dark); vertical-align: -0.12em;
  clip-path: inset(0 0 0 0 round 4px);
  animation: draw 700ms cubic-bezier(.7, 0, .2, 1) var(--bd, 900ms) both;
}
/* No gap before the closing full stop. */
.bar.end { margin-right: 0.08em; }
@keyframes draw { from { clip-path: inset(0 100% 0 0 round 4px); } }

h1 {
  margin: 0;
  font-weight: 620;
  font-size: clamp(2.7rem, 5.6vw, 5.4rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}
h1 span, h1 em { display: block; width: fit-content; }
h1 em {
  font-family: var(--italic);
  font-style: italic;
  font-weight: 380;
  font-size: 1.12em;
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--stage-dark);
  padding-left: 0.04em;
}

.lead { margin: 24px 0 0; max-width: 30em; font-size: clamp(1rem, 1.25vw, 1.12rem); opacity: 0.9; text-wrap: pretty; }
.lead span + span::before { content: " "; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 34px; }
.btn {
  display: inline-flex; align-items: center; gap: 14px;
  height: 54px; padding: 0 12px 0 22px; border-radius: 16px;
  font-size: 1.04rem; font-weight: 540; text-decoration: none;
  transition: transform .3s var(--ease), background-color .3s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--stage-dark); color: var(--stage-ink); }
.btn.ghost { background: color-mix(in srgb, var(--stage-ink) 16%, transparent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--stage-ink) 24%, transparent); }
kbd {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
  border: 1px solid currentColor; border-radius: 7px; font: 600 0.7rem/1 var(--sans); opacity: 0.5;
}
@media (pointer: coarse) { kbd { display: none; } .btn { padding-right: 22px; } }

.foot { display: flex; flex-wrap: wrap; gap: 6px 18px; width: fit-content; font-size: 0.85rem; opacity: 0.8; }
.foot a { text-decoration: none; }
.foot a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* portal page: the list of systems */
.systems { list-style: none; margin: 30px 0 0; padding: 0; display: grid; gap: 8px; max-width: 460px; }
.sys {
  display: grid; grid-template-columns: 1.9rem minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 16px 16px 16px 14px; border-radius: 18px; text-decoration: none;
  background: color-mix(in srgb, var(--stage-ink) 12%, transparent);
  transition: background-color .25s var(--ease), color .25s var(--ease), transform .3s var(--ease);
}
.sys .n { font-size: 0.78rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
.sys .name { font-size: 1.6rem; font-weight: 560; letter-spacing: -0.03em; line-height: 1.1; }
.sys .go { width: 1.2rem; text-align: right; font-size: 1.1rem; transition: transform .3s var(--ease); }
.sys .soon { font-size: 0.8rem; opacity: 0.7; }
a.sys:hover { background: var(--stage-dark); transform: translateX(4px); }
a.sys:hover .go { transform: translateX(4px); }
.sys.off { opacity: 0.55; }

/* Chinese: the italic line becomes 楷体; Hei for the rest, looser rhythm, no negative tracking. */
:lang(zh) h1 { font-weight: 600; letter-spacing: 0.01em; line-height: 1.12; }
:lang(zh) h1 em {
  font-family: var(--kai); font-style: normal; font-weight: 400;
  font-size: 1.08em; letter-spacing: 0.02em; line-height: 1.12; padding-left: 0;
}
:lang(zh) .lead { line-height: 1.9; letter-spacing: 0.04em; }
:lang(zh) .lead span + span::before { content: none; }
:lang(zh) .bar { margin: 0 0.3em; }
:lang(zh) .bar.end { margin-right: 0; }
:lang(zh) .chip, :lang(zh) .tag, :lang(zh) .lang button, :lang(zh) .foot { letter-spacing: 0.06em; }
:lang(zh) .btn { letter-spacing: 0.08em; }
.sys .name:lang(zh) { font-family: var(--kai); font-weight: 400; letter-spacing: 0.08em; font-size: 1.75rem; }

/* load-in */
.rise { animation: rise 900ms var(--ease) var(--d, 0ms) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.stage.rise { animation-name: unveil; animation-duration: 1100ms; }
@keyframes unveil { from { opacity: 0; transform: scale(.99); } }

@media (max-width: 760px) {
  .stage { justify-content: flex-start; padding-top: 72px; min-height: 92svh; border-radius: 26px; }
  .foot { margin-top: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .rise, .bar, .glyph::after, .chip::before { animation: none; }
  .btn, .sys, .sys .go { transition: none; }
}
