:root {
  /* asa paper for the legal pages; the piece itself (html.piece) ends in the dark after the sunset */
  --paper: rgb(240, 234, 222);
  --ink: rgb(44, 30, 36);
  --accent: rgb(214, 76, 86);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", Georgia, serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans Mono CJK JP", monospace;
  --faint: color-mix(in srgb, var(--ink) 52%, transparent);
}
html.piece { --ink: rgb(236, 228, 236); --accent: rgb(238, 122, 84); }
* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); scroll-behavior: smooth; }
body { margin: 0; font-family: var(--serif); background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
::selection { background: var(--accent); color: var(--paper); }
a { color: inherit; text-underline-offset: 0.3em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
a:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

main { position: relative; z-index: 1; }
p { margin: 0; }

/* ---- the journey: a pinned stage; the page scrolls, the camera pulls back ---- */
.journey { position: relative; height: 660vh; --h-ink: rgb(44, 30, 36); --h-accent: rgb(208, 66, 46); }
.stage { position: sticky; top: 0; height: 100vh; width: 100%; overflow: hidden; background: rgb(240, 234, 222); --cap: rgb(60, 38, 36); contain: layout paint; }
.stage > * { position: absolute; }
.art { position: absolute; left: 0; top: 0; width: 100%; pointer-events: none; transform-origin: 50% 50%; will-change: transform, opacity; backface-visibility: hidden; }
.art.lyr { display: block; }
.art.sky { left: 0; top: 0; width: 100%; }
.art.tone { left: 0; top: 0; width: 100%; height: 100%; mix-blend-mode: multiply; background: rgb(255, 255, 255); }
.art.glow { left: 0; top: 0; width: 100%; height: 100%; }
.art.stgrain { left: 0; top: 0; width: 100%; height: 100%; background-size: 160px 160px; opacity: 0; will-change: opacity; }
.art.veil { left: 0; top: 0; width: 100%; height: 100%; opacity: 0; will-change: opacity;
  background: radial-gradient(ellipse 70% 38% at 22% 74%, rgba(190,150,184,0.9), rgba(190,150,184,0) 100%), radial-gradient(ellipse 80% 34% at 78% 66%, rgba(176,136,172,0.85), rgba(176,136,172,0) 100%),
    linear-gradient(to top, rgba(160,122,158,0.94) 0%, rgba(160,122,158,0.78) 34%, rgba(160,122,158,0.34) 58%, rgba(160,122,158,0) 76%); }
.art.lyr.sinks { translate: 0 calc(var(--tail, 0) * 9vh); }
#wa { }
.art.pondp { left: 0; top: 0; width: 100%; height: 100%; display: block; will-change: transform, clip-path; transform-origin: 50% 50%; }
.art.ground.lit { background: linear-gradient(to bottom, rgb(226, 220, 206) 0, rgb(232, 225, 210) 22vh, rgb(236, 229, 214) 100%); }
.art.ground.sil { background: linear-gradient(to bottom, rgb(110, 48, 70) 0, rgb(58, 30, 56) 6vh, rgb(34, 24, 48) 24vh, rgb(30, 22, 44) 100%); }
#wa { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; display: block; font-family: var(--mono); will-change: transform, clip-path; transform-origin: 50% 50%; }
#leaves { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; display: block; }

.hero-copy { left: 0; right: 0; top: 0; bottom: 0; display: grid; place-content: center; text-align: center; padding: 2rem; pointer-events: none; will-change: transform, opacity; }
.hero-kanji { font-size: clamp(6rem, 20vw, 14rem); line-height: 1; color: var(--h-accent); opacity: 0.92; margin-bottom: 0.4rem; }
.wordmark { margin: 0; font-weight: 400; font-size: clamp(2.6rem, 9vw, 7rem); letter-spacing: 0.18em; text-indent: 0.18em; line-height: 1; color: var(--h-ink); }
.sub { margin-top: 1.4rem; letter-spacing: 0.5em; text-indent: 0.5em; font-size: 0.95rem; color: color-mix(in srgb, var(--h-ink) 55%, transparent); }
.dot { color: var(--accent); }
.hint { left: 0; right: 0; bottom: calc(1.5rem + (100vh - 100svh)); text-align: center; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.4em; text-indent: 0.4em; color: color-mix(in srgb, var(--h-ink) 55%, transparent); pointer-events: none; }
.hint-touch { display: none; }
@media (hover: none) { .hint-fine { display: none; } .hint-touch { display: inline; } }

/* caption: tiny, in the clear ground at the foot of every frame */
.cap { left: 0; right: 0; bottom: calc(1.5rem + (100vh - 100svh)); height: 2.4rem; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.34em; color: var(--cap); pointer-events: none; }
.cap-i { position: absolute; left: 0; right: 0; bottom: 0.9rem; margin: 0; padding: 0 clamp(1.1rem, 3.2vw, 2.6rem); opacity: 0; text-transform: lowercase; white-space: nowrap; }
.cap-i b { font-weight: 400; opacity: 0.55; margin-right: 0.7em; }
.cap-i em { font-style: normal; font-family: var(--serif); font-size: 1.05rem; letter-spacing: 0.3em; margin-left: 0; }
.dots { position: absolute; left: clamp(1.1rem, 3.2vw, 2.6rem); bottom: 0; display: flex; gap: 0.5rem; }
.dots i { display: block; width: 0.34rem; height: 0.34rem; border-radius: 50%; background: var(--cap); opacity: 0.25; transition: opacity 0.6s, transform 0.6s; }
.dots i.on { opacity: 0.95; transform: scale(1.35); }
@media (max-aspect-ratio: 1/1) {
  .hint { bottom: calc(4.6rem + (100vh - 100svh)); }
  .cap { text-align: center; }
  .cap-i { text-align: center; }
  .dots { left: 0; right: 0; justify-content: center; }
  .cap { letter-spacing: 0.3em; }
}

.journey.static { height: auto; }
.journey.static .stage { position: relative; }

.study { padding: 28vh 1.5rem 22vh; max-width: 70rem; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.2rem; justify-items: center; text-align: center; }
.label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.4em; text-indent: 0.4em; color: var(--faint); margin-top: 6rem; }
.label:first-child { margin-top: 0; }
.words { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(2rem, 8vw, 6rem); }
.words figure, .big figure { margin: 0; }
.words p { font-size: clamp(2.6rem, 9vw, 5.5rem); line-height: 1.1; }
.w-serif { font-weight: 400; letter-spacing: 0.1em; }
.w-mono { font-family: var(--mono); letter-spacing: 0.3em; }
.w-light { font-style: italic; font-weight: 300; }
figcaption { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.4em; text-indent: 0.4em; color: var(--faint); margin-top: 0.6rem; }
.big { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(1rem, 6vw, 6rem); }
.big p { font-size: clamp(6rem, 20vw, 15rem); line-height: 1.05; }
.big figure:nth-child(2) p { color: var(--accent); }
.big figure:nth-child(3) p { color: color-mix(in srgb, var(--accent) 55%, var(--ink)); }
.scale { display: flex; align-items: baseline; gap: 0.4rem; }
.spacing { display: grid; gap: 0.4rem; font-size: 1.6rem; }
.ramp { font-family: var(--mono); font-size: clamp(1.6rem, 6vw, 3.4rem); letter-spacing: 0.3em; white-space: pre; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr)); width: 100%; max-width: 56rem; gap: 0.2rem; font-size: 1.5rem; }
.grid span { display: block; padding: 0.35rem 0; transition: color 0.2s; transform: scale(calc(1 + var(--k, 0) * 1.1)); opacity: calc(0.45 + var(--k, 0) * 0.55); will-change: transform; }
.grid span.hot { color: var(--accent); }

