:root {
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

[data-theme="garage"] {
  --paper: #f2eee8;
  --ink: #252323;
  --blue: #8d3518;
  --muted: #62554c;
  --rule: #cec0b5;
  --wash: #e7ded5;
  --scene-bg: #20232a;
  --scene-ink: #fff6eb;
  --scene-accent: #ffb481;
}

[data-theme="shop"] {
  --paper: #edf1f5;
  --ink: #1b2835;
  --blue: #225687;
  --muted: #4c6072;
  --rule: #bbc9d5;
  --wash: #e1e9f0;
  --scene-bg: #18293b;
  --scene-ink: #f4f8fb;
  --scene-accent: #f8d482;
}

[data-theme="camp"] {
  --paper: #ebf1e9;
  --ink: #1a2c24;
  --blue: #265a45;
  --muted: #486052;
  --rule: #b7c9bc;
  --wash: #dce7dd;
  --scene-bg: #102b2a;
  --scene-ink: #f4faf0;
  --scene-accent: #f8c38c;
}

[data-theme="tag"] {
  --paper: #f1edf7;
  --ink: #2a2036;
  --blue: #614588;
  --muted: #61536f;
  --rule: #c9bcd9;
  --wash: #e8dff3;
  --scene-accent: var(--blue);
}

.hero {
  padding-block: clamp(24px, 4vw, 58px) clamp(28px, 4vw, 58px);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
}

.hero-composition {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  align-items: end;
  gap: clamp(20px, 6vw, 90px);
  padding-block: clamp(14px, 3.2vw, 45px) clamp(20px, 3vw, 44px);
}

.hero h1 {
  font-size: clamp(2.6rem, 7.2vw, 7rem);
  font-weight: 630;
  line-height: .94;
  letter-spacing: -.066em;
}

.hero h1 span { display: block; }
.hero-composition p {
  max-width: 33ch;
  padding-bottom: .2em;
  color: var(--muted);
  font-size: clamp(.95rem, 1.5vw, 1.24rem);
  line-height: 1.55;
}

.chapter-links {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.2vw, 18px);
}

.chapter-links a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(.55rem, 1vw, 1rem);
  min-height: 58px;
  padding: clamp(9px, 1.35vw, 20px);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 16px;
  transition: background-color .18s, transform .2s ease-out;
}

.chapter-links a:hover {
  background: var(--wash);
  color: var(--ink);
  text-decoration: none;
}

.chapter-links a:active { transform: scale(.985); transition-duration: 80ms; }
.chapter-links strong, .chapter-links small { display: block; }
.chapter-links strong { font-size: clamp(.82rem, 1.25vw, 1.04rem); line-height: 1.2; }
.chapter-links small { margin-top: .25em; font-size: .75rem; color: var(--muted); }
.chapter-icon { font: clamp(1.35rem, 2.8vw, 2.3rem)/1 var(--emoji); }
.chapter-arrow { color: var(--blue); }

.assignment {
  padding-block: clamp(20px, 3.6vw, 52px) clamp(40px, 6.4vw, 92px);
  background: var(--paper);
  color: var(--ink);
  scroll-margin-top: 0;
}

.concept-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1.25rem 2rem;
  padding: clamp(20px, 4vw, 64px);
  border: 1px solid var(--rule);
  border-radius: clamp(18px, 3vw, 34px);
}
.concept-panel h2 {
  margin-block: .18em .24em;
  font-size: clamp(2.6rem, 6vw, 5rem);
}
.concept-link {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  min-height: 44px;
  padding: .55rem .85rem;
  border: 1px solid currentColor;
  border-radius: 10px;
  color: var(--blue);
}
.concept-link:hover { background: var(--wash); }

.scene-cover {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 44fr) minmax(0, 56fr);
  align-items: stretch;
  isolation: isolate;
  overflow: clip;
  min-height: clamp(265px, 31vw, 440px);
  background: var(--scene-bg);
  color: var(--scene-ink);
  border-radius: clamp(18px, 3vw, 34px);
}

.scene-copy {
  position: relative;
  z-index: 1;
  align-self: center;
  padding: clamp(20px, 4vw, 64px);
  padding-right: 0;
}

