/* =============================================================
   Drawing studio. Phone first: the canvas gets the room, the
   controls sit under the thumb, every target is at least 44px.
   ============================================================= */

/* The studio page keeps its header small so the canvas and the toolbar can
   share the screen without scrolling. */
.section--tight { padding-block: clamp(1.2rem, 3vw, 2rem); }
.section--tight .section-head { margin-block-end: 1.1rem; }
.section--tight .section-head h1 {
  font-size: clamp(1.7rem, 1.3rem + 1.5vw, 2.6rem);
  margin-block-end: .3rem;
}
.section--tight .section-head p { margin-block-end: .5rem; font-size: .96rem; }
.section--tight .rule { margin-block: .5rem 0; }

.studio {
  display: grid;
  gap: 1rem;
  max-width: 1160px;
  margin-inline: auto;
}

/* On a wide screen the tools and the actions share one row, which keeps the
   toolbar short and hands the height back to the canvas. */
@media (min-width: 900px) {
  .studio__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .5rem;
  }
  .studio__bar .toolrow { flex: 0 1 auto; overflow: visible; }
  .studio__bar .panel { flex: 1 0 100%; }
}

/* =============================================================
   Canvas stage — glassmorphism.
   Soft colour shapes are laid down first; a frosted panel sits on
   top of them, so the blur actually has something to work with.
   ============================================================= */
.studio__stage {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(1rem, 3vw, 2rem);
  border-radius: 30px;
  overflow: hidden;
  /* The canvas is sized by JS once the page has laid out. Reserving the space
     here stops everything below it jumping when that happens (CLS). */
  min-height: clamp(300px, 62vh, 680px);
  background:
    radial-gradient(120% 100% at 15% 10%, rgba(20, 160, 106, .10), transparent 55%),
    linear-gradient(160deg, rgba(255, 255, 255, .75), rgba(223, 240, 231, .85));
  border: 1px solid var(--line-soft);
}

/* blurred colour clouds */
.studio__blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  z-index: -2;
  pointer-events: none;
}
.studio__blob--1 {
  width: 46%; aspect-ratio: 1;
  inset-block-start: -8%; inset-inline-start: 4%;
  background: radial-gradient(circle, rgba(112, 252, 86, .62), transparent 70%);
}
.studio__blob--2 {
  width: 40%; aspect-ratio: 1;
  inset-block-end: -10%; inset-inline-end: 6%;
  background: radial-gradient(circle, rgba(20, 160, 106, .45), transparent 70%);
}
.studio__blob--3 {
  width: 34%; aspect-ratio: 1;
  inset-block-end: 12%; inset-inline-start: -6%;
  background: radial-gradient(circle, rgba(60, 220, 160, .55), transparent 70%);
}

/* The crisp rounded squares peeking out from behind the glass. Tinted toward
   the site's turquoise rather than pure green so they belong here. */
.studio__tile {
  position: absolute;
  border-radius: 20px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(150deg, #70FC56, #21B7A6);
  opacity: .82;
  box-shadow: 0 18px 40px -22px rgba(33, 183, 166, .7);
}
.studio__tile--1 {
  width: 17%; aspect-ratio: 1;
  inset-block-start: 6%; inset-inline-end: 4%;
}
.studio__tile--2 {
  width: 10%; aspect-ratio: 1;
  inset-block-end: 22%; inset-inline-start: 2%;
  border-radius: 14px;
}
.studio__tile--3 {
  width: 8%; aspect-ratio: 1;
  inset-block-end: 5%; inset-inline-end: 26%;
  border-radius: 12px;
}

/* the frosted pane the canvas lives in */
.studio__glass {
  position: relative;
  /* Wraps the canvas exactly — the canvas takes its width from the stage, so
     there is no circular measurement here. */
  width: fit-content;
  max-width: 100%;
  padding: clamp(.5rem, 1.4vw, .9rem);
  border-radius: 26px;
  background: rgba(255, 255, 255, .62);
  border: 1px solid rgba(255, 255, 255, .85);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  backdrop-filter: blur(22px) saturate(150%);
  box-shadow:
    0 24px 60px -24px rgba(6, 20, 40, .65),
    inset 0 1px 0 rgba(255, 255, 255, .75);
}

#board {
  display: block;
  /* Before draw.js measures, the intrinsic 800x600 attributes scale like an
     image so the reserved box is already the right shape. */
  max-width: 100%;
  height: auto;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 6px 22px -14px rgba(12, 60, 44, .35);
  cursor: crosshair;
  max-width: 100%;
  /* Critical: the browser must never steal the gesture to scroll or zoom. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.studio[data-active-tool="eraser"] #board { cursor: cell; }

/* ------------------------------------------------------ toolbar */
.studio__bar {
  position: relative;
  display: grid;
  gap: .55rem;
  padding: .8rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, .70);
  border: 1px solid var(--line-soft);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 8px 24px -18px rgba(12, 60, 44, .35);
}

