/* ===========================================================================
 * IrisKids — Photomaton (kids-photomaton)
 * Style mobile-first, palette violet (--ik-accent: #8b5cf6) cohérente avec la
 * carte "Outils créatifs" de la home. Identité IrisKids classique : fond
 * gradient pastel, gros boutons, emojis comme repères visuels.
 *
 * Architecture des écrans : 4 sections <section class="screen">, une seule
 * porte .screen--active à la fois (display:flex), les autres sont display:none.
 * photomaton.js bascule la classe sur le bon écran.
 * ========================================================================== */

/* ──────────────────────────────────────────────────────────────────────────
 * Reset léger + variables
 * ────────────────────────────────────────────────────────────────────────── */
:root {
  --pm-accent: #8b5cf6;
  --pm-accent-dark: #6d28d9;
  --pm-accent-light: #c4b5fd;
  --pm-ink: #1a1033;
  --pm-ink-soft: #4c1d95;
  --pm-bg: #fffafc;
  --pm-card-bg: #ffffffea;
  --pm-shadow: 0 8px 24px rgba(109, 40, 217, 0.15);
  --pm-radius: 16px;
  --pm-strip-bg: #ffffff;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--ik-font, 'Baloo 2', system-ui, -apple-system, sans-serif);
  color: var(--pm-ink);
  background:
    radial-gradient(circle at 15% -10%, #ede9fe 0%, transparent 45%),
    radial-gradient(circle at 100% 100%, #fce7f3 0%, transparent 50%),
    var(--pm-bg);
  overscroll-behavior: none;
}

body {
  padding-top: var(--ik-header-h, 52px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.hidden { display: none !important; }

/* ──────────────────────────────────────────────────────────────────────────
 * Layout des écrans : un seul visible à la fois.
 * ────────────────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 1.25rem 1rem;
  gap: 1.25rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.screen--active {
  display: flex;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Hero (utilisé écran welcome + done)
 * ────────────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 1.5rem 0 0.5rem;
}
.hero--compact { padding: 0.5rem 0; }

.hero-emoji {
  font-size: 4.5rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.hero-title {
  margin: 0 0 0.5rem;
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--pm-ink);
  letter-spacing: -0.02em;
}

.hero-sub {
  margin: 0;
  font-size: 1.05rem;
  color: var(--pm-ink-soft);
  font-weight: 600;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 1rem auto 0;
  padding: 0.4rem 0.9rem;
  background: #f5f3ff;
  border: 1px solid var(--pm-accent-light);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--pm-ink-soft);
  font-weight: 600;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Boutons géants (welcome + done) et boutons standard
 * ────────────────────────────────────────────────────────────────────────── */
.welcome-actions, .done-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
  align-items: stretch;
}

.btn-giant {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.1rem 1.5rem;
  border: 0;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .08s ease, box-shadow .15s ease;
}

.btn-giant:active { transform: scale(0.97); }

.btn-giant--primary {
  background: linear-gradient(135deg, var(--pm-accent), #ec4899);
  color: #fff;
  box-shadow: var(--pm-shadow);
}

.btn-giant--secondary {
  background: #fff;
  color: var(--pm-ink);
  border: 2px solid var(--pm-accent-light);
}

.btn-giant-icon { font-size: 1.4rem; line-height: 1; }

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border-radius: 999px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: 0;
  transition: transform .08s ease;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--pm-accent), #ec4899);
  color: #fff;
  box-shadow: var(--pm-shadow);
}

.btn-secondary {
  background: #fff;
  color: var(--pm-ink);
  border: 2px solid var(--pm-accent-light);
}

.error-msg {
  margin: 1rem auto 0;
  padding: 0.8rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: var(--pm-radius);
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  max-width: 28rem;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Écran 2 — CABINE
 * ────────────────────────────────────────────────────────────────────────── */
.cabin-counter {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.4rem;
  font-weight: 700;
  color: var(--pm-ink-soft);
  font-size: 1.1rem;
}
.cabin-counter strong {
  font-size: 1.5rem;
  color: var(--pm-accent-dark);
}
.cabin-counter-label { text-transform: lowercase; }

.cabin-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--pm-radius);
  overflow: hidden;
  box-shadow: var(--pm-shadow);
}

#cabin-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Effet miroir comme une glace : intuitif pour les enfants */
  transform: scaleX(-1);
}

.cabin-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,0.5);
  pointer-events: none;
  animation: countdown-pop 1s ease-out;
}

