/* =============================================================
   SAKURA NIGHTFALL — the fused layer
   -------------------------------------------------------------
   Loaded AFTER styles.css. It does not touch the hero timeline,
   the four angles, the film, the creatures or the pointer — those
   are the site's, and they stay exactly as they were.

   What it does: takes the chrome and the page below the pin and
   rebuilds them in the Sakura Nightfall language — ink ground,
   sakura pink as the one interactive hue, crimson lacquer for
   emphasis, brushed-ink ornament hung off the edges of the frame,
   engraved display type, glow instead of shadow.

   Hebrew stays Hebrew: the display face is Frank Ruhl Libre (the
   nearest Hebrew serif to Cinzel's engraved weight) and the label
   face is Heebo tracked wide, so the brand's uppercase-and-tracked
   rhythm survives in a script that has no uppercase.
   ============================================================= */

:root {
  --he-display: "Frank Ruhl Libre", var(--font-serif), Georgia, serif;
  --he-ui: "Heebo", var(--font-ui), system-ui, sans-serif;
  --worn: polygon(0.6% 6%, 3% 0, 97% 1.5%, 99.4% 8%, 100% 90%, 97.5% 100%, 3.5% 98.5%, 0.8% 92%);
  --rule-fade: linear-gradient(90deg, rgba(244,167,189,.34), rgba(244,167,189,0));

  /* The pinned timeline grows to make room for the object: the rotation
     keeps its original physical length, the inspect phase gets ~1.6vh,
     and the video scrub keeps roughly the 3.3vh it always had.
     main.js puts this back to 5.6 if the GLB never arrives. */
  --scroll-len: calc(var(--vh) * 7.2);
}

/* =============================================================
   THE OBJECT — same box as the four pictures, to the pixel
   -------------------------------------------------------------
   It has to occupy the EXACT frame the PNGs occupy, or the
   crossfade reads as a swap instead of a material change. So it
   inherits the identical geometry rule, sits directly above
   .figures in the stack, and is faded by main.js alone.
   ============================================================= */

.model-layer {
  position: absolute;
  left: 50%;
  top: calc(50% - var(--vh) * 0.015);
  height: var(--fig-h);
  aspect-ratio: 1024 / 1536;
  transform: translate(-50%, -50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* vertical drags still scroll the page — only sideways is ours */
  touch-action: pan-y;
  -webkit-user-select: none;
          user-select: none;
  will-change: opacity;
}
.model-layer canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* The one affordance. Tracked label in the brand's rhythm, sitting where
   the scroll hint sat — the frame's own lower register. */
.model-cue {
  position: absolute;
  left: 50%;
  bottom: calc(var(--sa-b, 0px) + 4.2vh);
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 20px;
  font: 500 10.5px/1 var(--he-ui);
  letter-spacing: .38em;
  text-indent: .38em;
  color: rgba(246,238,241,.82);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  text-shadow: 0 1px 14px rgba(0,0,0,.8);
  border: 1px solid var(--border-hairline);
  border-radius: 999px;
  background: rgba(8,6,7,.34);
  -webkit-backdrop-filter: var(--blur-glass);
          backdrop-filter: var(--blur-glass);
  z-index: 3;
}
@media (max-width: 780px) {
  .model-cue { letter-spacing: .28em; text-indent: .28em; font-size: 9.5px; }
}

body { background: var(--ink-1000); }
::selection { background: var(--sakura-700); color: var(--parchment-100); }

/* =============================================================
   CHROME — the glass header
   ============================================================= */

.nav {
  background: linear-gradient(180deg, rgba(5,4,5,.9) 0%, rgba(5,4,5,.55) 62%, rgba(5,4,5,0) 100%);
  -webkit-backdrop-filter: var(--blur-glass);
          backdrop-filter: var(--blur-glass);
  border-bottom: 1px solid var(--border-hairline);
}
.nav__brand { gap: 3px; }
.nav__brand-he {
  font: 600 20px/1 var(--he-display);
  letter-spacing: .04em;
  color: var(--text-primary);
  text-shadow: var(--glow-text);
}
.nav__brand-sub {
  font: 500 9.5px/1 var(--he-ui);
  letter-spacing: .3em;
  color: var(--sakura-300);
  opacity: .78;
}
.nav__links a {
  font: 500 12px/1 var(--he-ui);
  letter-spacing: .2em;
  color: var(--text-secondary);
  border-bottom: 0;
}
.nav__links a.is-active { color: var(--sakura-200); text-shadow: var(--glow-text); }
.nav__links a.is-active::after {
  left: 8px; right: 8px; bottom: 8px; height: 8px;
  border-radius: 0;
  background: url("ds-assets/ornaments/brush-swash-red.png") center / 100% 100% no-repeat;
  opacity: .9;
}
@media (hover: hover) and (pointer: fine) {
  .nav__links a:hover { color: var(--sakura-200); }
}

/* =============================================================
   CONTROLS — the worn plaque, taken from the kit's buttons
   ============================================================= */

.btn {
  min-height: 46px;
  padding: 0 26px;
  gap: 12px;
  border: 0;
  border-radius: var(--radius-xs, 2px);
  clip-path: var(--worn);
  font: 500 12.5px/1 var(--he-ui);
  letter-spacing: .18em;
  text-transform: none;
  color: var(--sakura-200);
  background: linear-gradient(178deg, rgba(26,22,24,.92), rgba(10,8,9,.96));
  box-shadow:
    0 0 0 1px var(--border-crimson),
    inset 0 0 0 4px rgba(10,8,9,.9),
    inset 0 0 0 5px rgba(232,38,55,.32);
  transition: var(--transition-control);
}
.btn--sm { min-height: 40px; padding: 0 18px; font-size: 11px; }
.btn--lg {
  min-height: 62px; padding: 0 44px; font-size: 14px; letter-spacing: .2em;
  color: var(--parchment-100);
  background: linear-gradient(178deg, var(--sakura-500), var(--sakura-700) 96%);
  box-shadow: var(--shadow-inset-lip), 0 0 0 1px rgba(38,10,16,.55);
  text-shadow: 0 1px 1px rgba(60,14,24,.55);
}
@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    color: var(--sakura-100);
    border-color: transparent;
    box-shadow:
      0 0 0 1px var(--border-crimson),
      inset 0 0 0 4px rgba(10,8,9,.9),
      inset 0 0 0 5px rgba(232,38,55,.32),
      0 0 22px var(--glow-crimson);
  }
  .btn--lg:hover {
    background: linear-gradient(178deg, var(--sakura-400), var(--sakura-600) 92%);
    box-shadow: var(--shadow-inset-lip), 0 0 0 1px rgba(38,10,16,.55), 0 0 26px var(--glow-sakura);
  }
}
.btn:active { transform: var(--press-scale); }