.toolrow {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-block-end: .15rem;
  -webkit-overflow-scrolling: touch;
}
.toolrow::-webkit-scrollbar { height: 4px; }
.toolrow::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.tool {
  flex: 0 0 auto;
  min-width: 60px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .18rem;
  padding: .4rem .55rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  background: rgba(12, 40, 32, .04);
  color: var(--text-dim);
  font: inherit;
  font-size: .68rem;
  line-height: 1.15;
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.tool .icon { width: 22px; height: 22px; }
.tool:hover:not([disabled]) { color: var(--white); border-color: var(--line); background: rgba(20, 160, 106, .10); }
.tool.is-active {
  background: var(--turquoise);
  border-color: var(--lime);
  box-shadow: 0 0 0 2px var(--lime-soft);
  color: var(--night-900);
  font-weight: 600;
}
.tool[disabled] { opacity: .35; cursor: not-allowed; }
.tool--wide { min-width: 84px; flex-direction: row; gap: .4rem; font-size: .78rem; }
.tool--danger:hover:not([disabled]) { color: #B7382E; border-color: #E4572E; background: rgba(183, 56, 46, .07); }

.colour-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(12, 40, 32, .25);
  box-shadow: 0 0 0 1px rgba(12, 40, 32, .12);
  flex: none;
}

/* -------------------------------------------------- drop panels */
.panel {
  display: none;
  padding: .85rem;
  margin-block-start: .15rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line);
}
.panel.is-open { display: block; }
.panel__title {
  margin: 0 0 .45rem;
  font-size: .78rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.panel__title:not(:first-child) { margin-block-start: 1rem; }

.swatches { display: flex; flex-wrap: wrap; gap: .45rem; }
.swatch {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(12, 40, 32, .18);
  cursor: pointer;
  padding: 0;
  transition: transform .15s var(--ease), border-color .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { border-color: var(--turquoise-light); box-shadow: 0 0 0 3px rgba(20, 160, 106, .32); }

.wheel { display: flex; justify-content: center; margin-block-start: .9rem; }
.wheel-fallback { color: var(--text-faint); font-size: .85rem; margin: 0 0 .5rem; }
.native-colour {
  width: 64px; height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
}

.slider-row { display: flex; align-items: center; gap: .9rem; }
.size-preview {
  flex: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--mist);
  box-shadow: 0 0 0 1px var(--line);
}

.panel input[type="range"] {
  width: 100%;
  height: 34px;
  accent-color: var(--turquoise);
  background: none;
  cursor: pointer;
}

/* ---------------------------------------------------- the form */
.draw-form {
  padding: 1.1rem;
  border-radius: 24px;
  background: rgba(255, 255, 255, .70);
  border: 1px solid var(--line-soft);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.draw-form__fields {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem;
  align-items: flex-end;
}
.draw-form .field { flex: 1 1 190px; margin: 0; }
.draw-form .field--narrow { flex: 0 1 110px; }
.draw-form label {
  display: block;
  font-size: .85rem;
  color: var(--text-dim);
  margin-block-end: .3rem;
}
.draw-form input[type="text"],
.draw-form input[type="number"] {
  width: 100%;
  padding: .7rem .85rem;
  font: inherit;
  font-size: 1rem;                 /* 16px stops iOS zooming on focus */
  color: var(--text);
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.draw-form input:focus {
  outline: none;
  border-color: var(--turquoise);
  box-shadow: 0 0 0 3px rgba(20, 160, 106, .18);
}
.draw-form .btn { flex: 0 0 auto; min-height: 48px; }
.draw-form .req { color: #B7382E; }

.draw-status { margin: .8rem 0 0; font-size: .9rem; min-height: 1.2em; }
.draw-status.is-error { color: #B7382E; }
.draw-status.is-info  { color: var(--turquoise-light); }

.draw-note {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin: .9rem 0 0;
  font-size: .84rem;
  /* --text-faint only reaches 4.15:1 on this panel; this clears 4.5:1. */
  color: var(--text-dim);
  line-height: 1.55;
}
.draw-note .icon { flex: none; color: var(--turquoise); margin-block-start: .15rem; }

/* ------------------------------------------------- thank you */
.sent-panel {
  padding: 1.6rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(79, 214, 160, .22), rgba(255, 255, 255, .92));
  border: 1px solid var(--turquoise);
  text-align: center;
}
.sent-panel__icon { width: 44px; height: 44px; color: var(--turquoise-light); margin-inline: auto; }
.sent-panel h2 { margin: .6rem 0 .3rem; }
.sent-panel p { color: var(--text-dim); max-width: 46ch; margin-inline: auto; }
.sent-panel .actions { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-block-start: 1.2rem; }
.studio.is-sent .studio__bar,
.studio.is-sent .draw-form { opacity: .4; pointer-events: none; }

/* ------------------------------------------ CTA on the kids page */
.draw-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.3rem;
  margin-block-end: 2rem;
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(79, 214, 160, .20), rgba(255, 255, 255, .85));
  border: 1px solid var(--line);
}
.draw-cta__icon { width: 34px; height: 34px; color: var(--turquoise-light); flex: none; }
.draw-cta__text { flex: 1 1 240px; display: grid; gap: .15rem; }
.draw-cta__text strong { color: var(--white); font-size: 1.05rem; }
.draw-cta__text span { color: var(--text-dim); font-size: .9rem; }

.kid__src {
  display: flex; align-items: center; gap: .35rem;
  margin: .35rem 0 0;
  font-size: .78rem;
  color: var(--turquoise-light);
}
.kid__src .icon { width: 15px; height: 15px; }

/* ------------------------------------------------ small screens */
@media (max-width: 560px) {
  .tool { min-width: 54px; min-height: 52px; font-size: .62rem; }
  .tool .icon { width: 20px; height: 20px; }
  .studio__stage { padding: .3rem; }
  .draw-form__fields .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .swatch:hover { transform: none; }
}