@keyframes countdown-pop {
  0%   { transform: scale(0.3); opacity: 0; }
  20%  { transform: scale(1.2); opacity: 1; }
  80%  { transform: scale(1.0); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0; }
}

.cabin-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.cabin-flash.is-flashing {
  animation: flash 0.4s ease-out;
}
@keyframes flash {
  0%   { opacity: 0; }
  10%  { opacity: 0.95; }
  100% { opacity: 0; }
}

.cabin-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  width: 100%;
}

.cabin-thumb {
  aspect-ratio: 4 / 3;
  background: #fff;
  border: 2px dashed var(--pm-accent-light);
  border-radius: 8px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.cabin-thumb.is-filled {
  border: 2px solid var(--pm-accent);
  border-style: solid;
}

.btn-shutter {
  align-self: center;
  width: 84px; height: 84px;
  border: 0; background: transparent; padding: 0;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
}

.btn-shutter:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-shutter-ring {
  position: absolute; inset: 0;
  border: 4px solid var(--pm-ink);
  border-radius: 50%;
}

.btn-shutter-dot {
  width: 64px; height: 64px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: inset 0 -4px 8px rgba(0,0,0,0.2);
  transition: transform .1s ease;
}

.btn-shutter:active .btn-shutter-dot { transform: scale(0.85); }

/* ──────────────────────────────────────────────────────────────────────────
 * Écran 3 — STUDIO
 * ────────────────────────────────────────────────────────────────────────── */
.studio-preview-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0.5rem 0;
}

.studio-preview {
  background: var(--pm-strip-bg);
  padding: 12px;
  border-radius: var(--pm-radius);
  box-shadow: var(--pm-shadow);
  display: flex;
  flex-direction: column;
  width: min(280px, 88vw);
  position: relative;
  overflow: hidden;
}

/* Bandeaux de cadre thématique (top + bot) - vides par défaut, remplis selon
   data-frame via les variables CSS injectées plus bas. */
.studio-frame-band {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  letter-spacing: 0.4em;
  user-select: none;
  flex-shrink: 0;
  transition: height .2s ease;
}

.studio-photos {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.studio-photo {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #f5f3ff;
  border-radius: 8px;
  overflow: hidden;
}

.studio-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Le filtre est posé via une variable CSS injectée par JS sur .studio-photos */
  filter: var(--pm-filter, none);
  /* Pas de mirror ici : la photo a été dé-mirorée à la capture pour l'export */
}

.studio-stickers {
  position: absolute;
  inset: 0;
  pointer-events: none; /* les emojis ont pointer-events: auto individuellement */
}

.sticker-instance {
  position: absolute;
  font-size: 2rem;
  line-height: 1;
  cursor: grab;
  user-select: none;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  transition: transform .08s ease;
}
.sticker-instance:active { cursor: grabbing; transform: translate(-50%, -50%) scale(1.15); }

/* ─── Cadres thématiques ──────────────────────────────────────────────────
 * On utilise data-frame sur .studio-preview pour piloter background +
 * contenu des bandeaux via ::before/::after de chaque bandeau.
 * ─────────────────────────────────────────────────────────────────────── */

