/* ---------- Tokens ----------
   The same look as iamalena.com: cream paper, pale-sage bands, a pink-and-butter
   gingham, peach lettering in Sniglet, chocolate text and rust buttons. */

:root {
  --paper: #fdf2e0;        /* cream */
  --paper-deep: #f6e5c8;
  --plate: #fbf7f3;        /* the off-white plate the title sits on */
  --card: #fffdfa;
  --ink: #411e06;          /* chocolate */
  --ink-soft: #6d4c36;
  --line: rgba(65, 30, 6, .13);

  --peach: #dca27c;
  --peach-text: #bf7a4c;
  --rust: #974c1f;
  --sage: #d9ead7;
  --pink: #fdbdc5;
  --butter: #fbe29a;

  --font-display: "Sniglet", "Nunito", ui-rounded, system-ui, sans-serif;
  --font-body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;

  --gutter: clamp(16px, 4vw, 48px);
  --max: 1200px;
  --radius: 18px;
  --panel-radius: clamp(22px, 3.5vw, 40px);
  --shadow-sm: 0 1px 2px rgba(65, 30, 6, .06), 0 6px 16px -8px rgba(65, 30, 6, .18);
  --shadow-lg: 0 2px 4px rgba(65, 30, 6, .06), 0 24px 48px -20px rgba(65, 30, 6, .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.3, 1.5, .5, 1);
  color-scheme: light;
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.7 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--pink); color: var(--ink); }

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  text-wrap: balance;
}
h2 { font-size: clamp(2rem, 4.4vw, 3.1rem); }
h3 { font-size: 1.35rem; }
p { margin: 0 0 1em; text-wrap: pretty; }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
svg { flex: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--rust); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }

.hand {
  display: inline-block;
  margin: 0;
  font: 700 1.6rem/1 var(--font-hand);
  color: var(--rust);
  rotate: -2deg;
}

.icon { width: 1.15em; height: 1.15em; }

.skip {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
}
.skip:focus { top: 12px; }

/* a pink-and-butter gingham, woven from two sets of see-through stripes */
.gingham {
  background-color: #fff8ec;
  background-image:
    linear-gradient(90deg, rgba(253, 189, 197, .5) 50%, transparent 0),
    linear-gradient(rgba(251, 226, 154, .55) 50%, transparent 0);
  background-size: 30px 30px;
}

.plate {
  border-radius: var(--radius);
  background: var(--plate);
  box-shadow: var(--shadow-sm);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55em;
  padding: .85em 1.45em;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 700 .98rem/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background-color .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -10px rgba(65, 30, 6, .5); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-primary { border-color: var(--rust); background: var(--rust); color: #fff; }
.btn-small { padding: .6em 1.1em; font-size: .92rem; }

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.site-header.scrolled { border-bottom-color: var(--line); }

.header-row {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.4vw, 28px);
  height: 72px;
}

.logo {
  display: inline-flex;
  align-items: flex-end;
  gap: .4rem;
  color: var(--peach-text);
  font: 400 clamp(1.35rem, 3.4vw, 1.75rem)/1 var(--font-display);
  text-decoration: none;
  white-space: nowrap;
}
.logo-mark { width: 22px; height: 28px; margin-bottom: .04em; transform-origin: 50% 100%; }
.logo:hover .logo-mark { animation: sway .9s var(--ease); }
@keyframes sway { 30% { rotate: -9deg; } 65% { rotate: 6deg; } }

.nav { display: flex; align-items: center; gap: clamp(14px, 2.4vw, 30px); margin-left: auto; }
.nav a:not(.btn) {
  position: relative;
  color: var(--ink-soft);
  font-weight: 700;
  text-decoration: none;
}
.nav a:not(.btn):hover { color: var(--rust); }
.nav a:not(.btn)::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  border-radius: 2px;
  background: var(--peach);
  scale: 0 1;
  transform-origin: left;
  transition: scale .3s var(--ease);
}
.nav a:not(.btn):hover::after { scale: 1 1; }

@media (max-width: 900px) { .nav a:not(.btn) { display: none; } }
@media (max-width: 520px) { .nav .btn { display: none; } }

/* ---------- Hero ---------- */

.hero { padding-block: clamp(10px, 2vw, 22px) clamp(36px, 5vw, 64px); }

.hero-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: clamp(560px, 76vh, 740px);
  padding: clamp(18px, 4vw, 56px);
  border-radius: var(--panel-radius);
}

