/* Coloring Pages: a warm cream table, white paper, chunky wooden-toy buttons. Calm by design: soft colors, nothing
   moves on its own, the few fades are 0.4 to 0.8 s, nothing loops or flashes. The canvas alone takes every touch
   (touch-action: none) so drawing never scrolls the page; everywhere else the page scrolls as usual. */
:root {
  --table: #f6efe2;
  --table-2: #efe4cf;
  --card: #fffdf7;
  --ink: #3b2a1a;
  --soft: #6d6250;
  --blue: #3f7fc4;
  --blue-d: #1f5fa8;
  --green: #3fa34d;
  --green-d: #2a7a36;
  --sun: #f4c55a;
  --radius: 20px;
  color-scheme: light;
}
/* Evening: dimmer and warmer (rule 4). The paper stays white so colors read true; the room around it dims. */
body.evening { --table: #e6dcc8; --table-2: #dacdb4; --card: #f6eedc; --green: #3d8a47; }
body.evening main > .screen:not(#color-screen), body.evening .top { filter: brightness(.9); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100dvh;
  /* Look B (Doug, Nov 3): the bright blue field comes from look-b.css; this is only the color before it loads. */
  background-color: #1f5fbf;
  color: var(--ink);
  font: 500 18px/1.45 'Fredoka', system-ui, sans-serif;
  overscroll-behavior: none;
  overflow-x: clip;
}
h1, h2 { font-family: 'Fredoka', system-ui, sans-serif; font-weight: 700; line-height: 1.1; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
a { color: var(--blue-d); }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 16px 6px; min-height: 64px; }
.grow { flex: 1; }
.brand { display: inline-flex; }
.back, .round {
  min-height: 48px; min-width: 48px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card);
  box-shadow: 0 4px 0 var(--ink); font-weight: 700; padding: 6px; display: inline-flex; align-items: center; justify-content: center;
}
.back:active, .round:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
#sound .mute { display: none; }
#sound[aria-pressed='false'] .mute { display: inline; }
#sound[aria-pressed='false'] .waves { display: none; }

main { max-width: 1600px; margin: 0 auto; padding: 0 16px calc(28px + env(safe-area-inset-bottom)); }
/* Pick a page: the list scrolls in its own box under the top bar, so a finger always scrolls it, even in full screen
   on a phone where the page itself may not (Doug, Oct 15: "on the pick a page page for example i cant scroll on mobile"). */
