/* ─────────────────────────────────────────────────────────────────
   css/coloring-page.css  (2026-06-23, rebuilt to match the builder
   design system — NOT bolted on)

   The Build-rail CARD reuses .smart-tpl-card (already native — it sits
   in the same list as Image or PDF / Social story). This file styles
   only the MODAL, scoped under .coloring-modal, mirroring the
   game-builder-wizard chrome exactly so it reads as one system:
     • white "paper" creation-modal card with a subtle amber tint
     • NAVY gradient header (#1A1A2E→#161527) + cream text + amber icon
     • spring entrance (translateY + cubic-bezier(0.16,1,0.3,1))
     • option cards with hover-lift, focus ring, amber SELECTED halo + ✓
     • amber-gradient primary, neutral secondary
   Text/surfaces inside are fixed light-paper (like the wizard header),
   so the modal is readable and consistent in BOTH app themes — the
   earlier version put theme-flipping --ink text on hardcoded light
   panels, which vanished in the builder's dark theme.
   Tokens used: --bb-ease-spring (press/entrance motion), --amber.
   Depth + microinteractions match the Rehab kiosk so the two features
   read as one premium system (spring entrance, press feedback, selected
   ✓ pop, preview reveal). Everything else is the same fixed paper
   palette the wizard uses. Honors prefers-reduced-motion.
   ───────────────────────────────────────────────────────────────── */

/* ── Modal card: white paper + spring entrance (mirrors the wizard) ── */
.coloring-modal {
  background:
    radial-gradient(at 0% 0%, rgba(232, 163, 61, 0.05) 0%, transparent 55%),
    #ffffff;
  color: #1f1b2e;
  border: 1px solid rgba(12, 21, 48, 0.08);
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 20px 60px rgba(12, 21, 48, 0.30);
  transform: translateY(16px) scale(0.97);
  transition: transform 360ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), opacity 240ms ease;
}
.smart-tpl-modal.open .coloring-modal { transform: none; }

