/* ============================================================
   Mi Primera Comunión — identidad "Vitral"
   Luz de catedral entrando por un vitral, para niños.
   Tema claro = mediodía · Tema oscuro = capilla a la luz de las velas.
   ============================================================ */

:root {
  /* Tipografías */
  --font-display: "Fredoka", "Baloo 2", "Segoe UI Rounded", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* --- Tema claro (mediodía) --- */
  --sky: #e8f1ff;          /* cielo pálido */
  --dawn: #fff4e0;         /* luz de vela cálida */
  --bg: #f4f7ff;
  --card: #ffffff;
  --card2: #f3f1fb;        /* tono lavanda suave */
  --line: #e7e3f5;
  --text: #2a2350;         /* índigo profundo, no negro puro */
  --muted: #837fae;

  --brand: #3b6fe0;        /* azul mariano */
  --brand-dk: #2b52ad;     /* sombra 3D del botón */
  --brand2: #8b5cf6;       /* violeta vitral */
  --gold: #f5a623;         /* oro de vela */
  --gold-dk: #c9821a;
  --good: #2fb47c;         /* verde hoja */
  --good-dk: #1f8c60;
  --bad: #ec5a72;          /* rosa rubí */

  /* Joyas del vitral (puntos de módulo, fallback) */
  --jewel-ruby: #e0455e;
  --jewel-cobalt: #3b6fe0;
  --jewel-emerald: #2fb47c;
  --jewel-amber: #f0a92b;
  --jewel-violet: #8b5cf6;

  --radius: 22px;
  --radius-sm: 15px;
  --shadow: 0 14px 32px rgba(59, 111, 224, .14);
  --shadow-soft: 0 6px 18px rgba(59, 111, 224, .10);
  --glow-a: rgba(255, 200, 120, .55);   /* halo cálido */
  --glow-b: rgba(120, 165, 255, .45);   /* halo frío */
}

@media (prefers-color-scheme: dark) {
  :root {
    /* --- Tema oscuro (capilla a la luz de las velas) --- */
    --sky: #171438;
    --dawn: #241a2e;
    --bg: #14122f;
    --card: #221f4d;
    --card2: #2b2860;
    --line: #38356f;
    --text: #f3f0ff;
    --muted: #a49ecf;

    --brand: #7c9cff;
    --brand-dk: #4a63c4;
    --brand2: #b79bff;
    --gold: #ffca5f;
    --gold-dk: #c99a3c;
    --good: #4fd894;
    --good-dk: #2f9c68;
    --bad: #ff7a90;

    --jewel-ruby: #ff6b83;
    --jewel-cobalt: #7c9cff;
    --jewel-emerald: #4fd894;
    --jewel-amber: #ffca5f;
    --jewel-violet: #b79bff;

    --shadow: 0 16px 40px rgba(0, 0, 0, .45);
    --shadow-soft: 0 8px 22px rgba(0, 0, 0, .35);
    --glow-a: rgba(255, 190, 100, .30);
    --glow-b: rgba(120, 150, 255, .30);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  background:
    linear-gradient(180deg, var(--sky) 0%, var(--bg) 45%, var(--dawn) 100%);
  background-attachment: fixed;
}

/* Luz entrando por el vitral: halos suaves fijos detrás de todo */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 78% 6%, var(--glow-a) 0%, transparent 60%),
    radial-gradient(55% 38% at 12% 2%, var(--glow-b) 0%, transparent 60%),
    radial-gradient(70% 30% at 50% 100%, var(--glow-a) 0%, transparent 65%);
  opacity: .9;
}

.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 20px 16px 108px;
  position: relative;
}

/* ---------- Barra superior ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 20px;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 19px; line-height: 1.05;
  color: var(--text);
}
.brand .logo {
  width: 42px; height: 42px; border-radius: 14px;
  background: linear-gradient(150deg, var(--brand), var(--brand2) 65%, var(--gold));
  display: grid; place-items: center; font-size: 22px;
  box-shadow: 0 6px 16px rgba(59,111,224,.4), inset 0 2px 6px rgba(255,255,255,.35);
  flex: 0 0 auto;
}
.stats { display: flex; gap: 8px; flex: 0 0 auto; }
.pill {
  display: flex; align-items: center; gap: 5px;
  background: var(--card); border: 2px solid var(--line);
  padding: 7px 12px; border-radius: 999px;
  font-weight: 800; font-size: 14px;
  box-shadow: var(--shadow-soft);
}
.pill.gold { color: var(--gold-dk); }
.pill.fire { color: #f2762e; }
@media (prefers-color-scheme: dark) {
  .pill.gold { color: var(--gold); }
  .pill.fire { color: #ff9f68; }
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 15px;
  position: relative;
  overflow: hidden;
}
/* Franja de vitral en el borde superior de la tarjeta principal */
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg,
    var(--jewel-ruby), var(--jewel-amber), var(--jewel-emerald),
    var(--jewel-cobalt), var(--jewel-violet));
  opacity: .85;
}
.card h2 {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700; margin-bottom: 4px;
  text-wrap: balance;
}
.card .sub { color: var(--muted); font-size: 13.5px; font-weight: 600; }

