/* Connect for Kids - Phase 1 styles. Bright, kid-safe, large readable text.
   No Tailwind CDN in shipped code. Android + iPhone parity:
   safe-area insets, dvh/svh units, never fixed 100vh, 44px minimum targets,
   no hover-only UI, playsinline + muted autoplay for any media. */

* { box-sizing: border-box; }

:root {
  --tap: 44px; /* minimum touch target */
  --radius: 20px;
  --font: "Comic Sans MS", "Chalkboard SE", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Light theme (DEFAULT) */
html[data-theme="light"] {
  --bg: #fff7e6;
  --surface: #ffffff;
  --surface-soft: #ffeecf;
  --text: #22223b;
  --muted: #5a5a72;
  --accent: #ff6b35;
  --accent-2: #2ec4b6;
  --accent-3: #ffd166;
  --border: #ffd166;
  --danger: #d00000;
  --ok: #2a9d8f;
  --shadow: 0 4px 16px rgba(34, 34, 59, 0.12);
}

/* Dark theme */
html[data-theme="dark"] {
  --bg: #1b1b2f;
  --surface: #2a2a44;
  --surface-soft: #34345a;
  --text: #f8f7ff;
  --muted: #c9c9e0;
  --accent: #ff8c5a;
  --accent-2: #4dd0c4;
  --accent-3: #ffd166;
  --border: #4a4a6e;
  --danger: #ff6b6b;
  --ok: #4dd0c4;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
  line-height: 1.5;
  min-height: 100dvh;
  min-height: 100svh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

h1 { font-size: 32px; line-height: 1.2; margin: 0; }
h2 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
h3 { font-size: 22px; margin: 0 0 6px; }
p { margin: 0 0 12px; }

.card {
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

button, .btn {
  font-family: var(--font);
  font-size: 19px;
  font-weight: 700;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 20px;
  border-radius: 999px;
  border: 3px solid transparent;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

button.secondary { background: var(--accent-2); color: #ffffff; }
button.ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
button.danger { background: var(--danger); color: #ffffff; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 4px solid var(--accent-3);
  outline-offset: 2px;
}

label { display: block; font-weight: 700; font-size: 19px; margin: 14px 0 6px; }
input[type="text"], input[type="number"], select, textarea {
  font-family: var(--font);
  font-size: 19px;
  min-height: var(--tap);
  width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  border: 3px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.career-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.career-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 3px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
}
.career-pick input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.avatar-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 3px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
}
.avatar-pick input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }
.avatar-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-3); color: #22223b; }
.kid-avatar { font-size: 26px; }
.kid-row select { flex: 1 1 160px; width: auto; }
/* Time is up: the kid home shows only the hero + the time-up note. */
#kidHomeView.time-up section:not(.kid-hero) { display: none; }
#timeUpBox { font-size: 22px; font-weight: 700; }
.career-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-3); color: #22223b; }

.kid-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 2px dashed var(--border);
}
.kid-row:last-child { border-bottom: 0; }
.kid-row .kid-info { flex: 1 1 160px; }
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--accent-3);
  color: #22223b;
  font-size: 15px;
  font-weight: 700;
}
.badge.paused { background: var(--accent-2); color: #ffffff; }
.badge.closed { background: var(--danger); color: #ffffff; }

.code-box {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 10px;
  text-align: center;
  background: var(--surface-soft);
  border: 3px dashed var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
}
.code-box input {
  font-size: 40px;
  letter-spacing: 10px;
  text-align: center;
  border: 0;
  background: transparent;
  width: 100%;
}
.code-box input:focus-visible { outline: none; }

.feed { display: grid; gap: 16px; }
.content-card { overflow: hidden; }
.content-card .pic { font-size: 64px; text-align: center; line-height: 1; margin-bottom: 8px; }
.content-card .read-btn { margin-top: 10px; }

.notice {
  background: var(--surface-soft);
  border: 3px solid var(--accent-2);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 17px;
}
.notice.error { border-color: var(--danger); }
.hint { color: var(--muted); font-size: 16px; }
.hidden { display: none !important; }

.theme-toggle { font-size: 16px; padding: 8px 16px; }

nav.view-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
nav.view-tabs button { flex: 1 1 120px; }

footer { text-align: center; color: var(--muted); font-size: 15px; margin-top: auto; }

/* Small phones: keep everything reachable, no horizontal scroll. */
@media (max-width: 400px) {
  h1 { font-size: 28px; }
  .career-grid { grid-template-columns: repeat(2, 1fr); }
  .code-box { font-size: 32px; letter-spacing: 6px; }
  .code-box input { font-size: 32px; letter-spacing: 6px; }
}

/* ---- Polish pass (19 Nov 2026): career colour, mascots, kid tiles,
   digit pad, rewards, quiz, activities. Dark stays joyful, never dull grey. ---- */
:root { --career-colour: #ff6b35; }
body[data-career] { --accent: var(--career-colour); }
.kid-hero {
  background: linear-gradient(135deg, var(--career-colour) 0%, var(--accent-3) 100%);
  border-color: var(--career-colour);
  color: #22223b;
  text-align: center;
}
html[data-theme="dark"] .kid-hero {
  background: linear-gradient(135deg, var(--career-colour) 0%, #3b2a6e 100%);
  color: #ffffff;
}
.kid-hero .hint, .kid-hero .badge { color: #22223b; }
html[data-theme="dark"] .kid-hero .hint { color: #ffeecf; }
.mascot { font-size: 72px; line-height: 1; }
.rewards-bar { font-size: 20px; font-weight: 800; background: var(--surface); border-radius: 999px; padding: 10px 16px; display: inline-block; }

/* Huge kid profile tiles: one tap to enter */
.kid-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 12px 0; }
.kid-tile {
  min-height: 120px; background: var(--surface-soft); border: 4px solid var(--border);
  border-radius: 20px; padding: 14px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 6px; font-family: var(--font); font-size: 19px; font-weight: 700; color: var(--text);
}
.kid-tile.picked { border-color: var(--accent); background: var(--accent-3); color: #22223b; }
.kid-face {
  width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 800; color: #ffffff; background: var(--accent);
}
.kid-tile-name { font-size: 22px; }

/* On-screen digit pad: 64px keys for little fingers */
.digit-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; margin: 12px auto; }
.digit-pad button {
  min-height: 64px; min-width: 64px; font-size: 28px; font-weight: 800; border-radius: 20px;
  border: 3px solid var(--border); background: var(--surface-soft); color: var(--text); cursor: pointer; font-family: var(--font);
}
.digit-pad button:active { background: var(--accent-3); }

/* Quiz options + picked/correct/wrong states */
.quiz-opt { display: block; width: 100%; margin: 6px 0; text-align: left; }
.quiz-opt.picked { border-color: var(--accent); background: var(--accent-3); color: #22223b; }
.quiz-opt.correct { background: var(--ok); color: #ffffff; border-color: var(--ok); }
.quiz-opt.wrong { background: var(--danger); color: #ffffff; border-color: var(--danger); }
.ka-feedback { font-size: 22px; font-weight: 800; min-height: 32px; margin: 10px 0; }

/* Career picker chips wear their career colour */
.career-pick[data-career="doctor"] { border-color: #0ea5a4; }
.career-pick[data-career="lawyer"] { border-color: #8b1e3f; }
.career-pick[data-career="teacher"] { border-color: #7c3aed; }
.career-pick[data-career="farmer"] { border-color: #22a03c; }
.career-pick[data-career="builder"] { border-color: #f97316; }
.career-pick[data-career="footballer"] { border-color: #e11d48; }
.career-pick[data-career="tech"] { border-color: #2563eb; }
.career-pick[data-career="artist"] { border-color: #ec4899; }
.career-pick[data-career="musician"] { border-color: #eab308; }
.career-pick[data-career="pilot"] { border-color: #0284c7; }
.career-pick[data-career="police-firefighter"] { border-color: #1e40af; }
.career-pick[data-career="chef"] { border-color: #b45309; }
.career-pick[data-career="scientist"] { border-color: #65a30d; }
.career-pick[data-career="inventor"] { border-color: #c026d3; }

/* ---- Young Inventors showcase (20 Nov 2026) ---- */
.showcase-card { border: 4px solid #c026d3; }
.showcase-tag { background: #c026d3; color: #ffffff; }
.showcase-steps { font-size: 19px; line-height: 1.5; padding-left: 28px; margin: 0 0 12px; }
.showcase-steps li { margin-bottom: 6px; }
.part-chip { margin: 2px; background: var(--surface-soft); border: 2px solid var(--border); }
.clap-btn { margin-top: 10px; }
.clap-count { font-size: 20px; font-weight: 800; margin-left: 10px; }
/* ---- Showcase demo video (20 Nov 2026) ---- */
/* Vertical 720x1280 file: full card width, capped height, black backing. */
.showcase-video-wrap { margin: 12px 0; }
.showcase-video { width: 100%; max-height: 520px; border-radius: 16px; background: #000000; display: block; }
/* Videos shelf (21 Nov 2026): 44px chip targets, 16:9 players, no fixed
   viewport heights anywhere - the page scrolls, the player keeps its ratio. */
.video-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.video-filters .video-chip { min-height: 44px; min-width: 44px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--border); background: var(--surface-soft); color: var(--text); font-size: 15px; cursor: pointer; }
.video-filters .video-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-3); color: #22223b; }
.video-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 16px; display: block; background: #000000; }
.video-player-wrap { margin: 12px 0; }
.video-player-wrap .video-frame, .video-player-wrap .video-frame iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 16px; background: #000000; display: block; }
.video-hosted { width: 100%; max-height: 520px; border-radius: 16px; background: #000000; display: block; }
.video-cannot-play { padding: 16px; border-radius: 16px; background: var(--surface-soft); text-align: center; }
.video-quiz { margin-top: 12px; }
.sc-quiz-q { border: 3px dashed var(--border); border-radius: 14px; padding: 12px; margin: 10px 0; }
.sc-quiz-q input, .sc-quiz-q select { margin-bottom: 8px; }

/* ---- Kids animation gate (front door, 19 Nov 2026) ---- */
.gate-card { text-align: center; padding: 28px 20px; }
.gate-art svg { width: 100%; max-width: 340px; height: auto; display: block; margin: 0 auto; }
.gate-sub { font-size: 22px; font-weight: 700; }
#gateEnterBtn { font-size: 24px; min-height: 64px; padding: 14px 28px; }
/* ---- Tap feedback (20 Nov 2026): every clickable thing must FEEL clicked.
   Top-app pattern, kid-sized: instant pressed state on touch (scale +
   bright colour, ~150ms), never hover-only. :active covers mouse and most
   touch; .is-pressed is added by JS on touchstart/pointerdown for iOS
   Safari, where :active alone is unreliable, and removed on
   touchend/touchcancel/pointerup. Feedback only: no handler, label,
   layout or text changed. ---- */
button, .btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  transition: transform 150ms ease, background-color 150ms ease, filter 150ms ease, opacity 150ms ease;
}
button:active, .btn:active,
button.is-pressed, .btn.is-pressed {
  transform: scale(0.96);
  filter: brightness(1.08);
}
/* Big kid surfaces press a touch more, so little fingers see it clearly. */
.kid-tile:active, .kid-tile.is-pressed { transform: scale(0.95); background: var(--accent-3); }
.career-pick:active, .career-pick.is-pressed,
.avatar-pick:active, .avatar-pick.is-pressed { transform: scale(0.97); background: var(--accent-3); }
.quiz-opt:active, .quiz-opt.is-pressed { transform: scale(0.97); }
.digit-pad button:active, .digit-pad button.is-pressed {
  background: var(--accent-3);
  transform: scale(0.94);
  filter: brightness(1.05);
}
/* Disabled must read as un-tappable: greyed, no press, no dead silence. */
button:disabled { opacity: 0.55; cursor: not-allowed; filter: grayscale(0.45); }
button:disabled:active, button:disabled.is-pressed { transform: none; filter: grayscale(0.45); }
/* Loading: spinner beside the label while the tap is working. Set by JS
   (demo video, clap, kid sign-in, parent row actions). */
@keyframes tap-spin { to { transform: rotate(360deg); } }
button.is-loading { pointer-events: none; }
button.is-loading::after {
  content: '';
  width: 18px; height: 18px; flex: none;
  border: 3px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: tap-spin 0.8s linear infinite;
}
button.ghost.is-loading::after { border-color: rgba(34, 34, 59, 0.25); border-top-color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  button, .btn { transition: none; }
  button.is-loading::after { animation-duration: 1.6s; }
}

/* One-shot joyful entrance: rainbow draws in, sun pops, face bounces once,
   stars twinkle once. No loops, no flashing. Respects reduced motion. */
.gate-arc { stroke-dasharray: 400; stroke-dashoffset: 400; animation: gate-draw 0.9s ease-out forwards; }
.gate-arc.arc-2 { animation-delay: 0.15s; }
.gate-arc.arc-3 { animation-delay: 0.3s; }
.gate-sun { transform-origin: 248px 42px; animation: gate-pop 0.6s ease-out 0.35s both; }
.gate-face { transform-origin: 150px 118px; animation: gate-bounce 0.7s ease-out 0.5s both; }
.gate-star { animation: gate-twinkle 0.8s ease-out 0.7s both; }
@keyframes gate-draw { to { stroke-dashoffset: 0; } }
@keyframes gate-pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes gate-bounce { 0% { transform: scale(0) translateY(20px); } 60% { transform: scale(1.08) translateY(-4px); } 100% { transform: scale(1) translateY(0); } }
@keyframes gate-twinkle { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .gate-arc, .gate-sun, .gate-face, .gate-star { animation: none; stroke-dashoffset: 0; opacity: 1; transform: none; }
}