.ma { min-height: 190vh; position: relative; }
.ma-pin { position: sticky; top: 0; height: 100vh; display: grid; place-items: center; }
.ma-pin > * { grid-area: 1 / 1; }
.enso { width: min(78vmin, 34rem); aspect-ratio: 1; }
.enso svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ma-mark { font-size: 1.1rem; letter-spacing: 0.5em; text-indent: 0.5em; color: rgba(244, 232, 206, 0.62); text-shadow: 0 0 14px rgba(20, 16, 40, 0.6); }

.ns { position: fixed; bottom: 1rem; left: 1rem; z-index: 3; font-family: var(--mono); font-size: 0.8rem; }

.js .rv { opacity: 0; transform: translateY(14px); transition: opacity 1.4s ease, transform 1.4s ease; }
.js .rv.in { opacity: 1; transform: none; }

/* legal pages */
.doc { position: relative; max-width: 38rem; margin: 0 auto; padding: 18vh 1.5rem 12vh; line-height: 1.9; }
.doc h1 { font-weight: 400; font-size: 1.6rem; letter-spacing: 0.25em; margin-bottom: 3rem; }
.doc h2 { font-weight: 400; font-size: 0.8rem; font-family: var(--mono); letter-spacing: 0.3em; color: var(--accent); margin: 2.6rem 0 0.4rem; }
.doc p { color: color-mix(in srgb, var(--ink) 85%, transparent); }
.doc .back { display: inline-block; margin-top: 4rem; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.3em; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .rv { opacity: 1; transform: none; transition: none; }
  .grid span { transition: none; }
}

/* ---- ACT 2: one fixed world behind the page (sky, ink ridges, mist, seigaiha, gold dust, night water) ---- */
html.piece { background: rgb(30, 22, 44); }
.world { position: fixed; left: 0; top: 0; width: 100%; height: 100vh; height: 100lvh; z-index: 0; overflow: hidden; pointer-events: none;
  background: linear-gradient(to bottom, rgb(30, 30, 80) 0%, rgb(128, 52, 104) 46%, rgb(34, 24, 50) 62%, rgb(30, 22, 44) 100%); contain: strict; }