.section-title {
  font-family: var(--font-display);
  font-size: 15px; color: var(--text); font-weight: 600;
  margin: 22px 4px 12px; letter-spacing: .2px;
}

/* ---------- Botones (estilo "3D" de juego) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display);
  border: none; cursor: pointer; font-weight: 600; font-size: 17px;
  padding: 15px 18px; border-radius: 16px; width: 100%;
  color: #fff; background: var(--brand);
  box-shadow: 0 6px 0 var(--brand-dk);
  transition: transform .06s ease, box-shadow .06s ease, filter .15s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--brand-dk); }
.btn.secondary {
  background: var(--card2); color: var(--text);
  box-shadow: 0 6px 0 var(--line);
}
.btn.good { background: var(--good); box-shadow: 0 6px 0 var(--good-dk); }
.btn.ghost {
  background: transparent; box-shadow: none; color: var(--muted);
  font-weight: 600; padding: 12px;
}
.btn.ghost:active { transform: none; }
.btn:disabled { opacity: .4; box-shadow: 0 6px 0 rgba(0,0,0,.08); cursor: default; filter: none; }

/* ---------- Lista de niños (catequista) ---------- */
.student {
  display: flex; align-items: center; gap: 13px; cursor: pointer;
  padding: 13px; border-radius: var(--radius-sm); background: var(--card);
  border: 1px solid var(--line); margin-bottom: 11px;
  box-shadow: var(--shadow-soft);
  transition: transform .1s ease, box-shadow .15s;
}
.student:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.student:active { transform: scale(.98); }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 25px;
  background: linear-gradient(150deg, var(--brand), var(--brand2) 70%, var(--gold));
  box-shadow: inset 0 2px 6px rgba(255,255,255,.4), 0 4px 10px rgba(59,111,224,.3);
}
.student .info { flex: 1; min-width: 0; }
.student .info .name { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.student .info .meta { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.progress-ring { font-family: var(--font-display); font-weight: 600; color: var(--good); font-size: 15px; }

/* ---------- Barra de progreso ---------- */
.bar {
  height: 11px; background: var(--card2); border-radius: 999px;
  overflow: hidden; margin-top: 9px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.12);
}
.bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--good), #7ce6b4);
  border-radius: 999px; transition: width .6s cubic-bezier(.2,.9,.3,1);
  position: relative;
}
.bar > i::after {
  content: ""; position: absolute; inset: 0 0 50% 0;
  background: linear-gradient(180deg, rgba(255,255,255,.45), transparent);
  border-radius: 999px;
}

/* ---------- Módulos y lecciones ---------- */
.module { margin-bottom: 12px; }
.module .mhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.module .dot {
  width: 13px; height: 13px; border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(0,0,0,.04);
}
.lesson {
  display: flex; align-items: center; gap: 13px; cursor: pointer;
  padding: 14px; border-radius: var(--radius-sm); background: var(--card);
  border: 1px solid var(--line); margin-bottom: 11px;
  box-shadow: var(--shadow-soft);
  transition: transform .1s ease, box-shadow .15s, border-color .15s;
}
.lesson:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.lesson:active { transform: scale(.98); }
.lesson .licon {
  width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(150deg, var(--sky), var(--card2));
  border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 24px; flex: 0 0 auto;
}
.lesson .linfo { flex: 1; min-width: 0; }
.lesson .linfo .lname { font-family: var(--font-display); font-weight: 600; font-size: 16px; }
.lesson .linfo .lmeta { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.lesson .check { font-size: 22px; flex: 0 0 auto; }
.lesson.done {
  border-color: var(--good);
  background: linear-gradient(180deg, rgba(47,180,124,.10), var(--card));
}
.lesson.done .licon {
  background: linear-gradient(150deg, var(--good), #7ce6b4);
  border-color: transparent;
}

/* ---------- Pantalla de ejercicio ---------- */
.ex-top { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.ex-top .x {
  font-size: 24px; color: var(--muted); cursor: pointer;
  background: var(--card); border: 2px solid var(--line);
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; line-height: 1;
  transition: transform .08s, color .15s;
}
.ex-top .x:hover { color: var(--bad); }
.ex-top .x:active { transform: scale(.9); }
.ex-bar {
  flex: 1; height: 16px; background: var(--card2); border-radius: 999px;
  overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.12);
}
.ex-bar > i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--gold), #ffd27a);
  transition: width .4s cubic-bezier(.2,.9,.3,1);
}

.prompt {
  font-family: var(--font-display);
  font-size: 23px; font-weight: 600; margin-bottom: 6px; line-height: 1.3;
  text-wrap: balance;
}
.hint { color: var(--muted); font-size: 14.5px; font-weight: 600; margin-bottom: 18px; line-height: 1.4; }