/* ── Header: navy bar, cream text, amber-lit icon ──────────────── */
.coloring-modal .smart-tpl-modal-head {
  background: linear-gradient(180deg, #1A1A2E 0%, #161527 100%);
  border-bottom: 1px solid rgba(232, 168, 56, 0.20);
}
.coloring-modal .smart-tpl-modal-icon {
  filter: drop-shadow(0 2px 6px rgba(232, 168, 56, 0.30));
}
.coloring-modal .smart-tpl-modal-head h3 { color: #F5EDE0; letter-spacing: -0.01em; }
.coloring-modal .smart-tpl-modal-close {
  color: rgba(245, 237, 224, 0.85);
  transition: background 140ms ease, transform 140ms ease;
}
.coloring-modal .smart-tpl-modal-close:hover {
  background: rgba(245, 237, 224, 0.16);
  color: #fff;
  transform: rotate(90deg);
}

/* ── Body labels (fixed dark on the paper card) ────────────────── */
.coloring-modal .smart-tpl-label { color: #2a2438; }

/* ── Privacy reassurance — calm teal, distinct from amber actions ── */
.coloring-modal .cp-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  line-height: 1.4;
  color: #2c5450;
  background: #eef7f6;
  border: 1px solid #cfe7e4;
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
}
.coloring-modal .cp-note-icon { flex-shrink: 0; }
.coloring-modal .cp-note strong { color: #1f3f3c; }

/* ── Step 1: branded photo picker (drop-zone feel) ─────────────── */
.cp-file-native {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.coloring-modal .cp-filebtn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 0.85rem;
  border: 1.5px dashed #D6CFC0;
  border-radius: 14px;
  background: #FBF8F2;
  color: #4a4458;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(12, 21, 48, 0.05);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), box-shadow 160ms ease;
}
.coloring-modal .cp-filebtn:hover {
  border-color: var(--amber, #E8A838);
  background: #fff7e6;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(12, 21, 48, 0.10);
}
.coloring-modal .cp-filebtn:active { transform: scale(0.985); box-shadow: 0 1px 3px rgba(12, 21, 48, 0.05); }
.cp-file-native:focus-visible + .cp-filebtn,
.coloring-modal .cp-filebtn.cp-dragover {
  border-color: #E8A838;
  border-style: solid;
  background: #fff3da;
  box-shadow: 0 0 0 3px rgba(232, 168, 56, 0.20);
}
.coloring-modal .cp-filebtn-icon { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.coloring-modal .cp-filebtn-text {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Step 2: skill-level option cards (mirror .gbw-*-card) ──────── */
.cp-levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.coloring-modal .cp-level {
  position: relative;            /* for the ✓ badge */
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  border: 1.5px solid rgba(12, 21, 48, 0.10);
  border-radius: 14px;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(12, 21, 48, 0.05);
  transition: transform 160ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}
.coloring-modal .cp-level:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(12, 21, 48, 0.12);
  border-color: rgba(232, 168, 56, 0.45);
}
.coloring-modal .cp-level:active { transform: translateY(0) scale(0.98); }
.cp-level-input {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0;
}
/* Selected — amber halo + gradient + ✓ badge (brand accent). */
.coloring-modal .cp-level:has(.cp-level-input:checked) {
  border-color: #E8A838;
  background: linear-gradient(180deg, #FFFCF3 0%, #FFF6DE 100%);
  box-shadow:
    0 0 0 3px rgba(232, 168, 56, 0.18),
    0 4px 14px rgba(232, 168, 56, 0.20);
}
.coloring-modal .cp-level:has(.cp-level-input:checked)::after {
  content: "✓";
  position: absolute;
  top: 8px; right: 9px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #F2B249 0%, #E8A838 100%);
  color: #fff;
  font: 700 11px/18px system-ui, sans-serif;
  text-align: center;
  box-shadow: 0 1px 3px rgba(232, 168, 56, 0.40);
  animation: cpCheckPop 0.32s var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}
@keyframes cpCheckPop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.coloring-modal .cp-level:has(.cp-level-input:focus-visible) {
  outline: 2px solid #E8A838;
  outline-offset: 2px;
}
.cp-level-emoji {
  font-size: 1.4rem; line-height: 1; flex-shrink: 0;
  filter: drop-shadow(0 2px 5px rgba(12, 21, 48, 0.10));
}
.cp-level-body { display: flex; flex-direction: column; min-width: 0; }
.coloring-modal .cp-level-name { font-weight: 700; font-size: 0.84rem; color: #211c30; }
.coloring-modal .cp-level-hint { font-size: 0.72rem; color: #6b6577; line-height: 1.2; }

/* ── Primary make button — amber gradient, spring ──────────────── */
.coloring-modal .cp-make {
  width: 100%;
  margin-top: 0.4rem;
  background: linear-gradient(180deg, #F2B24A 0%, #E8A838 100%);
  border-color: #E2A02E;
  box-shadow: 0 4px 14px rgba(232, 168, 56, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 180ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1)), box-shadow 180ms ease, filter 180ms ease;
}
.coloring-modal .cp-make:hover:not([disabled]) {
  transform: translateY(-2px);
  filter: brightness(1.03);
  box-shadow: 0 10px 26px rgba(232, 168, 56, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
.coloring-modal .cp-make:active:not([disabled]) { transform: translateY(0) scale(0.985); box-shadow: 0 3px 10px rgba(232, 168, 56, 0.30); }
.coloring-modal .cp-make[disabled] { filter: grayscale(0.25); box-shadow: none; }

/* ── Errors ────────────────────────────────────────────────────── */
.coloring-modal .cp-error {
  font-size: 0.85rem;
  color: #b42318;
  background: #fdf0ee;
  border: 1px solid #f3c6c0;
  border-radius: 12px;
  padding: 0.6rem 0.75rem;
  margin-top: 0.65rem;
}

/* ── Preview + export ──────────────────────────────────────────── */
.cp-preview {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(12, 21, 48, 0.08);
  animation: cpPreviewIn 360ms var(--bb-ease-spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}
@keyframes cpPreviewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.cp-canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 48vh;
  object-fit: contain;
  background: #ffffff;
  border: 1px solid #E2DCD0;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(12, 21, 48, 0.08);
}
.cp-actions { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.coloring-modal .cp-actions #cpDownload {
  flex: 1 1 auto;
  background: linear-gradient(180deg, #F2B24A 0%, #E8A838 100%);
  border-color: #E2A02E;
}
.coloring-modal .cp-actions #cpPrint {
  flex: 0 0 auto;
  background: #ffffff;
  color: #2a2438;
  border-color: rgba(12, 21, 48, 0.16);
}
.coloring-modal .cp-actions #cpDownload:hover { transform: translateY(-2px); filter: brightness(1.03); }
.coloring-modal .cp-actions #cpPrint:hover { background: #f6f3ee; transform: translateY(-1px); }
.coloring-modal .cp-actions #cpDownload:active,
.coloring-modal .cp-actions #cpPrint:active,
.coloring-modal #cpClose:active { transform: scale(0.985); }

/* ── Footer Close (neutral on the paper card) ──────────────────── */
.coloring-modal .smart-tpl-modal-foot { border-top-color: rgba(12, 21, 48, 0.08); }
.coloring-modal #cpClose { color: #4a4458; border-color: rgba(12, 21, 48, 0.16); }
.coloring-modal #cpClose:hover { background: #f6f3ee; color: #1f1b2e; }

/* Reduced-motion: honor the user setting. */
@media (prefers-reduced-motion: reduce) {
  .coloring-modal,
  .coloring-modal .cp-make,
  .coloring-modal .cp-level,
  .coloring-modal .cp-filebtn { transition: none; }
  .cp-preview { animation: none; }
  .coloring-modal .cp-level:has(.cp-level-input:checked)::after { animation: none; }
}

/* Narrow phones: stack the level chips one per row. */
@media (max-width: 380px) { .cp-levels { grid-template-columns: 1fr; } }