/* =============================================================
   THE PAGE — ink ground, atmospheric plates, brush rules
   ============================================================= */

.content {
  counter-reset: chapter;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(156,68,89,.16) 0%, rgba(156,68,89,0) 62%),
    linear-gradient(180deg, var(--ink-1000) 0%, var(--ink-900) 40%, var(--ink-1000) 100%);
}
.page-atmos {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

/* No z-index here on purpose: a stacking context would isolate every
   screen-blended brush stroke inside it and leave it sitting on its own
   black backing plate. Positioned-but-auto keeps the sections above the
   atmosphere while the ornament still blends with the ground. */
.sec {
  position: relative;
  counter-increment: chapter;
  border-top: 0;
  max-width: 76ch;
  padding: clamp(84px, 13vh, 168px) 0 clamp(72px, 11vh, 140px);
}
/* brush stroke instead of a hairline between chapters.
   The divider plates were cropped off the sheet with their dark ground
   attached, so `screen` lifts that ground into a visible rectangle — the
   elliptical mask dissolves the crop and leaves only the stroke. */
.sec::before {
  content: "";
  display: block;
  width: min(430px, 72%);
  aspect-ratio: 450 / 64;
  margin: 0 auto clamp(52px, 8vh, 104px);
  background: url("ds-assets/ornaments/divider-brush-blossoms.png") center / contain no-repeat;
  mix-blend-mode: screen;
  opacity: .7;
  -webkit-mask-image: radial-gradient(ellipse 58% 62% at 50% 50%, #000 42%, transparent 100%);
          mask-image: radial-gradient(ellipse 58% 62% at 50% 50%, #000 42%, transparent 100%);
}
.sec:first-child::before { display: none; }

/* eyebrow: chapter numeral, tracked label, a rule running off toward the margin */
.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  font: 500 11px/1 var(--he-ui);
  letter-spacing: .28em;
  color: var(--sakura-300);
  text-transform: none;
  margin: 0 0 26px;
}
.eyebrow::before {
  content: counter(chapter, decimal-leading-zero);
  font: 600 12px/1 var(--font-display);
  letter-spacing: .14em;
  color: var(--crimson-400);
  text-shadow: 0 0 12px rgba(232,38,55,.5);
}
.eyebrow::after {
  content: "";
  flex: 1;
  max-width: 120px;
  height: 1px;
  background: var(--rule-fade);
  transform: scaleX(-1);
}

.h1 {
  font: 600 clamp(40px, 6.6vw, 86px)/1.04 var(--he-display);
  letter-spacing: -.005em;
  color: var(--text-primary);
  text-shadow: var(--glow-text);
  margin: 0 0 28px;
}
.h2 {
  font: 600 clamp(27px, 3.9vw, 46px)/1.14 var(--he-display);
  letter-spacing: 0;
  color: var(--text-primary);
  text-shadow: var(--glow-text);
  margin: 0 0 24px;
}
.lede {
  font: 300 clamp(17px, 1.5vw, 21px)/1.72 var(--he-display);
  color: var(--text-secondary);
  max-width: 52ch;
  margin: 0 0 32px;
}
.sec--end .lede { margin-inline: auto; }
.lede a { color: var(--sakura-300); border-bottom: 1px solid var(--border-hairline); }
.lede a:hover { color: var(--sakura-200); border-bottom-color: var(--border-strong); }

.actions { gap: 14px; margin-top: 36px; }
.sec--end .actions { justify-content: center; }

/* ---------- cards ---------- */
.grid {
  gap: 14px;
  background: transparent;
  border: 0;
}
.grid article {
  position: relative;
  overflow: hidden;
  padding: 28px 26px 30px;
  background: var(--surface-card);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-xs, 2px);
  box-shadow: var(--shadow-md);
  transition: var(--transition-control);
}
.grid article::after {
  content: "";
  position: absolute;
  inset-inline-start: -18px;
  bottom: -22px;
  width: 96px; height: 96px;
  background: url("ds-assets/ornaments/blossom-sprig.png") center / contain no-repeat;
  opacity: 0;
  transform: rotate(-6deg);
  transition: opacity var(--dur-slow) var(--ease-drift);
  pointer-events: none;
}
.grid h3 {
  font: 600 17px/1.3 var(--he-display);
  color: var(--text-primary);
  margin: 0 0 10px;
}
.grid p {
  font: 400 13px/1.62 var(--he-ui);
  color: var(--text-muted);
}
.grid p a { color: var(--sakura-300); }
@media (hover: hover) and (pointer: fine) {
  .grid article:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md), var(--glow-soft);
    transform: var(--hover-lift);
  }
  .grid article:hover::after { opacity: .42; }
}

