/* Playful Geometric tokens, base, header, footer and shared components.
   Spec lives in CLAUDE.md. Never hardcode a colour a token covers. */

:root {
  /* Palette, straight from the design system */
  --background: #FFFDF5;
  --foreground: #1E293B;
  --muted: #F1F5F9;
  --muted-fg: #64748B;
  --accent: #8B5CF6;
  --accent-fg: #FFFFFF;
  --secondary: #F472B6;
  --tertiary: #FBBF24;
  --quaternary: #34D399;
  --border: #E2E8F0;
  --input-border: #CBD5E1;
  --input: #FFFFFF;
  --card: #FFFFFF;
  --ring: #8B5CF6;

  /* Answer colours. Violet never means an answer. */
  --yes: var(--quaternary);
  --no: var(--secondary);
  --maybe: var(--tertiary);

  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Major third scale */
  --fs-sm: 0.8rem;
  --fs-base: 1rem;
  --fs-md: 1.25rem;
  --fs-lg: 1.563rem;
  --fs-xl: 1.953rem;
  --fs-2xl: 2.441rem;
  --fs-3xl: 3.052rem;
  --fs-4xl: 3.815rem;

  --r-sm: 8px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 12px;
  --r-full: 9999px;
  --r-bubble: 24px 24px 24px 0;
  --bw: 2px;

  --pop: 4px 4px 0 0 var(--foreground);
  --pop-hover: 6px 6px 0 0 var(--foreground);
  --pop-active: 2px 2px 0 0 var(--foreground);
  --sticker: 8px 8px 0 0 var(--border);
  --sticker-featured: 8px 8px 0 0 var(--secondary);

  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-bounce: 300ms var(--bounce);

  --maxw: 1152px;
  --gutter: clamp(16px, 4vw, 32px);

  color-scheme: light;
}

@media (max-width: 899px) {
  :root {
    --pop: 2px 2px 0 0 var(--foreground);
    --pop-hover: 3px 3px 0 0 var(--foreground);
    --sticker: 4px 4px 0 0 var(--border);
    --sticker-featured: 4px 4px 0 0 var(--secondary);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 88px; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  overflow-x: hidden;
  overflow-wrap: break-word;
}

img, svg { max-width: 100%; }

a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 4px; }
a:hover { color: var(--accent); }

:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; border-radius: var(--r-sm); }

.skip-link {
  position: absolute; left: 12px; top: -80px; z-index: 50;
  padding: 10px 18px; border: var(--bw) solid var(--foreground); border-radius: var(--r-full);
  background: var(--tertiary); color: var(--foreground); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Icons: enclosed in shapes, never floating alone ---------- */

.icon {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}
.icon-dot {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: var(--r-full);
  border: var(--bw) solid var(--foreground);
  color: var(--foreground);
}
.icon-dot .icon { width: 20px; height: 20px; }
.bg-yes, .bg-quaternary { background: var(--quaternary); }
.bg-no, .bg-secondary { background: var(--secondary); }
.bg-maybe, .bg-tertiary { background: var(--tertiary); }
.bg-accent { background: var(--accent); color: var(--accent-fg); }

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(3deg); }
  75% { transform: rotate(-3deg); }
}
.wiggle:hover .icon-dot, .icon-dot.wiggle:hover { animation: wiggle 400ms ease-in-out; }

/* Highlight a word with a colour shape behind dark text */
.hl { position: relative; display: inline-block; padding: 0 0.14em; z-index: 0; white-space: nowrap; }
.hl::before {
  content: ""; position: absolute; z-index: -1; inset: 0.08em -0.04em -0.02em;
  border: var(--bw) solid var(--foreground); border-radius: var(--r-sm);
  transform: rotate(-2deg);
}
.hl-yes::before { background: var(--yes); }
.hl-no::before { background: var(--no); transform: rotate(2deg); }
.hl-maybe::before { background: var(--maybe); }

