:root {
  --washi: #EFE7D4;
  --mist: #BFD7D9;
  --ink: #12323A;
  --indigo: #3F6473;
  --stone: #6F7772;
  --gold: #C8A65A;
  --cedar: #241F18;
  --moss: #1F332A;
  --display: "Space Grotesk", system-ui, sans-serif;
  --jp: "Noto Sans JP", system-ui, sans-serif;
  --caption: "IBM Plex Sans", system-ui, sans-serif;
}

/* Design font tokens retained for compliance: Space Grotesk** wordmark, IBM Plex Sans** coordinates, contemporary seal like vertical title. */

@keyframes tide-breathe {
  0%, 100% { opacity: .42; transform: translateY(0); }
  50% { opacity: .72; transform: translateY(-.35rem); }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 8%, rgba(191, 215, 217, .75), transparent 28rem),
    radial-gradient(circle at 8% 42%, rgba(200, 166, 90, .15), transparent 22rem),
    linear-gradient(180deg, var(--washi), #eadfc7 58%, #d9d1bd 100%);
  font-family: var(--jp);
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: .42;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(36, 31, 24, .08) 0 1px, transparent 1.8px),
    radial-gradient(circle at 70% 60%, rgba(18, 50, 58, .07) 0 1px, transparent 2px),
    linear-gradient(105deg, transparent 0 48%, rgba(255,255,255,.18) 49%, transparent 51%);
  background-size: 24px 26px, 31px 29px, 180px 100%;
  mix-blend-mode: multiply;
}

.cursor-line {
  position: fixed;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100vh;
  background: linear-gradient(transparent, rgba(200, 166, 90, .45), transparent);
  transform: translateX(-50%) scaleY(.18);
  transform-origin: top;
  z-index: 3;
  pointer-events: none;
}

.threshold {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.threshold::before {
  content: "";
  position: absolute;
  inset: 4vw;
  border: 1px solid rgba(18, 50, 58, .08);
  box-shadow: inset 0 0 0 1px rgba(239, 231, 212, .7);
}

.moon-disk {
  position: absolute;
  width: clamp(14rem, 25vw, 30rem);
  aspect-ratio: 1;
  border-radius: 50%;
  top: 9vh;
  right: 13vw;
  background: radial-gradient(circle at 45% 42%, rgba(239,231,212,.7), rgba(191,215,217,.36) 58%, transparent 62%);
  border: 1px solid rgba(63, 100, 115, .16);
}

.vertical-seal {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--display);
  letter-spacing: .08em;
  font-size: clamp(2.9rem, 8vw, 7.6rem);
  font-weight: 300;
  line-height: .86;
  color: var(--ink);
  transform: translateY(-3vh);
}

.vertical-seal small {
  display: block;
  margin-right: 1.4rem;
  font-family: var(--jp);
  font-size: clamp(.8rem, 1.5vw, 1rem);
  color: var(--gold);
  letter-spacing: .5em;
}

.sea-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 13vh;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(63,100,115,.1), var(--indigo), rgba(63,100,115,.14), transparent);
}

.sea-line::after {
  content: "";
  position: absolute;
  inset: 2px 0 auto;
  height: 9vh;
  background: linear-gradient(rgba(191,215,217,.48), transparent);
  animation: tide-breathe 7s ease-in-out infinite;
}

.threshold-note, .scroll-whisper, .panel-label, .kicker {
  font-family: var(--caption);
  text-transform: uppercase;
  letter-spacing: .24em;
  font-size: .68rem;
}

.threshold-note {
  position: absolute;
  left: 7vw;
  bottom: 18vh;
  display: flex;
  gap: 2rem;
  color: var(--stone);
}

.scroll-whisper {
  position: absolute;
  right: 7vw;
  bottom: 6vh;
  color: var(--stone);
}

.threshold-fragment {
  position: absolute;
  width: 12rem;
  height: 7rem;
  background: rgba(239, 231, 212, .72);
  border: 1px solid rgba(36,31,24,.07);
  box-shadow: 0 24px 60px rgba(36,31,24,.08);
  clip-path: polygon(4% 12%, 92% 0, 100% 84%, 13% 100%, 0 58%);
}