.scene-setting { color: var(--scene-accent); font-size: .78rem; font-weight: 620; }
.scene-setting span { margin-inline: .3em; }
.scene-cover h2 {
  margin-block: .23em .29em;
  font-size: clamp(2.1rem, 5.15vw, 5.25rem);
  font-weight: 630;
  letter-spacing: -.061em;
  line-height: .97;
  text-wrap: balance;
}
.scene-topic { max-width: 35ch; font-size: clamp(.78rem, 1.2vw, 1.04rem); line-height: 1.45; }

.scene-art {
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  min-width: 0;
}
.scene-art > span, .scene-art::before, .scene-art::after { position: absolute; }
.scene-art::before, .scene-art::after { content: ""; }
.scene-prop {
  z-index: 3;
  display: block;
  font: var(--size)/1 var(--emoji);
  transform-origin: 50% 85%;
  filter: drop-shadow(0 12px 11px #0005);
}

/* Home garage: sectional door, perforated tool wall, steel bench and concrete. */
[data-theme="garage"] .scene-art::before {
  inset: 5% -5% 0 1%;
  background: linear-gradient(115deg, #20232a, #35353a 60%, #563e36);
  clip-path: polygon(0 22%, 74% 0, 100% 13%, 100% 100%, 0 100%);
}
[data-theme="garage"] .scene-art::after {
  inset: 71% -2% 0 -9%;
  z-index: 1;
  background: repeating-linear-gradient(168deg, #ffffff13 0 1px, transparent 1px 27px), linear-gradient(100deg, #313037, #624538);
  clip-path: polygon(9% 30%, 100% 0, 100% 100%, 0 100%);
}
.garage-door {
  inset: 14% 35% 25% 11%;
  border: 7px solid #44444a;
  background: repeating-linear-gradient(#646366 0 2px, #48484d 2px 15%, #38393e 15% 16%);
  transform: skewY(-8deg);
  box-shadow: inset 0 0 40px #14182099;
}
.garage-pegboard {
  inset: 10% -2% 34% 67%;
  background: radial-gradient(circle, #231f21 0 1.3px, transparent 1.8px) 0 0 / 11px 11px, #684437;
  border: 6px solid #49332d;
  transform: skewY(8deg);
}
.garage-bench {
  inset: 60% 4% 16% 66%;
  z-index: 2;
  background: repeating-linear-gradient(#51342e 0 3px, #864f37 3px 30%);
  border-top: 8px solid #ba774f;
  transform: skewY(8deg);
}
.prop-tire { --size: clamp(3.25rem, 15cqw, 5.5rem); left: 34%; bottom: 12%; --move-x: -8px; --turn: -13deg; }
.prop-wrench { --size: clamp(2rem, 10cqw, 4rem); right: 14%; top: 28%; --move-y: -7px; --turn: 10deg; }

/* Fade the parts aisle into the solid chapter title surface. */
.shop-interior {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 56%;
  mask-image: linear-gradient(90deg, transparent, #000 27%);
}
.prop-cart { --size: clamp(2.5rem, 12cqw, 4.5rem); left: 24%; bottom: 9%; --move-x: 13px; --turn: 4deg; }
.prop-toolbox { --size: clamp(1.75rem, 8cqw, 3.25rem); right: 12%; bottom: 13%; --move-y: -9px; --turn: -5deg; }

/* Forest clearing: offset ridgelines and paired facets give each pine a lit side. */
[data-theme="camp"] .scene-art::before {
  inset: 0;
  background: radial-gradient(ellipse at 72% 36%, #2c5c57, transparent 70%);
}
.camp-moon {
  top: 10%;
  right: 20%;
  width: 13%;
  aspect-ratio: 1;
  background: #c3dcaf;
  clip-path: polygon(50% 0, 80% 9%, 100% 40%, 95% 72%, 71% 95%, 36% 100%, 8% 75%, 0 39%, 20% 10%);
}
.camp-ridge {
  inset: 17% 0 16% 0;
  background: linear-gradient(110deg, #102b2a, #30564f);
  clip-path: polygon(0 62%, 16% 37%, 26% 50%, 43% 16%, 54% 44%, 70% 26%, 85% 58%, 100% 29%, 100% 100%, 0 100%);
}
.camp-ground {
  inset: 69% 0 0 -5%;
  z-index: 1;
  background: conic-gradient(from 78deg at 60% 42%, #263e35, #315144, #192f2b, #284c3b, #244036, #263e35);
  clip-path: polygon(0 41%, 12% 25%, 35% 12%, 65% 0, 80% 14%, 100% 5%, 100% 100%, 0 100%);
}
.camp-pine {
  z-index: 2;
  left: var(--x);
  bottom: 16%;
  width: var(--width);
  height: var(--height);
  background: linear-gradient(90deg, #47785b 50%, #244b3f 50%);
  clip-path: polygon(50% 0, 76% 32%, 65% 31%, 87% 58%, 76% 56%, 100% 90%, 56% 87%, 56% 100%, 44% 100%, 44% 87%, 0 90%, 24% 56%, 13% 58%, 35% 31%, 24% 32%);
}
.camp-pine:nth-of-type(even) {
  bottom: 19%;
  background: linear-gradient(90deg, #396552 50%, #1c4138 50%);
}
.camp-glow {
  z-index: 2;
  inset: 51% 8% -2% 38%;
  background: radial-gradient(ellipse, #f5a55b86, #d47e3135 45%, transparent 72%);
}
.camp-glow::after {
  content: "";
  position: absolute;
  inset: auto 47% 11% 40%;
  height: 11%;
  background: linear-gradient(172deg, #a36d45 50%, #553e2d 51%);
  clip-path: polygon(0 24%, 83% 0, 100% 46%, 95% 84%, 13% 100%);
}
.prop-tent { --size: clamp(2.75rem, 15cqw, 5.5rem); left: 31%; bottom: 12%; --move-y: -6px; --turn: -3deg; }
.prop-tree { --size: clamp(1.65rem, 8cqw, 3.25rem); right: 10%; bottom: 13%; --turn: 5deg; }
.prop-fire { --size: clamp(2rem, 10cqw, 4.25rem); left: 59%; bottom: 7%; --move-y: -5px; --turn: -5deg; }

.scene-cover.is-in-view .scene-prop {
  animation: scene-settle 1.5s cubic-bezier(.38, 0, .26, 1) both;
}
.scene-cover.is-in-view .scene-prop:last-child { animation-delay: 160ms; }
.scene-cover.is-in-view .prop-fire { animation: fire-flicker .72s ease-in-out 3 both; }

@keyframes scene-settle {
  0%, 100% { transform: none; }
  48% { transform: translate(var(--move-x, 0px), var(--move-y, 0px)) rotate(var(--turn)); }
}
@keyframes fire-flicker {
  0%, 100% { transform: none; }
  45% { transform: translateY(-4px) rotate(-4deg) scale(.95, 1.08); }
  70% { transform: rotate(3deg) scale(1.04, .96); }
}

.closing {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(18px, 5vw, 74px);
  align-items: start;
  padding-block: clamp(34px, 6vw, 92px);
}

@media (max-width: 760px) {
  .hero-composition, .closing { grid-template-columns: 1fr; gap: 14px; }
  .hero h1 span { display: inline; }
  .hero-composition p { max-width: 46ch; }
  .chapter-links { grid-template-columns: 1fr; }
  .chapter-links a { min-height: 48px; padding: 7px 12px; border-radius: 12px; }
  .chapter-links small { margin-top: .08em; }
  .scene-cover { grid-template-columns: 1fr; min-height: 0; }
  .scene-copy { padding: 22px 20px 0; }
  .scene-cover h2 { text-wrap: wrap; }
  .scene-art { min-height: clamp(145px, 47vw, 285px); }
  .shop-interior { mask-image: linear-gradient(180deg, transparent, #000 27%); }
  .assignment { scroll-margin-top: calc(-1 * min(45svh, 370px) + 12px); }
}

@media (prefers-reduced-motion: reduce), (forced-colors: active) {
  .chapter-links a:active { transform: none; }
}

@media (forced-colors: active) {
  [data-theme] {
    --paper: Canvas;
    --ink: CanvasText;
    --blue: LinkText;
    --muted: CanvasText;
    --rule: GrayText;
    --wash: Canvas;
    --scene-bg: Canvas;
    --scene-ink: CanvasText;
    --scene-accent: CanvasText;
  }
  .scene-cover { border: 1px solid GrayText; }
  .scene-prop { filter: none; animation: none !important; }
}
