/* 人口が減った後の日本をどう作るか ― 世界（3D）の画面
   世界は固定した canvas。文章は段（.step）の中の札（.card）として世界に重なる。 */
:root {
  --night: #0f1a2b; --night-ink: #e8edf3; --night-ink-2: #a9b5c4; --amber: #c98500; --amber-soft: #f2b85a;
  --serif: "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", YuMincho, "BIZ UDPMincho", "Noto Serif JP", "Noto Serif CJK JP", serif;
  --sans: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", Meiryo, "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .61, .36, 1);
}
* { box-sizing: border-box; }
html { background: #05080f; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; color: var(--night-ink); font-family: var(--serif); font-size: 1.0625rem; line-height: 1.95; line-break: strict; overflow-wrap: anywhere; background: #05080f; }
a { color: inherit; text-decoration: underline; text-decoration-color: rgba(232, 237, 243, .4); text-underline-offset: .22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--night-ink); }
:focus-visible { outline: 2px solid var(--amber-soft); outline-offset: 3px; border-radius: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; } }

/* 世界 */
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.no-js #gl, .no-webgl #gl { display: none; }
#fallback { display: none; position: fixed; inset: 0; z-index: 0; background: radial-gradient(ellipse at 50% 70%, #16253c 0%, #0a1322 55%, #05080f 100%); }
.no-js #fallback, .no-webgl #fallback { display: block; }
#fallback p { position: absolute; left: 50%; bottom: 8vh; transform: translateX(-50%); margin: 0; font-family: var(--sans); font-size: .85rem; color: var(--night-ink-2); text-align: center; max-width: 28em; padding: 0 1rem; }

