:root {
  --terracotta: #B95532;
  --clay: #3A211B;
  --teal: #2F7F76;
  --plum: #221822;
  --cream: #FFF4E6;
  --copper: #D8893A;
  --blush: #FF8B9A;
  --heat: 0;
  --distance: 1;
  --tilt: 0deg;
}

/* Typography tokens: Inter** from Google Fonts in Regular and Medium for clean instructional rhythm. Interface labels Roboto Mono** from Google Fonts in Medium. */

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--cream);
  background: radial-gradient(circle at 72% 18%, rgba(185, 85, 50, .22), transparent 34%), radial-gradient(circle at 14% 88%, rgba(47, 127, 118, .18), transparent 36%), var(--plum);
  font-family: Inter, Roboto, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.lesson-deck {
  position: relative;
  min-height: 100vh;
  padding: 32px clamp(18px, 4vw, 64px) 40px;
  isolation: isolate;
}

.grain, .grain::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.grain {
  opacity: .32;
  background-image: linear-gradient(115deg, transparent 0 48%, rgba(255,244,230,.045) 49% 50%, transparent 51% 100%), repeating-linear-gradient(0deg, rgba(255,244,230,.025) 0 1px, transparent 1px 5px);
}

.grain::after {
  content: "";
  opacity: .28;
  background: radial-gradient(circle at 20% 20%, rgba(255,244,230,.12) 0 1px, transparent 1px 100%), radial-gradient(circle at 80% 70%, rgba(216,137,58,.16) 0 1px, transparent 1px 100%);
  background-size: 19px 23px, 29px 31px;
}

.hud-map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  opacity: .74;
}

.hud-map path, .hud-map circle {
  fill: none;
  stroke: var(--copper);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-dasharray: 12 16;
  animation: drawline 8s linear infinite;
}

.hud-map .trace-b { stroke: var(--teal); animation-duration: 11s; }
.hud-map .scan { stroke: var(--blush); stroke-dasharray: 4 12; opacity: .42; }
.hud-map .bracket { stroke: var(--cream); opacity: .32; stroke-dasharray: none; }

@keyframes drawline { to { stroke-dashoffset: -220; } }

.hero-slate {
  width: min(980px, 100%);
  margin: 0 0 18px;
  padding: 24px 26px;
  background: linear-gradient(135deg, rgba(58,33,27,.78), rgba(34,24,34,.72));
  border: 1px solid rgba(216,137,58,.45);
  border-radius: 30px 8px 30px 8px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,244,230,.07);
  clip-path: polygon(0 0, calc(100% - 34px) 0, 100% 34px, 100% 100%, 34px 100%, 0 calc(100% - 34px));
}

.topline, .coord, .phase-strip button, .landing-line span, .landing-line em {
  font-family: "Roboto Mono", ui-monospace, monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topline {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--copper);
  font-size: 12px;
}

.wordmark {
  position: relative;
  margin: 18px 0 8px;
  font-family: "Nunito Sans", Inter, sans-serif;
  font-weight: 900;
  font-size: clamp(58px, 12vw, 150px);
  line-height: .78;
  letter-spacing: -.07em;
}

.wordmark .tsun { color: var(--cream); filter: drop-shadow(8px 0 0 rgba(185,85,50,.34)); }
.wordmark .dere { color: var(--blush); opacity: calc(.22 + var(--heat) * .78); transform: translateY(calc(18px - var(--heat) * 18px)); display: inline-block; text-shadow: 0 0 calc(8px + var(--heat) * 26px) rgba(255,139,154,.7); }
.wordmark .xyz { display: inline-flex; gap: 7px; margin-left: 13px; vertical-align: middle; }
.wordmark .xyz i { width: clamp(10px, 1.4vw, 18px); height: clamp(10px, 1.4vw, 18px); border-radius: 50%; background: var(--copper); box-shadow: 0 0 18px var(--blush); transform: scale(calc(.55 + var(--heat) * .45)); }

.hero-slate p {
  max-width: 650px;
  margin: 0 0 20px;
  color: rgba(255,244,230,.78);
  font-size: 18px;
  line-height: 1.55;
}

.phase-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.phase-strip button {
  border: 1px solid rgba(216,137,58,.44);
  border-radius: 999px;
  padding: 10px 13px;
  color: var(--cream);
  background: rgba(34,24,34,.54);
  cursor: pointer;
  transition: transform .28s ease, background .28s ease, color .28s ease;
}

.phase-strip button.active, .phase-strip button:hover {
  background: var(--cream);
  color: var(--clay);
  transform: translateY(-3px);
}

.grid-field {
  --cell: minmax(132px, 1fr);
  display: grid;
  grid-template-columns: repeat(5, var(--cell));
  grid-auto-rows: 156px;
  gap: clamp(14px, 2.2vw, 28px);
  max-width: 1220px;
  min-height: 650px;
  perspective: 1200px;
}

.lesson-card {
  --heat: .05;
  --distance: 1;
  --tilt: 0deg;
  position: relative;
  min-height: 140px;
  transform: translate3d(var(--move-x, 0), var(--move-y, 0), 0) rotate(calc(var(--r) + var(--tilt))) scale(calc(.96 + var(--heat) * .05));
  transform-style: preserve-3d;
  transition: transform .42s cubic-bezier(.2,.8,.2,1), filter .42s ease;
  filter: saturate(calc(.75 + var(--heat) * .55));
}

