:root {
  --paper: #F4E9D2;
  --wax: #FFF7E6;
  --ink: #17120F;
  --indigo: #1E3A4A;
  --celadon: #87A98F;
  --seal: #C84A32;
  --sand: #D6C69A;
  --plum: #4B3140;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Gowun Batang", serif;
  background: var(--paper);
  overflow-x: hidden;
}

button { font: inherit; }

.grain-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: .42;
  mix-blend-mode: multiply;
  background:
    repeating-linear-gradient(102deg, rgba(23,18,15,.045) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(6deg, rgba(75,49,64,.035) 0 1px, transparent 1px 13px),
    radial-gradient(circle at 22% 18%, rgba(255,247,230,.65), transparent 28%),
    radial-gradient(circle at 70% 80%, rgba(214,198,154,.28), transparent 34%);
}

.edge-sequence { position: relative; }

.story-scene {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background: var(--paper);
}

.story-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, transparent 0 6%, rgba(255,247,230,.38) 6.5%, transparent 7.2%),
    radial-gradient(circle at 15% 70%, rgba(214,198,154,.24), transparent 31%),
    radial-gradient(circle at 88% 15%, rgba(135,169,143,.16), transparent 28%);
}

.swatch-nav {
  position: fixed;
  top: 20px;
  left: 22px;
  z-index: 90;
  display: grid;
  gap: 8px;
}

.swatch {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: rgba(255,247,230,.58);
  color: rgba(23,18,15,.76);
  padding: 6px 9px 6px 6px;
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(23,18,15,.15);
  transition: transform .45s ease, background .45s ease, color .45s ease;
}

.swatch:hover, .swatch.is-active { transform: translateX(6px); background: rgba(255,247,230,.9); color: var(--ink); }
.swatch span { width: 18px; height: 18px; border-radius: 45% 55% 48% 52%; border: 1px solid rgba(23,18,15,.25); display: block; }
.swatch[data-material="ink"] span { background: var(--ink); }
.swatch[data-material="tide"] span { background: var(--indigo); }
.swatch[data-material="sand"] span { background: var(--sand); }
.swatch[data-material="moon"] span { background: var(--wax); }
.swatch[data-material="seal"] span { background: var(--seal); }

.scene-number, .material-tag, .tiny-label {
  font-family: "Zen Kaku Gothic New", sans-serif;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-size: 11px;
}

.scene-number {
  position: absolute;
  color: rgba(23,18,15,.58);
  z-index: 5;
}

h1, h2 { font-weight: 400; margin: 0; }

h1 {
  font-family: "Song Myung", serif;
  font-size: clamp(56px, 13vw, 190px);
  letter-spacing: -.055em;
}

h2 {
  font-family: "Song Myung", serif;
  font-size: clamp(38px, 6vw, 96px);
  line-height: .95;
}

p { line-height: 1.72; }

.resist-path {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  overflow: visible;
}

.resist-path path {
  fill: none;
  stroke: var(--wax);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  filter: drop-shadow(0 2px 0 rgba(23,18,15,.12));
  animation: drawResist 2.7s cubic-bezier(.35,0,.05,1) forwards;
}