.world > * { position: absolute; }
.w-sky { left: 0; top: 0; width: 100%; height: 100%; will-change: opacity; }
.w-par { left: 0; top: 0; will-change: transform; backface-visibility: hidden; }
.w-par canvas { display: block; }
.w-mist canvas { display: block; will-change: transform; }
.w-sea { left: -10%; width: 120%; will-change: transform, opacity; background-repeat: repeat; }
.w-moon { border-radius: 50%; will-change: transform, opacity; }
.w-water { left: 0; width: 100%; will-change: opacity; }
.w-stars { left: 0; top: 0; width: 100%; height: 100%; }
.w-stars g { animation: w-twink 6s ease-in-out infinite; }
.w-stars g:nth-child(2) { animation-duration: 8s; animation-delay: -2.5s; }
.w-stars g:nth-child(3) { animation-duration: 5s; animation-delay: -4s; }
.w-dust { left: 0; top: 0; width: 100%; height: 100%; }
.w-rip rect { animation: w-sway ease-in-out infinite alternate; }
@keyframes w-drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(var(--per, -1000px), 0, 0); } }
@keyframes w-twink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes w-sway { from { transform: translateX(calc(var(--amp, 4px) * -1)); } to { transform: translateX(var(--amp, 4px)); } }
@keyframes w-slide { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(var(--tile, -160px), 0, 0); } }
.w-sea.slide { animation: w-slide 70s linear infinite; }
@media (prefers-reduced-motion: reduce) {
  .w-stars g, .w-rip rect, .w-sea.slide { animation: none; }
}

/* ---- ACT 3: shodō. The night gives way to paper; a pinned stage; two sheets of writing ---- */
.night { height: 110vh; }
.shodo { position: relative; height: 825vh; }
.sd-stage { position: sticky; top: 0; height: 100vh; width: 100%; overflow: hidden; --sumi: rgb(46, 38, 44); background: transparent; }
.sd-stage > * { position: absolute; }
.sd-paper, .sd-brush { left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.sd-sheet { left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; will-change: opacity, transform; }
.sd-sheet > * { position: absolute; }
.sd-ink { display: block; }
.sd-col { margin: 0; writing-mode: vertical-rl; text-orientation: upright; font-family: var(--serif); font-weight: 500; line-height: 1.12; letter-spacing: 0; color: rgb(60, 48, 52); white-space: nowrap; }
.sd-col span { position: relative; will-change: opacity, filter; }
.sd-seal { mix-blend-mode: multiply; transform-origin: 50% 50%; opacity: 0; }
.sd-foot { left: 0; right: 0; bottom: calc(1.4rem + (100vh - 100svh)); display: grid; gap: 0.5rem; justify-items: center; text-align: center; padding: 0 1rem; color: var(--sumi); }
html.js .sd-foot { opacity: 0; visibility: hidden; }
.sd-foot .small { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.5em; text-indent: 0.5em; color: rgba(70, 56, 56, 0.8); margin: 0; }
.sd-foot nav { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.3em; margin-top: 0.4rem; }
.sd-foot a:hover { color: rgb(200, 58, 40); }
.sd-foot .dot { color: rgb(200, 58, 40); }
.sd-foot .credit { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.08em; color: rgba(70, 56, 56, 0.72); margin: 0.5rem 0 0; }
@media (max-aspect-ratio: 1/1) { .sd-foot .credit { font-size: 0.58rem; max-width: 22rem; } }
.shodo.static .sd-stage { position: relative; overflow: hidden; }
@media (prefers-reduced-motion: reduce) {
  .night { height: 60vh; }
}
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- v8: legibility of the study over the misty world; keyboard skip link ---- */
.study { --faint: color-mix(in srgb, var(--ink) 88%, transparent); }
.study .label, .study figcaption, .study .ramp, .study .spacing, .study .scale { text-shadow: 0 0 0.9rem rgba(22, 14, 42, 0.95), 0 0 0.25rem rgba(22, 14, 42, 0.75); }
.study .words p, .study .big p { text-shadow: 0 0 1.4rem rgba(22, 14, 42, 0.7); }
.grid span { opacity: calc(0.86 + var(--k, 0) * 0.14); text-shadow: 0 0 0.6rem rgba(22, 14, 42, 0.95), 0 0 0.15rem rgba(22, 14, 42, 0.8); }
.skip { position: fixed; left: 1rem; top: 1rem; z-index: 10; padding: 0.7rem 1rem; font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.2em; text-decoration: none; background: rgb(246, 237, 233); color: rgb(44, 30, 36); transform: translateY(-300%); }
.skip:focus, .skip:focus-visible { transform: none; outline: 2px solid rgb(208, 66, 46); outline-offset: 2px; }

/* v8: the specimen block is gone; the mountains travel through an empty stretch of page */
.drift { height: 80vh; }
.sd-col { display: none; }