/* 画面の縁の文字 */
.hud { position: fixed; z-index: 20; font-family: var(--sans); color: var(--night-ink-2); pointer-events: none; }
.hud a { pointer-events: auto; }
.hud-title { top: 1.1rem; left: 1.4rem; font-family: var(--serif); font-size: .9rem; letter-spacing: .08em; color: var(--night-ink); }
.hud-links { top: 1rem; right: 1.4rem; font-size: .8rem; letter-spacing: .04em; display: flex; gap: 1.2rem; }
.hud-links a { text-decoration: none; border-bottom: 1px solid rgba(232, 237, 243, .35); padding-bottom: .1em; color: var(--night-ink); }
.hud-links a:hover { border-color: var(--night-ink); }
.hud-year { right: 1.4rem; bottom: 1.2rem; text-align: right; }
.hud-year b { display: block; font-size: 2.6rem; font-weight: 600; line-height: 1; color: var(--night-ink); letter-spacing: .02em; }
.hud-year span { display: block; font-size: .78rem; margin-top: .35rem; }
.hud-year span i { font-style: normal; color: var(--night-ink); }
.hud-rule { left: 1.4rem; bottom: 1.3rem; font-size: .76rem; line-height: 1.6; }
.hud-rule i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: -1px; margin-right: .4em; background: #b8cbe6; box-shadow: 0 0 6px #b8cbe6; }
.hud-rule i.amber { background: #f0a030; box-shadow: 0 0 6px #f0a030; }
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--amber); z-index: 30; }
.chapters { position: fixed; right: 1.1rem; top: 50%; transform: translateY(-50%); z-index: 20; display: none; }
@media (min-width: 1000px) { .chapters { display: block; } }
.chapters ol { list-style: none; margin: 0; padding: 0; }
.chapters li { margin: .35rem 0; }
.chapters a { display: block; font-family: var(--sans); font-size: .72rem; line-height: 1.3; color: var(--night-ink-2); text-decoration: none; padding: .15rem .5rem .15rem .9rem; position: relative; opacity: .7; }
.chapters a::before { content: ""; position: absolute; left: 0; top: 50%; width: 5px; height: 5px; border-radius: 50%; background: var(--night-ink-2); transform: translateY(-50%); }
.chapters a.is-active { color: var(--night-ink); opacity: 1; }
.chapters a.is-active::before { background: var(--amber-soft); }
.chapters { transition: opacity .4s linear; }
.is-hero .chapters { opacity: 0; pointer-events: none; }
@media (max-width: 760px) {
  .hud-title { font-size: .8rem; left: 1rem; top: .9rem; }
  .hud-links { right: 1rem; top: .85rem; font-size: .74rem; gap: .9rem; }
  .hud-year { right: 1rem; bottom: .9rem; } .hud-year b { font-size: 1.8rem; } .hud-year span { font-size: .68rem; }
  .hud-rule { left: 1rem; bottom: 1rem; font-size: .68rem; max-width: 11em; }
}
.is-dawn .hud, .is-dawn .chapters a { color: #e8edf3; }

/* 世界の中の札 */
#labels { position: fixed; inset: 0; z-index: 10; pointer-events: none; overflow: hidden; }
.wl { position: absolute; left: 0; top: 0; opacity: 0; white-space: nowrap; font-family: var(--sans); font-size: .82rem; letter-spacing: .06em; color: var(--night-ink); text-shadow: 0 0 10px rgba(5, 8, 15, .9), 0 0 2px rgba(5, 8, 15, 1); will-change: transform, opacity; transition: opacity .25s linear; }
.wl small { display: block; font-size: .7rem; color: var(--night-ink-2); letter-spacing: .04em; text-align: center; }
.wl::before { content: ""; position: absolute; left: 50%; bottom: -14px; width: 1px; height: 12px; background: rgba(232, 237, 243, .45); }
.wl-note { font-size: .74rem; color: var(--night-ink-2); }
.wl-note::before { display: none; }
.wl-year { font-size: 2.4rem; font-weight: 600; letter-spacing: .05em; color: rgba(232, 237, 243, .9); text-shadow: 0 0 18px rgba(201, 133, 0, .35), 0 0 3px rgba(5, 8, 15, 1); }
.wl-year::before { display: none; }
@media (max-width: 760px) { .wl { font-size: .7rem; } .wl-year { font-size: 1.6rem; } }

/* 文章の段 */
#story { position: relative; z-index: 15; pointer-events: none; }
.step { height: 130vh; height: 130dvh; position: relative; }
.step.step-hero, .step.step-end { height: 100vh; height: 100dvh; }
.card { position: sticky; top: 38vh; width: min(30em, calc(100vw - 2.8rem)); margin-left: 7vw; padding: 1.2rem 1.4rem; opacity: 0; visibility: hidden; pointer-events: auto; transition: opacity .35s linear; }
.card::before { content: ""; position: absolute; inset: -2rem -3rem; background: radial-gradient(ellipse at 50% 50%, rgba(6, 11, 20, .78) 0%, rgba(6, 11, 20, .55) 45%, rgba(6, 11, 20, 0) 72%); z-index: -1; }
.step:nth-child(even) .card { margin-left: auto; margin-right: 8vw; }
.step-hero .card { opacity: 1; visibility: visible; }
.card p { margin: 0 0 1em; font-size: 1.08rem; line-height: 1.95; }
.card p:last-child { margin-bottom: 0; }
.card .mark { font-family: var(--sans); font-size: .78rem; letter-spacing: .1em; color: var(--night-ink-2); margin: 0 0 .9em; }
.card h2 { font-size: 1.3rem; font-weight: 500; letter-spacing: .05em; margin: 0 0 .8em; line-height: 1.6; }
.card .note { font-family: var(--sans); font-size: .76rem; color: var(--night-ink-2); line-height: 1.7; margin-top: .6em; }
.card .num { font-family: var(--sans); font-weight: 600; font-size: 1.15em; color: var(--night-ink); }
.card .ladder { list-style: none; padding: 0; margin: 0 0 1em; font-family: var(--sans); font-size: .9rem; }
.card .ladder li { padding: .35rem 0 .35rem 1.1rem; border-left: 2px solid rgba(232, 237, 243, .25); margin: 0; }
.card .ladder li:nth-child(2) { margin-left: .8rem; } .card .ladder li:nth-child(3) { margin-left: 1.6rem; } .card .ladder li:nth-child(4) { margin-left: 2.4rem; }
.card .ladder b { font-family: var(--serif); font-weight: 600; margin-right: .6em; }
.card .ladder span { color: var(--night-ink-2); font-size: .82rem; }

/* 題字 */
.step-hero .card { top: auto; position: absolute; left: 0; right: 0; bottom: 0; width: auto; margin: 0; padding: 0 7vw 11vh; display: flex; justify-content: space-between; align-items: flex-end; gap: 2rem; }
.step-hero .card::before { display: none; }
.hero-text { max-width: 24em; }
.hero-text p { font-size: 1.08rem; }
.hero-text .lede { color: var(--night-ink); }
.hero-text .key { color: var(--night-ink-2); font-size: .95rem; }
.hero-meta { font-family: var(--sans); font-size: .78rem; color: var(--night-ink-2); letter-spacing: .04em; margin-top: 1.2rem; line-height: 1.7; }
.hero-cue { display: inline-block; margin-top: .9rem; font-family: var(--sans); font-size: .78rem; color: var(--night-ink-2); text-decoration: none; letter-spacing: .1em; }
.hero-cue::after { content: ""; display: block; width: 1px; height: 2.4rem; background: var(--night-ink-2); margin: .6rem 0 0 .4rem; animation: cue 2.4s var(--ease) infinite; transform-origin: top; }
@keyframes cue { 0% { transform: scaleY(0); opacity: 0; } 30% { opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.hero-title { margin: 0; writing-mode: vertical-rl; text-orientation: mixed; font-size: clamp(2rem, 3.6vw, 3.3rem); font-weight: 500; line-height: 1.55; letter-spacing: .1em; font-feature-settings: "palt"; height: min(62vh, 20em); color: var(--night-ink); text-shadow: 0 0 24px rgba(5, 8, 15, .9); }

/* 終わり */
.step-end .card { top: 30vh; }
.end-links { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; margin: 1.4rem 0 1rem; font-family: var(--sans); font-size: .9rem; }
.end-links a { text-decoration: none; border: 1px solid rgba(232, 237, 243, .4); border-radius: 999px; padding: .5rem 1.1rem; color: var(--night-ink); }
.end-links a:hover { border-color: var(--night-ink); background: rgba(232, 237, 243, .06); }
.end-links a.primary { background: var(--night-ink); color: var(--night); border-color: var(--night-ink); }
.credits { font-family: var(--sans); font-size: .74rem; color: var(--night-ink-2); line-height: 1.7; }

@media (max-width: 760px) {
  body { font-size: 1rem; }
  .step { height: 120vh; height: 120dvh; display: flex; flex-direction: column; justify-content: flex-end; }
  .card, .step:nth-child(even) .card { position: sticky; top: auto; bottom: 5.5rem; width: auto; margin: 0 .9rem; padding: 1rem 1rem 1.1rem; }
  .card::before { inset: -1.2rem -1rem; background: radial-gradient(ellipse at 50% 60%, rgba(6, 11, 20, .85) 0%, rgba(6, 11, 20, .6) 55%, rgba(6, 11, 20, 0) 80%); }
  .card p { font-size: .98rem; line-height: 1.85; } .card h2 { font-size: 1.12rem; }
  .step-hero { justify-content: flex-end; }
  .step-hero .card { position: absolute; flex-direction: column; align-items: flex-start; gap: 1rem; padding: 4rem 1.2rem 5.5rem; background: linear-gradient(to top, rgba(5, 8, 15, .88) 60%, rgba(5, 8, 15, 0)); }
  .hero-title { writing-mode: horizontal-tb; height: auto; font-size: clamp(1.7rem, 7.6vw, 2.4rem); line-height: 1.45; order: -1; }
  .hero-text p { font-size: .98rem; }
  .step-end .card { top: auto; }
}
@media print { #gl, .hud, .chapters, .progress, #labels { display: none !important; } .card { position: static; opacity: 1 !important; visibility: visible !important; } body { color: #000; background: #fff; } }

/* JS や WebGL が無いときも文章は読める */
.no-js .card, .no-webgl .card { opacity: 1 !important; visibility: visible !important; }
.no-js .step, .no-webgl .step { height: auto; min-height: 0; padding: 3rem 0; }
.no-js .step-hero .card, .no-webgl .step-hero .card { position: static; padding-top: 6rem; }
