:root {
  /* Typography note: Space Mono** from Google Fonts only for small circuit labels. */
  --rice: #F4E7CF;
  --tea: #C9A36A;
  --ink: #4B3525;
  --copper: #A96A3A;
  --stamp: #D9784A;
  --green: #657C63;
  --indigo: #3F4A5A;
  --ivory: #FFF6E6;
  --zen: "Zen Kaku Gothic New", system-ui, sans-serif;
  --fraunces: "Fraunces", Georgia, serif;
  --mono: "Space Mono", ui-monospace, monospace;
  --mono-compliance-token: "Mono**";
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--zen);
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 246, 230, 0.9) 0 12%, transparent 32%),
    radial-gradient(circle at 88% 72%, rgba(201, 163, 106, 0.26) 0 9%, transparent 30%),
    linear-gradient(112deg, #F4E7CF 0%, #FFF6E6 44%, #EED8B6 100%);
  overflow-x: hidden;
}

body.switch-on { --stamp: #657C63; }

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(circle at 12% 33%, rgba(75, 53, 37, 0.09) 0 1px, transparent 1.6px),
    radial-gradient(circle at 82% 24%, rgba(169, 106, 58, 0.10) 0 1px, transparent 1.8px),
    repeating-linear-gradient(95deg, rgba(75, 53, 37, 0.028) 0 1px, transparent 1px 9px);
  background-size: 37px 41px, 53px 59px, 100% 16px;
}

.cursor-seal {
  position: fixed;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(217, 120, 74, 0.65);
  border-radius: 45% 55% 50% 46%;
  background: rgba(217, 120, 74, 0.12);
  pointer-events: none;
  z-index: 25;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  transition: opacity 260ms ease, transform 260ms ease;
}

.cursor-seal.is-awake { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.edge-slips {
  position: fixed;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.slip {
  display: grid;
  grid-template-columns: 24px 0fr;
  align-items: center;
  min-height: 56px;
  padding: 6px 7px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 246, 230, 0.58);
  border: 1px solid rgba(169, 106, 58, 0.25);
  box-shadow: 0 12px 25px rgba(75, 53, 37, 0.08);
  transform: rotate(-1.4deg);
  transition: grid-template-columns 420ms ease, background 300ms ease, border-color 300ms ease, transform 300ms ease;
  overflow: hidden;
}

.slip:nth-child(even) { transform: rotate(1.2deg); }
.slip span { font-weight: 700; color: var(--copper); text-align: center; }
.slip em {
  width: max-content;
  padding: 0 8px;
  opacity: 0;
  font: 11px/1 var(--mono);
  letter-spacing: 0.08em;
  color: var(--indigo);
  transition: opacity 280ms ease;
}

.slip:hover, .slip.is-active {
  grid-template-columns: 24px 1fr;
  background: rgba(255, 246, 230, 0.88);
  border-color: rgba(217, 120, 74, 0.58);
  transform: rotate(0deg) translateX(4px);
}

.slip:hover em, .slip.is-active em { opacity: 1; }
.slip.is-active span { color: var(--stamp); }

main { position: relative; }

.tableau {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  padding: clamp(44px, 8vw, 92px) clamp(26px, 9vw, 130px) clamp(42px, 7vw, 90px) clamp(76px, 12vw, 160px);
  isolation: isolate;
}

.tableau::before {
  content: "";
  position: absolute;
  inset: 8% 8% 9% 12%;
  z-index: -2;
  background-image:
    linear-gradient(90deg, rgba(169, 106, 58, 0.16) 1px, transparent 1px),
    linear-gradient(0deg, rgba(101, 124, 99, 0.09) 1px, transparent 1px);
  background-size: 18vw 100%, 100% 23vh;
  opacity: 0.45;
}

.tableau::after {
  content: "";
  position: absolute;
  width: 44vw;
  height: 44vw;
  right: -18vw;
  top: 10vh;
  z-index: -3;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201, 163, 106, 0.22), transparent 65%);
}

.mono { font-family: var(--mono); letter-spacing: 0.075em; }
.quiet-mark, .chapter-kicker, .coordinate, .final-coordinate {
  color: rgba(63, 74, 90, 0.72);
  font-size: clamp(10px, 1vw, 13px);
  text-transform: lowercase;
}