/* ---------- Header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--background);
  border-bottom: var(--bw) solid var(--foreground);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 68px;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 800; font-size: var(--fs-md);
  letter-spacing: -0.01em; text-decoration: none; white-space: nowrap;
}
.brand:hover { color: var(--foreground); }
.brand svg { width: 36px; height: 36px; flex: none; transition: transform var(--t-bounce); }
.brand:hover svg { transform: rotate(-12deg) scale(1.08); }
.mark-yes { fill: var(--yes); }
.mark-no { fill: var(--no); }
.mark-line { stroke: var(--foreground); stroke-width: 2; stroke-linejoin: round; }

.site-nav ul { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 8px 16px;
  border: var(--bw) solid transparent; border-radius: var(--r-full);
  font-weight: 600; font-size: 0.95rem; text-decoration: none;
  transition: background var(--t-bounce), border-color var(--t-bounce);
}
.site-nav a:hover { background: var(--tertiary); border-color: var(--foreground); color: var(--foreground); }

@media (max-width: 680px) { .site-nav { display: none; } }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 48px; padding: 10px 24px;
  border: var(--bw) solid var(--foreground); border-radius: var(--r-full);
  font: 700 1rem/1 var(--font-body); text-decoration: none;
  cursor: pointer;
  transition: transform var(--t-bounce), box-shadow var(--t-bounce), background var(--t-bounce);
}

/* The Candy Button */
.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--pop); }
.btn-primary:hover { color: var(--accent-fg); transform: translate(-2px, -2px); box-shadow: var(--pop-hover); }
.btn-primary:active { transform: translate(2px, 2px); box-shadow: var(--pop-active); }
.btn-primary .btn-icon {
  display: inline-grid; place-items: center; width: 34px; height: 34px; margin-right: -12px;
  border-radius: var(--r-full); background: var(--accent-fg); color: var(--accent);
}
.btn-primary .btn-icon .icon { width: 18px; height: 18px; }
.btn[disabled] { cursor: progress; }
.btn-primary[disabled] { transform: none; box-shadow: var(--pop-active); }
.btn[disabled] .btn-icon .icon { animation: spin-icon 700ms linear infinite; }
@keyframes spin-icon { to { transform: rotate(360deg); } }

/* Secondary */
.btn-secondary { background: transparent; color: var(--foreground); }
.btn-secondary:hover { background: var(--tertiary); color: var(--foreground); }

/* ---------- Sticker card ---------- */

.sticker {
  position: relative;
  background: var(--card);
  border: var(--bw) solid var(--foreground);
  border-radius: var(--r-xl);
  box-shadow: var(--sticker);
}
.sticker-featured { box-shadow: var(--sticker-featured); }
.sticker-hover { transition: transform var(--t-bounce); }
.sticker-hover:hover { transform: rotate(-1deg) scale(1.02); }
.sticker > .icon-dot.float {
  position: absolute; top: -21px; left: 24px;
}

/* ---------- Pop-in entrance ---------- */

.js .pop-in { transform: scale(0.85); opacity: 0; }
.js .pop-in.is-in { transform: none; opacity: 1; transition: transform 500ms var(--bounce), opacity 200ms ease; }

/* ---------- Footer ---------- */

.site-footer {
  position: relative;
  margin-top: 96px;
  background: var(--foreground);
  color: var(--muted);
  padding: 56px 0 64px;
  font-size: 0.95rem;
}
.site-footer .wrap { display: grid; gap: 14px; }
.site-footer .brand { color: var(--background); }
.site-footer p { margin: 0; max-width: 62ch; color: var(--border); }
.footer-squiggle { position: absolute; left: 0; right: 0; top: -14px; width: 100%; height: 16px; }
.footer-squiggle path { fill: none; stroke: var(--foreground); stroke-width: 3; stroke-linecap: round; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .pop-in { transform: none; opacity: 1; }
}

/* ---------- Header sticker book button ---------- */

.header-right { display: flex; align-items: center; gap: 10px; }
.book-btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 4px 14px 4px 4px;
  background: var(--card); color: var(--foreground);
  border: var(--bw) solid var(--foreground); border-radius: var(--r-full);
  box-shadow: var(--pop-active);
  font: 700 0.92rem/1 var(--font-body); cursor: pointer;
  transition: transform var(--t-bounce), box-shadow var(--t-bounce);
}
.book-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--pop); }
.book-btn .icon-dot { width: 34px; height: 34px; }
.book-btn .icon-dot .icon { width: 17px; height: 17px; }
.book-count { font-variant-numeric: tabular-nums; color: var(--muted-fg); }
.book-btn.is-pulsing .icon-dot { animation: wiggle 500ms ease-in-out 2; }
@media (max-width: 420px) { .book-label { display: none; } }

