/* Konnichiwa. Palette is taken from the photo: kimono indigo, fur gold, headband red, sakura white. */
:root {
  --kon: #1D2340;        /* kimono indigo, the base */
  --kon-deep: #141933;   /* night sky behind the gate */
  --kon-lift: #2A3159;   /* raised indigo surfaces */
  --shiba: #E3A857;      /* fur gold */
  --shu: #D63A2B;        /* torii and headband red */
  --shu-deep: #C4301F;   /* button fill: the same red, deep enough for white text */
  --shu-ink: #B42E21;    /* red text on shrine paper */
  --shu-lit: #F0705F;    /* the same red, lifted so small text holds 4.5:1 on the night sky */
  --gofun: #F3F1EC;      /* shell white */
  --sakura: #F2C9D4;
  --ink: #15182E;

  --display: "Dela Gothic One", "Zen Kaku Gothic New", system-ui, sans-serif;
  --brush: "Yuji Syuku", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --body: "Zen Kaku Gothic New", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* classical scale */
  --t-14: .875rem;
  --t-16: 1rem;
  --t-18: 1.125rem;
  --t-21: 1.3125rem;
  --t-24: 1.5rem;
  --t-36: 2.25rem;
  --t-48: 3rem;
  --t-72: 4.5rem;

  --wrap: 1160px;
  --gutter: clamp(20px, 5vw, 56px);
  /* full-bleed bars keep their content on the same column as the page */
  --bleed: max(var(--gutter), calc((100% - var(--wrap)) / 2 + var(--gutter)));

  --ease-out: cubic-bezier(.16, 1, .3, 1);

  /* washi: a fine pulp grain from SVG noise, so nothing extra downloads */
  --washi-grain:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .36 0 0 0 0 .27 0 0 0 .11 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth; -webkit-text-size-adjust: 100%;
  scroll-padding-top: 72px;
  overflow-x: clip; /* the tilted hero ema must not widen the page on phones */
  scrollbar-color: #3A4275 var(--kon-deep);
}
::selection { background: var(--shiba); color: var(--ink); }

body {
  margin: 0;
  background: var(--kon);
  color: var(--gofun);
  font: 400 var(--t-18)/1.65 var(--body);
  -webkit-font-smoothing: antialiased;
  /* clip, not hidden: with html clipping too, hidden would make body its own scroll box and break the sticky top bar */
  overflow-x: clip;
}
/* html is no longer overflow: visible, so body's overflow no longer locks the viewport; lock both while the gate is up */
html.js.gate-open, html.js.gate-open body { overflow: hidden; }

img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

:focus-visible { outline: 3px solid var(--shiba); outline-offset: 3px; border-radius: 2px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--gofun); color: var(--ink); padding: 8px 14px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: 0 22px;
  font: 400 var(--t-16)/1 var(--display);
  letter-spacing: .02em;
  text-decoration: none; cursor: pointer;
  border: 2px solid transparent; border-radius: 3px;
  transition: transform .25s var(--ease-out), background-color .2s ease, border-color .2s ease, color .2s ease, box-shadow .25s var(--ease-out);
}
@media (hover: hover) and (pointer: fine) { .btn:hover { transform: translateY(-2px); } }
.btn:active { transform: scale(.97); transition-duration: .1s; }
.btn-primary {
  background: var(--shu-deep); color: var(--gofun);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 10px 22px -12px rgba(8, 10, 24, .7);
}
.btn-primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 16px 28px -12px rgba(8, 10, 24, .8); }
.btn-ghost { background: transparent; border-color: rgba(243, 241, 236, .45); color: var(--gofun); }
.btn-ghost:hover { border-color: var(--gofun); background: rgba(243, 241, 236, .06); }
.btn-icon { width: 48px; padding: 0; }
.btn-icon svg { width: 20px; height: 20px; }

/* Links not set in config.js yet: the button keeps its shape, dims, and the text buttons carry a small gold "Soon" tag.
   Icon buttons only dim (their title says "Link coming soon"), so the row stays calm instead of a cluster of tags. */
.btn[aria-disabled="true"] {
  cursor: not-allowed; transform: none; box-shadow: none;
  background: rgba(243, 241, 236, .03);
  border-color: rgba(243, 241, 236, .2); color: rgba(243, 241, 236, .6);
}
.btn-primary[aria-disabled="true"] {
  background: rgba(196, 48, 31, .3); border-color: rgba(214, 58, 43, .55); color: rgba(243, 241, 236, .88);
}
.btn[aria-disabled="true"]::after {
  content: "Soon";
  margin-left: .35em; padding: 4px 6px 3px;
  font: 700 10px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  color: var(--shiba);
  background: rgba(227, 168, 87, .12);
  border: 1px solid rgba(227, 168, 87, .42); border-radius: 2px;
  pointer-events: none;
}
.btn-icon[aria-disabled="true"]::after { content: none; }
.btn-icon[aria-disabled="true"] { color: rgba(243, 241, 236, .5); }

/* ---------- Seal (hanko) ---------- */
.seal {
  display: inline-grid; place-items: center;
  background: var(--shu-deep); color: var(--gofun);
  font-family: var(--brush);
  writing-mode: vertical-rl;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px var(--shu-deep), inset 0 0 0 3.5px rgba(243, 241, 236, .85);
  line-height: 1;
}
.seal-sm { font-size: 12px; padding: 6px 5px; letter-spacing: .05em; }
.seal-lg { font-size: 26px; padding: 14px 10px; letter-spacing: .08em; transform: rotate(-3deg); }

