/* =====================================================================
   SCAP home — projector stage (desktop). Shown only with body.stage-on,
   which an inline script sets on wide screens with a mouse. Phones and
   tablets never see it and keep the classic hero below.
   ===================================================================== */

.slide--stage { display: none; }
.stage-on .slide--stage { display: block; }
.stage-on .slide--hero,
.stage-on .slide--words { display: none; }

.slide--stage {
  --ink: #15131a;
  --paper: #f3eee4;
  height: calc(var(--count, 6) * 100vh);
  background: #050608;
}
.stage-pin {
  --accent: #29c3ff;
  --mx: 0;
  --my: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  cursor: pointer;
  isolation: isolate;
}
.stage-gl {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* no-WebGL fallback: plain pictures that crossfade */
.stage-plates { display: none; }
.stage-nogl .stage-gl { display: none; }
.stage-nogl .stage-plates { display: block; position: absolute; inset: 0; }
.stage-plate { position: absolute; inset: 0; opacity: 0; transition: opacity .9s ease; }
.stage-plate.tone-light { background: #f3eee4; }
.stage-plate.tone-dark { background: #07080b; }
.stage-plate.is-on { opacity: 1; }
.stage-plate i { position: absolute; inset: 0; background: center 30% / cover no-repeat; }
.stage-plate.frame-right i { left: 42%; }
.stage-plate.frame-left i { right: 42%; }
.stage-plate.tone-dark i { filter: grayscale(.4) brightness(.6) contrast(1.1); }

/* ---------------------------------------------------------------
   Scenes (text layer)
   --------------------------------------------------------------- */
.stage-scenes { position: absolute; inset: 0; pointer-events: none; }
.scene {
  position: absolute;
  inset: 0;
  visibility: hidden;
  color: #f3eee4;
}
/* pointer parallax on the type, via `translate` so it composes with the entrance transforms
   and doesn't create a stacking context that would cancel the blend modes */
.scene > * { translate: calc(var(--mx) * -18px) calc(var(--my) * -12px); }
.scene.tone-light { color: var(--ink); }
.scene.is-on,
.scene.is-out { visibility: visible; }
.scene a { pointer-events: auto; }

/* glyph masks — each character rises out of its own slot */
/* The mask is padded on every side (and pulled back with negative margins so layout
   doesn't move): fonts draw well outside a tight line-height box, and an unpadded
   mask would shave the tops, bottoms and sides off the glyphs. */
.g {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding: .3em;
  margin: -.3em;
}
.g > span {
  display: inline-block;
  transform: translate3d(0, calc(100% + .7em), 0);
  transition: transform .5s cubic-bezier(.7, 0, .84, 0);
}
.scene.is-on .g > span {
  transform: none;
  transition: transform 1.05s cubic-bezier(.16, 1, .3, 1);
  transition-delay: calc(.5s + var(--i) * 70ms);
}
.scene.is-out .g > span {
  transform: translate3d(0, calc(-100% - .7em), 0);
  transition-delay: calc(var(--i) * 30ms);
}

/* shared bits that fade/slide in after the title */
.sc-kicker, .sc-sub, .sc-hint, .sc-no, .sc-en, .sc-cta {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition: opacity .35s ease, transform .35s ease;
}
.scene.is-on .sc-kicker, .scene.is-on .sc-sub, .scene.is-on .sc-hint,
.scene.is-on .sc-no, .scene.is-on .sc-en, .scene.is-on .sc-cta {
  opacity: 1;
  transform: none;
  transition: opacity .8s ease, transform 1s cubic-bezier(.16, 1, .3, 1);
  transition-delay: 1s;
}
.scene.is-on .sc-en { transition-delay: 1.1s; }
.scene.is-on .sc-sub { transition-delay: 1.25s; }
.scene.is-on .sc-cta { transition-delay: 1.5s; }
.scene.is-on .sc-hint { transition-delay: 2s; }

.mono {
  font-family: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
}

/* typewriter for mono kickers */
.scene.is-on .sc-kicker { animation: stage-type 1.1s steps(28, end) 1s both; }
.scene.is-on .sc-en { animation: stage-type .9s steps(20, end) 1.1s both; }
@keyframes stage-type {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* ---------------- opening: SCAP ---------------- */
.scene--open .sc-kicker {
  position: absolute;
  left: 4vw;
  top: 15vh;
  margin: 0;
  font-size: 12px;
  color: #f6f2ea;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .8);
}
.scene--open .sc-kicker::before {
  content: "";
  display: inline-block;
  width: 22px;
  height: 2px;
  margin-right: 12px;
  vertical-align: middle;
  background: var(--accent);
  filter: brightness(1.6);
}
.sc-title { margin: 0; font-weight: 900; line-height: .82; }
.sc-title--mega {
  position: absolute;
  left: 3.4vw;
  bottom: 6vh;
  font-family: "Helvetica Neue", "Arial Black", Arial, sans-serif;
  font-size: min(25vw, 52vh);
  letter-spacing: -.065em;
  color: #f6f2ea;
  white-space: nowrap;
}
.sc-vert {
  writing-mode: vertical-rl;
  position: absolute;
  right: 6.5vw;
  top: 15vh;
  margin: 0;
  font-size: 15px;
  letter-spacing: .5em;
  font-weight: 500;
}
.sc-vert::before {
  content: "";
  display: inline-block;
  width: 1px;
  height: 60px;
  margin-bottom: 18px;
  background: currentColor;
  opacity: .6;
}
.sc-hint {
  position: absolute;
  right: 4vw;
  bottom: 7vh;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  opacity: .7;
}
.sc-hint i { position: relative; display: block; width: 48px; height: 1px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.sc-hint i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  filter: brightness(1.5);
  animation: stage-hint 2s cubic-bezier(.16, 1, .3, 1) infinite;
}
@keyframes stage-hint { from { transform: translateX(-100%); } 60%, to { transform: translateX(100%); } }

/* ---------------- chapters: 看番。合奏。… ---------------- */
.sc-no {
  position: absolute;
  top: 14vh;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
}
.sc-no b {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 72px;
  font-weight: 200;
  letter-spacing: -.04em;
  color: var(--accent);
}
.sc-no span { opacity: .55; }

/* the vertical title straddles the edge of the picture, printed over it */
.sc-title--vert {
  position: absolute;
  top: 12vh;
  writing-mode: vertical-rl;
  font-family: "PingFang SC", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: min(23vh, 14vw);
  letter-spacing: -.02em;
  line-height: 1;
}
.tone-light .sc-title--vert { color: var(--ink); mix-blend-mode: multiply; }
.tone-dark .sc-title--vert { color: #f3eee4; mix-blend-mode: normal; text-shadow: 0 0 60px rgba(0, 0, 0, .4); }

.sc-copy {
  position: absolute;
  bottom: 12vh;
  width: min(25vw, 360px);
}
.sc-en { margin: 0 0 16px; font-size: 11px; color: var(--accent); }
.tone-dark .sc-en { filter: brightness(1.5); }
.sc-copy .sc-sub { margin: 0; font-size: 17px; line-height: 1.9; font-weight: 500; }
.tone-light .sc-copy .sc-sub { color: rgba(21, 19, 26, .78); }
.tone-dark .sc-copy .sc-sub { color: rgba(243, 238, 228, .82); }

/* picture on the right → words on the left, title crossing the edge */
.scene.frame-right .sc-no { left: 6vw; }
.scene.frame-right .sc-copy { left: 6vw; }
.scene.frame-right .sc-title--vert { left: calc(42vw - min(23vh, 14vw) * .55); }
/* picture on the left → mirror */
.scene.frame-left .sc-no { right: 6vw; flex-direction: row-reverse; }
.scene.frame-left .sc-copy { right: 6vw; text-align: right; }
.scene.frame-left .sc-title--vert { left: calc(58vw - min(23vh, 14vw) * .45); }
/* dark full frames: words on the left over a shaded side */
.scene.frame-full.scene--chapter .sc-no,
.scene.frame-full.scene--chapter .sc-copy { left: 6vw; }
.scene.frame-full.scene--chapter .sc-title--vert { left: 30vw; }

/* ---------------- closing: 加入我们？ ---------------- */
.scene--close {
  z-index: 0;   /* own stacking context so the shadow below sits under the words, above the picture */
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 26px;
  text-align: center;
}
.sc-title--close {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 12.5vw;
  letter-spacing: -.03em;
  line-height: 1;
  color: #f6f2ea;
}
/* a pool of shadow behind the closing words */
.scene--close::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(60% 55% at 50% 50%, rgba(4, 4, 6, .72), rgba(4, 4, 6, .25) 70%, transparent);
  opacity: 0;
  transition: opacity 1s ease;
}
.scene--close.is-on::before { opacity: 1; }
.scene--close .sc-sub { margin: 0; font-size: 12px; opacity: .8; }
.sc-cta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 15px 26px;
  border: 1px solid rgba(255, 255, 255, .5);
  color: #fff;
  font-size: 12px;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  transition: color .35s ease, border-color .35s ease;
}
.sc-cta::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--accent);
  transform: translateX(-101%);
  transition: transform .5s cubic-bezier(.16, 1, .3, 1);
}
.sc-cta:hover, .sc-cta:focus-visible { border-color: var(--accent); }
.sc-cta:hover::before, .sc-cta:focus-visible::before { transform: none; }
.sc-cta i { font-style: normal; transition: transform .35s cubic-bezier(.16, 1, .3, 1); }
.sc-cta:hover i { transform: translateX(6px); }

/* ---------------- HUD: counter + ticks, bottom right ---------------- */
.stage-hud {
  position: absolute;
  right: 4vw;
  bottom: 3.4vh;
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 10px;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}
.stage-count b { font-weight: 600; }
.stage-ticks { display: flex; gap: 5px; }
.stage-ticks i {
  display: block;
  width: 18px;
  height: 2px;
  background: rgba(255, 255, 255, .3);
  transition: background .5s ease, width .5s cubic-bezier(.16, 1, .3, 1);
}
.stage-ticks i.is-on { background: #fff; }
.stage-ticks i.is-on:last-of-type { width: 28px; }

/* ---------------- page chrome over the stage ---------------- */
/* the frosted strip under the header would blur the top of every picture into a smudge */
.stage-view .deck-topfade { opacity: 0 !important; }
/* the nav sits on a small frosted pill so it stays readable over any picture.
   The blur lives on a pseudo-element: a backdrop-filter on the <ul> itself would
   become the containing block of the position:fixed dropdowns inside it. */
.stage-on header.site-header nav > ul { position: relative; }
.stage-on header.site-header nav > ul::before {
  content: "";
  position: absolute;
  inset: 4px -14px;
  z-index: -1;
  border-radius: 999px;
  background: rgba(8, 9, 12, .42);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease, background .6s ease;
}
.stage-view header.site-header nav > ul::before { opacity: 1; }
.stage-light header.site-header nav > ul::before { background: rgba(243, 238, 228, .75); }

.stage-light header.site-header { color: #15131a; }
.stage-light header.site-header a { color: #15131a; }
.stage-light .deck-topfade {
  background: linear-gradient(180deg, rgba(243, 238, 228, .85), rgba(243, 238, 228, .5) 40%, rgba(243, 238, 228, 0));
}
.stage-light .deck-topfade::after { opacity: 0; }
.stage-light .deck-dots button::before { background: rgba(21, 19, 26, .35); }
.stage-light .deck-dots button.is-current::before { background: #15131a; }
.stage-light .deck-cursor { border-color: rgba(21, 19, 26, .7); mix-blend-mode: normal; }
.stage-light .deck-cursor span { background: #15131a; }
.home-deck header.site-header,
.home-deck header.site-header a,
.deck-topfade { transition: color .6s ease, background .6s ease, opacity .6s ease; }

/* ---------------------------------------------------------------
   Portrait (phones, tablets held upright). Same scenes, same effects,
   stacked: "right" frames put the picture on top (0–58%), "left" frames
   at the bottom (42–100%) — see RECT_TALL in home-stage.js. Vertical
   positions are % of the stage so they stay locked to those frames.
   --------------------------------------------------------------- */
@media (max-aspect-ratio: 1/1) {
  /* small-viewport height: doesn't jump when the phone's address bar slides */
  .stage-pin { height: 100vh; height: 100svh; }
  .slide--stage { --vt: min(15.5vw, 12.5svh); }

  /* opening */
  .scene--open .sc-kicker { left: 6vw; top: 11%; font-size: 10px; letter-spacing: .12em; max-width: 64vw; line-height: 1.7; }
  .scene--open .sc-kicker::before { width: 16px; margin-right: 8px; }
  .sc-title--mega { left: 4.5vw; bottom: 15%; font-size: min(27vw, 36svh); }
  .sc-vert { right: 5vw; top: 11%; font-size: 12px; letter-spacing: .4em; }
  .sc-vert::before { height: 36px; margin-bottom: 12px; }
  .sc-hint { right: auto; left: 6vw; bottom: 8.5%; }

  /* chapters */
  .sc-title--vert { font-size: var(--vt); top: auto; }
  .sc-no b { font-size: 46px; }
  .sc-copy .sc-sub { font-size: 15px; line-height: 1.85; }
  .sc-en { margin-bottom: 10px; }

  /* picture on top → title straddles its bottom edge on the left, words below on the right */
  .scene.frame-right .sc-title--vert { left: 6vw; top: calc(58% - var(--vt) * 1.65); }
  .scene.frame-right .sc-no { left: auto; right: 6vw; top: 62%; flex-direction: row; }
  .scene.frame-right .sc-copy {
    left: calc(12vw + var(--vt));
    right: 6vw;
    width: auto;
    bottom: 9%;
    text-align: left;
  }

  /* picture at the bottom → words on top, title straddles the picture's top edge on the right */
  .scene.frame-left .sc-title--vert { left: auto; right: 6vw; top: calc(42% - var(--vt) * 1.35); }
  .scene.frame-left .sc-no { right: auto; left: 6vw; top: 11%; flex-direction: row; }
  .scene.frame-left .sc-copy {
    right: auto;
    left: 6vw;
    width: calc(100vw - 18vw - var(--vt));
    top: calc(11% + 64px);
    bottom: auto;
    text-align: left;
  }

  /* closing */
  .sc-title--close { font-size: 15vw; }
  .scene--close { gap: 20px; }

  .stage-hud { right: 5vw; bottom: 2.6%; gap: 10px; }
  .stage-ticks i { width: 10px; }
  .stage-ticks i.is-on:last-of-type { width: 16px; }
}

/* phones held sideways: very little height, keep the type clear of the bottom HUDs */
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  .sc-title--mega { bottom: 17%; font-size: min(25vw, 44vh); }
  .sc-hint { bottom: 16%; }
  .scene--open .sc-kicker, .sc-vert { top: 17%; }
  .sc-vert { font-size: 12px; letter-spacing: .28em; }
  .sc-vert::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .g > span, .scene .sc-kicker, .scene .sc-sub, .scene .sc-hint, .scene .sc-no, .scene .sc-en, .scene .sc-cta {
    transition: none !important;
    animation: none !important;
  }
  .scene > * { translate: none; }
}