/* ---------- quotes ---------- */
#s02 .limits { position: relative; margin: 0 0 clamp(64px, 9vh, 110px); }
#s02 .limits li {
  border-top: 1px solid var(--border-hairline);
  padding: 26px 0;
  font: 300 clamp(18px, 2.1vw, 27px)/1.5 var(--he-display);
  color: var(--text-secondary);
}
#s02 .limits li:first-child { border-top: 0; }
#s02 .limits li::before {
  content: "";
  display: inline-block;
  width: 26px; height: 10px;
  margin-inline-end: 14px;
  vertical-align: middle;
  background: url("ds-assets/ornaments/divider-red-wave.png") center / contain no-repeat;
  mix-blend-mode: screen;
  opacity: .85;
  -webkit-mask-image: radial-gradient(ellipse 60% 62% at 50% 50%, #000 40%, transparent 100%);
          mask-image: radial-gradient(ellipse 60% 62% at 50% 50%, #000 40%, transparent 100%);
}

/* ---------- the soundtrack list ---------- */
#s04 .limits li {
  display: flex;
  align-items: baseline;
  gap: 16px;
  border-top: 1px solid var(--border-hairline);
  padding: 17px 0;
  font: 400 14.5px/1.4 var(--he-ui);
  letter-spacing: .06em;
  color: var(--text-secondary);
  transition: var(--transition-control);
}
#s04 .limits li:hover { color: var(--sakura-200); }
#s04 .lede { font-family: var(--font-serif); font-style: italic; color: var(--sakura-300); }

/* =============================================================
   ORNAMENT — hung off the edges of the frame, never inside it
   ============================================================= */

