/* Free Colouring Pages: bright, chunky, paper-and-crayon. Light only (it's paper). */
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("/fonts/fredoka-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #2d2a4a;
  --ink-soft: #5d5a7a;
  --paper: #fff6e5;
  --card: #ffffff;
  --yellow: #ffd166;
  --orange: #ff7a45;
  --pink: #ff4d6d;
  --green: #3dbf6b;
  --blue: #5b6cff;
  --purple: #b45fd6;
  --radius: 22px;
  --shadow: 0 5px 0 rgba(45, 42, 74, .16);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 500;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(45, 42, 74, .07) 1.5px, transparent 1.5px);
  background-size: 22px 22px;
  line-height: 1.45;
}
a { color: var(--blue); }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; }

/* ---------- header ---------- */
.top { display: flex; flex-direction: column; align-items: center; padding: 18px 16px 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.mascot { width: 72px; flex: none; display: block; }
.mascot svg { width: 100%; height: auto; display: block; overflow: visible; }
.mascot .m-arm { transform-origin: 86px 78px; animation: wave 2.4s ease-in-out infinite; }
.mascot.bounce { animation: bounce .6s ease; }
.brand-text { font-weight: 700; font-size: clamp(28px, 7vw, 54px); line-height: 1; letter-spacing: .5px; text-shadow: 0 3px 0 rgba(45, 42, 74, .15); }
.brand-text .w1 { color: var(--pink); }
.brand-text .w2 { color: var(--blue); }
.brand-text .w3 { color: var(--green); }
.free-ribbon {
  display: inline-block; margin: 12px 0 0; padding: 8px 18px; border-radius: 999px;
  background: var(--yellow); font-weight: 600; font-size: clamp(16px, 4vw, 20px); box-shadow: var(--shadow);
  transform: rotate(-1.5deg);
}
.top-small { padding-top: 12px; }
.top-small .mascot { width: 48px; }
.top-small .brand-text { font-size: clamp(22px, 5.5vw, 34px); }
.top-small .free-ribbon { font-size: 15px; padding: 6px 14px; margin-top: 8px; }

@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-18deg); } 80% { transform: rotate(10deg); } 90% { transform: rotate(-12deg); } }
@keyframes bounce { 0% { transform: translateY(0); } 30% { transform: translateY(-14px) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } 80% { transform: translateY(-5px); } 100% { transform: none; } }
@keyframes wiggle { 0%, 100% { transform: rotate(var(--tilt, 0deg)); } 25% { transform: rotate(-3deg) scale(1.03); } 75% { transform: rotate(3deg) scale(1.03); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- hello + buttons ---------- */
.hello { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 18px 0 8px; }
.bubble {
  position: relative; background: var(--card); border: 3px solid var(--ink); border-radius: 26px;
  padding: 12px 22px; font-size: clamp(18px, 4.5vw, 24px); font-weight: 600; box-shadow: var(--shadow); text-align: center;
}
.big-btn, .mid-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  border: 3px solid var(--ink); border-radius: 999px; cursor: pointer; text-decoration: none; color: var(--ink);
  font-weight: 600; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.big-btn { min-height: 64px; padding: 10px 28px; font-size: 24px; background: var(--yellow); }
.mid-btn { min-height: 52px; padding: 8px 20px; font-size: 18px; background: var(--card); }
.big-btn:hover, .mid-btn:hover { transform: translateY(-2px); }
.big-btn:active, .mid-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(45, 42, 74, .16); }
.big-btn:focus-visible, .mid-btn:focus-visible, .pic:focus-visible, .theme:focus-visible, .icon-btn:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.surprise { background: var(--pink); color: #fff; }
.colour-btn { background: var(--green); color: #fff; }
.print-btn { background: var(--blue); color: #fff; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--ink-soft); text-decoration: underline; cursor: pointer; font-size: 14px; }
.center { text-align: center; margin: 28px 0; }

/* ---------- themes + tiles ---------- */
.section-title { font-size: clamp(24px, 5vw, 32px); font-weight: 700; margin: 30px 0 14px; text-align: center; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.theme {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 10px 14px;
  background: var(--c); color: #fff; border: 3px solid var(--ink); border-radius: var(--radius);
  text-decoration: none; box-shadow: var(--shadow); text-align: center; -webkit-tap-highlight-color: transparent;
}
.theme:hover, .theme:active { animation: wiggle .5s ease; }
.theme-emoji { font-size: 56px; line-height: 1.1; filter: drop-shadow(0 3px 0 rgba(0, 0, 0, .15)); }
.theme-name { font-size: 22px; font-weight: 700; text-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
.theme-count { font-size: 15px; opacity: .95; }

.pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.pic {
  display: flex; flex-direction: column; background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius);
  padding: 8px 8px 10px; text-decoration: none; color: var(--ink); box-shadow: var(--shadow);
  transform: rotate(var(--tilt, 0deg)); -webkit-tap-highlight-color: transparent;
}
.pic:hover, .pic:active { animation: wiggle .5s ease; }
.pic img { border-radius: 14px; aspect-ratio: 3 / 4; object-fit: cover; background: #fff; }
.pic span { font-weight: 600; font-size: 18px; text-align: center; margin-top: 6px; }
.soon { text-align: center; font-size: 20px; font-weight: 600; margin: 36px 0 0; }

/* ---------- drawing page ---------- */
.back { display: inline-block; margin: 14px 0 0; font-weight: 600; font-size: 18px; color: var(--ink); text-decoration: none; padding: 8px 4px; }
.page-title { text-align: center; font-size: clamp(32px, 8vw, 52px); font-weight: 700; margin: 6px 0 18px; color: var(--c, var(--ink)); text-shadow: 0 3px 0 rgba(45, 42, 74, .12); }
.drawing-grid { display: grid; gap: 24px; align-items: start; }
@media (min-width: 820px) { .drawing-grid { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.sheet { margin: 0; background: #fff; border: 3px solid var(--ink); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.sheet img { display: block; width: 100%; border-radius: 10px; }
.actions { display: flex; flex-direction: column; gap: 14px; }
.actions .big-btn { width: 100%; }
.pdfs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pdfs .mid-btn { font-size: 17px; padding: 8px 10px; }
.hint { margin: 0; text-align: center; color: var(--ink-soft); }

/* ---------- text pages ---------- */
.text-page { max-width: 760px; font-size: 18px; }
.text-page h2 { font-size: 26px; margin: 30px 0 8px; }
.text-page li { margin: 6px 0; }
.lead { font-size: 21px; text-align: center; }

/* ---------- footer ---------- */
.foot { text-align: center; padding: 24px 16px 40px; color: var(--ink-soft); font-size: 16px; }
.foot a { color: var(--ink); font-weight: 600; }
.foot-links { font-size: 18px; }
.foot-small { font-size: 14px; }
.family-note { max-width: 560px; margin: 18px auto 0; padding: 10px 14px; border-radius: 14px; background: rgba(255, 255, 255, .6); font-size: 13px; }
.family-note p { margin: 0 0 2px; }
.family-note a { font-weight: 500; }

/* ---------- colouring studio ---------- */
body.colouring { background: #fdf0d8; overscroll-behavior: none; }
.studio { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; flex: none; }
.studio-title { flex: 1; margin: 0; font-size: clamp(18px, 4.5vw, 28px); font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px; min-width: 56px; min-height: 56px; padding: 6px 14px;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--card); box-shadow: var(--shadow);
  font-size: 22px; font-weight: 600; text-decoration: none; color: var(--ink); cursor: pointer; justify-content: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.icon-btn .lbl { font-size: 18px; }
.icon-btn:disabled { opacity: .45; cursor: default; }
.icon-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 rgba(45, 42, 74, .16); }
.done-btn { background: var(--yellow); }
@media (max-width: 620px) { .icon-btn .lbl { display: none; } .icon-btn { min-width: 50px; padding: 6px 8px; } .bar { gap: 6px; } }

.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 4px 12px; }
.paper {
  position: relative; flex: none; width: 300px; height: 400px; /* exact size set by colour.js */
  background: #fff; border: 3px solid var(--ink); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.paper canvas, .paper img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.paper .lines { mix-blend-mode: multiply; pointer-events: none; }
.paper .fx { pointer-events: none; }
.paper .paint { cursor: pointer; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; font-size: 22px; font-weight: 600; background: #fff; }
.loading[hidden] { display: none; }

.palette { flex: none; display: flex; gap: 10px; overflow-x: auto; padding: 18px 12px 12px; justify-content: safe center; scrollbar-width: thin; }
.swatch {
  flex: none; position: relative; width: 58px; height: 74px; border: 0; padding: 0; background: none; cursor: pointer;
  transition: transform .15s ease; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.swatch::before { /* crayon tip */
  content: ""; position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  border-left: 15px solid transparent; border-right: 15px solid transparent; border-bottom: 20px solid var(--sw);
  filter: drop-shadow(0 -2px 0 var(--ink));
}
.swatch::after { /* crayon body */
  content: ""; position: absolute; left: 7px; right: 7px; top: 18px; bottom: 2px; border-radius: 6px 6px 12px 12px;
  background: var(--sw); border: 3px solid var(--ink);
  background-image: linear-gradient(transparent 55%, rgba(255, 255, 255, .45) 55%, rgba(255, 255, 255, .45) 66%, transparent 66%);
}
.swatch.rainbow { --sw: #ff4d6d; }
.swatch.rainbow::after { background-image: linear-gradient(#ff4d6d, #ffb703, #3dbf6b, #3aa8ff, #9b5de5); }
.swatch.rainbow::before { border-bottom-color: #ffb703; }
.swatch[aria-checked="true"] { transform: translateY(-12px) scale(1.08); }
.swatch:focus-visible { outline: 4px solid var(--blue); outline-offset: 2px; border-radius: 10px; }
@media (min-width: 900px) and (min-height: 600px) {
  .studio { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; }
  .bar { grid-column: 1 / -1; }
  .palette { flex-direction: column; overflow-y: auto; overflow-x: visible; justify-content: flex-start; padding: 12px 22px 12px 8px; display: grid; grid-template-columns: repeat(2, 58px); gap: 16px 12px; align-content: start; }
  .swatch[aria-checked="true"] { transform: translateX(-8px) scale(1.1); }
}

.finish { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(45, 42, 74, .35); padding: 16px; z-index: 5; }
.finish[hidden] { display: none; }
.finish-card { background: var(--card); border: 3px solid var(--ink); border-radius: 28px; padding: 22px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); animation: pop .35s ease; }
.finish-title { font-size: 34px; font-weight: 700; margin: 0 0 16px; color: var(--pink); }
.finish-btns { display: flex; flex-direction: column; gap: 12px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 6; width: 100%; height: 100%; }
.print-out { display: none; }

/* ---------- printing ---------- */
@page { margin: 10mm; }
@media print {
  body { background: #fff; }
  body > *:not(main):not(.studio) { display: none !important; }
  main > *:not(.drawing-grid), .drawing-grid > *:not(.sheet), .studio > *:not(.print-out) { display: none !important; }
  main, .drawing-grid, .sheet { display: block; padding: 0; margin: 0; border: 0; box-shadow: none; max-width: none; }
  .sheet img, .print-out { display: block !important; width: auto; max-width: 100%; max-height: 270mm; margin: 0 auto; }
  .studio { display: block; height: auto; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Eisa ---------- */
.eisa-card {
  display: flex; align-items: center; gap: 14px; max-width: 460px; width: 100%; padding: 10px 18px 10px 10px;
  background: linear-gradient(135deg, #e9f6e8, #efe4fb); border: 3px solid var(--ink); border-radius: 999px;
  text-decoration: none; color: var(--ink); box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent;
}
.eisa-card[hidden] { display: none; }
.eisa-card:hover, .eisa-card:active { animation: wiggle .5s ease; }
.eisa-card img { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--ink); flex: none; object-fit: cover; }
.eisa-card strong { display: block; font-size: 24px; font-weight: 700; }
.eisa-card small { display: block; font-size: 16px; color: var(--ink-soft); }

body.eisa-page { background: linear-gradient(180deg, #fff6e5, #f3ecfb); min-height: 100vh; }
.eisa { max-width: 900px; margin: 0 auto; padding: 0 12px 30px; }
.eisa-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 6px 0 18px; }
.eisa-face {
  width: 170px; height: 170px; padding: 0; border-radius: 50%; border: 4px solid var(--ink); overflow: hidden;
  background: #fff; box-shadow: 0 0 0 8px rgba(180, 95, 214, .18), var(--shadow); cursor: pointer;
  animation: float 3.2s ease-in-out infinite; -webkit-tap-highlight-color: transparent;
}
.eisa-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.eisa-face.talking { box-shadow: 0 0 0 10px rgba(255, 209, 102, .7), 0 0 30px 10px rgba(255, 209, 102, .45), var(--shadow); }
.eisa-face.wiggle { animation: bounce .6s ease; }
.eisa-bubble {
  margin: 0; max-width: 560px; background: var(--card); border: 3px solid var(--ink); border-radius: 26px;
  padding: 12px 22px; font-size: clamp(20px, 5vw, 26px); font-weight: 600; text-align: center; box-shadow: var(--shadow);
}
.eisa-start { text-align: center; }
.eisa-start[hidden] { display: none; }
.eisa-hello { font-size: 26px; min-height: 72px; animation: pulse 1.6s ease-in-out infinite; }
.eisa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
.eisa-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 130px;
  background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
  font-size: 20px; font-weight: 600; cursor: pointer; color: var(--ink); -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  animation: pop .35s ease backwards;
}
.eisa-tile .e { font-size: 58px; line-height: 1.1; }
.eisa-tile:hover:not(:disabled), .eisa-tile:active:not(:disabled) { animation: wiggle .5s ease; }
.eisa-tile.picked { background: var(--yellow); opacity: 1; }
.eisa-tile:disabled:not(.picked) { opacity: .5; }
.surprise-tile { background: var(--pink); color: #fff; }
.eisa-chosen-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.eisa-chosen .eisa-tile { min-height: 0; flex-direction: row; padding: 6px 18px; animation: none; }
.eisa-chosen .eisa-tile .e { font-size: 34px; }
.eisa-who[hidden], .eisa-where[hidden], .eisa-on[hidden], .eisa-off[hidden] { display: none; }
.finish-eisa { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--ink); object-fit: cover; margin: -60px auto 6px; display: block; background: #fff; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* grown-ups settings */
.settings { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.settings-row { display: flex; flex-wrap: wrap; gap: 10px; }
.settings input[type="text"] { flex: 1 1 180px; min-height: 52px; font: inherit; font-size: 20px; padding: 6px 14px; border: 3px solid var(--ink); border-radius: 14px; }
.settings .check { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.settings .check input { width: 26px; height: 26px; }
.settings-saved { margin: 0; color: var(--green); font-weight: 600; }