/* Pirate ☠️ — parchemin + drapeaux */
.studio-preview[data-frame="pirate"] {
  background: linear-gradient(135deg, #fde68a, #fcd34d, #f59e0b);
  box-shadow: 0 8px 24px rgba(180, 83, 9, 0.3), inset 0 0 20px rgba(180, 83, 9, 0.15);
}
.studio-preview[data-frame="pirate"] .studio-frame-band {
  height: 38px;
  background: #422006;
  color: #fde68a;
}
.studio-preview[data-frame="pirate"] .studio-frame-band--top::before {
  content: "☠️ ⚓ ☠️ ⚓ ☠️";
  letter-spacing: 0.3em;
}
.studio-preview[data-frame="pirate"] .studio-frame-band--bot::before {
  content: "⚔️ 🏴‍☠️ ⚔️ 🏴‍☠️ ⚔️";
  letter-spacing: 0.3em;
}

/* Princesse 👑 — rose pastel + étoiles */
.studio-preview[data-frame="princesse"] {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8, #f9a8d4);
  box-shadow: 0 8px 24px rgba(190, 24, 93, 0.25), inset 0 0 20px rgba(190, 24, 93, 0.1);
}
.studio-preview[data-frame="princesse"] .studio-frame-band {
  height: 38px;
  background: #831843;
  color: #fce7f3;
}
.studio-preview[data-frame="princesse"] .studio-frame-band--top::before {
  content: "👑 ✨ 👑 ✨ 👑";
  letter-spacing: 0.3em;
}
.studio-preview[data-frame="princesse"] .studio-frame-band--bot::before {
  content: "🌸 💖 🌸 💖 🌸";
  letter-spacing: 0.3em;
}

/* Super-héros 🦸 — bleu + étoiles + pow */
.studio-preview[data-frame="hero"] {
  background: linear-gradient(135deg, #dbeafe, #93c5fd, #3b82f6);
  box-shadow: 0 8px 24px rgba(29, 78, 216, 0.3), inset 0 0 20px rgba(29, 78, 216, 0.15);
}
.studio-preview[data-frame="hero"] .studio-frame-band {
  height: 38px;
  background: #1e3a8a;
  color: #fde68a;
}
.studio-preview[data-frame="hero"] .studio-frame-band--top::before {
  content: "💥 ⭐ 💥 ⭐ 💥";
  letter-spacing: 0.3em;
}
.studio-preview[data-frame="hero"] .studio-frame-band--bot::before {
  content: "⚡ 🦸 ⚡ 🦸 ⚡";
  letter-spacing: 0.3em;
}

/* ─── Palette d'outils en bas (tabs) ──────────────────────────────────────── */
.studio-tools {
  background: var(--pm-card-bg);
  backdrop-filter: blur(6px);
  border-radius: var(--pm-radius);
  padding: 0.5rem;
  box-shadow: 0 2px 12px rgba(109, 40, 217, 0.08);
}

.studio-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e9d5ff;
  margin-bottom: 0.5rem;
}

.studio-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.5rem;
  background: transparent;
  border: 0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pm-ink-soft);
  cursor: pointer;
}
.studio-tab--active {
  background: var(--pm-accent);
  color: #fff;
}
.studio-tab-emoji { font-size: 1.4rem; line-height: 1; }

.studio-panel {
  display: none;
  padding: 0.5rem 0.25rem;
  min-height: 96px;
}
.studio-panel--active { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: stretch; }

.studio-hint {
  flex: 1 0 100%;
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--pm-ink-soft);
  text-align: center;
}

/* Filtre buttons */
.filter-btn, .frame-btn {
  flex: 1 0 calc(33.33% - 0.35rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 0.3rem;
  background: #fff;
  border: 2px solid #ede9fe;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--pm-ink);
  cursor: pointer;
  transition: transform .08s ease, border-color .15s ease;
}
.filter-btn:active, .frame-btn:active { transform: scale(0.97); }
.filter-btn--active, .frame-btn--active {
  border-color: var(--pm-accent);
  background: #faf5ff;
  box-shadow: 0 0 0 3px #ede9fe inset;
}
.filter-emoji, .frame-emoji { font-size: 1.5rem; line-height: 1; }

/* Stickers palette */
.sticker-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  width: 100%;
}

.sticker-btn {
  aspect-ratio: 1;
  background: #fff;
  border: 2px solid #ede9fe;
  border-radius: 12px;
  font-size: 1.6rem;
  cursor: pointer;
  transition: transform .08s ease, border-color .15s ease;
  padding: 0;
  font-family: inherit;
}
.sticker-btn:active { transform: scale(0.92); }
.sticker-btn:hover { border-color: var(--pm-accent); }

/* Actions globales studio */
.studio-actions {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.75rem;
  margin-top: 0.25rem;
}

/* ──────────────────────────────────────────────────────────────────────────
 * Écran 4 — DONE
 * ────────────────────────────────────────────────────────────────────────── */
.done-preview-wrap {
  display: flex;
  justify-content: center;
  padding: 0.5rem 0;
}

.done-preview {
  max-width: min(280px, 80vw);
  height: auto;
  border-radius: var(--pm-radius);
  box-shadow: var(--pm-shadow);
}

/* ──────────────────────────────────────────────────────────────────────────
 * Tablet/desktop : le studio passe en 2 colonnes (preview à gauche, palette à droite)
 * ────────────────────────────────────────────────────────────────────────── */
@media (min-width: 720px) {
  .hero-title { font-size: 2.75rem; }
  .hero-emoji { font-size: 5.5rem; }

  #screen-studio { max-width: 960px; }

  #screen-studio .studio-preview-wrap {
    /* Mode 2 colonnes implémenté via une grille parent injectée par .screen */
  }

  .studio-preview { width: min(320px, 40vw); }

  .sticker-palette {
    grid-template-columns: repeat(8, 1fr);
  }
}