/* ---------- Banco de palabras / ordenar ---------- */
.answer-zone {
  min-height: 96px; border: 2.5px dashed var(--line); border-radius: 16px;
  padding: 13px; display: flex; flex-wrap: wrap; gap: 9px; align-content: flex-start;
  margin-bottom: 16px; background: var(--card2);
  transition: border-color .2s;
}
.bank { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  font-family: var(--font-display);
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 11px 15px; border-radius: 13px; font-weight: 500; font-size: 16px;
  cursor: pointer; box-shadow: 0 4px 0 var(--line);
  transition: transform .06s ease, box-shadow .06s ease;
  animation: pop .22s cubic-bezier(.2,1.3,.4,1) both;
}
.chip:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.chip.used { opacity: .22; pointer-events: none; }

/* ---------- Opción múltiple ---------- */
.choices { display: flex; flex-direction: column; gap: 11px; }
.choice {
  font-family: var(--font-body);
  text-align: left; padding: 16px; border-radius: 15px; cursor: pointer;
  background: var(--card); border: 2.5px solid var(--line); color: var(--text);
  font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow-soft);
  transition: transform .08s, border-color .15s, background .15s;
}
.choice:hover { border-color: var(--brand); }
.choice:active { transform: scale(.99); }
.choice.sel { border-color: var(--brand); background: rgba(59,111,224,.10); }
.choice.correct { border-color: var(--good); background: rgba(47,180,124,.15); }
.choice.wrong { border-color: var(--bad); background: rgba(236,90,114,.15); }

/* ---------- Recitar ---------- */
.recite-text {
  font-family: var(--font-body);
  font-size: 19px; line-height: 1.7; font-weight: 700;
  background: linear-gradient(180deg, var(--dawn), var(--card));
  border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-soft);
}
.recite-text.hidden-text { filter: blur(8px); user-select: none; }

/* ---------- Barra de feedback ---------- */
.feedback {
  position: fixed; left: 0; right: 0; bottom: 0;
  max-width: 460px; margin: 0 auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 3px solid var(--line);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 30px rgba(0,0,0,.14);
  transform: translateY(130%); transition: transform .3s cubic-bezier(.2,.9,.3,1);
  z-index: 20;
}
.feedback.show { transform: translateY(0); }
.feedback.ok { background: linear-gradient(180deg, rgba(47,180,124,.18), var(--card)); border-top-color: var(--good); }
.feedback.err { background: linear-gradient(180deg, rgba(236,90,114,.18), var(--card)); border-top-color: var(--bad); }
.feedback .msg {
  font-family: var(--font-display);
  font-weight: 600; font-size: 17px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; line-height: 1.3;
}
.feedback.ok .msg { color: var(--good-dk); }
.feedback.err .msg { color: var(--bad); }
@media (prefers-color-scheme: dark) { .feedback.ok .msg { color: var(--good); } }

/* ---------- Pantalla de logro ---------- */
.celebrate { text-align: center; padding: 34px 10px; }
.celebrate .big {
  font-size: 76px; margin-bottom: 12px; line-height: 1;
  display: inline-block;
  animation: bounceIn .7s cubic-bezier(.2,1.4,.4,1) both;
  filter: drop-shadow(0 8px 16px rgba(245,166,35,.5));
}
.celebrate h1 {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 700; margin-bottom: 8px; text-wrap: balance;
}
.celebrate p { color: var(--muted); font-weight: 700; margin-bottom: 24px; }
.reward { display: flex; justify-content: center; gap: 12px; margin-bottom: 26px; }
.reward .box {
  font-family: var(--font-display);
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 15px 18px; font-weight: 600; font-size: 18px; min-width: 74px;
  box-shadow: var(--shadow-soft);
}
.reward .box small { display: block; color: var(--muted); font-weight: 800; font-size: 10px; letter-spacing: .6px; margin-top: 3px; }

/* ---------- Nav inferior ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; max-width: 460px; margin: 0 auto;
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 24px rgba(0,0,0,.08);
  z-index: 10;
}
.nav button {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 12px 0 15px; font-family: var(--font-display);
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: color .15s;
}
.nav button .ico { display: block; font-size: 22px; margin-bottom: 3px; transition: transform .15s; }
.nav button:active .ico { transform: scale(.85); }
.nav button.active { color: var(--brand); }
.nav button.active .ico { transform: translateY(-2px); }

.empty { text-align: center; color: var(--muted); font-weight: 700; padding: 34px 14px; line-height: 1.5; }

/* ---------- Confeti de celebración ---------- */
.confetti-bit {
  position: fixed; top: -48px; z-index: 50; pointer-events: none;
  animation: fall 2.4s linear forwards;
  will-change: transform, opacity;
}

/* ---------- Animaciones ---------- */
.fade { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes bounceIn {
  0% { opacity: 0; transform: scale(.3) translateY(20px); }
  60% { opacity: 1; transform: scale(1.15) translateY(-8px); }
  100% { transform: scale(1) translateY(0); }
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: 0; }
}

/* ---------- Accesibilidad ---------- */
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .confetti-bit { display: none; }
}