.ink-until {
  background:
    radial-gradient(circle at 55% 45%, rgba(255,247,230,.78), transparent 25%),
    linear-gradient(115deg, var(--paper), #ead9b7 100%);
}

.ink-until .scene-number { right: 11vw; top: 12vh; }

.ink-stage {
  position: absolute;
  width: min(74vmin, 760px);
  height: min(74vmin, 760px);
  left: 7vw;
  top: 8vh;
  border-radius: 49% 51% 52% 48%;
}

.wax-crescent {
  position: absolute;
  width: 62vmin;
  height: 62vmin;
  left: 20vw;
  top: 10vh;
  border-radius: 50%;
  border: 28px solid rgba(255,247,230,.7);
  border-left-color: transparent;
  border-bottom-color: rgba(255,247,230,.25);
  transform: rotate(-28deg);
  filter: blur(.3px);
}

.ink-bloom {
  position: absolute;
  left: 24%;
  top: 27%;
  width: 22vmin;
  height: 22vmin;
  border-radius: 42% 58% 48% 52%;
  transform: scale(.04);
  transform-origin: 50% 50%;
  background:
    radial-gradient(circle at 48% 48%, rgba(23,18,15,.98) 0 14%, rgba(30,58,74,.94) 32%, rgba(30,58,74,.56) 55%, rgba(23,18,15,.12) 72%, transparent 74%),
    conic-gradient(from 18deg, rgba(23,18,15,.2), rgba(30,58,74,.75), rgba(75,49,64,.5), rgba(23,18,15,.7), rgba(23,18,15,.2));
  filter: url(#none) blur(.2px);
  mix-blend-mode: multiply;
  animation: inkBloom 4.2s cubic-bezier(.1,.72,.08,1) .35s forwards, breatheInk 6s ease-in-out 4.5s infinite;
}

.ink-granules {
  position: absolute;
  inset: 9%;
  opacity: 0;
  background-image:
    radial-gradient(circle, rgba(23,18,15,.42) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255,247,230,.5) 0 1px, transparent 1.4px);
  background-size: 23px 19px, 31px 29px;
  border-radius: 47% 53% 51% 49%;
  mask-image: radial-gradient(circle at 42% 44%, #000 0 47%, transparent 69%);
  animation: granulesAppear 2s ease 3.1s forwards;
}

.resist-arc { width: 72%; height: 72%; left: 12%; top: 8%; }

.brush {
  position: absolute;
  left: 19%;
  top: 22%;
  width: 130px;
  height: 16px;
  transform: rotate(-24deg);
  cursor: grab;
  z-index: 7;
}

.brush::before { content: ""; position: absolute; width: 86px; height: 7px; right: 0; top: 5px; background: var(--plum); border-radius: 9px; }
.brush span { position: absolute; width: 44px; height: 18px; left: 0; top: 0; background: linear-gradient(90deg, var(--ink), rgba(23,18,15,.2)); clip-path: polygon(0 50%, 85% 0, 100% 50%, 85% 100%); }

.title-reveal {
  position: absolute;
  right: 7vw;
  bottom: 12vh;
  max-width: 58vw;
  opacity: 0;
  transform: translateY(18px);
  filter: blur(7px);
  animation: revealTitle 1.4s ease 4.25s forwards;
}

.tiny-label { color: var(--seal); margin: 0 0 12px; }

.particles {
  display: flex;
  align-items: baseline;
  gap: .28em;
  font-family: "Song Myung", serif;
  font-size: clamp(40px, 9vw, 134px);
  line-height: 1;
}

.particles .jp, .vertical-made, .jp-side-note, .red-seal .jp { font-family: "Noto Serif JP", serif; }
.particles i { font-style: normal; color: var(--seal); font-family: "Noto Serif JP", serif; }

.edge-copy {
  position: absolute;
  left: 9vw;
  bottom: 8vh;
  max-width: 330px;
  color: rgba(23,18,15,.73);
}

.paper-tab {
  position: absolute;
  z-index: 12;
  padding: 8px 13px;
  background: var(--wax);
  color: var(--plum);
  font-family: "Gowun Batang", serif;
  box-shadow: 0 12px 25px rgba(23,18,15,.12);
  transform: rotate(var(--r, -3deg));
  cursor: pointer;
  transition: transform .35s ease, background .35s ease;
}

.paper-tab:hover { transform: rotate(0deg) translateY(-5px); background: #fff1d6; }
.tab-one { --r: 4deg; right: 17vw; top: 34vh; }
.tab-two { --r: -6deg; left: 14vw; bottom: 17vh; }
.tab-three { --r: 2deg; right: 22vw; bottom: 25vh; }
.tab-four { --r: -2deg; left: 11vw; top: 21vh; }
.tab-five { --r: 5deg; right: 10vw; top: 16vh; }

.door-until { background: linear-gradient(90deg, var(--wax) 0 16%, var(--paper) 16% 100%); }
.lacquer-bar { position: absolute; left: 15.6%; top: 0; bottom: 0; width: 18px; background: var(--ink); box-shadow: 16px 0 45px rgba(23,18,15,.28); }
.door-wash { position: absolute; left: 16%; bottom: 0; width: 75%; height: 58%; background: radial-gradient(ellipse at 40% 100%, rgba(30,58,74,.78), rgba(30,58,74,.26) 46%, transparent 68%); clip-path: polygon(0 34%, 16% 26%, 28% 39%, 44% 28%, 62% 34%, 79% 20%, 100% 31%, 100% 100%, 0 100%); animation: tideBreathe 6s ease-in-out infinite; }
.door-line { left: 10%; bottom: 22%; width: 78%; height: 42%; }
.door-until .scene-number { left: 20vw; top: 12vh; }
.vertical-made { position: absolute; left: calc(15.6% + 42px); top: 19vh; writing-mode: vertical-rl; font-size: clamp(64px, 12vw, 160px); color: rgba(30,58,74,.82); letter-spacing: .08em; }
.margin-note { position: absolute; max-width: 430px; }
.right-notch { right: 8vw; top: 19vh; padding: 28px 32px; background: rgba(255,247,230,.58); clip-path: polygon(0 0, 100% 0, 100% 78%, 86% 78%, 86% 100%, 0 100%); }
.bristle-row { position: absolute; left: 22vw; bottom: 10vh; display: flex; gap: 12px; }
.bristle-row i { width: 2px; height: 48px; background: rgba(23,18,15,.45); transform: rotate(var(--a, 4deg)); }
.bristle-row i:nth-child(2) { --a: -7deg; height: 36px; } .bristle-row i:nth-child(3) { --a: 11deg; height: 55px; } .bristle-row i:nth-child(4) { --a: -2deg; height: 40px; } .bristle-row i:nth-child(5) { --a: 8deg; height: 60px; }

.morning-until { background: linear-gradient(180deg, #ead9b7 0, var(--paper) 56%, var(--wax)); }
.dawn-panel { position: absolute; inset: 0; background: linear-gradient(100deg, transparent 0 24%, rgba(214,198,154,.22) 24% 39%, rgba(255,247,230,.82) 39% 47%, rgba(200,74,50,.14) 47% 63%, transparent 63%); animation: dawnFill 8s ease-in-out infinite alternate; }
.hanging-cord { position: absolute; top: 0; left: 52%; width: 3px; height: 72vh; background: var(--plum); box-shadow: 8px 0 0 rgba(75,49,64,.18); }
.hanging-cord span { position: absolute; bottom: -24px; left: -11px; width: 26px; height: 38px; border-radius: 50%; border: 2px solid var(--plum); background: transparent; }
.light-pool { position: absolute; left: 0; bottom: 0; width: 54%; height: 78%; background: radial-gradient(ellipse at 100% 78%, rgba(255,247,230,.92), rgba(214,198,154,.38) 42%, transparent 65%); clip-path: polygon(0 0, 89% 0, 100% 100%, 0 100%); }
.cord-path { left: 35%; top: 0; width: 34%; height: 83%; }
.morning-until .scene-number { right: 8vw; top: 10vh; }
.low-ledge { position: absolute; left: 11vw; bottom: 12vh; max-width: 520px; border-bottom: 9px solid var(--sand); padding-bottom: 18px; }
.jp-side-note { position: absolute; right: 16vw; bottom: 13vh; writing-mode: vertical-rl; color: var(--plum); font-size: clamp(34px, 5vw, 78px); line-height: 1.1; }

.even-to-the-edge { background: linear-gradient(180deg, var(--indigo) 0, #2d4c59 39%, var(--sand) 39%, var(--paper) 100%); color: var(--wax); }
.even-to-the-edge::before { opacity: .25; }
.sand-mound { position: absolute; bottom: -12vh; left: -8vw; width: 74vw; height: 43vh; background: radial-gradient(ellipse at 50% 0, var(--sand), rgba(214,198,154,.75) 45%, transparent 70%); border-radius: 50% 50% 0 0; }
.carved-line { position: absolute; left: 18vw; right: 11vw; top: 39%; height: 4px; background: rgba(23,18,15,.58); box-shadow: 0 9px 0 rgba(255,247,230,.18); transform: rotate(-2deg); }
.moon-disc { position: absolute; right: 12vw; top: 11vh; width: 24vmin; height: 24vmin; border-radius: 50%; background: var(--wax); box-shadow: inset -42px 0 0 rgba(214,198,154,.42), 0 0 60px rgba(255,247,230,.28); animation: moonStop 7s ease-in-out infinite alternate; }
.fold-shadow { position: absolute; right: 25vw; top: 0; height: 100%; width: 18vw; background: linear-gradient(90deg, transparent, rgba(23,18,15,.24), transparent); transform: skewX(-8deg); }
.tide-ring { left: 6%; top: 28%; width: 88%; height: 48%; }
.tide-ring path { stroke: rgba(255,247,230,.72); }
.even-to-the-edge .scene-number { left: 9vw; bottom: 12vh; color: rgba(255,247,230,.7); }
.extent-copy { position: absolute; right: 8vw; bottom: 12vh; max-width: 530px; color: var(--wax); }
.seal-small { position: absolute; left: 45vw; top: 53vh; width: 74px; height: 74px; display: grid; place-items: center; border-radius: 44% 56% 48% 52%; background: var(--seal); color: var(--wax); font-family: "Noto Serif JP", serif; font-size: 36px; transform: rotate(9deg); opacity: .9; }

.seal-of-stop { background: radial-gradient(circle at 50% 48%, var(--wax) 0 23%, var(--paper) 24% 100%); }
.boundary-orbit { position: absolute; left: 50%; top: 50%; border-radius: 48% 52% 47% 53%; transform: translate(-50%, -50%); border: 2px solid rgba(23,18,15,.18); }
.orbit-one { width: 56vmin; height: 52vmin; border-color: rgba(30,58,74,.45); animation: orbitSettle 8s ease-in-out infinite; }
.orbit-two { width: 64vmin; height: 59vmin; border-color: rgba(135,169,143,.62); animation: orbitSettle 9s ease-in-out infinite reverse; }
.orbit-three { width: 72vmin; height: 67vmin; border-color: rgba(214,198,154,.8); animation: orbitSettle 10s ease-in-out infinite; }
.final-circle { left: 50%; top: 50%; width: 70vmin; height: 70vmin; transform: translate(-50%, -50%); }
.final-circle path { stroke: rgba(23,18,15,.42); stroke-width: 4; }
.final-text { position: absolute; left: 8vw; top: 14vh; max-width: 430px; }
.red-seal { position: absolute; left: 50%; top: 50%; width: 220px; height: 220px; margin: -110px 0 0 -110px; border-radius: 45% 55% 50% 48%; background: rgba(200,74,50,.92); color: var(--wax); display: grid; place-items: center; transform: rotate(-7deg) scale(.82); box-shadow: 0 18px 45px rgba(200,74,50,.26); font-family: "Song Myung", serif; font-size: 52px; opacity: .12; transition: opacity 1.2s ease, transform 1.2s cubic-bezier(.1,.7,.08,1); }
.red-seal.is-imprinted { opacity: 1; transform: rotate(-7deg) scale(1); }
.red-seal span { grid-area: 1 / 1; mix-blend-mode: screen; }
.red-seal .jp { transform: translate(18px, 20px); opacity: .86; }
.red-seal em { position: absolute; bottom: 34px; font-style: normal; font-family: "Zen Kaku Gothic New", sans-serif; font-size: 11px; letter-spacing: .28em; text-transform: uppercase; }
.ceramic-drips { position: absolute; left: 62vw; top: 59vh; display: flex; gap: 19px; }
.ceramic-drips i { width: 12px; height: 80px; border-radius: 0 0 12px 12px; background: linear-gradient(var(--celadon), transparent); animation: dripFreeze 5s ease-in-out infinite; }
.ceramic-drips i:nth-child(2) { height: 132px; animation-delay: .4s; } .ceramic-drips i:nth-child(3) { height: 58px; animation-delay: .8s; } .ceramic-drips i:nth-child(4) { height: 102px; animation-delay: 1.1s; }

.note-bubble {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  max-width: 260px;
  padding: 10px 14px;
  background: var(--plum);
  color: var(--wax);
  font-family: "Zen Kaku Gothic New", sans-serif;
  font-size: 12px;
  letter-spacing: .06em;
  opacity: 0;
  pointer-events: none;
  transform: translate(12px, 12px) rotate(-1deg);
  transition: opacity .25s ease;
}
.note-bubble.is-visible { opacity: .96; }

body.material-tide .ink-bloom { background: radial-gradient(circle, rgba(30,58,74,.95), rgba(30,58,74,.5) 58%, transparent 72%); }
body.material-sand .ink-bloom { background: radial-gradient(circle, rgba(214,198,154,.9), rgba(200,74,50,.24) 55%, transparent 72%); }
body.material-moon .ink-bloom { background: radial-gradient(circle, rgba(255,247,230,.95), rgba(135,169,143,.26) 55%, transparent 72%); }
body.material-seal .ink-bloom { background: radial-gradient(circle, rgba(200,74,50,.92), rgba(75,49,64,.45) 55%, transparent 72%); }

@keyframes inkBloom { to { transform: scale(3.85); border-radius: 52% 48% 58% 42%; } }
@keyframes breatheInk { 0%,100% { filter: blur(.2px); } 50% { filter: blur(1.4px); } }
@keyframes granulesAppear { to { opacity: .48; } }
@keyframes revealTitle { to { opacity: 1; transform: translateY(0); filter: blur(0); } }
@keyframes drawResist { to { stroke-dashoffset: 0; } }
@keyframes tideBreathe { 0%,100% { transform: translateY(0); opacity: .78; } 50% { transform: translateY(-18px); opacity: .94; } }
@keyframes dawnFill { from { clip-path: inset(0 48% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes moonStop { from { transform: translateX(-9vw); } to { transform: translateX(0); } }
@keyframes orbitSettle { 0%,100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); } 50% { transform: translate(-50%, -50%) rotate(7deg) scale(1.03); } }
@keyframes dripFreeze { 0%,100% { transform: scaleY(.55); opacity: .45; } 55% { transform: scaleY(1); opacity: .9; } }

@media (max-width: 760px) {
  .swatch-nav { grid-template-columns: repeat(5, auto); top: auto; bottom: 12px; left: 10px; right: 10px; gap: 4px; }
  .swatch { font-size: 8px; padding-right: 5px; gap: 4px; }
  .swatch span { width: 13px; height: 13px; }
  .title-reveal { right: 6vw; bottom: 23vh; max-width: 88vw; }
  .edge-copy, .right-notch, .low-ledge, .extent-copy, .final-text { left: 7vw; right: 7vw; max-width: none; }
  .right-notch { top: 42vh; }
  .vertical-made { left: 20vw; font-size: 84px; }
  .jp-side-note { right: 8vw; }
  .red-seal { width: 170px; height: 170px; margin: -85px 0 0 -85px; font-size: 40px; }
}