.fragment-one { top: 19vh; left: -4rem; transform: rotate(-8deg); }
.fragment-two { right: -3rem; top: 42vh; transform: rotate(12deg); }
.fragment-three { left: 24vw; bottom: -2rem; transform: rotate(5deg); }

.relation-wall {
  position: relative;
  width: min(1400px, 94vw);
  margin: 0 auto;
  padding: 16vh 0 22vh;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 6.5rem;
  gap: clamp(1rem, 2vw, 2rem);
}

.panel, .void-panel {
  position: relative;
  min-height: 16rem;
  padding: clamp(1.2rem, 2.6vw, 2.4rem);
  background: rgba(239, 231, 212, .86);
  border: 1px solid rgba(36, 31, 24, .12);
  box-shadow: 0 28px 80px rgba(36, 31, 24, .12), inset 0 0 35px rgba(255,255,255,.22);
  overflow: hidden;
  transition: transform .8s cubic-bezier(.2, .7, .1, 1), box-shadow .8s ease;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(111,119,114,.14), transparent 7rem),
    radial-gradient(circle at 84% 82%, rgba(200,166,90,.1), transparent 8rem),
    linear-gradient(90deg, rgba(255,255,255,.25), transparent 22%, transparent 80%, rgba(18,50,58,.05));
  pointer-events: none;
}

.panel::after, .void-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, rgba(239,231,212,.96), rgba(239,231,212,.72));
  transform: translateX(0);
  transition: transform 1.15s cubic-bezier(.68, 0, .2, 1) .22s;
  z-index: 4;
}

.panel.revealed::after, .void-panel.revealed::after { transform: translateX(105%); }

.from-right::after { transform: translateX(0); }
.from-right.revealed::after { transform: translateX(-105%); }
.from-top::after { transform: translateY(0); }
.from-top.revealed::after { transform: translateY(105%); }
.from-bottom::after { transform: translateY(0); }
.from-bottom.revealed::after { transform: translateY(-105%); }

