:root {
  --rose: #FF7A90;
  --paper: #F7E8C6;
  --shadow: #6B563C;
  --amber: #F2A541;
  --honey: #D98B24;
  --blue: #4E9DE6;
  --mint: #6ED6A0;
  --ink: #241A12;
  --parchment: #FFF6E3;
  --fraunces: "Fraunces", Georgia, serif;
  --recursive: "Recursive", "Trebuchet MS", sans-serif;
  --kr: "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--kr);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 12%, rgba(242, 165, 65, .18), transparent 34vw),
    radial-gradient(circle at 88% 70%, rgba(255, 122, 144, .11), transparent 30vw),
    linear-gradient(115deg, var(--parchment), var(--paper));
}

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .42;
  background-image:
    radial-gradient(rgba(107, 86, 60, .16) 1px, transparent 1.4px),
    radial-gradient(rgba(217, 139, 36, .12) .8px, transparent 1.2px);
  background-size: 34px 38px, 19px 23px;
  mix-blend-mode: multiply;
}

.tutorial-scroll { position: relative; z-index: 2; }

.tableau {
  min-height: 100vh;
  position: relative;
  padding: clamp(4rem, 8vw, 8rem) clamp(1.5rem, 6vw, 7rem);
  overflow: hidden;
  isolation: isolate;
}

.wide-quiet {
  position: absolute;
  inset: 8% 38% 14% 3%;
  border-radius: 48% 52% 43% 57%;
  background: rgba(255, 246, 227, .55);
  filter: blur(2px);
  z-index: -1;
}

.lesson-tabs {
  position: fixed;
  right: 0;
  top: 18vh;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.lesson-tabs a {
  font-family: var(--recursive);
  font-variation-settings: "MONO" 1, "CASL" .25, "wght" 650;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 246, 227, .82);
  border: 1px solid rgba(107, 86, 60, .2);
  border-right: 0;
  border-radius: 16px 0 0 16px;
  padding: .55rem .75rem .55rem .9rem;
  box-shadow: -8px 8px 24px rgba(107, 86, 60, .08);
  transform: translateX(14px);
  transition: transform .35s ease, background .35s ease, color .35s ease;
}

.lesson-tabs a.active,
.lesson-tabs a:hover {
  transform: translateX(0);
  background: var(--amber);
  color: var(--ink);
}

.candle-guide {
  --x: 18vw;
  --y: 30vh;
  position: fixed;
  left: var(--x);
  top: var(--y);
  width: 1px;
  height: 1px;
  z-index: 9;
  pointer-events: none;
  transition: left 1.1s cubic-bezier(.2,.8,.2,1), top 1.1s cubic-bezier(.2,.8,.2,1);
}

.candle-halo {
  position: absolute;
  width: clamp(220px, 36vw, 520px);
  height: clamp(220px, 36vw, 520px);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 165, 65, .38), rgba(217, 139, 36, .16) 36%, rgba(255, 246, 227, 0) 72%);
  filter: blur(12px);
  animation: haloBreath 3.8s ease-in-out infinite;
}

.flame-wrap {
  position: absolute;
  left: -14px;
  top: -42px;
  width: 32px;
  height: 76px;
  filter: drop-shadow(0 0 12px rgba(242, 165, 65, .75));
}

