/* Reset, typography, layout shell, header and footer. Colors come from tokens.css only. */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img { max-width: 100%; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
figure { margin: 0; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }

.page { position: relative; overflow-x: clip; min-height: 100vh; display: flex; flex-direction: column; }
.page > main { flex: 1; }
/* Paper grain overlay; the SVG only defines a grey noise mask, opacity is themed. */
.page::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: var(--noise-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .5 0 0 0 .18 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wrap { position: relative; z-index: 1; max-width: 1180px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 760px) { .wrap { padding-inline: 32px; } }

.display { font-family: "Fredoka", "Nunito", system-ui, sans-serif; font-weight: 700; line-height: 1.05; letter-spacing: -.01em; text-wrap: balance; }
.hand { font-family: "Caveat", "Segoe Script", "Bradley Hand", cursive; font-weight: 700; line-height: 1.15; }
h2.display { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); }
.lead { font-size: 1.0625rem; max-width: 34em; }
.muted { color: var(--text-muted); }

/* ---------- rainbow wordmark ---------- */
.mark { display: inline-flex; align-items: baseline; text-decoration: none; }
.mark .display { font-size: 1.75rem; line-height: 1; }
.rb span { display: inline-block; }
.rb span:nth-child(7n+1) { color: var(--accent-red); }
.rb span:nth-child(7n+2) { color: var(--accent-orange); }
.rb span:nth-child(7n+3) { color: var(--accent-yellow); }
.rb span:nth-child(7n+4) { color: var(--accent-green); }
.rb span:nth-child(7n+5) { color: var(--accent-blue); }
.rb span:nth-child(7n+6) { color: var(--accent-purple); }
.rb span:nth-child(7n) { color: var(--accent-pink); }
.rb-sticker span {
  paint-order: stroke fill;
  -webkit-text-stroke: .16em var(--chip-edge);
  filter: drop-shadow(0 3px 4px var(--shadow-soft));
}
.mark .tag { font-size: .8rem; color: var(--text-muted); margin-left: .5em; font-weight: 600; white-space: nowrap; }

/* ---------- header ---------- */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  background: var(--header-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top .wrap {
  display: grid; align-items: center; gap: 4px 10px;
  grid-template-columns: auto 1fr; grid-template-areas: "mark tools" "nav nav";
  padding-block: 8px;
}
.top .mark { grid-area: mark; white-space: nowrap; }
/* single-row header gets tight before 1000px: drop the tagline there */
@media (min-width: 760px) and (max-width: 999px) { .top .mark .tag { display: none; } }
.tools { grid-area: tools; display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.nav { grid-area: nav; }
@media (min-width: 760px) {
  .top .wrap { grid-template-columns: auto 1fr auto; grid-template-areas: "mark nav tools"; min-height: 68px; }
  .nav .stickers { justify-content: center; }
}
.nav .stickers { flex-wrap: nowrap; overflow-x: auto; padding: 6px 2px; scrollbar-width: none; }
.nav .stk { text-decoration: none; white-space: nowrap; min-height: 40px; }
.nav .stk[aria-current="page"] { box-shadow: 0 0 0 3px var(--text), 0 3px 8px var(--shadow-soft); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: var(--text); text-decoration: none; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--line); }
/* light switch: a cord with a fuse-bead knob hangs from the header's right edge */
.lamp-cord {
  position: absolute; top: 100%; right: 16px; z-index: 31;
  display: flex; flex-direction: column; align-items: center;
  width: 44px; height: 58px; padding: 0; border: 0; background: none; cursor: pointer;
  transform-origin: top center; animation: sway 4s ease-in-out infinite;
}
.lamp-cord .cord { flex: 1; width: 2px; background: var(--cord-line); }
.lamp-cord .knob {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle, var(--bg) 0 4px, var(--cord-knob) 4.5px);
  box-shadow: inset 0 -3px 3px var(--bead-shade), 0 3px 6px var(--shadow-soft);
}
.lamp-cord:hover .knob { transform: scale(1.1); }
.lamp-cord.pulled { animation: pull .5s cubic-bezier(.3,1.6,.5,1); }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes pull { 0% { transform: translateY(0); } 35% { transform: translateY(16px); } 100% { transform: translateY(0); } }
@media (min-width: 760px) { .lamp-cord { right: 32px; height: 66px; } }

/* language picker: a washi-tape label that opens a small sticker menu */
.langs { position: relative; }
.langs summary { list-style: none; }
.langs summary::-webkit-details-marker { display: none; }
/* chevron makes the picker read as a dropdown; flips while open */
.langs summary.lang { gap: 6px; }
.langs summary.lang::after {
  content: ""; width: 6px; height: 6px; margin-top: -3px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); transition: transform .2s;
}
.langs[open] summary.lang::after { margin-top: 3px; transform: rotate(-135deg); }
.lang {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 40px; padding: 0 10px;
  border-radius: 4px 4px 2px 2px; cursor: pointer; text-decoration: none;
  font: 700 .9rem/1 "Fredoka", "Nunito", sans-serif; letter-spacing: .04em;
  color: var(--chip-text);
  background-color: var(--note-yellow);
  background-image: repeating-linear-gradient(-45deg, var(--tape-stripe) 0 6px, transparent 6px 12px);
  transform: rotate(-1.5deg);
}
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  display: grid; gap: 8px; padding: 12px; margin: 0; list-style: none;
  background: var(--surface); box-shadow: 0 14px 34px var(--shadow);
}
.lang-menu .lang { width: 100%; justify-content: flex-start; transform: none; white-space: nowrap; }
.lang-menu li:nth-child(2) .lang { background-color: var(--note-blue); }
.lang-menu li:nth-child(3) .lang { background-color: var(--note-pink); }
.lang-menu li:nth-child(4) .lang { background-color: var(--note-green); }
.lang-menu .lang[aria-current="true"] { box-shadow: 0 0 0 2px var(--chip-text); }

/* ---------- sections & footer ---------- */
section { padding-block: 28px; }
.sec-head { max-width: 40em; display: grid; gap: 12px; margin-bottom: 26px; }
.split { display: grid; gap: 34px; align-items: center; }
@media (min-width: 880px) {
  section { padding-block: 44px; }
  .split { grid-template-columns: 1fr 1fr; gap: 56px; }
  .split .first { order: -1; }
}
.page-head { padding-block: 40px 8px; }
.page-head h1 { font-size: clamp(2.3rem, 1.5rem + 3.5vw, 3.8rem); }
.page-head .lead { margin-top: 14px; }

footer.end { position: relative; z-index: 1; padding-block: 26px 40px; border-top: 1px solid var(--line); }
footer.end .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px 24px; color: var(--text-muted); font-size: .95rem; }
footer.end ul { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 0; list-style: none; }
footer.end a { text-underline-offset: 3px; }

@media (max-width: 479px) {
  .mark .display { font-size: 1.55rem; }
  .mark .tag { display: none; }
  .icon-btn { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