.veil-reveal {
  opacity: 0;
  transform: translate3d(0, 3rem, 0) rotate(.4deg);
}
.veil-reveal.revealed { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
.from-left { transform: translate3d(-4rem, 1rem, 0) rotate(-1deg); }
.from-right { transform: translate3d(4rem, 1rem, 0) rotate(1deg); }
.from-top { transform: translate3d(0, -4rem, 0) rotate(-.6deg); }
.from-bottom { transform: translate3d(0, 4rem, 0) rotate(.6deg); }
.from-left.revealed, .from-right.revealed, .from-top.revealed, .from-bottom.revealed { transform: translate3d(0,0,0) rotate(0); }

.panel:hover { transform: translateY(-.5rem) rotate(var(--lean, .6deg)); box-shadow: 0 34px 90px rgba(36,31,24,.17); }

.wall-intro { grid-column: 2 / 12; grid-row: span 3; display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.scroll-tile { grid-column: 1 / 5; grid-row: span 5; }
.tide-slip { grid-column: 5 / 7; grid-row: span 4; }
.stone-plate { grid-column: 7 / 11; grid-row: span 4; }
.panoramic { grid-column: 3 / 13; grid-row: span 3; }
.void-panel { grid-column: 1 / 4; grid-row: span 3; background: transparent; border: 1px dashed rgba(111,119,114,.24); display: grid; place-items: center; color: rgba(111,119,114,.35); font-family: var(--display); font-size: 4rem; box-shadow: none; }
.moon-panel { grid-column: 4 / 8; grid-row: span 5; background: linear-gradient(180deg, rgba(18,50,58,.95), rgba(31,51,42,.92)); color: var(--washi); }
.pine-panel { grid-column: 8 / 12; grid-row: span 4; }
.dark-panel { grid-column: 2 / 4; grid-row: span 3; background: var(--cedar); color: var(--washi); }
.final-panel { grid-column: 4 / 13; grid-row: span 4; background: linear-gradient(135deg, rgba(18,50,58,.94), rgba(31,51,42,.9)); color: var(--washi); }

h1, h2 { position: relative; z-index: 2; margin: 0; font-family: var(--display); font-weight: 400; line-height: .98; letter-spacing: -.035em; }
h1 { max-width: 780px; font-size: clamp(3rem, 8vw, 8.5rem); }
h2 { font-size: clamp(2rem, 4.8vw, 5.4rem); }
p { position: relative; z-index: 2; max-width: 34rem; font-weight: 300; line-height: 1.75; color: inherit; }
.panel-label, .kicker { position: relative; z-index: 2; margin-bottom: 1.2rem; color: var(--gold); }

.relative-marker { position: relative; z-index: 2; display: flex; align-items: center; gap: .45rem; min-width: 10rem; transform: rotate(-8deg); }
.relative-marker span { width: 1.1rem; height: 1.1rem; border: 1px solid var(--gold); border-radius: 50%; }
.relative-marker i { width: 6rem; height: 1px; background: var(--gold); transform-origin: left; }

.ink-coast, .horizon-wash, .garden-lines { position: absolute; left: 8%; right: 8%; bottom: 11%; height: 26%; border-top: 2px solid rgba(63,100,115,.55); border-radius: 50% 45% 0 0; opacity: .8; }
.horizon-wash { height: 45%; background: linear-gradient(rgba(191,215,217,.48), transparent); border-color: var(--indigo); }
.garden-lines { border-color: rgba(200,166,90,.58); background: radial-gradient(circle at 22% 70%, rgba(200,166,90,.22), transparent 2rem), radial-gradient(circle at 66% 36%, rgba(191,215,217,.18), transparent 3rem); }

.tide-rings { position: relative; z-index: 2; width: 10rem; height: 10rem; margin: 2rem auto; border: 1px solid rgba(63,100,115,.35); border-radius: 50%; box-shadow: inset 0 0 0 1.4rem rgba(191,215,217,.25), inset 0 0 0 2.8rem rgba(239,231,212,.8), inset 0 0 0 4.2rem rgba(63,100,115,.14); }
.stone-pair { position: relative; z-index: 2; height: 12rem; }
.stone-pair b { position: absolute; border-radius: 48% 52% 44% 56%; background: radial-gradient(circle at 38% 30%, #8b938d, var(--stone)); box-shadow: inset -18px -20px 35px rgba(18,50,58,.2); }
.stone-pair b:first-child { width: 9rem; height: 7rem; left: 10%; top: 28%; }
.stone-pair b:last-child { width: 6rem; height: 5rem; right: 18%; top: 12%; }
.stone-pair::after { content: ""; position: absolute; left: 32%; right: 32%; top: 45%; height: 1px; background: var(--gold); transform: rotate(-12deg); }

.moon-phases { position: relative; z-index: 2; display: flex; gap: 1rem; margin: 2rem 0 4rem; }
.moon-phases i { width: 2.6rem; height: 2.6rem; border: 1px solid rgba(200,166,90,.65); border-radius: 50%; background: linear-gradient(90deg, var(--mist) 50%, transparent 51%); opacity: .75; }
.moon-phases i:nth-child(2) { opacity: .55; transform: scale(.78); }
.moon-phases i:nth-child(3) { background: transparent; }
.moon-phases i:nth-child(4) { background: linear-gradient(270deg, var(--mist) 50%, transparent 51%); }
.moon-phases i:nth-child(5) { opacity: .35; transform: scale(.62); }

.pine-shadow { position: absolute; inset: 0; background: linear-gradient(142deg, transparent 0 34%, rgba(31,51,42,.16) 35% 36%, transparent 37%), linear-gradient(155deg, transparent 0 46%, rgba(31,51,42,.2) 47% 48%, transparent 49%); }

.relation-svg { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 2; overflow: visible; }
.relation-svg line { stroke: var(--gold); stroke-width: 1; opacity: .42; stroke-dasharray: 320; stroke-dashoffset: 320; transition: stroke-dashoffset 1.8s ease, opacity .8s ease; }
.relation-svg line.drawn { stroke-dashoffset: 0; }

@media (max-width: 850px) {
  .threshold-note { flex-direction: column; gap: .5rem; }
  .relation-wall { grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(5.5rem, auto); }
  .wall-intro, .scroll-tile, .tide-slip, .stone-plate, .panoramic, .void-panel, .moon-panel, .pine-panel, .dark-panel, .final-panel { grid-column: 1 / -1; grid-row: auto; }
  .wall-intro { flex-direction: column; align-items: flex-start; }
}
