/* 洹水之盟 · Oath of the Huan — waitlist page.
   The first screen is one in-game camera pulling back while you scroll;
   map instruments (width readout, log ruler, scale bar) are the page chrome. */

:root {
  color-scheme: light;
  --paper: #ece2c8;
  --paper-deep: #e0d3b2;
  --ground: #b6a973;        /* median of the pull frames */
  --ink: #17140f;
  --ink-soft: #4a4135;
  --ink-faint: rgba(23, 20, 15, .55);
  --cinnabar: #b3321c;
  --cinnabar-deep: #8c2614;
  --night: #15120e;
  --night-2: #1d1914;
  --night-text: #ebe0c6;
  --night-soft: rgba(235, 224, 198, .62);
  --rule: rgba(235, 224, 198, .16);
  --zh: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --en: "Spectral", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --en-sc: "Spectral SC", "Spectral", Georgia, serif;
  --gutter: clamp(16px, 4vw, 56px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { background: var(--night); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--zh); font-size: 17px; line-height: 1.75;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
[data-lang="en"] body { font-family: var(--en); font-size: 18px; line-height: 1.6; }
.en { display: none; }
[data-lang="en"] .en { display: revert; }
[data-lang="en"] .zh { display: none; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--cinnabar); outline-offset: 3px; }
.num { font-family: var(--en); font-variant-numeric: tabular-nums lining-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 30; pointer-events: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: calc(14px + var(--safe-t)) var(--gutter) 0;
  color: var(--ink); transition: color .4s;
}
.top > * { pointer-events: auto; }
.word { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .22em; font-size: 15px; text-decoration: none; }
[data-lang="en"] .word { font-family: var(--en-sc); letter-spacing: .12em; font-size: 16px; }
.word .g { width: 26px; height: 26px; }
.word .glyph { width: 100%; height: 100%; display: block; }
.word .glyph-guide { stroke: transparent; }
.word .glyph-ink { stroke: currentColor; }
.top-r { position: relative; display: flex; align-items: center; gap: 10px; }
.top-r .toast {
  position: absolute; right: 0; top: calc(100% + 10px); white-space: nowrap; pointer-events: none;
  padding: 7px 12px; border-radius: 3px; background: var(--ink); color: var(--paper); font-size: 13px;
  opacity: 0; transform: translateY(-4px);
}
.top-r .toast.pulse { animation: toast 2.4s var(--ease); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-4px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.langs {
  display: flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: rgba(236, 226, 200, .74); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px rgba(23, 20, 15, .1), 0 6px 20px -12px rgba(23, 20, 15, .5);
}
.langs button {
  font: 500 13px/1 var(--en); letter-spacing: .06em; color: var(--ink-soft);
  border: 0; background: none; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  transition: background .2s, color .2s;
}
.langs button[data-set-lang="zh"] { font-family: var(--zh); }
.langs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.top .cta-sm { opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .35s, transform .35s var(--ease), background .2s; }
.top.away .cta-sm { opacity: 1; transform: none; pointer-events: auto; }
.top.dark { color: var(--night-text); }
.top.dark .langs { background: rgba(29, 25, 20, .7); box-shadow: 0 0 0 1px rgba(235, 224, 198, .14); }
.top.dark .langs button { color: var(--night-soft); }
.top.dark .langs button[aria-pressed="true"] { background: var(--night-text); color: var(--night); }

/* ---------- buttons ---------- */
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.cta {
  display: inline-flex; align-items: center; gap: 12px; padding: 14px 24px 14px 18px; border-radius: 3px;
  background: var(--cinnabar); color: #f8efdc; text-decoration: none;
  font-weight: 600; font-size: 17px; letter-spacing: .14em; line-height: 1.2;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 14px 28px -16px rgba(140, 38, 20, .95);
  transition: background .2s, transform .2s var(--ease);
}
[data-lang="en"] .cta { letter-spacing: .02em; font-weight: 500; font-size: 18px; }
.cta:hover { background: var(--cinnabar-deep); transform: translateY(-1px); }
.cta:active { transform: none; }
.cta svg { width: 22px; height: 22px; flex: none; }
.cta-sm { padding: 8px 14px 8px 11px; font-size: 14px; gap: 8px; letter-spacing: .1em; }
[data-lang="en"] .cta-sm { font-size: 14px; }
.cta-sm svg { width: 17px; height: 17px; }
.pending { font-size: 14px; color: var(--ink-soft); }
.pending.pulse { animation: pulse 1.6s ease; }
@keyframes pulse { 20%, 60% { color: var(--cinnabar); } }

/* ---------- the pull ---------- */
.pull { position: relative; height: 640vh; }
.stage {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow: hidden;
  background: var(--ground) center / cover no-repeat;
  contain: layout paint;
}
.frames { position: absolute; inset: 0; z-index: 0; isolation: isolate; }
.frames img {
  position: absolute; display: none; max-width: none;
  transform-origin: 50% 50%; backface-visibility: hidden;
  user-select: none; -webkit-user-select: none; pointer-events: none;
}
.frames img.on { display: block; }
/* The closer frame sits on the wider one; a rectangular feather hides its edge.
   Both frames show the same ground at the same place, so the seam is invisible. */
.frames img.over {
  --f: 5%;
  -webkit-mask-image:
    linear-gradient(to right, transparent, #000 var(--f), #000 calc(100% - var(--f)), transparent),
    linear-gradient(to bottom, transparent, #000 var(--f), #000 calc(100% - var(--f)), transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent, #000 var(--f), #000 calc(100% - var(--f)), transparent),
    linear-gradient(to bottom, transparent, #000 var(--f), #000 calc(100% - var(--f)), transparent);
  mask-composite: intersect;
}
.frames.tall img.over {
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 var(--f), #000 calc(100% - var(--f)), transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 var(--f), #000 calc(100% - var(--f)), transparent);
}

/* Soft washes that keep type readable over the painting. */
.wash { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.wash.edge {
  background:
    linear-gradient(to bottom, rgba(236, 226, 200, .55), rgba(236, 226, 200, 0) 120px),
    linear-gradient(to top, rgba(40, 30, 14, .28), rgba(40, 30, 14, 0) 200px),
    radial-gradient(ellipse 130% 100% at 50% 50%, transparent 60%, rgba(52, 38, 16, .3) 100%);
}
.wash.title {
  background:
    linear-gradient(to top, rgba(236, 226, 200, .96) 0, rgba(236, 226, 200, .9) 26%, rgba(236, 226, 200, .5) 44%, rgba(236, 226, 200, 0) 62%),
    linear-gradient(to right, rgba(236, 226, 200, .5), rgba(236, 226, 200, 0) 50%);
}

/* instruments */
.plate {
  background: rgba(236, 226, 200, .8); -webkit-backdrop-filter: blur(10px) saturate(1.1); backdrop-filter: blur(10px) saturate(1.1);
  border-radius: 3px; box-shadow: 0 0 0 1px rgba(23, 20, 15, .08), 0 12px 32px -20px rgba(23, 20, 15, .7);
}
.readout {
  position: absolute; z-index: 5; right: calc(var(--gutter) + 44px); top: calc(76px + var(--safe-t));
  text-align: right; padding: 12px 16px 13px; min-width: 150px;
}
.readout .lbl { font: 500 12px/1 var(--en-sc); letter-spacing: .2em; color: var(--ink-soft); }
.readout .lbl .zh { font-family: var(--zh); letter-spacing: .32em; }
.readout .val {
  margin-top: 8px; font-size: clamp(32px, 3.6vw, 52px); line-height: 1; letter-spacing: -.01em;
  display: flex; align-items: baseline; justify-content: flex-end; gap: 8px;
}
.readout .unit { font-size: .4em; letter-spacing: .08em; font-family: var(--zh); }
[data-lang="en"] .readout .unit { font-family: var(--en); letter-spacing: 0; }

.ruler { position: absolute; z-index: 5; right: calc(var(--gutter) + 8px); top: calc(84px + var(--safe-t)); bottom: calc(104px + var(--safe-b)); width: 20px; }
.ruler .track { position: absolute; inset: 0; }
.ruler .line { position: absolute; right: 9px; top: 0; bottom: 0; width: 1px; background: var(--ink); box-shadow: 0 0 0 1.5px rgba(236, 226, 200, .55); }
.ruler .line::before, .ruler .line::after { content: ""; position: absolute; left: -5px; width: 11px; height: 1px; background: var(--ink); }
.ruler .line::before { top: 0; } .ruler .line::after { bottom: 0; }
.ruler .tick { position: absolute; right: 5px; width: 9px; height: 1px; background: var(--ink); box-shadow: 0 0 0 1px rgba(236, 226, 200, .55); }
.ruler .tick span {
  position: absolute; right: 16px; top: -9px; white-space: nowrap; padding: 3px 6px; border-radius: 2px;
  font: 500 11px/1 var(--en); font-variant-numeric: tabular-nums; color: var(--ink-soft);
  background: rgba(236, 226, 200, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.ruler .marker {
  position: absolute; right: 4px; width: 11px; height: 11px; margin-top: -5.5px; border-radius: 50%;
  background: var(--cinnabar); box-shadow: 0 0 0 2.5px var(--paper), 0 2px 8px rgba(23, 20, 15, .45);
}
.scalebar { position: absolute; z-index: 5; right: var(--gutter); bottom: calc(28px + var(--safe-b)); padding: 10px 14px 12px; }
.scalebar .lab {
  display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px;
  font: 500 12px/1 var(--en); font-variant-numeric: tabular-nums; color: var(--ink);
}
.scalebar .bar { height: 6px; display: flex; border: 1px solid var(--ink); background: var(--paper); margin-left: auto; transition: width .12s linear; }
.scalebar .bar i { flex: 1; }
.scalebar .bar i:nth-child(odd) { background: var(--ink); }

.beat {
  position: absolute; z-index: 6; left: var(--gutter); bottom: calc(96px + var(--safe-b));
  max-width: min(36rem, calc(100% - 2 * var(--gutter)));
  opacity: 0; transform: translateY(12px); transition: opacity .7s var(--ease), transform .7s var(--ease);
  pointer-events: none;
}
.beat.on { opacity: 1; transform: none; }
.beat p {
  margin: 0; display: inline; font-size: clamp(21px, 2.4vw, 32px); line-height: 1.62; font-weight: 600; letter-spacing: .06em;
  background: rgba(236, 226, 200, .86); box-decoration-break: clone; -webkit-box-decoration-break: clone; padding: 3px 12px;
}
[data-lang="en"] .beat p { letter-spacing: 0; font-weight: 500; }

/* title and end cards */
.card { position: absolute; z-index: 7; left: var(--gutter); bottom: calc(clamp(28px, 6vh, 64px) + var(--safe-b)); width: min(40rem, calc(100% - 2 * var(--gutter))); }
.card.end { top: 50%; bottom: auto; transform: translateY(-50%); width: min(34rem, calc(100% - 2 * var(--gutter))); }
.card .glyphs { display: flex; gap: clamp(4px, .8vw, 14px); margin: 0 0 20px -6px; }
.card .glyphs .g { width: clamp(58px, 7.4vw, 112px); aspect-ratio: 1; }
.card .glyph { width: 100%; height: 100%; display: block; overflow: visible; }
.card .glyph-guide { stroke: rgba(23, 20, 15, .1); }
.card .glyph-ink { stroke: var(--ink); }
.card h1, .card h2 { margin: 0; font-size: clamp(20px, 1.9vw, 26px); font-weight: 600; letter-spacing: .5em; line-height: 1.3; }
[data-lang="en"] .card h1 { font-family: var(--en-sc); letter-spacing: .2em; }
.card .sub { margin: 16px 0 26px; font-size: clamp(17px, 1.35vw, 19px); max-width: 30em; color: #2b251c; }
.hint { position: absolute; left: 50%; bottom: calc(22px + var(--safe-b)); transform: translateX(-50%); z-index: 7; flex-direction: column; display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-soft); letter-spacing: .12em; }
[data-lang="en"] .hint { letter-spacing: .04em; }
.hint .arrow { width: 1px; height: 34px; background: linear-gradient(var(--ink), transparent); animation: drop 2.2s ease-in-out infinite; transform-origin: top; }
@keyframes drop { 0% { transform: scaleY(.2); opacity: 0; } 40% { opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.start { transition: opacity .25s linear; }

.end { opacity: 0; pointer-events: none; transition: opacity .6s var(--ease); }
.end.on { opacity: 1; pointer-events: auto; }
.end .panel {
  background: rgba(236, 226, 200, .9); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  padding: clamp(22px, 3vw, 38px); border-radius: 3px; box-shadow: 0 30px 70px -40px rgba(23, 20, 15, .7);
}
.end h2 { letter-spacing: .3em; }
[data-lang="en"] .end h2 { font-family: var(--en-sc); letter-spacing: .16em; }
.end .sub { margin-bottom: 24px; }

/* ---------- footage ---------- */
.reel { background: var(--night); color: var(--night-text); padding: clamp(72px, 12vh, 140px) var(--gutter) clamp(56px, 9vh, 100px); }
.wrap { max-width: 1400px; margin: 0 auto; }
.reel .head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 30px; }
.reel h2 { margin: 0; font-size: clamp(24px, 2.4vw, 32px); font-weight: 600; letter-spacing: .24em; }
[data-lang="en"] .reel h2 { letter-spacing: 0; font-weight: 500; }
.reel .head p { margin: 0; color: var(--night-soft); font-size: 15px; }
.hero-clip { margin: 0 0 14px; }
.clip.hero-clip video { aspect-ratio: 21 / 9; }
.feats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 14px; margin-top: 14px; }
.feat { margin: 0; }
.feat .clip { margin-bottom: 16px; }
.feat h3 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: .14em; color: #f4e9cf; }
[data-lang="en"] .feat h3 { letter-spacing: .01em; font-weight: 500; font-size: 20px; }
.feat p { margin: 6px 0 0; color: var(--night-soft); font-size: 15px; line-height: 1.7; max-width: 30em; }
.clip { margin: 0; position: relative; overflow: hidden; border-radius: 2px; background: #0b0907; }
.clip video { width: 100%; height: 100%; object-fit: cover; display: block; aspect-ratio: 16 / 9; }
.clip .tag {
  position: absolute; right: 10px; bottom: 9px; padding: 3px 7px; border-radius: 2px;
  font: 500 11px/1 var(--en); letter-spacing: .08em; color: rgba(235, 224, 198, .86); background: rgba(11, 9, 7, .55);
}
.clip figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 44px 18px 14px;
  background: linear-gradient(rgba(11, 9, 7, 0), rgba(11, 9, 7, .8));
  font-size: 15px; color: rgba(235, 224, 198, .94);
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
}
.clip figcaption b { font-weight: 600; letter-spacing: .12em; }
[data-lang="en"] .clip figcaption b { letter-spacing: 0; font-weight: 500; }
.clip figcaption .num { font-size: 12px; opacity: .7; letter-spacing: .1em; }

.facts { margin-top: clamp(64px, 10vh, 110px); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; border-top: 1px solid var(--rule); padding-top: 28px; }
.fact .n { font-family: var(--en); font-variant-numeric: tabular-nums lining-nums; font-size: clamp(30px, 3.2vw, 46px); line-height: 1.1; color: #f4e9cf; }
.fact .n small { font-family: var(--zh); font-size: .44em; margin-left: 5px; letter-spacing: .06em; }
[data-lang="en"] .fact .n small { font-family: var(--en); letter-spacing: 0; }
.fact p { margin: 10px 0 0; color: var(--night-soft); font-size: 15px; max-width: 22em; }

.foot { background: var(--night); color: var(--night-text); padding: 0 var(--gutter) calc(48px + var(--safe-b)); }
.foot .wrap { border-top: 1px solid var(--rule); padding-top: 44px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 24px; }
.foot .pending { color: var(--night-soft); }
.foot .pending.pulse { animation: pulse2 1.6s ease; }
@keyframes pulse2 { 20%, 60% { color: #f2b49b; } }
.social { display: flex; gap: 22px; flex-wrap: wrap; font-size: 15px; }
.social a { text-decoration: none; color: rgba(235, 224, 198, .82); border-bottom: 1px solid rgba(235, 224, 198, .25); padding-bottom: 1px; transition: color .2s, border-color .2s; }
.social a:hover { color: #fff; border-color: rgba(255, 255, 255, .6); }
.fine { flex-basis: 100%; font-size: 13px; color: rgba(235, 224, 198, .42); margin: 6px 0 0; }
.fine.contact { font-size: 14px; color: rgba(235, 224, 198, .7); margin-top: 0; }
.fine.contact a { color: rgba(235, 224, 198, .9); text-decoration: none; border-bottom: 1px solid rgba(235, 224, 198, .3); }
.fine.contact a:hover { color: #fff; border-color: rgba(255, 255, 255, .6); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .feats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .clip.hero-clip video { aspect-ratio: 16 / 9; }
  .facts { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 720px) {
  .feats { grid-template-columns: 1fr; gap: 32px; }
  .ruler { display: none; }
  .readout { right: var(--gutter); top: calc(70px + var(--safe-t)); padding: 9px 12px 10px; min-width: 0; }
  .readout .lbl { font-size: 11px; }
  .readout .val { margin-top: 6px; font-size: 26px; }
  .top .cta-sm span.zh, .top .cta-sm span.en { display: none; }
  .top .cta-sm { padding: 8px 10px; }
  .wash.title { background: linear-gradient(to top, rgba(236, 226, 200, .97) 0, rgba(236, 226, 200, .9) 40%, rgba(236, 226, 200, 0) 70%); }
  .card { bottom: calc(22px + var(--safe-b)); }
  .scalebar { bottom: auto; top: calc(140px + var(--safe-t)); padding: 8px 12px 10px; }
  .card .glyphs { margin-bottom: 12px; }
  .card .glyphs .g { width: 54px; }
  .card .sub { margin: 12px 0 20px; font-size: 16px; }
  .hint { display: none; }
  .beat { bottom: calc(84px + var(--safe-b)); }
  .cta { font-size: 16px; padding: 13px 20px 13px 16px; }
}
@media (max-height: 560px) and (min-width: 721px) {
  .card .glyphs { display: none; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .beat, .end, .start, .top .cta-sm { transition: none; }
  .hint .arrow { animation: none; }
}