.flame {
  position: absolute;
  left: 8px;
  top: 0;
  width: 18px;
  height: 31px;
  border-radius: 60% 40% 55% 45% / 70% 45% 55% 35%;
  transform-origin: 50% 90%;
  background: linear-gradient(180deg, #FFF6E3 0%, var(--amber) 46%, var(--honey) 100%);
  animation: flameFlicker .72s infinite alternate cubic-bezier(.36,.07,.19,.97);
}

.flame-b {
  left: 12px;
  top: 6px;
  width: 10px;
  height: 19px;
  background: linear-gradient(180deg, #FFF6E3, #FFCF73);
  animation-duration: .46s;
  opacity: .95;
}

.wick {
  position: absolute;
  left: 15px;
  top: 27px;
  width: 3px;
  height: 17px;
  border-radius: 2px;
  background: var(--ink);
}

.wax-body {
  position: absolute;
  left: 5px;
  top: 41px;
  width: 23px;
  height: 35px;
  border-radius: 9px 9px 6px 6px;
  background: linear-gradient(90deg, #F7E8C6, #FFF6E3 48%, #EECF91);
  box-shadow: inset -5px 0 10px rgba(107, 86, 60, .14);
}

.lesson-mark,
.eyebrow,
.concept-kicker {
  display: inline-block;
  font-family: var(--recursive);
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--honey);
  font-variation-settings: "MONO" 1, "CASL" .4, "wght" 760;
}

.hero-copy {
  width: min(920px, 78vw);
  margin-left: clamp(6rem, 18vw, 18rem);
  margin-top: 11vh;
}

.variable-title {
  margin: .4rem 0 1rem;
  font-family: var(--fraunces);
  font-size: clamp(4.7rem, 13vw, 14rem);
  line-height: .78;
  letter-spacing: -.09em;
  color: var(--ink);
  font-variation-settings: "wght" 420, "SOFT" 82, "WONK" 1;
  text-shadow: 0 10px 32px rgba(217, 139, 36, .2);
  animation: typeClarify 6s ease-in-out infinite alternate;
}

.opening-line {
  width: min(640px, 70vw);
  margin: 0 0 0 1vw;
  font-family: var(--recursive);
  font-size: clamp(1.15rem, 2vw, 1.75rem);
  line-height: 1.55;
  color: var(--shadow);
  font-variation-settings: "CASL" .65, "wght" 440;
}

.note-card,
.glossary-spark,
.micro-note,
.closing-note {
  background: rgba(255, 246, 227, .72);
  border: 1px solid rgba(107, 86, 60, .18);
  box-shadow: 0 20px 55px rgba(107, 86, 60, .11);
  backdrop-filter: blur(6px);
}

.intro-annotation {
  position: absolute;
  right: 10vw;
  bottom: 18vh;
  width: 225px;
  padding: 1rem 1.1rem;
  border-radius: 22px 22px 22px 7px;
  transform: rotate(-2deg);
}

.intro-annotation strong { color: var(--rose); font-family: var(--recursive); }
.intro-annotation p { margin: .45rem 0 0; color: var(--shadow); line-height: 1.45; }
.pin-dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--rose); box-shadow: 0 0 0 6px rgba(255, 122, 144, .14); margin-right: .35rem; }

.annotation-svg {
  position: absolute;
  pointer-events: none;
  overflow: visible;
}

.annotation-svg path,
.map-svg path {
  fill: none;
  stroke: rgba(107, 86, 60, .72);
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 900;
  stroke-dashoffset: 900;
  animation: drawInk 2.4s ease forwards;
}

.hero-line { left: 12vw; bottom: 7vh; width: min(620px, 55vw); transform: rotate(-4deg); }

.section-title-block {
  width: min(640px, 72vw);
  margin-left: clamp(2rem, 12vw, 13rem);
}

.section-title-block h2,
.afterglow-copy h2 {
  margin: .7rem 0 0;
  font-family: var(--fraunces);
  font-size: clamp(2.6rem, 6vw, 6.4rem);
  line-height: .96;
  letter-spacing: -.045em;
  font-variation-settings: "wght" 520, "SOFT" 65, "WONK" 1;
}

.concept-card {
  position: absolute;
  left: clamp(5rem, 29vw, 29rem);
  top: 45vh;
  width: min(405px, 52vw);
  padding: 2rem;
  border-radius: 34px 34px 12px 34px;
  background: linear-gradient(145deg, rgba(255,246,227,.88), rgba(247,232,198,.72));
  border: 1px solid rgba(107, 86, 60, .18);
  box-shadow: 0 28px 80px rgba(107, 86, 60, .13);
}

.concept-card h3 { margin: .65rem 0 1.1rem; font-family: var(--fraunces); font-size: clamp(1.65rem, 3vw, 3rem); line-height: 1.03; }
.concept-card code { font-family: var(--recursive); font-variation-settings: "MONO" 1, "CASL" .1, "wght" 520; color: var(--blue); background: rgba(78,157,230,.1); padding: .4rem .55rem; border-radius: 10px; }

.tab-stack { position: absolute; right: 22px; top: -14px; display: flex; gap: .35rem; }
.tab-stack span { display: block; width: 36px; height: 18px; border-radius: 10px 10px 0 0; background: var(--rose); }
.tab-stack span:nth-child(2) { background: var(--blue); }
.tab-stack span:nth-child(3) { background: var(--amber); }

.right-rail { position: absolute; right: 7vw; top: 30vh; width: 220px; display: grid; gap: 1rem; }
.glossary-spark { border-radius: 18px; padding: .9rem; transition: transform .35s ease, box-shadow .35s ease; }
.glossary-spark:hover { transform: translateX(-8px) rotate(-1deg); box-shadow: 0 18px 50px rgba(242, 165, 65, .22); }
.glossary-spark b { display: block; font-family: var(--recursive); color: var(--rose); margin-bottom: .25rem; }
.glossary-spark span { color: var(--shadow); font-size: .9rem; }
.margin-lines { inset: 18vh 4vw auto auto; width: 72vw; height: 54vh; }
.ko-note { position: absolute; left: 7vw; bottom: 17vh; padding: .8rem 1rem; border-radius: 18px; color: var(--shadow); transform: rotate(2deg); }