body:has(#pick-screen:not([hidden])) { height: 100dvh; overflow-y: clip; display: flex; flex-direction: column; }
body:has(#pick-screen:not([hidden])) > .top { flex: none; }
body:has(#pick-screen:not([hidden])) > main { flex: 1; min-height: 0; width: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.screen { display: grid; gap: 18px; min-width: 0; }
.screen:not([hidden]) { animation: fade-in .5s ease-in-out both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
body.still .screen { animation: none; }

/* home */
.hero { text-align: center; display: grid; gap: 8px; justify-items: center; padding-top: 4px; }
.hero h1 { font-size: clamp(34px, 10vw, 54px); }
.lede { margin: 0; font-size: 20px; color: var(--soft); max-width: 640px; }

.big {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 76px;
  border: 3px solid var(--ink); border-radius: 24px; font-size: 30px; font-weight: 700; box-shadow: 0 7px 0 var(--ink); padding: 10px 20px;
}
.big:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--ink); }
.big.go { background: var(--green); color: #fff; text-shadow: 0 2px 0 #0003; }
.big.plain { background: var(--card); font-size: 24px; min-height: 64px; }

.pick { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; min-width: 0; }
.pick legend { font-weight: 700; font-size: 18px; margin-bottom: 8px; padding: 0; }
.pick button {
  border: 3px solid var(--ink); border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--ink); padding: 10px 4px;
  display: grid; justify-items: center; align-content: start; gap: 4px; font-weight: 700; font-size: 20px; line-height: 1.15; min-height: 96px;
}
.pick button small { font-size: 14px; font-weight: 500; color: var(--soft); }
.pick button[aria-pressed='true'] { background: #dff3e1; border-color: var(--green-d); box-shadow: 0 4px 0 var(--green-d); outline: 3px solid var(--green); outline-offset: 1px; }
.pick button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
/* Level marks: one, two, three dots, so the level reads without color. */
.lv-dot { display: block; height: 14px; background: radial-gradient(circle, var(--ink) 0 5px, transparent 6px) 0 0 / 16px 14px repeat-x; }
.lv-1 { width: 16px; }
.lv-2 { width: 32px; }
.lv-3 { width: 48px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chips button { display: inline-flex; min-height: 48px; padding: 6px 14px; font-size: 18px; align-items: center; }

.grownups, .about { background: var(--card); border: 3px solid var(--ink); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 5px 0 #3b2a1a33; }
.grownups summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.grownups p, .about p { margin: 10px 0 0; }
.gu-h { font-size: 22px; margin-top: 16px; }
.private { color: var(--green-d); }
.pill { margin-top: 10px; min-height: 56px; padding: 6px 20px; border: 3px solid var(--ink); border-radius: 999px; background: #e7f4e8; font-weight: 700; font-size: 19px; box-shadow: 0 4px 0 var(--ink); }
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.about h2 { font-size: 22px; margin-top: 14px; }
.about h2:first-child { margin-top: 0; }
.about h3 { font-size: 18px; margin: 12px 0 0; }
.about ul { padding-left: 22px; display: grid; gap: 6px; }
.small { font-size: 14px; color: var(--soft); }

/* pick a page */
.pick-title { font-size: 30px; text-align: center; }
/* The kinds of pages in equal rows (2 a row on a phone, 3 on a tablet, 4 on a computer), each chip the same size. */
.cats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 8px; }
@media (min-width: 600px) { .cats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .cats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cats button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 52px; padding: 6px 10px; line-height: 1.15; text-align: center; border: 3px solid var(--ink); border-radius: 999px; background: var(--card); font-weight: 700; font-size: 18px; box-shadow: 0 3px 0 var(--ink); }
.cats button[aria-pressed='true'] { background: #fde7b0; outline: 3px solid var(--sun); outline-offset: 1px; }
@media (max-width: 599px) { .cats button { font-size: 16px; gap: 5px; padding: 6px 8px; } }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.thumb {
  display: grid; gap: 4px; justify-items: center; align-content: start; padding: 8px; min-height: 150px;
  border: 3px solid var(--ink); border-radius: 18px; background: #fff; box-shadow: 0 4px 0 var(--ink); font-weight: 700; font-size: 17px; letter-spacing: .04em;
}
.thumb:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.thumb img { width: 100%; aspect-ratio: 1000 / 780; object-fit: contain; }
.thumbs.art .thumb img { aspect-ratio: 1; }
.thumb.add { background: #f2f8ee; border-style: dashed; align-content: center; letter-spacing: 0; }
.thumb .plus { font-size: 54px; line-height: 1; }
.empty { grid-column: 1 / -1; margin: 0; color: var(--soft); }
/* Easiest pages first (rank.js); the pages past the child's level follow a quiet line, still there to pick. */
.harder { grid-column: 1 / -1; margin: 8px 0 0; padding-top: 10px; border-top: 3px dashed #d9c9a8; color: var(--soft); font-size: 15px; text-align: center; }
/* Picture credits: a small grown-up button under the pages, out of the way. */
.credits-row { display: flex; justify-content: center; margin: 22px 0 8px; }
.credits-btn { min-height: 44px; padding: 4px 16px; border: 2px solid var(--soft); border-radius: 999px; background: transparent; color: var(--soft); font-weight: 600; font-size: 15px; }
.credits-view .card { width: min(680px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; display: grid; gap: 10px; padding: 16px; background: var(--card); border: 3px solid var(--ink); border-radius: 22px; }
.credits-view h2 { margin: 0; font-size: 24px; }
.credit-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 15px; overflow-wrap: anywhere; }
.credit-list a { color: #1f5fa8; font-weight: 600; text-decoration: none; background: #e8f0fb; border-radius: 6px; padding: 0 4px; }

/* coloring: the paper is placed by view.js (fixed, in screen pixels) to fill the free space; it shows only the part
   of the page with the drawing on it, so the drawing itself comes out big. */
body.coloring { overflow: hidden; }
body.coloring .top { position: relative; z-index: 25; pointer-events: none; }
body.coloring .top > * { pointer-events: auto; }
/* The little crayon mark steps away while coloring, so the picture can come up beside the home button. */
body.coloring .brand { display: none; }
/* The coloring layer sits over the top bar's band (the paper may rise beside its buttons, never under them), so the
   colors sheet covers the whole screen when open. */
#color-screen:not([hidden]) { display: block; position: relative; z-index: 30; }
.paper {
  position: fixed; left: 16px; top: 72px; width: calc(100% - 32px); aspect-ratio: 1; z-index: 10;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 #3b2a1a55; overflow: hidden;
}
.sheet { position: absolute; left: 0; top: 0; width: 100%; height: 100%; }
.sheet canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#wet, #paint { pointer-events: none; }
/* Only the page itself takes the finger: drawing never scrolls or zooms the page. */
#lines { touch-action: none; cursor: crosshair; outline: none; }
#lines:focus-visible { box-shadow: inset 0 0 0 4px var(--blue); }
.cursor { position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border: 3px solid var(--blue-d); border-radius: 50%; pointer-events: none; }
.cursor.down { background: #3f7fc455; }
.making { position: absolute; inset: auto 0 40%; margin: 0; text-align: center; font-weight: 700; color: var(--soft); }
.making[hidden] { display: none; }

/* The round buttons float in the screen's corners: the palette bottom left, I'm done bottom right, and the word's
   speaker between them (upright) or over the palette (sideways). */
.dock button { position: fixed; z-index: 20; bottom: calc(14px + env(safe-area-inset-bottom)); }
.palette-btn, .done-btn, .hear {
  width: 80px; height: 80px; border-radius: 50%; border: 4px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  display: grid; place-items: center; padding: 0;
}
.palette-btn { left: calc(16px + env(safe-area-inset-left)); background: var(--card); --c: #e04f4a; }
.done-btn { right: calc(16px + env(safe-area-inset-right)); background: var(--green); color: #fff; }
.hear { left: calc(50% - 40px); background: var(--sun); }
body.side .hear { left: calc(16px + env(safe-area-inset-left)); bottom: calc(14px + 80px + 18px + env(safe-area-inset-bottom)); }
.palette-btn .now { fill: var(--c); }
.palette-btn svg { width: 80%; height: 80%; }
.done-btn svg { width: 56%; height: 56%; }
.hear svg { width: 50%; height: 50%; }
.palette-btn[aria-expanded='true'] { background: #fde7b0; }
.palette-btn:active, .done-btn:active, .hear:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }

/* The colors and tools: a sheet that slides up over the bottom of the screen (0.6 s, no bounce), or in from the right
   when the phone is sideways. It goes away once something is picked, with the big X, or with a tap outside it, so it
   never makes the picture smaller. */
.kit {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(100%, 560px); max-height: 94dvh; overflow-y: auto; z-index: 50;
  display: grid; gap: 12px; padding: 12px 16px calc(18px + env(safe-area-inset-bottom)); background: var(--card);
  border: 4px solid var(--ink); border-bottom: 0; border-radius: 26px 26px 0 0; box-shadow: 0 -6px 0 #3b2a1a33;
  transform: translateY(110%); opacity: 0; pointer-events: none; transition: transform .6s ease-in-out, opacity .6s ease-in-out;
}
.kit.open { transform: none; opacity: 1; pointer-events: auto; }
.kit-close {
  justify-self: end; width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--ink); background: var(--card);
  box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; padding: 0;
}
.kit-close:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
body.side .kit {
  left: auto; right: 0; top: auto; bottom: 0; margin: 0; width: min(100%, 720px); max-height: 100dvh; align-content: start;
  grid-template-columns: auto 1fr; column-gap: 14px; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)) 14px;
  border: 4px solid var(--ink); border-right: 0; border-bottom: 0; border-radius: 26px 0 0 0; transform: translateX(110%);
}
body.side .kit.open { transform: none; }
body.side .kit-close { grid-column: 1; grid-row: 1; justify-self: start; }
body.side .swatches { grid-column: 1; grid-row: 2 / span 2; align-content: start; }
body.side .tools { grid-column: 2; grid-row: 1 / span 2; }
body.side .sizes { grid-column: 2; grid-row: 3; align-self: start; }
/* Big, obvious tools (Doug, Oct 14, mockup B): 72px pictures on 108px buttons, 6 in 3 + 3, Easy's 4 in 2 + 2. */
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-content: start; }
.tools.few { grid-template-columns: repeat(4, 1fr); }
body.side .tools.few { grid-template-columns: repeat(2, 1fr); }
.tools button {
  min-height: 108px; min-width: 0; border: 3px solid var(--ink); border-radius: 18px; background: var(--card); box-shadow: 0 3px 0 var(--ink);
  display: grid; justify-items: center; align-content: center; gap: 2px; padding: 6px 2px; font-size: 18px; font-weight: 700; line-height: 1.1;
}
.tools svg { width: min(72px, 100%); height: auto; aspect-ratio: 1; }
.tools button[aria-pressed='true'] { background: #fde7b0; outline: 4px solid var(--sun); outline-offset: 1px; transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.sizes { display: flex; gap: 8px; }
.sizes[hidden] { display: none; }
.sizes button { flex: 1; min-height: 64px; border: 3px solid var(--ink); border-radius: 16px; background: var(--card); box-shadow: 0 3px 0 var(--ink); display: grid; place-items: center; }
.sizes button i { display: block; border-radius: 50%; background: var(--ink); }
.sizes [data-size='s'] i { width: 8px; height: 8px; }
.sizes [data-size='m'] i { width: 16px; height: 16px; }
.sizes [data-size='l'] i { width: 28px; height: 28px; }
.sizes button[aria-pressed='true'] { background: #fde7b0; outline: 3px solid var(--sun); outline-offset: 1px; }
.tools .undo { background: #eef3fb; }
.sizes button:active, .tools button:active, .swatches button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

/* Colors at least 64px across for little fingers, in equal rows: 16 in 4 x 4, Easy's 10 in 5 x 2. */
.swatches { display: grid; grid-template-columns: repeat(4, minmax(64px, 76px)); justify-content: center; gap: 8px; }
.swatches.few { grid-template-columns: repeat(5, minmax(64px, 76px)); }
body.side .swatches { grid-template-columns: repeat(4, 64px); }
body.side .swatches.few { grid-template-columns: repeat(5, 64px); }
.swatches button {
  aspect-ratio: 1; min-height: 64px; border: 3px solid var(--ink); border-radius: 50%; background: var(--c); box-shadow: inset 0 -5px 0 #0002, 0 3px 0 var(--ink);
  display: grid; place-items: center; padding: 0;
}
.swatches button svg { width: 60%; height: 60%; stroke: #fff; visibility: hidden; }
.swatches [data-color='yellow'] svg, .swatches [data-color='white'] svg, .swatches [data-color='peach'] svg, .swatches [data-color='lime'] svg, .swatches [data-color='pink'] svg, .swatches [data-color='sky'] svg, .swatches [data-color='gray'] svg { stroke: var(--ink); }
.swatches button[aria-pressed='true'] { outline: 4px solid var(--ink); outline-offset: 2px; }
.swatches button[aria-pressed='true'] svg { visibility: visible; }

/* All done */
#finish { text-align: center; padding-top: 10px; justify-items: center; }
#finish > * { width: min(100%, 640px); }
.cheer { font-size: clamp(32px, 9vw, 46px); }
.art-done { width: auto !important; max-width: min(100%, 420px); max-height: 56dvh; justify-self: center; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 6px 0 #3b2a1a55; }
.used { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 4px; border: 2px solid var(--ink); border-radius: 999px; background: var(--card); font-size: 16px; }
.chip i { width: 20px; height: 20px; border-radius: 50%; background: var(--c); border: 2px solid var(--ink); }
.rest { margin: 0; font-weight: 700; color: var(--green-d); }
.talk { margin: 0; background: #f6fbf2; border: 2px dashed var(--green-d); border-radius: 16px; padding: 12px 14px; text-align: left; font-size: 18px; }
.saved { margin: 0; font-size: 16px; color: var(--soft); }

/* dialogs: My art, and the photo maker */
/* My art's big look: the picture keeps its own shape (only the part with the drawing is saved) and fits the screen. */
.art-view .card {
  width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; display: grid; gap: 10px; padding: 14px;
  background: var(--card); border: 3px solid var(--ink); border-radius: 22px;
}
.art-view img { width: 100%; max-height: max(160px, calc(100dvh - 220px)); object-fit: contain; border: 3px solid var(--ink); border-radius: 12px; background: #fff; }
.art-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.art-btns .again-btn { background: #f6c933; }
.gu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.art-view .dl { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.fridge-btn svg { flex: none; }
.photo-maker .card { width: min(620px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
.pick-photos { display: inline-flex; align-items: center; justify-content: center; min-height: 60px; border: 3px solid var(--ink); border-radius: 16px; background: #e7f4e8; font-weight: 700; font-size: 20px; cursor: pointer; }
.pm-work { display: grid; gap: 10px; }
.pm-work[hidden] { display: none; }
.pm-count { margin: 0; font-weight: 700; }
.pm-count:empty { display: none; }
.pm-frame { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 12px; min-height: 120px; display: grid; place-items: center; }
.pm-preview { max-width: 100%; max-height: 46dvh; display: block; }
.pm-wait { position: absolute; margin: 0; padding: 4px 12px; border-radius: 999px; background: var(--card); font-weight: 700; }
.pm-wait[hidden] { display: none; }
.pm-slider { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; font-size: 15px; }
.pm-slider input { width: 100%; min-height: 44px; accent-color: var(--green); }
.pm-word { display: grid; gap: 4px; font-size: 15px; }
.pm-word input { min-height: 48px; border: 3px solid var(--ink); border-radius: 12px; padding: 4px 12px; font: 700 22px 'Fredoka', sans-serif; text-transform: uppercase; }
.pm-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pm-note { margin: 0; font-weight: 600; color: var(--green-d); }
.pm-note:empty { display: none; }
.pm-mine { list-style: none; padding: 0 !important; margin: 0; display: grid; gap: 6px; }
.pm-mine:empty { display: none; }
.pm-mine li { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; }
.pm-mine .pm-h { display: block; font-weight: 700; }
.pm-mine img { width: 64px; height: 50px; object-fit: contain; background: #fff; border: 2px solid var(--ink); border-radius: 8px; }
.kid-dialog .pm-mine button { min-height: 44px; font-size: 16px; padding: 0 12px; }

/* Look B: the heading and the saved note sit on the blue field, so they turn white. */
.look-b.b-field .pick-title { color: #fff; text-shadow: 0 3px 0 #143f80; }
.look-b.b-field .saved { color: #e6eefb; }