/* ---------- Gate ---------- */
.gate { display: none; }
html.js .gate {
  position: fixed; inset: 0; z-index: 100;
  display: grid; grid-template-rows: 1fr auto; justify-items: center;
  background:
    radial-gradient(ellipse 70% 55% at 50% 30%, #2B3364 0%, var(--kon-deep) 70%),
    var(--kon-deep);
  overflow: hidden;
  transition: opacity .9s ease 1.1s, visibility 0s linear 2s;
}
.gate-petals { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gate-moon {
  position: absolute; top: 7vh; right: 14vw;
  width: clamp(70px, 11vw, 140px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 40% 38%, #FFF6E0, #F1DFB4 70%);
  box-shadow: 0 0 60px 18px rgba(241, 223, 180, .18);
}
.gate-scene {
  align-self: end;
  min-height: 0;
  width: 100%;
  display: grid; justify-items: center;
  padding-top: 4vh;
}
.torii {
  /* scale by width, but never taller than the space above the buttons */
  width: min(860px, 100vw, calc((100vh - 300px) * 1.4286));
  width: min(860px, 100vw, calc((100svh - 300px) * 1.4286));
  height: auto;
  overflow: visible;
}
.torii-body {
  transform-box: view-box;
  transform-origin: 400px 330px;
  transition: transform 1.8s cubic-bezier(.55, 0, .75, .3), opacity 1.2s ease .6s;
}
.plaque-text { font: 20px var(--brush); fill: var(--shiba); text-anchor: middle; dominant-baseline: middle; }
.toro-light { animation: flicker 3.2s ease-in-out infinite; }
.toro-glow { animation: flicker 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.toro-r .toro-light, .toro-r .toro-glow { animation-delay: -1.4s; }
@keyframes flicker {
  0%, 100% { opacity: 1; }
  40% { opacity: .78; }
  55% { opacity: .95; }
  70% { opacity: .82; }
}

.gate-copy {
  position: relative;
  display: grid; justify-items: center; gap: 14px;
  padding: 8px 24px max(32px, 6vh);
  text-align: center;
  transition: opacity .5s ease;
}
.gate-name { font: var(--t-36)/1.1 var(--brush); color: var(--shiba); letter-spacing: .12em; }
.gate-title { font: var(--t-18)/1.3 var(--body); font-weight: 500; color: rgba(243, 241, 236, .8); margin-bottom: 8px; }
.btn-enter {
  min-height: 56px; padding: 0 34px; font-size: var(--t-21);
  background: var(--shu-deep); color: var(--gofun);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 14px 30px -12px rgba(8, 10, 24, .7);
}
.btn-enter:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 18px 36px -12px rgba(8, 10, 24, .8); }
/* walking through */
.gate.is-entering .torii-body { transform: scale(5.5); opacity: 0; }
.gate.is-entering .toro, .gate.is-entering .gate-moon { opacity: 0; transition: opacity .8s ease; }
.gate.is-entering .gate-copy { opacity: 0; }
.gate.is-entering { opacity: 0; visibility: hidden; pointer-events: none; }
.gate.is-gone { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--bleed);
  background: var(--kon);
}
/* at the top the bar floats over the night sky; once the page scrolls it fills in and lifts off with a hairline */
@supports (animation-timeline: scroll()) {
  .topbar { background: transparent; animation: bar-lift linear both; animation-timeline: scroll(root); animation-range: 0 120px; }
  @keyframes bar-lift {
    from { background-color: rgba(29, 35, 64, 0); box-shadow: 0 1px 0 rgba(243, 241, 236, 0), 0 14px 28px -18px rgba(8, 10, 24, 0); }
    to { background-color: rgba(29, 35, 64, 1); box-shadow: 0 1px 0 rgba(243, 241, 236, .08), 0 14px 28px -18px rgba(8, 10, 24, .9); }
  }
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-ticker { font: var(--t-16)/1 var(--display); letter-spacing: .02em; }
.topnav { display: flex; gap: clamp(14px, 3vw, 32px); }
.topnav a { text-decoration: none; font-size: var(--t-16); font-weight: 500; color: rgba(243, 241, 236, .8); padding: 6px 0; }
.topnav a:hover { color: var(--gofun); text-decoration: underline; text-underline-offset: 6px; text-decoration-color: var(--shu); }
@media (max-width: 560px) { .topnav a:not([href="#dojo"]) { display: none; } }

main:focus { outline: none; }

/* ---------- Hero ---------- */
/* full bleed, and deliberately not a stacking context: the night scene sits at z-index -2 in the root context,
   so the ambient sakura canvas (z-index -1, js/motion.js) drifts in front of the sky and behind the words */
.hero {
  position: relative;
  min-height: calc(100svh - 76px);
  display: grid; align-items: center;
}
.hero-inner {
  width: 100%; max-width: var(--wrap); margin: 0 auto;
  padding: clamp(16px, 3vh, 40px) var(--gutter) clamp(64px, 11vh, 120px);
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, .7fr);
  align-items: center; gap: clamp(32px, 5vw, 72px);
}

/* the shrine grounds at night, in flat woodblock layers. The sky runs up under the transparent top bar. */
.night {
  position: absolute; z-index: -2;
  inset: -96px 0 0 0;
  overflow: hidden;
  pointer-events: none;
  /* bokashi: the printer's graded wipe of ink, darkest at the zenith, paling into the moonlit haze on the horizon */
  background: linear-gradient(to bottom, #0E1228 0%, #141936 30%, #20275A 62%, #303A72 82%, #2B3363 100%);
}
.night-stars {
  position: absolute; inset: 0 0 35% 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 22%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1px 1px at 27% 8%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1.2px 1.2px at 44% 31%, #F6E8C6 60%, transparent 62%),
    radial-gradient(1px 1px at 58% 12%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1.6px 1.6px at 71% 40%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1px 1px at 86% 19%, #F6E8C6 60%, transparent 62%),
    radial-gradient(1.2px 1.2px at 93% 52%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1px 1px at 6% 61%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1px 1px at 36% 58%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1.3px 1.3px at 64% 70%, #F6E8C6 60%, transparent 62%);
  background-size: 420px 300px;
  mask-image: linear-gradient(to bottom, #000 30%, transparent);
  opacity: .7;
  animation: twinkle 6s ease-in-out infinite alternate;
}
.night-stars::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(1px 1px at 18% 34%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1.4px 1.4px at 52% 18%, #F3F1EC 60%, transparent 62%),
    radial-gradient(1px 1px at 77% 63%, #F6E8C6 60%, transparent 62%),
    radial-gradient(1.2px 1.2px at 33% 80%, #F3F1EC 60%, transparent 62%);
  background-size: 260px 210px;
  animation: twinkle 4.2s ease-in-out -2s infinite alternate;
}
@keyframes twinkle { from { opacity: .45; } to { opacity: 1; } }

.night-layer { position: absolute; left: 0; right: 0; bottom: 0; background-repeat: repeat-x; background-position: 50% 100%; }
.night-far { height: clamp(150px, 30vh, 280px); bottom: clamp(70px, 12vh, 120px); background-image: url(../assets/night/far.svg); background-size: auto 100%; }
.night-mid { height: clamp(120px, 24vh, 230px); bottom: clamp(36px, 6vh, 64px); background-image: url(../assets/night/mid.svg); background-size: auto 100%; }
.night-near { height: clamp(150px, 30vh, 300px); background-image: url(../assets/night/near.svg); background-size: cover; background-repeat: no-repeat; }
/* low mist pooling between the cedars */
.night-mist {
  position: absolute; left: 0; right: 0; bottom: clamp(20px, 4vh, 48px); height: clamp(90px, 16vh, 150px);
  background: linear-gradient(to top, rgba(176, 172, 222, 0) 0%, rgba(176, 172, 222, .11) 45%, rgba(176, 172, 222, 0) 100%);
}
/* distant stone lanterns along the approach, lit and flickering under the trees */
.lantern {
  position: absolute; left: var(--x); bottom: 13%;
  width: 4px; height: 5px; border-radius: 1px;
  background: #FFD58A;
  animation: flicker 3.2s ease-in-out var(--d, 0s) infinite;
}
.lantern::after {
  content: ""; position: absolute; left: 50%; top: 100%; translate: -50% 0;
  width: 2px; height: 16px;
  background: linear-gradient(to bottom, rgba(255, 213, 138, .5), rgba(255, 213, 138, 0));
}
.hero-copy { container-type: inline-size; }
.hero-title {
  display: grid;
  font-family: var(--display);
  font-size: clamp(3rem, 8vw, 7.25rem);
  font-size: min(19.5cqi, 6.75rem);
  line-height: .98;
  letter-spacing: -.01em;
  color: var(--gofun);
}
.hero-title:focus { outline: none; }
.hero-line { display: block; }
.hero-line:nth-child(2) { padding-left: .5em; }
.hero-line:nth-child(3) { padding-left: 1em; color: var(--shiba); }
.hero-title ruby { ruby-position: over; ruby-align: center; }
.hero-title rt {
  font: 400 .2em/1 var(--brush);
  color: var(--shu-lit);
  letter-spacing: .12em;
  text-align: center;
  padding-bottom: .25em;
}
.hero-lede { margin-top: 22px; max-width: 40ch; font-size: var(--t-21); line-height: 1.55; color: rgba(243, 241, 236, .88); }

/* contract slip: a strip of shrine paper */
.slip {
  margin-top: 26px; max-width: 560px;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 12px 12px 12px 20px;
  background: var(--gofun); color: var(--ink);
  clip-path: polygon(0 4%, 2% 0, 98% 3%, 100% 0, 100% 96%, 98% 100%, 3% 97%, 0 100%);
}
.slip-label { font-size: var(--t-14); font-weight: 700; color: var(--shu-ink); }
.slip-ca {
  font: 500 var(--t-16)/1.3 var(--body);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slip-copy {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 3px; cursor: pointer;
  background: var(--kon); color: var(--gofun); font: var(--t-14)/1 var(--display);
}
/* before launch there is nothing to copy: an ink outline on the paper with the same small Soon tag as the buttons */
.slip-copy:disabled {
  cursor: not-allowed;
  display: inline-flex; align-items: center; gap: .45em;
  background: transparent; color: rgba(21, 24, 46, .55);
  box-shadow: inset 0 0 0 1.5px rgba(21, 24, 46, .22);
}
.slip-copy:disabled::after {
  content: "Soon";
  padding: 4px 6px 3px;
  font: 700 10px/1 var(--body); letter-spacing: .12em; text-transform: uppercase;
  color: var(--shu-ink); background: rgba(180, 46, 33, .08);
  border: 1px solid rgba(180, 46, 33, .4); border-radius: 2px;
}
.slip.is-empty .slip-ca { color: rgba(21, 24, 46, .7); }

.hero-actions { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 560px) {
  .hero-actions .btn-primary { flex: 1 0 100%; }
  .hero-actions .btn:not(.btn-primary, .btn-icon) { flex: 1; }
}

.hero-ema { position: relative; isolation: isolate; margin: 0; display: grid; justify-items: center; gap: 14px; }
/* the moon from the gate follows you in and hangs behind the plaque, a cloud strip drifting across it */
.moon {
  position: absolute; z-index: -1;
  top: -9%; right: -34%;
  width: 92%; height: auto; overflow: visible;
  pointer-events: none;
}
.moon-cloud { animation: cloud-drift 22s ease-in-out infinite alternate; }
@keyframes cloud-drift { from { translate: -14px 0; } to { translate: 18px 0; } }
.ema {
  width: min(380px, 100%); height: auto; overflow: visible;
  transform-origin: 50% 1%;
  animation: sway 7s ease-in-out infinite;
  filter: drop-shadow(0 24px 28px rgba(8, 10, 24, .45));
}
.ema-wish { font: 40px var(--brush); fill: #2A1A0C; letter-spacing: .14em; }
.hero-ema figcaption { font-size: var(--t-14); color: rgba(243, 241, 236, .65); }
@keyframes sway {
  0%, 100% { transform: rotate(-1.6deg); }
  50% { transform: rotate(1.6deg); }
}
/* arriving: as the gate fades, the greeting inks in letter by letter and the plaque drops onto its cord.
   js/motion.js wraps each title letter in .hero-ch (kept inline so the display face still kerns). */
@keyframes arrive { from { opacity: 0; transform: translateY(32px); } }
@keyframes hang { from { opacity: 0; transform: translateY(-48px) rotate(-4deg); } }
@keyframes hero-rise { from { transform: translateY(24px); } }
@keyframes hero-ink {
  from { opacity: 0; clip-path: inset(100% -20% -20% -20%); filter: blur(4px); }
  to { opacity: 1; clip-path: inset(-20%); filter: blur(0); }
}
/* the furigana is brushed on left to right once its line has landed */
@keyframes hero-furigana {
  from { opacity: 0; clip-path: inset(-20% 100% -20% -20%); }
  to { opacity: 1; clip-path: inset(-20%); }
}
html.arrived .hero-line { animation: hero-rise 1.1s var(--ease-out) 1.05s both; }
html.arrived .hero-line:nth-child(2) { animation-delay: 1.2s; }
html.arrived .hero-line:nth-child(3) { animation-delay: 1.45s; }
html.arrived .hero-ch { animation: hero-ink .8s var(--ease-out) calc(1.05s + var(--i, 0) * 50ms) backwards; }
html.arrived .hero-title rt { animation: hero-furigana .6s var(--ease-out) 1.35s backwards; }
html.arrived .hero-line:nth-child(2) rt { animation-delay: 1.6s; }
html.arrived .hero-line:nth-child(3) rt { animation-delay: 1.7s; }
html.arrived .hero-lede,
html.arrived .slip,
html.arrived .hero-actions { animation: arrive 1.1s var(--ease-out) 1.05s both; }
html.arrived .hero-lede { animation-delay: 1.4s; }
html.arrived .slip { animation-delay: 1.5s; }
html.arrived .hero-actions { animation-delay: 1.6s; }
html.arrived .hero-ema { transform-origin: 50% 0; animation: hang 1.5s var(--ease-out) 1.1s both; }

@media (max-width: 860px) {
  .hero { min-height: 0; }
  .hero-inner { grid-template-columns: 1fr; padding-bottom: clamp(110px, 22vw, 160px); }
  .hero-ema { order: -1; gap: 8px; }
  .moon { top: -4%; right: max(-60px, calc(50% - 250px)); width: min(260px, 66vw); }
  .ema { width: min(230px, 60vw); }
}

/* ---------- Sections ---------- */
.section {
  max-width: var(--wrap); margin: 0 auto;
  padding: clamp(72px, 11vh, 128px) var(--gutter);
}
.section-kanji {
  font: clamp(4rem, 9vw, 7.5rem)/1 var(--brush);
  color: var(--shu);
  writing-mode: vertical-rl;
  letter-spacing: .08em;
  user-select: none;
}
.section-title {
  font: var(--t-48)/1.1 var(--display);
  font-size: clamp(2.25rem, 5vw, var(--t-48));
  letter-spacing: -.005em;
  margin-bottom: 24px;
}

.legend, .buy {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(28px, 6vw, 96px); align-items: start;
}
/* sized so "The gatekeeper" holds one line beside the rack */
.legend { grid-template-columns: auto minmax(0, 1fr) minmax(300px, 340px); column-gap: clamp(28px, 4vw, 56px); }
.legend .section-body p { max-width: 62ch; color: rgba(243, 241, 236, .88); }
.legend .section-body p + p { margin-top: 1.1em; }
.legend [data-ticker] { color: var(--shiba); font-weight: 700; }

/* the gatekeeper's three ways, on ofuda: paper talismans tied to a shimenawa rope */
.rack { position: relative; aspect-ratio: 360 / 430; margin-top: 4px; }
.rack-rope { position: absolute; left: -4%; top: 0; width: 108%; height: auto; overflow: visible; }
.rope-body { fill: none; stroke: #C9A56A; stroke-width: 11; stroke-linecap: round; }
.rope-twist { fill: none; stroke: #8E6A35; stroke-width: 11; stroke-dasharray: 3 7; stroke-linecap: butt; opacity: .7; }
.ofuda {
  position: absolute; left: var(--x); top: calc(var(--rope-y, 5.4%) + var(--cord));
  width: clamp(78px, 26%, 96px);
  translate: -50% 0;
  transform-origin: 50% calc(-1 * var(--cord));
  rotate: var(--tilt);
  animation: ofuda-sway 7s ease-in-out var(--sway, 0s) infinite alternate;
}
.ofuda:nth-of-type(2) { --rope-y: 7.2%; }
/* the paper cord from the rope down to the talisman */
.ofuda::before {
  content: ""; position: absolute; left: 50%; bottom: 100%; translate: -50% 0;
  width: 2px; height: var(--cord);
  background: rgba(243, 241, 236, .7);
}
@keyframes ofuda-sway { from { rotate: calc(var(--tilt) - 1.6deg); } to { rotate: calc(var(--tilt) + 1.6deg); } }
.ofuda-paper {
  position: relative;
  display: grid; justify-items: center; align-content: start; gap: 10px;
  padding: 16px 0 12px;
  aspect-ratio: 1 / 2.9;
  background-color: var(--gofun);
  background-image: var(--washi-grain);
  color: var(--ink);
  box-shadow: inset 0 0 0 5px var(--gofun), inset 0 0 0 6px rgba(180, 46, 33, .55), 0 18px 26px -14px rgba(8, 10, 24, .75);
}
.ofuda-paper b { font: 400 clamp(2.75rem, 4.4vw, 3.5rem)/1 var(--brush); margin-top: 6px; }
.ofuda-word {
  writing-mode: vertical-rl;
  font: 400 var(--t-14)/1 var(--display); letter-spacing: .18em; text-transform: uppercase;
  color: var(--shu-ink);
}
.ofuda-seal {
  position: absolute; left: 50%; bottom: 12px; translate: -50% 0;
  display: grid; place-items: center;
  width: 28px; height: 28px;
  font: 16px/1 var(--brush); color: var(--gofun);
  background: var(--shu-deep);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1.5px var(--shu-deep), inset 0 0 0 2.5px rgba(243, 241, 236, .8);
  rotate: -4deg;
}
.ofuda-line {
  margin-top: 14px;
  font-size: var(--t-14); line-height: 1.35; text-align: center;
  color: rgba(243, 241, 236, .78);
  rotate: calc(-1 * var(--tilt));
}

@media (max-width: 1159px) {
  .legend { grid-template-columns: auto minmax(0, 1fr); }
  .rack { grid-column: 2; width: min(360px, 100%); margin-top: 40px; }
}
@media (max-width: 640px) {
  .legend, .buy { grid-template-columns: 1fr; gap: 12px; }
  .section-kanji { writing-mode: horizontal-tb; font-size: 3.5rem; }
  .rack { grid-column: auto; justify-self: center; margin-top: 36px; }
}

/* ---------- Dojo ---------- */
/* the dojo is its own room: a full-bleed band of night indigo that dusks in and out of the page,
   so there is no hard seam. border-image paints the gradient across the whole viewport width. */
.dojo {
  --dusk: clamp(140px, 20vh, 240px);
  border-image: linear-gradient(to bottom,
    var(--kon) 0,
    color-mix(in oklab, var(--kon), var(--kon-deep) 55%) calc(var(--dusk) * .5),
    var(--kon-deep) var(--dusk),
    var(--kon-deep) calc(100% - var(--dusk)),
    color-mix(in oklab, var(--kon), var(--kon-deep) 55%) calc(100% - var(--dusk) * .5),
    var(--kon) 100%) fill 0 / 0 / 0 100vmax;
}
/* the dojo is entered differently from the story sections: a centred name board with the dojo's seal pressed above it */
.dojo-head {
  display: grid; justify-items: center; text-align: center;
  max-width: 720px; margin: 0 auto clamp(36px, 5vw, 56px);
}
.dojo-seal { font-size: 22px; padding: 12px 8px; letter-spacing: .08em; rotate: -3deg; margin-bottom: 22px; }
.dojo-intro { max-width: 52ch; color: rgba(243, 241, 236, .85); }
.dojo-head .section-title { margin-bottom: 12px; }

/* the picture stays 600px so its column ends level with the panel; the panel takes what is left */
.dojo-grid { display: grid; grid-template-columns: minmax(0, 600px) minmax(340px, 1fr); gap: 48px; align-items: start; }
.dojo-stage { position: sticky; top: 92px; }
.pfp-frame {
  padding: 12px;
  background: linear-gradient(160deg, #C99358, #A9733C);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 236, 205, .35), 0 0 0 2px #5E3519, 0 30px 60px rgba(8, 10, 24, .5);
}
.pfp-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 1;
  background: var(--kon-lift);
  border-radius: 4px;
  box-shadow: 0 0 0 2px #5E3519;
}

/* the control panel: a lacquered tray with a thin gold rim, every row on the same grid */
.dojo-controls {
  display: grid; gap: 0;
  padding: 4px 24px 6px;
  background: linear-gradient(180deg, #242B52 0%, var(--kon) 46%);
  border: 1px solid rgba(227, 168, 87, .2);
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(243, 241, 236, .07), 0 30px 60px -34px rgba(8, 10, 24, .9);
}
.dojo-controls fieldset { position: relative; margin: 0; padding: 16px 0; border: 0; min-width: 0; }
.dojo-controls fieldset:last-child { padding-bottom: 11px; }
.dojo-controls fieldset + fieldset { border-top: 1px solid rgba(243, 241, 236, .08); }
/* a floated legend sits inside the fieldset instead of being drawn into its top border */
.dojo-controls legend {
  float: left; width: 100%; padding: 0; margin-bottom: 12px;
  display: flex; align-items: center; min-height: 26px;
  font: 700 var(--t-16)/1 var(--body); letter-spacing: .01em; color: var(--gofun);
}
.dojo-controls legend + * { clear: both; }

/* equal-width segmented rows */
.chips, .tiles { display: grid; gap: 8px; clear: both; }
.chips-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chips-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.chip, .tile { position: relative; display: flex; cursor: pointer; min-width: 0; }
.chip input, .tile input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; margin: 0; }
.chip span, .tile span {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1.5px solid rgba(243, 241, 236, .16); border-radius: 8px;
  background: rgba(243, 241, 236, .025);
  font-size: var(--t-14); font-weight: 500; line-height: 1.15; color: rgba(243, 241, 236, .88);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .2s var(--ease-out);
}
.chip span { min-height: 42px; padding: 0 10px; white-space: nowrap; }
.tile span { flex-direction: column; gap: 8px; padding: 10px 4px 9px; font-size: 13px; }
.chip:hover span, .tile:hover span { border-color: rgba(243, 241, 236, .5); background: rgba(243, 241, 236, .06); }
.chip input:checked + span, .tile input:checked + span { background: var(--gofun); color: var(--ink); border-color: var(--gofun); }
.chip input:focus-visible + span, .tile input:focus-visible + span { outline: 3px solid var(--shiba); outline-offset: 2px; }
.chip:active span, .tile:active span { transform: scale(.97); }
.chip-upload span { border-style: dashed; }
.chip-upload.is-active span { background: var(--gofun); color: var(--ink); border-style: solid; border-color: var(--gofun); }

/* backdrop swatches */
.swatch {
  display: block; width: 100%; max-width: 44px; aspect-ratio: 1; border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(243, 241, 236, .25);
}
.tile input:checked + span .swatch { box-shadow: 0 0 0 1.5px rgba(21, 24, 46, .35); }
.swatch-full { background: url(../assets/shiba.jpg) 90% 0% / 180% no-repeat; }
.swatch-sun { background: radial-gradient(circle at 50% 50%, var(--shu) 0 54%, var(--gofun) 55%); }
.swatch-night {
  background:
    radial-gradient(circle at 70% 30%, #F6E8C6 0 12%, transparent 13%),
    radial-gradient(circle at 28% 62%, rgba(243, 241, 236, .9) 0 2.5%, transparent 3.5%),
    radial-gradient(circle at 48% 78%, rgba(227, 168, 87, .9) 0 2.5%, transparent 3.5%),
    radial-gradient(circle at 50% 40%, var(--kon-lift), var(--kon-deep) 75%);
}
.swatch-waves {
  background:
    radial-gradient(circle at 50% 100%, transparent 0 18%, rgba(243, 241, 236, .7) 19% 23%, transparent 24% 33%, rgba(243, 241, 236, .7) 34% 38%, var(--kon) 39%) 0 0 / 50% 50%,
    var(--kon);
}

.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 40px; font-size: var(--t-16); }
.toggle input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 42px; height: 24px; border-radius: 999px;
  background: rgba(243, 241, 236, .22); position: relative; cursor: pointer;
  transition: background-color .15s ease;
}
.toggle input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--gofun); transition: transform .18s var(--ease-out);
}
.toggle input:checked { background: var(--shu); }
.toggle input:checked::after { transform: translateX(18px); }
.toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; clear: both; }
.toggles .toggle { font-size: var(--t-14); font-weight: 500; }

.dojo-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; margin-top: 20px; }
.dojo-actions .btn { min-height: 54px; font-size: var(--t-18); }
.dojo-actions .btn { width: 100%; }
.dojo-status { min-height: 1.4em; margin-top: 10px; font-size: var(--t-14); color: var(--shiba); }
.dojo-status:empty { min-height: 0; margin: 0; }

@media (max-width: 1180px) {
  .dojo-grid { gap: 36px; }
  .dojo-controls { padding-left: 20px; padding-right: 20px; }
}
/* one column: picture, the controls, then the buttons */
@media (max-width: 1119px) {
  .dojo-head { max-width: 600px; margin-left: auto; margin-right: auto; }
  .dojo-grid { grid-template-columns: minmax(0, 600px); justify-content: center; gap: 0; }
  .dojo-stage { display: contents; }
  .pfp-frame { order: 1; margin-bottom: 20px; }
  .dojo-controls { order: 3; }
  .dojo-actions { order: 4; margin-top: 16px; }
  .dojo-status { order: 5; text-align: center; }
}
@media (max-width: 420px) {
  .dojo-controls { padding: 4px 16px 18px; }
  .tile span { font-size: 12px; }
}

/* ---------- How to buy: a sheet of washi ---------- */
/* the one light room on the page: shell-white paper with torn edges, ink type and red seals, like a goshuin page */
.washi {
  position: relative;
  margin: 0 0 26px; /* the top tear lies over the section above, so no strip of page shows between them */
  background-color: var(--gofun);
  background-image: var(--washi-grain);
  color: var(--ink);
}
.washi::before, .washi::after {
  content: ""; position: absolute; left: 0; right: 0; height: 26px;
  /* one unrepeated image: a repeating, scaled background wraps its sampling and draws a hairline along the top */
  background: url(../assets/night/torn.svg) 0 0 / max(100%, 1200px) 100% no-repeat;
  pointer-events: none;
}
.washi::before { bottom: calc(100% - 1px); }
.washi::after { top: calc(100% - 1px); scale: -1 -1; }
.washi ::selection { background: var(--shu-deep); color: var(--gofun); }
.washi .section { position: relative; }
.washi .section-title { color: var(--ink); }
.washi :focus-visible { outline-color: var(--shu-ink); }
/* the buy link in step three; before launch it is a red-ink outline on the paper with its gold "Soon" tag turned to red */
.step-buy { justify-self: start; margin-top: 8px; white-space: nowrap; }
@media (max-width: 900px) { .steps li .step-buy { grid-column: 2; } }
.washi .btn[aria-disabled="true"] { background: rgba(180, 46, 33, .06); border-color: rgba(180, 46, 33, .45); color: var(--shu-ink); }
.washi .btn[aria-disabled="true"]::after { color: var(--shu-ink); background: rgba(180, 46, 33, .08); border-color: rgba(180, 46, 33, .4); }

/* Laid out like a goshuin rather than the page's usual red-kanji-left scaffold: the visit's steps on the left,
   the shrine's black brush calligraphy on the right with its red seal pressed on the paper just beneath it.
   The body is display: contents so the title, the steps and the goshuin share one grid at every width. */
.washi .buy { grid-template-columns: minmax(0, 1fr) auto; column-gap: clamp(32px, 6vw, 96px); row-gap: 0; }
.washi .buy .section-body { display: contents; }
.washi .buy .section-title { grid-column: 1; grid-row: 1; }
.washi .buy .steps { grid-column: 1; grid-row: 2; }
.goshuin {
  grid-column: 2; grid-row: 1 / span 2; align-self: start;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 10px 28px 0;
}
.washi .section-kanji {
  color: var(--ink);
  font-size: clamp(5rem, 9vw, 8rem); line-height: 1.04; letter-spacing: 0;
  /* a dry brush: the ink breaks up a little where the hair ran out */
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='d'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3.2 3.05'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23d)'/%3E%3C/svg%3E");
}

/* the shrine's red seal, pressed onto the page at a slant below the calligraphy (never over the ink), a little uneven */
.washi-seal {
  margin-top: clamp(14px, 2vw, 28px); translate: 22% 0;
  display: grid; place-items: center;
  writing-mode: vertical-rl;
  padding: 16px 12px;
  font: 400 clamp(1.5rem, 2.6vw, 2rem)/1 var(--brush); letter-spacing: .08em;
  color: var(--gofun);
  background: var(--shu-deep);
  border-radius: 4px;
  box-shadow: inset 0 0 0 3px var(--shu-deep), inset 0 0 0 5px rgba(243, 241, 236, .85);
  rotate: -7deg;
  opacity: .9;
  mix-blend-mode: multiply;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='2' seed='8'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.4 2.1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.steps {
  --rule: rgba(21, 24, 46, .16);
  list-style: none; margin: 12px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(24px, 3.4vw, 48px);
}
.steps li {
  position: relative;
  display: grid; align-content: start; row-gap: 10px;
  padding-top: 26px;
}
/* the hairline above each step is its own layer, so motion.css can draw it in ink */
.steps li::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background-color: var(--rule);
  transform-origin: 0 50%;
  pointer-events: none;
}
.step-num { justify-self: start; font: clamp(4rem, 6.4vw, 5.75rem)/1 var(--brush); color: var(--shu); margin-bottom: 2px; }
.steps h3 { font: clamp(1.25rem, 1.9vw, 1.5rem)/1.2 var(--display); color: var(--ink); }
.steps h3 [data-ticker] { display: block; color: var(--shu-ink); }
.steps p { font-size: var(--t-16); color: rgba(21, 24, 46, .78); max-width: 34ch; }
/* the three steps walk down the page like stones on the approach, each rule a step lower than the last */
@media (min-width: 901px) {
  .steps li:nth-child(2) { margin-top: clamp(32px, 4vw, 56px); }
  .steps li:nth-child(3) { margin-top: clamp(64px, 8vw, 112px); }
}
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr; gap: 8px; }
  .steps li { grid-template-columns: auto 1fr; column-gap: 20px; padding-bottom: 18px; }
  .step-num { grid-row: span 2; font-size: 3.25rem; }
}
@media (max-width: 640px) {
  /* the goshuin shrinks into the corner beside the title; the steps take the full width beneath */
  .washi .buy .steps { grid-column: 1 / -1; }
  .goshuin { grid-row: 1; padding: 0 4px 16px 0; }
  .washi .section-kanji { writing-mode: vertical-rl; font-size: 2.75rem; }
  .washi-seal { margin-top: 10px; padding: 8px 6px; font-size: 1rem; box-shadow: inset 0 0 0 2px var(--shu-deep), inset 0 0 0 3.5px rgba(243, 241, 236, .85); }
}

/* ---------- Finale ---------- */
.finale {
  position: relative;
  max-width: var(--wrap); margin: 0 auto;
  padding: clamp(96px, 16vh, 168px) var(--gutter) clamp(88px, 14vh, 140px);
  display: grid; justify-items: center; text-align: center;
}
.finale-kana {
  font: 400 clamp(2.75rem, 14vw, 10rem)/1 var(--brush);
  letter-spacing: .06em;
  white-space: nowrap;
  color: var(--shiba);
  user-select: none;
}
.finale-title {
  margin-top: clamp(12px, 2vw, 20px);
  font: 400 clamp(2.25rem, 5.2vw, 4rem)/1.05 var(--display);
  letter-spacing: -.01em;
}
.finale-actions { margin-top: clamp(28px, 4vw, 40px); display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Footer (seigaiha waves) ---------- */
/* the sea at the foot of the shrine: a band of seigaiha across the top that settles into still, deep water */
.footer {
  --w1: var(--kon-lift);
  --w2: var(--kon);
  --sea: clamp(132px, 15vw, 192px);
  position: relative; isolation: isolate; overflow: clip;
  background-color: var(--kon-deep);
  padding: calc(var(--sea) - 24px) var(--gutter) 64px;
}
/* the wave pattern sits on its own layer, one tile wider than the footer, so motion.css can let it drift */
.footer::before {
  content: ""; position: absolute; inset: 0 -96px auto 0; height: var(--sea); z-index: -1;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent);
  mask-image: linear-gradient(to bottom, #000 30%, transparent);
  background-image:
    radial-gradient(circle at 100% 150%, var(--w2) 24%, var(--w1) 24%, var(--w1) 28%, var(--w2) 28%, var(--w2) 36%, var(--w1) 36%, var(--w1) 40%, transparent 40%, transparent),
    radial-gradient(circle at 0 150%, var(--w2) 24%, var(--w1) 24%, var(--w1) 28%, var(--w2) 28%, var(--w2) 36%, var(--w1) 36%, var(--w1) 40%, transparent 40%, transparent),
    radial-gradient(circle at 50% 100%, var(--w1) 10%, var(--w2) 10%, var(--w2) 23%, var(--w1) 23%, var(--w1) 30%, var(--w2) 30%, var(--w2) 43%, var(--w1) 43%, var(--w1) 50%, var(--w2) 50%, var(--w2) 63%, var(--w1) 63%, var(--w1) 71%, transparent 71%, transparent),
    radial-gradient(circle at 100% 50%, var(--w1) 5%, var(--w2) 5%, var(--w2) 15%, var(--w1) 15%, var(--w1) 20%, var(--w2) 20%, var(--w2) 29%, var(--w1) 29%, var(--w1) 34%, var(--w2) 34%, var(--w2) 44%, var(--w1) 44%, var(--w1) 49%, transparent 49%, transparent),
    radial-gradient(circle at 0 50%, var(--w1) 5%, var(--w2) 5%, var(--w2) 15%, var(--w1) 15%, var(--w1) 20%, var(--w2) 20%, var(--w2) 29%, var(--w1) 29%, var(--w1) 34%, var(--w2) 34%, var(--w2) 44%, var(--w1) 44%, var(--w1) 49%, transparent 49%, transparent);
  background-size: 96px 48px;
}
.footer-inner {
  max-width: calc(var(--wrap) - 2 * var(--gutter)); margin: 0 auto;
  display: flex; gap: clamp(24px, 3vw, 36px); align-items: flex-start;
  padding-top: 32px;
  border-top: 1px solid rgba(243, 241, 236, .1);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-bottom: 14px; font: var(--t-18)/1.2 var(--display); }
.footer-links a { text-decoration: none; }
.footer-links a:hover { color: var(--shiba); }
.footer-links a[aria-disabled="true"] { color: rgba(243, 241, 236, .5); cursor: not-allowed; }
.footer-links a[aria-disabled="true"]:hover { color: rgba(243, 241, 236, .5); }
.footer-links a[aria-disabled="true"]::after {
  content: "Soon"; margin-left: 6px; vertical-align: .35em;
  font: 700 9px/1 var(--body); letter-spacing: .1em; text-transform: uppercase; color: var(--shiba);
}
.disclaimer { font-size: var(--t-14); line-height: 1.6; color: rgba(243, 241, 236, .65); max-width: 72ch; }
@media (max-width: 560px) {
  .footer-inner { flex-direction: column; gap: 20px; }
  /* one row on a phone, Soon tags included */
  .footer-links { flex-wrap: nowrap; justify-content: space-between; gap: 12px; font-size: var(--t-16); }
  .footer-links a { white-space: nowrap; }
}

/* ---------- Sound toggle ---------- */
.sound {
  position: fixed; right: 18px; bottom: 18px; z-index: 30;
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--kon-lift); color: var(--shiba);
  border: 1.5px solid rgba(227, 168, 87, .5);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(8, 10, 24, .4);
}
.sound[hidden] { display: none; }
.sound svg { width: 24px; height: 24px; }
.sound .sound-off { display: none; }
.sound[aria-pressed="true"] .sound-on { display: none; }
.sound[aria-pressed="true"] .sound-off { display: block; }
.sound:hover { border-color: var(--shiba); }

/* ---------- 3D layers (js/3d). The SVG stays underneath as the fallback. ---------- */
.gate-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  opacity: 0; transition: opacity .9s ease;
}
.gate.has-3d .gate-canvas { opacity: 1; }
.gate.has-3d .gate-scene,
.gate.has-3d .gate-moon,
.gate.has-3d .gate-petals { opacity: 0; transition: opacity .9s ease; pointer-events: none; }
/* while the 3D gate loads, the SVG gate stays hidden so it never shows first; it fades in only if the 3D gate can't run
   (html.gate-wait: set by the inline script in <head>, removed by js/3d/boot.js or its backstop timer) */
html.js .gate-scene, html.js .gate-moon, html.js .gate-petals { transition: opacity .6s ease; }
html.gate-wait .gate:not(.has-3d) .gate-scene,
html.gate-wait .gate:not(.has-3d) .gate-moon,
html.gate-wait .gate:not(.has-3d) .gate-petals { opacity: 0; }
.gate.has-3d .gate-copy::before {
  content: ""; position: absolute; z-index: -1; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100vw; height: 140%;
  background: linear-gradient(to bottom, rgba(12, 14, 32, 0), rgba(12, 14, 32, .82) 60%);
  pointer-events: none;
}

.hero-ema { position: relative; }
.ema3d {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: min(380px, 100%); aspect-ratio: 400 / 640; height: auto; display: block;
  opacity: 0; transition: opacity .8s ease; pointer-events: none;
}
.hero-ema.has-3d .ema3d { opacity: 1; }
.hero-ema.has-3d .ema { visibility: hidden; animation: none; }
@media (max-width: 860px) {
  .ema3d { width: min(230px, 60vw); }
}

/* ---------- 3D grounds (js/3d/gate.js) ---------- */
/* After the walk-through the gate's 3D shrine stays on as a fixed backdrop (html.grounds-3d). The hero and the finale
   are open to it; one indigo sheet covers everything between them. Without WebGL none of this applies and the hero
   keeps its printed night. */
.grounds {
  position: fixed; inset: 0 0 auto 0; z-index: -2;
  height: 100vh; height: 100lvh; /* the large viewport, so the scene does not jump when a phone's URL bar slides */
  pointer-events: none;
}
.grounds .gate-canvas { opacity: 1; transition: none; }

/* the gate turns clear as you walk through, so the camera flies straight on into the page */
html.grounds-3d .gate { background: transparent; }
/* the top bar lands with the hero instead of sitting over the fly-through */
html.grounds-3d.arrived .topbar > * { animation: arrive 1s var(--ease-out) 1.25s both; }

/* the 3D scene has its own moon, sky and petals, so the printed ones step aside */
html.grounds-3d .night,
html.grounds-3d .hero-ema .moon,
html.grounds-3d .ambient-petals { display: none; }

/* hero: a moonlit scrim keeps the words on calm dark ground, then the scene sinks into the indigo below */
html.grounds-3d .hero::before {
  content: ""; position: absolute; z-index: -1; inset: -96px 0 0 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(29, 35, 64, 0) 62%, rgba(29, 35, 64, .7) 84%, var(--kon) 100%),
    linear-gradient(to right, rgba(9, 11, 28, .8) 0%, rgba(9, 11, 28, .68) 30%, rgba(9, 11, 28, .42) 46%, rgba(9, 11, 28, 0) 66%),
    linear-gradient(to bottom, rgba(9, 11, 28, .5) 0%, rgba(9, 11, 28, 0) 22%);
}
/* a soft pool of shade under the copy column, so the lanterns and trees behind it never compete with the words */
html.grounds-3d .hero-copy { position: relative; }
html.grounds-3d .hero-copy::before {
  content: ""; position: absolute; z-index: -1; inset: -14% -22% -12% -40%;
  pointer-events: none;
  background: radial-gradient(ellipse 50% 50% at 50% 52%, rgba(8, 10, 26, .62) 0%, rgba(8, 10, 26, .44) 48%, rgba(8, 10, 26, .16) 78%, rgba(8, 10, 26, 0) 100%);
}
html.grounds-3d .hero-title,
html.grounds-3d .hero-lede { text-shadow: 0 2px 28px rgba(6, 8, 22, .55); }
html.grounds-3d .hero-ema figcaption { color: rgba(243, 241, 236, .75); text-shadow: 0 1px 12px rgba(6, 8, 22, .8); }
@media (max-width: 860px) {
  /* one column: the plaque sits over the path and the words below it, so the scrim deepens toward the bottom */
  html.grounds-3d .hero::before {
    background:
      linear-gradient(to bottom, rgba(9, 11, 28, .35) 0%, rgba(9, 11, 28, .1) 30%, rgba(9, 11, 28, .62) 56%, rgba(29, 35, 64, .9) 88%, var(--kon) 100%);
  }
}

/* the sheet between the hero and the finale; gate.js measures where it starts and stops */
html.grounds-3d main { position: relative; }
html.grounds-3d main::before {
  content: ""; position: absolute; z-index: -1; left: 0; right: 0;
  top: var(--cover-top, 100vh); bottom: var(--cover-bottom, 0px);
  background: var(--kon);
  pointer-events: none;
}

/* finale: the path ends at the lit hall. A full screen of it, faded in from the indigo above and out into the footer. */
/* The copy sits in the upper half on night sky; the camera (gate.js) tilts up so the lit hall stays in the lower third. */
html.grounds-3d .finale {
  min-height: 100svh;
  align-content: start;
  padding-top: clamp(120px, 22vh, 230px);
  padding-bottom: clamp(180px, 34vh, 360px); /* the lit hall, held in view by gate.js until the footer rises over it */
}
html.grounds-3d .finale::before,
html.grounds-3d .finale::after {
  content: ""; position: absolute; z-index: -1; left: 50%; width: 100vw; translate: -50% 0;
  pointer-events: none;
}
html.grounds-3d .finale::before {
  top: 0; height: 100%;
  background:
    linear-gradient(to bottom, var(--kon) 0%, rgba(29, 35, 64, .6) 18%, rgba(29, 35, 64, 0) 40%),
    radial-gradient(ellipse 46% 30% at 50% 36%, rgba(8, 10, 26, .6) 0%, rgba(8, 10, 26, .38) 55%, rgba(8, 10, 26, 0) 100%);
}
html.grounds-3d .finale::after { bottom: 0; height: 22%; background: linear-gradient(to bottom, rgba(20, 25, 51, 0), var(--kon-deep)); }
html.grounds-3d .finale-kana,
html.grounds-3d .finale-title { text-shadow: 0 2px 30px rgba(6, 8, 22, .6); }