.lesson-card::before, .lesson-card::after {
  content: "";
  position: absolute;
  inset: 10px -8px -10px 14px;
  border-radius: 22px;
  background: var(--blush);
  opacity: calc(.12 + var(--heat) * .58);
  transform: translate3d(calc(14px * var(--heat)), calc(18px * var(--heat)), -18px) rotate(2deg);
  transition: opacity .35s ease, transform .35s ease;
}

.lesson-card::after {
  inset: -8px 8px 12px -8px;
  background: transparent;
  border: 1px solid rgba(216,137,58,.58);
  opacity: .55;
  transform: translateZ(-4px);
}

.shell {
  position: relative;
  height: 100%;
  min-height: inherit;
  padding: 18px;
  overflow: hidden;
  border-radius: 24px 7px 24px 7px;
  background: linear-gradient(145deg, rgba(185,85,50, calc(.78 - var(--heat) * .24)), rgba(58,33,27,.93) 58%), linear-gradient(90deg, transparent 0 68%, rgba(255,244,230, calc(var(--heat) * .72)) 69%);
  border: 1px solid rgba(255,244,230,.13);
  box-shadow: 0 22px 50px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,244,230,calc(.05 + var(--heat) * .16));
  clip-path: polygon(0 0, calc(100% - 22px) 0, 100% 22px, 100% 100%, 22px 100%, 0 calc(100% - 22px));
}

.shell::before {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid rgba(216,137,58,.28);
  border-radius: 18px 5px 18px 5px;
  pointer-events: none;
}

.coord {
  display: inline-block;
  color: var(--copper);
  font-size: 11px;
  margin-bottom: 12px;
}

h2 {
  margin: 0 0 9px;
  font-family: "M PLUS Rounded 1c", Inter, sans-serif;
  font-size: clamp(19px, 2.1vw, 31px);
  line-height: 1.02;
  color: var(--cream);
}

.lesson-card p {
  margin: 0;
  max-width: 31em;
  color: rgba(255,244,230, calc(.58 + var(--heat) * .3));
  line-height: 1.45;
  font-size: 14px;
}

.icon {
  position: absolute;
  right: 14px;
  bottom: 12px;
  width: 78px;
  height: 78px;
  fill: none;
  stroke: var(--copper);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: calc(.46 + var(--heat) * .48);
  transform: rotate(calc(var(--tilt) * -1)) scale(calc(.86 + var(--heat) * .18));
  transition: transform .38s ease, stroke .38s ease;
}

.teal .icon, .teal .coord { stroke: var(--teal); color: var(--teal); }

.note {
  position: absolute;
  left: 24px;
  right: 18px;
  bottom: 7px;
  z-index: -1;
  padding: 12px 14px;
  border-radius: 0 0 18px 18px;
  color: var(--clay);
  background: var(--cream);
  font-family: "M PLUS Rounded 1c", Inter, sans-serif;
  font-size: 13px;
  transform: translateY(calc(32px - var(--heat) * 46px));
  opacity: calc(.08 + var(--heat) * .92);
  box-shadow: 0 12px 30px rgba(255,139,154,.22);
}

.lesson-card.hot .shell {
  background: linear-gradient(145deg, var(--cream), #ffe5d9 58%, rgba(255,139,154,.58));
}

.lesson-card.hot h2, .lesson-card.hot p { color: var(--clay); }
.lesson-card.hot .icon { stroke: var(--blush); }

.lesson-card:nth-child(1) { grid-column: 1 / span 2; grid-row: 1 / span 2; }
.lesson-card:nth-child(2) { grid-column: 3 / span 1; grid-row: 1 / span 1; }
.lesson-card:nth-child(3) { grid-column: 5 / span 1; grid-row: 1 / span 1; }
.lesson-card:nth-child(4) { grid-column: 2 / span 2; grid-row: 3 / span 1; }
.lesson-card:nth-child(5) { grid-column: 5 / span 1; grid-row: 2 / span 2; }
.lesson-card:nth-child(6) { grid-column: 1 / span 2; grid-row: 4 / span 1; }
.lesson-card:nth-child(7) { grid-column: 3 / span 1; grid-row: 4 / span 1; }
.lesson-card:nth-child(8) { grid-column: 4 / span 2; grid-row: 4 / span 1; }

.landing-line {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  margin-top: 30px;
  padding: 18px 22px;
  color: rgba(255,244,230,.72);
  border-top: 1px solid rgba(216,137,58,.34);
}

.landing-line strong {
  font-family: "Nunito Sans", Inter, sans-serif;
  font-size: clamp(28px, 5vw, 70px);
  color: var(--cream);
  letter-spacing: -.05em;
}

.landing-line strong span { color: var(--blush); }
.landing-line em { font-style: normal; text-align: right; font-size: 12px; color: var(--copper); }

.lesson-deck.settled .lesson-card {
  --heat: .92 !important;
  --move-x: 0px !important;
  --move-y: 0px !important;
  --tilt: 0deg !important;
}

.lesson-deck.settled .wordmark { animation: pulseWord 1.6s ease both; }

@keyframes pulseWord { 50% { text-shadow: 0 0 34px rgba(255,139,154,.45); } }

@media (max-width: 860px) {
  .grid-field { grid-template-columns: 1fr; grid-auto-rows: auto; min-height: 0; }
  .lesson-card, .thermal-core, .narrow, .strip, .landing-card { grid-column: 1 / -1; grid-row: auto; min-height: 210px; }
  .landing-line { grid-template-columns: 1fr; }
  .landing-line em { text-align: left; }
}