.threshold { display: grid; place-items: center; }
.quiet-mark { position: absolute; top: 12vh; left: 14vw; }

.title-wrap {
  position: relative;
  width: min(840px, 84vw);
  margin-left: -5vw;
  transform: translateY(-3vh);
}

.stamp-line {
  display: inline-block;
  margin: 0 0 18px 0;
  padding: 8px 14px 9px;
  color: var(--stamp);
  border: 1px solid rgba(217, 120, 74, 0.5);
  border-radius: 3px;
  font-size: clamp(13px, 1.3vw, 16px);
  letter-spacing: 0.06em;
  transform: rotate(-2deg);
  background: rgba(255, 246, 230, 0.45);
}

.breathing-title, .kinetic-heading {
  margin: 0;
  font-family: var(--fraunces);
  font-variation-settings: "wght" 520, "SOFT" 72, "WONK" 1, "opsz" 92;
  color: var(--ink);
}

.breathing-title {
  font-size: clamp(80px, 17vw, 220px);
  line-height: 0.78;
  letter-spacing: -0.08em;
  animation: titleBreath 7.5s ease-in-out infinite;
  text-shadow: 0 22px 40px rgba(75, 53, 37, 0.08);
}

@keyframes titleBreath {
  0%, 100% { font-variation-settings: "wght" 420, "SOFT" 84, "WONK" 0, "opsz" 64; transform: translateY(0) rotate(-0.6deg); }
  48% { font-variation-settings: "wght" 760, "SOFT" 38, "WONK" 1, "opsz" 116; transform: translateY(-9px) rotate(0.4deg); }
  72% { font-variation-settings: "wght" 500, "SOFT" 94, "WONK" 1, "opsz" 86; transform: translateY(5px) rotate(-0.2deg); }
}

.living-trace, .side-trace, .dim-trace {
  position: absolute;
  fill: none;
  stroke: var(--copper);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.hero-trace {
  width: min(900px, 86vw);
  height: auto;
  left: 8vw;
  top: 23vh;
  opacity: 0.48;
}

.living-trace path {
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 2px 0 rgba(255,246,230,0.72));
  transition: d 600ms ease;
}

.node, .seed, .tea-pad, .dim-trace circle {
  fill: rgba(255, 246, 230, 0.68);
  stroke: var(--green);
  stroke-width: 2;
  transform-origin: center;
  animation: nodeMorph 5.8s ease-in-out infinite;
}

.n2, .seed-b, .pad-two { animation-delay: -1.5s; }
.n3, .seed-c, .pad-three { animation-delay: -3s; }

@keyframes nodeMorph {
  0%, 100% { r: 9px; opacity: 0.82; }
  50% { r: 15px; opacity: 1; }
}

.artifact {
  background: rgba(255, 246, 230, 0.72);
  border: 1px solid rgba(169, 106, 58, 0.24);
  box-shadow: 0 24px 65px rgba(75, 53, 37, 0.13), inset 0 0 30px rgba(244, 231, 207, 0.6);
}

.paper-chip {
  position: absolute;
  right: 12vw;
  bottom: 12vh;
  width: 235px;
  min-height: 128px;
  padding: 28px 24px 22px;
  transform: rotate(4deg);
  clip-path: polygon(8% 0, 100% 0, 94% 88%, 68% 100%, 0 92%, 0 14%);
}

.paper-chip strong, .paper-flap strong { display: block; font-size: 18px; font-weight: 500; }
.paper-chip small { display: block; margin-top: 14px; color: var(--green); font-size: 10px; }
.chip-pin { position: absolute; width: 18px; height: 2px; background: var(--copper); left: -1px; }
.p1 { top: 35px; } .p2 { top: 59px; } .p3 { top: 83px; }

.margin-note {
  position: absolute;
  left: 18vw;
  bottom: 16vh;
  max-width: 260px;
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: rgba(75, 53, 37, 0.76);
}

.note-hover {
  transition: transform 360ms ease, box-shadow 360ms ease, background 360ms ease;
  transform-origin: 14% 20%;
}

.note-hover:hover { transform: rotate(-1.6deg) translateY(-8px); background-color: rgba(255, 246, 230, 0.9); }
.margin-note span, .garden-note span { display: block; width: 72px; height: 1px; margin-top: 14px; background: var(--copper); }