.melt-tableau { padding-top: 12vh; }
.wash { position: absolute; border-radius: 42% 58% 55% 45%; filter: blur(10px); opacity: .38; transform: scale(.75); transition: transform 1.4s ease, opacity 1.4s ease; }
.wash-blue { right: 7vw; top: 15vh; width: 36vw; height: 30vw; background: var(--blue); }
.wash-amber { left: 10vw; bottom: 8vh; width: 39vw; height: 26vw; background: var(--amber); }
.tableau.in-view .wash { transform: scale(1); opacity: .2; animation: watercolorBloom 5.5s ease-in-out infinite alternate; }

.dependency-map {
  position: relative;
  width: min(760px, 82vw);
  height: 360px;
  margin: 12vh 0 0 clamp(2rem, 24vw, 24rem);
}
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-node {
  position: absolute;
  z-index: 2;
  min-width: 112px;
  padding: .85rem 1rem;
  border-radius: 999px;
  text-align: center;
  font-family: var(--recursive);
  font-variation-settings: "MONO" .35, "CASL" .35, "wght" 680;
  background: rgba(255, 246, 227, .82);
  border: 1px solid rgba(107, 86, 60, .2);
  box-shadow: 0 18px 45px rgba(107, 86, 60, .12);
  transition: transform .7s ease, background .7s ease;
}
.map-node.abstract { left: 2%; bottom: 20%; color: var(--rose); filter: blur(1px); }
.map-node.source { left: 14%; top: 8%; color: var(--blue); }
.map-node.transform { left: 43%; top: 42%; color: var(--honey); }
.map-node.output { right: 0; top: 18%; color: #2E8B62; }
.tableau.in-view .map-node.abstract { filter: blur(0); transform: translate(18px, -18px); }
.tableau.in-view .map-node.transform { transform: scale(1.06); background: rgba(242, 165, 65, .18); }
.melt-caption { width: min(475px, 70vw); margin-left: clamp(2rem, 14vw, 16rem); color: var(--shadow); line-height: 1.7; font-size: 1.08rem; }

.token-stage {
  position: absolute;
  left: clamp(2rem, 18vw, 20rem);
  bottom: 28vh;
  width: min(650px, 74vw);
  min-height: 145px;
}
.wax-token {
  position: absolute;
  border: 0;
  border-radius: 999px;
  padding: .95rem 1.35rem;
  font-family: var(--recursive);
  font-size: 1rem;
  color: var(--ink);
  box-shadow: 0 18px 42px rgba(107, 86, 60, .16), inset 0 -4px 8px rgba(107, 86, 60, .08);
  cursor: pointer;
  transition: transform .65s cubic-bezier(.2,1.4,.2,1), box-shadow .35s ease, filter .35s ease;
}
.wax-token.rose { background: rgba(255, 122, 144, .82); left: 8%; top: 35%; transform: rotate(-13deg); }
.wax-token.blue { background: rgba(78, 157, 230, .76); left: 32%; top: 0; transform: rotate(9deg); }
.wax-token.honey { background: rgba(217, 139, 36, .78); left: 54%; top: 42%; transform: rotate(-7deg); }
.wax-token.mint { background: rgba(110, 214, 160, .86); right: 0; top: 18%; transform: rotate(11deg); }
.tableau.in-view .wax-token { animation: tokenSettle 1.1s cubic-bezier(.2,1.4,.2,1) both; }
.wax-token.clicked { transform: translateY(-12px) scale(1.12) rotate(0deg) !important; filter: saturate(1.25); box-shadow: 0 20px 60px rgba(242, 165, 65, .32); }
.proof-strip {
  position: absolute;
  right: 9vw;
  bottom: 14vh;
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  max-width: 410px;
  padding: 1rem;
  border-radius: 24px;
  background: rgba(255, 246, 227, .78);
}
.proof-strip span,
.proof-strip strong { padding: .45rem .65rem; border-radius: 13px; background: rgba(247,232,198,.78); font-family: var(--recursive); }
.proof-strip strong { background: rgba(110,214,160,.22); color: #2E8B62; }
.firefly-field i { position: absolute; width: 9px; height: 9px; border-radius: 50%; opacity: .75; animation: firefly 3.2s ease-in-out infinite alternate; }
.firefly-field i:nth-child(1) { left: 10%; top: 28%; background: var(--rose); }
.firefly-field i:nth-child(2) { left: 72%; top: 22%; background: var(--mint); animation-delay: .2s; }
.firefly-field i:nth-child(3) { left: 80%; top: 64%; background: var(--blue); animation-delay: .5s; }
.firefly-field i:nth-child(4) { left: 24%; top: 72%; background: var(--amber); animation-delay: .8s; }
.firefly-field i:nth-child(5) { left: 44%; top: 27%; background: var(--rose); animation-delay: 1s; }
.firefly-field i:nth-child(6) { left: 61%; top: 78%; background: var(--mint); animation-delay: 1.2s; }
.firefly-field i:nth-child(7) { left: 16%; top: 54%; background: var(--blue); animation-delay: 1.4s; }
.firefly-field i:nth-child(8) { left: 90%; top: 42%; background: var(--honey); animation-delay: 1.6s; }

.afterglow-tableau { display: grid; place-items: center; text-align: center; }
.closing-wash { position: absolute; width: min(780px, 80vw); height: min(520px, 60vw); border-radius: 50%; background: radial-gradient(circle, rgba(242,165,65,.28), rgba(255,122,144,.09) 45%, transparent 70%); filter: blur(10px); }
.afterglow-copy { position: relative; width: min(760px, 84vw); }
.afterglow-copy p { margin: 1.2rem auto 2rem; width: min(500px, 72vw); color: var(--shadow); line-height: 1.65; }
.signature { font-family: var(--fraunces); font-size: clamp(3.4rem, 9vw, 9rem); line-height: 1; color: var(--honey); font-variation-settings: "wght" 360, "SOFT" 100, "WONK" 1; text-shadow: 0 0 34px rgba(242, 165, 65, .4); }
.closing-note { position: absolute; right: 8vw; bottom: 12vh; padding: .95rem 1.15rem; border-radius: 24px 24px 8px 24px; color: var(--shadow); }

.reveal-note { opacity: 0; transform: translateY(28px); transition: opacity .9s ease, transform .9s ease, filter .9s ease; }
.tableau.in-view .reveal-note { opacity: 1; transform: translateY(0); }
[data-note] { transition: transform .45s ease, box-shadow .45s ease, filter .45s ease; }
[data-note].glow { box-shadow: 0 18px 70px rgba(242, 165, 65, .34); filter: saturate(1.14); }

@keyframes flameFlicker { from { transform: rotate(-4deg) scaleY(.92) scaleX(1.08); } to { transform: rotate(5deg) scaleY(1.12) scaleX(.88); } }
@keyframes haloBreath { 0%,100% { opacity: .7; transform: translate(-50%, -50%) scale(.94); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } }
@keyframes typeClarify { from { font-variation-settings: "wght" 340, "SOFT" 100, "WONK" 1; letter-spacing: -.105em; } to { font-variation-settings: "wght" 720, "SOFT" 35, "WONK" 0; letter-spacing: -.075em; } }
@keyframes drawInk { to { stroke-dashoffset: 0; } }
@keyframes watercolorBloom { from { border-radius: 42% 58% 55% 45%; } to { border-radius: 58% 42% 45% 55%; } }
@keyframes tokenSettle { from { opacity: .3; filter: blur(3px); } to { opacity: 1; filter: blur(0); } }
@keyframes firefly { from { transform: translate(0,0) scale(.7); opacity: .35; } to { transform: translate(18px,-22px) scale(1.25); opacity: 1; } }

@media (max-width: 760px) {
  .tableau { padding: 5rem 1.2rem; }
  .lesson-tabs { top: auto; right: .5rem; bottom: .5rem; flex-direction: row; max-width: calc(100vw - 1rem); }
  .lesson-tabs a { border-radius: 999px; transform: none; font-size: .72rem; padding: .48rem .55rem; }
  .hero-copy, .section-title-block { margin-left: 0; width: 92vw; }
  .variable-title { font-size: clamp(3.4rem, 18vw, 7rem); }
  .intro-annotation, .concept-card, .right-rail, .proof-strip, .closing-note { position: relative; inset: auto; right: auto; left: auto; top: auto; bottom: auto; width: auto; margin: 2rem 0 0; }
  .concept-card { padding: 1.35rem; }
  .dependency-map { margin: 4rem 0 0; width: 100%; transform: scale(.9); transform-origin: left center; }
  .token-stage { position: relative; left: auto; bottom: auto; width: 100%; margin-top: 4rem; }
  .wax-token { position: relative; left: auto !important; right: auto !important; top: auto !important; margin: .4rem; display: inline-block; }
  .hero-line, .margin-lines { opacity: .35; }
}