/* ---------- Sticker book dialog ---------- */

.sticker-book {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 0; background: transparent; overflow: visible;
}
.sticker-book::backdrop { background: rgba(30, 41, 59, 0.55); }
.sticker-book[open] .book-inner { animation: book-in 420ms var(--bounce); }
@keyframes book-in { from { transform: scale(0.85) rotate(-2deg); opacity: 0; } to { transform: none; opacity: 1; } }
.book-inner { max-height: calc(100vh - 48px); overflow-y: auto; padding: 26px; box-shadow: var(--sticker-featured); }
.book-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.book-head h2 { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: var(--fs-xl); line-height: 1.1; }
.book-sum { margin: 6px 0 0; font-weight: 600; color: var(--muted-fg); }
.book-close {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0;
  background: var(--card); color: var(--foreground);
  border: var(--bw) solid var(--foreground); border-radius: var(--r-full); cursor: pointer;
  transition: transform var(--t-bounce), background var(--t-bounce);
}
.book-close:hover { background: var(--secondary); transform: rotate(90deg); }
.book-note { margin: 18px 0 0; font-size: 0.85rem; color: var(--muted-fg); }

.stk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.stk {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px;
  padding: 16px 10px 14px; border: var(--bw) dashed var(--input-border); border-radius: var(--r-md);
}
.stk.is-got { border: var(--bw) solid var(--foreground); background: var(--background); }
.stk.is-got:hover .stk-shape { animation: wiggle 400ms ease-in-out; }
.stk-name { margin-top: 8px; font-family: var(--font-display); font-weight: 700; font-size: 1rem; line-height: 1.2; }
.stk-desc { font-size: 0.8rem; line-height: 1.35; color: var(--muted-fg); }
.stk-date { margin-top: 2px; font-size: 0.72rem; font-weight: 700; color: var(--foreground); }
.stk:not(.is-got) .stk-name { color: var(--muted-fg); }

.stk-shape {
  display: grid; place-items: center; width: 64px; height: 64px;
  border: var(--bw) solid var(--foreground); color: var(--foreground);
  box-shadow: 3px 3px 0 0 var(--foreground);
}
.stk-shape .icon { width: 28px; height: 28px; }
.stk-circle { border-radius: var(--r-full); }
.stk-square { border-radius: 14px; transform: rotate(-6deg); }
.stk-bubble { border-radius: 22px 22px 22px 0; }
.stk-blob { border-radius: 48% 52% 38% 62% / 55% 40% 60% 45%; transform: rotate(5deg); }
.stk-shape.is-locked { background: var(--muted); color: var(--muted-fg); border-color: var(--input-border); box-shadow: none; }

/* ---------- Toasts ---------- */

.sticker-toast, .toast {
  position: fixed; left: 50%; z-index: 70;
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  transition: transform 420ms var(--bounce), opacity 200ms ease;
}
.sticker-toast.is-shown, .toast.is-shown { transform: translate(-50%, 0); opacity: 1; }
/* Only the sticker toast has a button, so only it may take clicks. */
.sticker-toast.is-shown { pointer-events: auto; }

.sticker-toast {
  bottom: 20px; display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 10px; width: max-content; max-width: calc(100vw - 32px);
  background: var(--card); border: var(--bw) solid var(--foreground); border-radius: var(--r-full);
  box-shadow: var(--pop);
}
.sticker-toast .stk-shape { width: 48px; height: 48px; box-shadow: none; }
.sticker-toast .stk-shape .icon { width: 22px; height: 22px; }
.toast-text { display: flex; flex-direction: column; line-height: 1.2; }
.toast-kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.toast-text strong { font-family: var(--font-display); font-size: 1.1rem; }
.toast-open {
  min-height: 40px; padding: 6px 14px; margin-left: 6px;
  background: var(--tertiary); color: var(--foreground);
  border: var(--bw) solid var(--foreground); border-radius: var(--r-full);
  font: 700 0.85rem/1 var(--font-body); cursor: pointer;
}

.toast {
  bottom: 92px; padding: 10px 18px; max-width: calc(100vw - 32px);
  background: var(--foreground); color: var(--background);
  border-radius: var(--r-full); font-weight: 600; font-size: 0.95rem; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .sticker-toast, .toast { transform: translate(-50%, 0); }
}