/* the plate in the middle, with START on it */
.hero-text {
  position: relative;
  z-index: 2;
  width: min(100%, 620px);
  padding: clamp(28px, 4.5vw, 52px) clamp(22px, 4vw, 52px) clamp(40px, 5vw, 60px);
  text-align: center;
}
.hero-kicker { margin-bottom: .9rem; }

.hero h1 { font-size: clamp(2.3rem, 4.8vw, 3.9rem); }
.hero h1 .name {
  position: relative;
  z-index: 0;
  color: var(--peach-text);
  white-space: nowrap;
}
.name-underline {
  position: absolute;
  z-index: -1;
  left: -3%;
  bottom: -.02em;
  width: 106%;
  height: .28em;
  overflow: visible;
}
.name-underline path {
  fill: none;
  stroke: var(--pink);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
  animation: draw 1s .45s var(--ease) forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.lede {
  max-width: 34ch;
  margin: 1.1rem auto 2.1rem;
  color: var(--ink-soft);
  font-size: clamp(1.05rem, 1.5vw, 1.22rem);
}

/* START: big and crisp, with a pastel rainbow ring turning around it and the
   same rainbow glowing behind, breathing gently, and a shine running across
   now and then, so it's the first thing a child sees */
@property --spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

.start {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  border-radius: 999px;
  color: #fff;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  animation: breathe 2.4s ease-in-out infinite;
}
.start::before,
.start::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 999px;
  background: conic-gradient(from var(--spin), #f2899a, #fbb36b, #fbe29a, #a7d17f, #8fcdea, #a98bdf, #f2899a);
  animation: spin 4s linear infinite;
}
.start::before { z-index: -1; }
.start::after { z-index: -2; filter: blur(18px); animation: spin 4s linear infinite, glow 2.4s ease-in-out infinite; }
.start-face {
  position: relative;
  display: flex;
  align-items: center;
  gap: .42em;
  overflow: hidden;
  padding: .3em 1em .32em .55em;
  border-radius: 999px;
  background: linear-gradient(#b0612f, var(--rust));
  font: 400 clamp(2.2rem, 5.4vw, 3.5rem)/1 var(--font-display);
  letter-spacing: .06em;
  text-shadow: 0 1px 0 rgba(65, 30, 6, .3);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .22);
  transition: transform .2s var(--spring);
}
.start-play {
  display: grid;
  place-items: center;
  width: .86em;
  height: .86em;
  border-radius: 50%;
  background: #fff;
}
.start-play::before {
  content: "";
  margin-left: .07em;
  border-left: .3em solid var(--rust);
  border-top: .19em solid transparent;
  border-bottom: .19em solid transparent;
}
.start-face::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -70%;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-20deg);
  animation: shine 3.6s ease-in-out infinite;
}
.start:hover .start-face { transform: translateY(-2px); }
.start:active .start-face { transform: scale(.96); }
.start:focus-visible { outline: none; }
.start:focus-visible .start-face { outline: 4px solid var(--ink); outline-offset: 10px; }