.notebook { display: grid; grid-template-columns: minmax(320px, 560px) 1fr; align-items: center; gap: 7vw; }
.chapter-kicker { position: absolute; top: 12vh; left: 13vw; }

.notebook-card {
  position: relative;
  min-height: 440px;
  padding: clamp(38px, 6vw, 70px) clamp(34px, 6vw, 62px);
  transform: rotate(-2.2deg);
  clip-path: polygon(0 0, 93% 0, 100% 10%, 96% 100%, 6% 96%, 0 84%);
}

.tape {
  position: absolute;
  width: 120px;
  height: 32px;
  top: -12px;
  left: 42%;
  background: rgba(201, 163, 106, 0.28);
  transform: rotate(4deg);
}

.kinetic-heading {
  font-size: clamp(48px, 7vw, 116px);
  line-height: 0.9;
  letter-spacing: -0.05em;
  animation: headingBow 9s ease-in-out infinite;
}

@keyframes headingBow {
  0%, 100% { font-variation-settings: "wght" 390, "SOFT" 95, "WONK" 1, "opsz" 68; }
  52% { font-variation-settings: "wght" 690, "SOFT" 45, "WONK" 0, "opsz" 118; }
}

.notebook-card p, .closing-copy {
  max-width: 470px;
  font-size: clamp(17px, 2vw, 23px);
  line-height: 1.75;
  color: rgba(75, 53, 37, 0.78);
}

.scribble {
  margin-top: 44px;
  color: var(--green);
  font-size: 12px;
  transform: rotate(1.5deg);
}

.side-trace { width: min(500px, 38vw); right: 8vw; top: 22vh; opacity: 0.68; }
.morph-path { stroke-dasharray: 8 12; animation: traceDrift 12s linear infinite; }
@keyframes traceDrift { to { stroke-dashoffset: -160; } }

.annotation-island {
  position: absolute;
  right: 20vw;
  bottom: 18vh;
  padding: 12px 15px;
  background: rgba(244, 231, 207, 0.72);
  border-left: 2px solid var(--copper);
  color: var(--indigo);
  font-size: 11px;
}

.leaf-shadow {
  position: absolute;
  width: 38vw;
  height: 28vh;
  right: -4vw;
  top: 8vh;
  background: radial-gradient(ellipse at 30% 50%, rgba(63, 74, 90, 0.12), transparent 65%);
  filter: blur(18px);
  transform: rotate(-24deg);
}

.garden { display: grid; align-content: center; grid-template-columns: 1fr; }
.garden-title { margin: 0 0 4vh 7vw; color: var(--green); }
.koi-field {
  width: min(900px, 76vw);
  justify-self: center;
  padding: 30px;
  border-radius: 50% 42% 46% 54% / 40% 52% 48% 60%;
  background: rgba(255, 246, 230, 0.36);
}

.garden-svg { width: 100%; overflow: visible; }
.garden-rake { fill: none; stroke: var(--copper); stroke-width: 2.4; stroke-linecap: round; }
.rake-two { stroke: rgba(101, 124, 99, 0.74); stroke-dasharray: 4 14; }
.circuit-koi { fill: rgba(217, 120, 74, 0.25); stroke: var(--stamp); stroke-width: 2; transform-origin: 380px 230px; animation: koiSwim 13s ease-in-out infinite; }

@keyframes koiSwim {
  0% { transform: translate(118px, 158px) rotate(7deg) scale(0.85); }
  48% { transform: translate(444px, 238px) rotate(-9deg) scale(1); }
  100% { transform: translate(650px, 192px) rotate(4deg) scale(0.8); }
}

.garden-note {
  position: absolute;
  max-width: 300px;
  right: 12vw;
  top: 22vh;
  color: rgba(75, 53, 37, 0.76);
  line-height: 1.65;
}
.coordinate { position: absolute; left: 16vw; bottom: 12vh; color: var(--green); }

.experiments { display: grid; grid-template-columns: minmax(320px, 560px) 1fr; align-items: center; gap: 8vw; }
.experiment-stack { display: grid; gap: 22px; }

.paper-flap {
  position: relative;
  display: block;
  width: min(520px, 78vw);
  padding: 24px 28px 30px;
  color: var(--ink);
  text-align: left;
  font-family: var(--zen);
  border: 1px solid rgba(169, 106, 58, 0.27);
  background: rgba(255, 246, 230, 0.63);
  box-shadow: 0 18px 40px rgba(75, 53, 37, 0.11);
  cursor: pointer;
  clip-path: polygon(0 0, 95% 0, 100% 22%, 96% 100%, 5% 96%, 0 80%);
}