.orn {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  /* every plate is a rectangular crop off the art sheet — the frame has to
     dissolve into the ink, never meet it at a straight edge */
  -webkit-mask-image: radial-gradient(ellipse 64% 64% at 50% 50%, #000 46%, transparent 100%);
          mask-image: radial-gradient(ellipse 64% 64% at 50% 50%, #000 46%, transparent 100%);
}
/* The intro reads as one composed scene down the empty (left) side of the
   column: moon above, tree below it. The text side stays clear. */
.orn--tree { top: 14%; inset-inline-end: -13%; width: min(360px, 40vw); opacity: .38; }
.orn--moon { top: 82px; inset-inline-end: 20%; width: min(160px, 21vw); mix-blend-mode: screen; opacity: .6; animation: sn-glow-pulse 9s var(--ease-in-out-soft) infinite; }
.orn--beads { top: -30px; inset-inline-end: -13%; width: min(150px, 20vw); opacity: .3; }
.orn--swash { top: 44%; inset-inline-end: -16%; width: min(420px, 48vw); opacity: .12; }
.orn--lantern { bottom: 10%; inset-inline-end: -6%; width: min(160px, 20vw); opacity: .5; }
.orn--enso { top: 34%; inset-inline-end: -9%; width: min(250px, 29vw); mix-blend-mode: screen; opacity: .28; animation: sn-slow-turn 120s linear infinite; }
.orn--katana { top: 4%; inset-inline-end: -7%; height: min(420px, 76%); width: auto; opacity: .34; transform: rotate(8deg); }
.orn--torii {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  width: 100%;
  z-index: -1;
  opacity: .26;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 58%), linear-gradient(90deg, transparent 0%, #000 14%, #000 86%, transparent 100%);
          mask-image: linear-gradient(180deg, transparent 0%, #000 58%), linear-gradient(90deg, transparent 0%, #000 14%, #000 86%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-composite: intersect;
}
/* the closing section is centred type over artwork, so it gets the vignette
   scrim the brand asks for whenever text sits on a painted scene */
#s06::after {
  content: "";
  position: absolute;
  inset: -10% -20% 0;
  z-index: -1;
  background: var(--scrim-center);
  pointer-events: none;
}
@keyframes sn-slow-turn { to { transform: rotate(360deg); } }

/* =============================================================
   FOOTER
   ============================================================= */

.foot {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--border-hairline);
  background: linear-gradient(180deg, var(--ink-900), var(--ink-1000));
  padding-top: 64px;
  padding-bottom: calc(var(--sa-b) + 64px);
}
.foot__divider {
  position: absolute;
  top: 0; left: 50%;
  transform: translate(-50%, -46%);
  width: min(520px, 76vw);
  aspect-ratio: 520 / 88;
  background: url("ds-assets/ornaments/divider-brush-wide.png") center / contain no-repeat;
  mix-blend-mode: screen;
  opacity: .55;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 56% 60% at 50% 50%, #000 40%, transparent 100%);
          mask-image: radial-gradient(ellipse 56% 60% at 50% 50%, #000 40%, transparent 100%);
}
.foot__links a {
  font: 500 12px/1 var(--he-ui);
  letter-spacing: .2em;
  color: var(--text-secondary);
  border-bottom: 0;
}
.foot__links a:hover { color: var(--sakura-200); }
.foot__org {
  font: 400 12px/1.6 var(--he-ui);
  letter-spacing: .1em;
  color: var(--text-muted);
}
.foot__jp {
  font: 400 13px/1 var(--font-jp);
  letter-spacing: .34em;
  color: var(--sakura-300);
  opacity: .5;
}

/* =============================================================
   HERO CHROME — the one place the hero is touched: its lettering
   ============================================================= */

.mark__kanji {
  font: 600 13px/1 var(--font-display);
  letter-spacing: .3em;
  color: var(--sakura-300);
  opacity: .9;
  text-shadow: var(--glow-text);
}
.mark__rule { background: var(--rule-fade); }
.mark__latin {
  font: 600 15px/1 var(--he-display);
  letter-spacing: .12em;
  text-transform: none;
  color: rgba(246,238,241,.72);
}
.hint__label {
  font: 500 10.5px/1 var(--he-ui);
  letter-spacing: .42em;
  text-indent: .42em;
  text-transform: none;
  color: rgba(246,238,241,.8);
}
.hint__arcs, .hint__chev { color: var(--sakura-300); }
.hint__bloom { background: var(--sakura-100); box-shadow: 0 0 10px var(--glow-sakura); }

/* =============================================================
   PROP SWITCHES — the root component's tweaks
   ============================================================= */

[data-orn="false"] .orn,
[data-orn="false"] .orn--torii { display: none; }
[data-num="false"] .eyebrow::before { display: none; }

/* Hebrew inside a design-system control: the engraved Latin face has no
   Hebrew glyphs, so the Hebrew serif takes the slot and keeps the tracking. */
.sn-btn {
  font-family: var(--he-display) !important;
  letter-spacing: .14em !important;
  font-weight: 600 !important;
}

/* =============================================================
   ADAPTATIONS
   ============================================================= */

@media (max-width: 780px) {
  .orn--tree, .orn--beads, .orn--katana, .orn--lantern { display: none; }
  .nav__links { gap: 0; }
  .nav__links a { padding: 0 7px; letter-spacing: .12em; }
}

@media (prefers-reduced-motion: reduce) {
  .orn--enso, .orn--moon, .nav__seal { animation: none; }
}