.start-spark { position: absolute; fill: #ffd54f; pointer-events: none; animation: twinkle 1.6s ease-in-out infinite; }
.start-spark.s1 { width: 28px; height: 28px; top: -26px; right: -18px; }
.start-spark.s2 { width: 20px; height: 20px; bottom: -18px; left: -22px; fill: #f2899a; animation-delay: -.6s; }
.start-spark.s3 { width: 15px; height: 15px; top: -22px; left: 22%; fill: #8fcdea; animation-delay: -1.1s; }

@keyframes breathe { 50% { scale: 1.04; } }
@keyframes spin { to { --spin: 360deg; } }
@keyframes glow { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes shine { 0%, 55% { left: -70%; } 85%, 100% { left: 130%; } }

/* colored-in pages taped on around the plate, one in each corner */
.hero-art { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

.card {
  position: absolute;
  width: clamp(170px, 21vw, 270px);
  margin: 0;
  padding: 10px 10px 40px;
  border-radius: 5px;
  background: var(--card);
  box-shadow: 0 2px 4px rgba(65, 30, 6, .1), 0 22px 40px -16px rgba(65, 30, 6, .45);
  text-decoration: none;
  pointer-events: auto;
  transition: transform .5s var(--spring);
  animation: bob 7s ease-in-out infinite;
}
.card::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 50%;
  z-index: 1;
  width: 84px;
  height: 25px;
  translate: -50% 0;
  rotate: -5deg;
  background: color-mix(in srgb, var(--butter) 80%, transparent);
  box-shadow: 0 1px 2px rgba(65, 30, 6, .08);
}
.card-1 { left: 2.5%; top: 6%; rotate: -8deg; animation-delay: -1s; }
.card-2 { right: 2.5%; top: 5%; rotate: 7deg; animation-delay: -3.5s; }
.card-3 { left: 3.5%; bottom: 6%; rotate: 5deg; animation-delay: -5.5s; }
.card-4 { right: 3.5%; bottom: 7%; rotate: -5deg; animation-delay: -2.2s; }
.card-2::before { background: color-mix(in srgb, var(--sage) 90%, transparent); rotate: 4deg; }
.card-3::before { background: color-mix(in srgb, var(--pink) 85%, transparent); rotate: 3deg; }
.card-4::before { background: color-mix(in srgb, var(--butter) 80%, transparent); }
.card:hover { transform: translateY(-6px) scale(1.04); }
/* each page starts as a blank coloring page; then a crayon runs across it and
   the colors come in behind it, one page after another, over and over */
.card-pic { position: relative; display: block; overflow: hidden; border-radius: 3px; }
.card-pic img { width: 100%; aspect-ratio: 4 / 3; background: #fff; }
.card-color {
  position: absolute;
  inset: 0;
  -webkit-mask: linear-gradient(100deg, #000 40%, transparent 60%) 0 0 / 250% 100% no-repeat;
  mask: linear-gradient(100deg, #000 40%, transparent 60%) 0 0 / 250% 100% no-repeat;
  animation: color-in 9s ease-in-out both infinite;
  animation-delay: var(--at);
}
.card-crayon {
  position: absolute;
  left: 125%;
  top: 40%;
  width: 34px;
  height: 42px;
  opacity: 0;
  filter: drop-shadow(0 2px 2px rgba(65, 30, 6, .3));
  animation: crayon-across 9s ease-in-out both infinite, scribble .32s ease-in-out infinite alternate;
  animation-delay: var(--at), 0s;
}
.card-1 { --at: .5s; }
.card-2 { --at: 2.7s; }
.card-4 { --at: 4.9s; }
.card-3 { --at: 7.1s; }
@keyframes color-in {
  0%, 12% { -webkit-mask-position: 100% 0; mask-position: 100% 0; opacity: 1; }
  34%, 86% { -webkit-mask-position: 0 0; mask-position: 0 0; opacity: 1; }
  96% { -webkit-mask-position: 0 0; mask-position: 0 0; opacity: 0; }
  100% { -webkit-mask-position: 100% 0; mask-position: 100% 0; opacity: 0; }
}
@keyframes crayon-across {
  0%, 12% { left: -25%; opacity: 0; }
  14%, 31% { opacity: 1; }
  34%, 100% { left: 105%; opacity: 0; }
}
@keyframes scribble { from { translate: 0 -28px; rotate: -8deg; } to { translate: 0 28px; rotate: 8deg; } }
.card-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  color: var(--ink);
  font: 700 1.45rem/1 var(--font-hand);
  text-align: center;
  rotate: -2deg;
}

@keyframes bob { 50% { translate: 0 -8px; } }

.doodle { position: absolute; fill: var(--peach); pointer-events: none; animation: twinkle 4.5s ease-in-out infinite; }
.hero-panel .d1 { width: 26px; height: 26px; top: 22px; left: 31%; }
.hero-panel .d2 { width: 18px; height: 18px; bottom: 24px; left: 64%; fill: #f2899a; animation-delay: -2s; }
@keyframes twinkle { 50% { scale: .7; rotate: 45deg; } }

/* narrower screens: the plate on top, two of the pages in a row under it */
@media (max-width: 900px) {
  .hero-panel { display: flex; flex-direction: column; align-items: center; min-height: 0; }
  .hero-art { position: relative; inset: auto; display: flex; justify-content: center; gap: 4%; width: 100%; margin-top: 26px; }
  .card { position: relative; inset: auto; width: min(44%, 240px); }
  .card-3, .card-4 { display: none; }
  .hero-panel .d1 { display: none; }
}

/* ---------- Ticker ---------- */

.ticker-wrap { overflow-x: clip; padding-block: 14px; }

.ticker {
  margin-inline: -24px;
  padding: 14px 0;
  overflow: hidden;
  background: var(--sage);
  color: var(--ink);
  rotate: -1deg;
}
.ticker-track {
  display: flex;
  width: max-content;
  animation: marquee 44s linear infinite;
  font: 400 clamp(1.2rem, 2.2vw, 1.65rem)/1.1 var(--font-display);
}
.ticker-track span { display: flex; align-items: center; gap: 1.5rem; padding-right: 1.5rem; white-space: nowrap; }
.ticker-track svg { width: .65em; height: .65em; fill: var(--peach); }
.ticker-track svg:nth-of-type(2n) { fill: #f2899a; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Sections ---------- */

.section { padding-block: clamp(64px, 9vw, 120px); }
.band { padding-block: clamp(64px, 9vw, 120px); background: var(--sage); }

.section-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .45rem;
  margin-bottom: clamp(26px, 4vw, 48px);
}

/* ---------- The pictures ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }

.chip {
  padding: .6em 1.1em;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--plate);
  color: var(--ink-soft);
  font: 700 .93rem/1 var(--font-body);
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s;
}
.chip:hover { border-color: var(--peach); color: var(--ink); }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: clamp(16px, 2.2vw, 28px);
}

.pic { position: relative; }
.pic[hidden] { display: none; }
.pic-link {
  display: block;
  padding: 10px 10px 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  transition: transform .4s var(--ease), box-shadow .4s var(--ease);
}
.pic:nth-child(3n + 1) .pic-link { rotate: -.6deg; }
.pic:nth-child(3n + 2) .pic-link { rotate: .5deg; }
.pic-link:hover { transform: translateY(-4px) rotate(-.6deg); box-shadow: var(--shadow-lg); }
.pic-sheet {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
  /* a faint edge, like a sheet of paper */
  box-shadow: inset 0 0 0 1px var(--line);
}
.pic-sheet img { position: absolute; inset: 0; width: 100%; height: 100%; }
/* the drawing lies over what's been colored, its white letting the color through */
.pic-lines { mix-blend-mode: multiply; }
.pic-paint[hidden] { display: none; }
.pic-name {
  display: flex;
  align-items: center;
  gap: .5em;
  padding: .7rem .3rem .8rem;
  font: 400 1.3rem/1.1 var(--font-display);
}
.pic-name .started {
  margin-left: auto;
  padding-right: 42px;
  color: var(--rust);
  font: 700 1.2rem/1 var(--font-hand);
}
.pic-print {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--plate);
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .2s, border-color .2s, background-color .2s;
}
.pic-print:hover { border-color: var(--peach); color: var(--ink); background: #fff; }
.pic-print svg { width: 20px; height: 20px; }

.noscript { padding: 24px; border: 2px dashed var(--line); border-radius: var(--radius); text-align: center; }

/* ---------- How it works ---------- */

.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(14px, 2vw, 24px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.step {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: clamp(22px, 2.6vw, 30px);
  border-radius: 24px;
  background: var(--butter);
}
.step:nth-child(2) { background: var(--pink); }
.step:nth-child(3) { background: var(--plate); }
.step:nth-child(4) { background: #fff3cf; }
.step-num { font: 400 3rem/1 var(--font-display); color: var(--rust); }
.step p { margin: 0; color: var(--ink-soft); }

@media (max-width: 900px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .steps { grid-template-columns: 1fr; } }

/* ---------- For grown-ups ---------- */

.grown-ups-card {
  display: grid;
  grid-template-columns: .7fr 1.3fr;
  gap: clamp(20px, 4vw, 56px);
  padding: clamp(28px, 5vw, 64px);
}
.grown-ups-card h2 { margin-top: .55rem; }
.notes { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; color: var(--ink-soft); font-size: 1.08rem; }
.notes li { position: relative; padding-left: 30px; }
.notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .38em;
  width: 16px;
  height: 16px;
  background: var(--peach);
  clip-path: path("M8 0C8.7 4.8 11.2 7.3 16 8 11.2 8.7 8.7 11.2 8 16 7.3 11.2 4.8 8.7 0 8 4.8 7.3 7.3 4.8 8 0Z");
}
.notes li:nth-child(2n)::before { background: #f2899a; }
.notes b { color: var(--ink); }

@media (max-width: 760px) { .grown-ups-card { grid-template-columns: 1fr; } }

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

.site-footer { padding-block: 0 40px; color: var(--ink-soft); font-size: .93rem; }
.footer-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.footer-row p { margin: 0; }
.logo-small { font-size: 1.3rem; }
.made { margin: 28px auto 0; text-align: center; font-size: .8rem; opacity: .7; }
.made a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
.made a:hover { color: var(--rust); text-decoration-color: currentColor; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .name-underline path { stroke-dashoffset: 0; }
  .card-crayon { display: none; }
}

/* ==================== The coloring page ==================== */

body.coloring { overflow: hidden; }
body.coloring .home { visibility: hidden; }

.studio {
  --c: #1e63c8;          /* the color in hand */
  --swatch: clamp(30px, 5.4vh, 46px);
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) calc(var(--swatch) * 2 + 40px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top top" "size stage colors" "tools tools tools";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background-color: #fffaf1;
  background-image:
    linear-gradient(90deg, rgba(253, 189, 197, .26) 50%, transparent 0),
    linear-gradient(rgba(251, 226, 154, .3) 50%, transparent 0);
  background-size: 34px 34px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
.studio[hidden] { display: none; }

.studio-top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px clamp(12px, 2vw, 22px) 6px;
}
.history { display: flex; gap: 10px; margin-inline: auto; }

.round {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 0 0 4px rgba(255, 253, 250, .6), var(--shadow-sm);
  cursor: pointer;
  transition: transform .2s var(--spring), opacity .2s;
}
.round svg { width: 24px; height: 24px; }
.round:hover:not(:disabled) { transform: scale(1.07); }
.round:active:not(:disabled) { transform: scale(.94); }
.round:disabled { opacity: .4; cursor: default; }

.finish { padding: .8em 1.4em; font-size: 1.05rem; box-shadow: 0 0 0 4px rgba(255, 253, 250, .6); }

/* the page, as big as fits, at the drawing's 4:3 */
.stage {
  grid-area: stage;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 8px;
  container-type: size;
}
.page {
  position: relative;
  width: min(100cqw, 100cqh * 4 / 3);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(65, 30, 6, .08), 0 20px 50px -18px rgba(65, 30, 6, .4);
  isolation: isolate;
  touch-action: none;
  cursor: crosshair;
}
.page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.page canvas:last-of-type { pointer-events: none; }
.page.brush { cursor: none; }
.page.loading canvas { visibility: hidden; }

/* where a mouse is about to paint, as big as the brush */
.ring {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  border: 2px solid rgba(65, 30, 6, .6);
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .8), inset 0 0 0 1.5px rgba(255, 255, 255, .8);
  pointer-events: none;
}
.ring[hidden] { display: none; }

.page-wait {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  rotate: 0deg;
  font-size: 2rem;
}
.page.loading .page-wait { display: grid; }

/* the brush size: a tapering track with a dot of the color, as big as the brush */
.size {
  --v: .4;
  grid-area: size;
  position: relative;
  justify-self: center;
  align-self: center;
  width: 56px;
  height: min(300px, 56%);
  cursor: pointer;
  touch-action: none;
  /* on the whole slider, since the track's own outline would be clipped off with it */
  filter: drop-shadow(0 0 1px rgba(65, 30, 6, .45)) drop-shadow(0 2px 3px rgba(65, 30, 6, .18));
}
.size-track {
  position: absolute;
  inset: 0 6px;
  border-radius: 28px;
  background: var(--card);
  clip-path: polygon(0 0, 100% 0, 64% 100%, 36% 100%);
}
.size-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(var(--paper-deep), transparent);
  opacity: .5;
}
.size-knob {
  --d: calc(16px + var(--v) * 26px);
  position: absolute;
  left: 50%;
  top: calc(21px + (1 - var(--v)) * (100% - 42px));
  width: var(--d);
  height: var(--d);
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 0 3px #fff, 0 2px 6px 2px rgba(65, 30, 6, .3);
  pointer-events: none;
}
.size:focus-visible { outline: none; }
.size:focus-visible .size-knob { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--rust); }

/* the colors */
.colors {
  grid-area: colors;
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(2, var(--swatch));
  gap: 10px 12px;
  padding: 12px 10px;
}
.swatch {
  position: relative;
  width: var(--swatch);
  height: var(--swatch);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--s);
  box-shadow: inset 0 0 0 1px rgba(65, 30, 6, .18), 0 2px 4px rgba(65, 30, 6, .18);
  cursor: pointer;
  transition: transform .25s var(--spring), box-shadow .2s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] {
  transform: scale(1.12);
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--s), 0 4px 10px rgba(65, 30, 6, .3);
}
.swatch[data-light][aria-checked="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink-soft), 0 4px 10px rgba(65, 30, 6, .3); }
/* any color at all, from a wheel */
.wheel {
  --s: #fff;
  background: conic-gradient(#e53935, #fb8c00, #fdd835, #7cb342, #4fc3f7, #1e63c8, #8e44ad, #f48fb1, #e53935);
  overflow: hidden;
}
.wheel::after {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: var(--s);
  box-shadow: 0 0 0 2px #fff;
}
.wheel[aria-checked="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--ink-soft), 0 4px 10px rgba(65, 30, 6, .3); }
.wheel input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* the tools stand along the bottom; the one in hand comes up */
.tools {
  grid-area: tools;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(0px, 1.2vw, 14px);
  height: 122px;
  overflow: hidden;
  padding: 0 12px;
}
.tool {
  position: relative;
  flex: none;
  width: 58px;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tool svg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: auto;
  overflow: visible;
  transform: translateY(54px);
  transition: transform .35s var(--spring);
  filter: drop-shadow(0 3px 2px rgba(65, 30, 6, .22));
}
.tool:hover svg { transform: translateY(44px); }
.tool[aria-checked="true"] svg { transform: translateY(8px); }
.tool:focus-visible { outline: none; }
.tool:focus-visible svg { filter: drop-shadow(0 0 0 var(--rust)) drop-shadow(0 0 3px var(--rust)); }

/* phones held upright: the page across the top, then the size, colors and tools below */
@media (max-width: 760px) and (orientation: portrait) {
  .studio {
    --swatch: 38px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "top" "stage" "size" "colors" "tools";
  }
  .round { width: 44px; height: 44px; }
  .history { gap: 8px; }
  .size { width: min(300px, 70%); height: 44px; margin-top: 4px; }
  .size-track { inset: 6px 0; clip-path: polygon(0 36%, 100% 0, 100% 100%, 0 64%); }
  .size-track::after { background: linear-gradient(90deg, transparent, var(--paper-deep)); }
  .size-knob { left: calc(21px + var(--v) * (100% - 42px)); top: 50%; }
  .colors {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-template-rows: repeat(2, var(--swatch));
    gap: 8px;
    max-width: 100%;
    overflow-x: auto;
    padding: 10px 12px;
  }
  .tools { height: 96px; gap: 0; }
  .tool { width: 44px; }
  .tool svg { transform: translateY(46px); }
  .tool:hover svg { transform: translateY(40px); }
  .tool[aria-checked="true"] svg { transform: translateY(8px); }
}

/* short landscape screens (phones on their side) */
@media (max-height: 520px) and (orientation: landscape) {
  .studio { --swatch: 30px; grid-template-columns: 64px minmax(0, 1fr) calc(var(--swatch) * 3 + 36px); }
  .colors { grid-template-columns: repeat(3, var(--swatch)); }
  .studio-top { padding-block: 6px 2px; }
  .round { width: 40px; height: 40px; }
  .round svg { width: 20px; height: 20px; }
  .finish { padding: .6em 1.1em; font-size: .95rem; }
  .colors { gap: 6px 8px; padding: 6px; }
  .swatch[aria-checked="true"] { transform: scale(1.06); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--s); }
  .tools { height: 76px; }
  .tool { width: 42px; }
  .tool svg { transform: translateY(40px); }
  .tool[aria-checked="true"] svg { transform: translateY(6px); }
}

/* ---------- Done ---------- */

.done {
  width: min(100vw - 24px, 640px);
  max-height: calc(100dvh - 24px);
  margin: auto;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.done::backdrop {
  background: rgba(65, 30, 6, .45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.done[open] { animation: pop .45s var(--spring); }
@keyframes pop { from { opacity: 0; scale: .9; } }
.done-card {
  position: relative;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: clamp(22px, 4vw, 36px);
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.done-card h2 { margin: .4rem 0 1.2rem; font-size: clamp(1.8rem, 4.5vw, 2.5rem); }
.done-pic {
  width: 100%;
  max-height: 52dvh;
  object-fit: contain;
  margin: 0 auto 1.4rem;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  rotate: -1deg;
}
.done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.done-close { position: absolute; top: 12px; right: 12px; width: 42px; height: 42px; }
.done-close svg { width: 20px; height: 20px; }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100dvh; pointer-events: none; }

/* ---------- Printing: just the picture, filling a landscape page ---------- */

.print { display: none; }

@media print {
  @page { size: landscape; margin: 10mm; }
  body > *:not(.print) { display: none !important; }
  body { background: #fff; }
  .print { display: block; }
  .print img { width: 100%; height: auto; max-height: 100vh; object-fit: contain; }
}