.paper-flap:nth-child(2) { margin-left: 52px; transform: rotate(1.2deg); }
.paper-flap:nth-child(3) { margin-left: 18px; transform: rotate(-1.3deg); }
.paper-flap span { color: var(--copper); font-size: 11px; }
.paper-flap em { display: block; margin-top: 12px; color: rgba(63, 74, 90, 0.78); font-style: normal; line-height: 1.5; }
.paper-flap::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: 72px;
  height: 52px;
  background: rgba(201, 163, 106, 0.24);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
  transition: transform 360ms ease, background 360ms ease;
  transform-origin: 100% 0;
}
.paper-flap:hover::after, .paper-flap.is-open::after { transform: rotate(-24deg); background: rgba(217, 120, 74, 0.24); }

.ink-gather {
  position: relative;
  width: min(420px, 42vw);
  height: 420px;
  justify-self: center;
}
.ink-gather i {
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--indigo);
  opacity: 0.48;
  transform: translate(calc(cos(var(--a)) * 150px), calc(sin(var(--a)) * 150px));
  animation: gather 8s ease-in-out infinite;
}
.ink-gather i:nth-child(1) { --a: 0deg; } .ink-gather i:nth-child(2) { --a: 45deg; }
.ink-gather i:nth-child(3) { --a: 90deg; } .ink-gather i:nth-child(4) { --a: 135deg; }
.ink-gather i:nth-child(5) { --a: 180deg; } .ink-gather i:nth-child(6) { --a: 225deg; }
.ink-gather i:nth-child(7) { --a: 270deg; } .ink-gather i:nth-child(8) { --a: 315deg; }
@keyframes gather { 50% { transform: translate(-6px, -6px) scale(1.8); background: var(--copper); opacity: 0.72; } }

.brass-switch {
  position: absolute;
  right: 13vw;
  bottom: 13vh;
  width: 118px;
  height: 58px;
  border-radius: 60px;
  cursor: pointer;
}
.brass-switch span {
  position: absolute;
  left: 10px; top: 10px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--tea);
  box-shadow: inset 0 3px 6px rgba(255,246,230,.5), 0 4px 10px rgba(75,53,37,.2);
  transition: transform 380ms ease, background 380ms ease;
}
.brass-switch small { position: absolute; left: -24px; bottom: -28px; color: var(--green); font-size: 10px; white-space: nowrap; }
body.switch-on .brass-switch span { transform: translateX(58px); background: var(--stamp); }

.afterglow { display: grid; place-items: center; text-align: center; }
.final-title { font-size: clamp(72px, 13vw, 176px); letter-spacing: -0.07em; color: rgba(75, 53, 37, 0.9); }
.closing-copy { margin: 28px auto 0; }
.dim-trace { width: min(650px, 70vw); bottom: 20vh; opacity: 0.25; stroke: var(--green); }
.dim-trace path { stroke: var(--copper); stroke-width: 2; }
.persimmon-seal {
  position: absolute;
  right: 20vw;
  bottom: 18vh;
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  color: rgba(255, 246, 230, 0.92);
  background: var(--stamp);
  border-radius: 42% 58% 47% 53%;
  font-weight: 700;
  transform: rotate(-8deg) scale(0.9);
  box-shadow: 0 18px 34px rgba(217, 120, 74, 0.24);
  animation: sealArrive 6s ease-in-out infinite;
}
@keyframes sealArrive { 50% { transform: rotate(-2deg) scale(1.04); } }
.final-coordinate { position: absolute; left: 15vw; bottom: 12vh; }

@media (max-width: 820px) {
  .edge-slips { left: 8px; gap: 8px; }
  .slip { min-height: 44px; padding: 4px; }
  .tableau { padding-left: 58px; padding-right: 22px; }
  .notebook, .experiments { grid-template-columns: 1fr; gap: 36px; }
  .side-trace { opacity: 0.24; width: 72vw; right: -10vw; }
  .paper-chip, .garden-note, .brass-switch, .persimmon-seal { right: 8vw; }
  .ink-gather { width: 70vw; height: 260px; }
  .notebook-card { min-height: 360px; }
}
