/* ============================================================
   styles.css — Estilos principales de LeoPlay.
   Glassmorphism + Neumorphism + gradientes + tarjetas.
   ============================================================ */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-ink);
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}
h1, h2, h3, .display {
  font-family: var(--font-display);
  margin: 0;
}
button { font-family: inherit; cursor: pointer; }
:focus-visible {
  outline: 3px solid var(--color-accent-3);
  outline-offset: 2px;
}

#app {
  position: relative;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 12%, rgba(244,169,196,0.16), transparent 40%),
    radial-gradient(circle at 92% 85%, rgba(126,200,185,0.18), transparent 45%),
    var(--color-bg);
}

/* ---------- Barra superior flotante ---------- */
.topbar {
  position: fixed;
  top: 14px; right: 14px;
  z-index: 50;
  display: flex;
  gap: 8px;
}
.topbar__btn {
  width: 42px; height: 42px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-soft);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.2s ease;
}
.topbar__btn:hover { transform: translateY(-2px) scale(1.05); }
.topbar__btn:active { transform: scale(0.94); }

/* ---------- Pantallas ---------- */
.screen {
  display: none;
  min-height: 100vh;
  padding: 28px 20px 60px;
  animation: fadeSlideIn 0.5s ease;
}
.screen--active { display: block; }
.screen-inner {
  max-width: 880px;
  margin: 0 auto;
}

/* ---------- Splash ---------- */
#screen-splash {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--grad-hero);
}
.splash-box { text-align: center; }
.splash-mascot {
  font-size: 5rem;
  animation: bounceIn 1s ease, float 2.4s ease-in-out infinite 1s;
}
.splash-title {
  font-size: 2.6rem;
  color: var(--color-ink);
  margin-top: 12px;
  letter-spacing: 0.5px;
}
.splash-sub {
  color: var(--color-muted);
  font-weight: 700;
  margin-top: 6px;
}
.splash-loader {
  width: 180px; height: 8px;
  border-radius: var(--radius-pill);
  background: rgba(0,0,0,0.08);
  margin: 24px auto 0;
  overflow: hidden;
}
.splash-loader::after {
  content: "";
  display: block;
  height: 100%;
  width: 40%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--color-accent-1), var(--color-accent-2));
  animation: loaderSlide 1.2s ease-in-out infinite;
}

/* ---------- Tarjetas (glass + neumorphism) ---------- */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  padding: 28px;
}
.card--neu {
  background: var(--color-bg);
  box-shadow: 8px 8px 16px var(--neu-dark), -8px -8px 16px var(--neu-light);
  border: none;
}

.hero-card {
  background: var(--grad-hero);
  border-radius: var(--radius-l);
  padding: 36px 30px;
  text-align: center;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.hero-mascot {
  font-size: 3.4rem;
  display: inline-block;
  animation: wiggle 3s ease-in-out infinite;
}
.hero-title { font-size: 2.1rem; margin-top: 10px; }
.hero-sub { color: var(--color-muted); font-weight: 700; margin-top: 6px; }

/* ---------- Formulario de inicio ---------- */
.form-grid { display: grid; gap: 16px; margin-top: 22px; }
.field label {
  display: block;
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--color-muted);
}
.field input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-m);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-size: 1rem;
  color: var(--color-ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field input:focus {
  border-color: var(--color-accent-2);
  box-shadow: 0 0 0 4px rgba(126,200,185,0.2);
}

.avatar-section { margin-top: 22px; }
.avatar-section h3 { font-size: 1rem; margin-bottom: 10px; }
.avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.avatar-chip {
  width: 58px; height: 58px;
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background: var(--avatar-grad, var(--grad-avatar-1));
  font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.avatar-chip:hover { transform: translateY(-3px) scale(1.06); }
.avatar-chip--active {
  border-color: var(--color-ink);
  transform: scale(1.1);
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 26px;
  border-radius: var(--radius-pill);
  border: none;
  font-weight: 800;
  font-size: 1rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--color-accent-1), var(--color-accent-1-dark));
  color: #fff;
  box-shadow: 0 10px 22px rgba(244,135,75,0.35);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-2px); }
.btn-secondary {
  background: linear-gradient(135deg, var(--color-accent-2), var(--color-accent-2-dark));
  color: #fff;
  box-shadow: 0 10px 22px rgba(126,200,185,0.32);
}
.btn-secondary:hover { filter: brightness(1.06); transform: translateY(-2px); }
.btn-ghost {
  background: transparent;
  border: 2px solid var(--color-border);
  color: var(--color-ink);
}
.btn-ghost:hover { border-color: var(--color-accent-3); }
.btn-block { width: 100%; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

.link-row {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.link-btn {
  background: none;
  border: none;
  color: var(--color-accent-3);
  font-weight: 800;
  text-decoration: underline;
  font-size: 0.9rem;
}

/* ---------- Historia ---------- */
.story-card { text-align: center; }
.story-mascot-lg { font-size: 4rem; animation: float 2.6s ease-in-out infinite; }
.story-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--color-ink);
  max-width: 640px;
  margin: 18px auto 0;
}

/* ---------- Lectura ---------- */
.reading-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.reading-badge {
  display: inline-block;
  background: var(--color-accent-3);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
}
.reading-illustration {
  margin: 18px 0;
  border-radius: var(--radius-m);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.reading-illustration svg { display: block; width: 100%; height: auto; }
.reading-illustration {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.reading-illustration__img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-m);
  background: var(--color-surface);
}
.reading-text { font-size: 1.02rem; line-height: 1.75; }
.reading-text p { margin: 0 0 10px; }

/* ---------- HUD del juego ---------- */
.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}
.hud-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: var(--shadow-soft);
}
.hud-chip__icon { font-size: 1rem; }

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--color-border);
  overflow: hidden;
  margin-bottom: 20px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--color-accent-2), var(--color-accent-1));
  transition: width 0.5s cubic-bezier(.4,1.4,.6,1);
}

/* ---------- Pregunta ---------- */
.question-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px;}
.question-meta { color: var(--color-muted); font-weight: 800; font-size: 0.85rem; }

.timer-widget { position: relative; width: 60px; height: 60px; }
.timer-widget svg { transform: rotate(-90deg); }
.timer-circle-bg { fill: none; stroke: var(--color-border); stroke-width: 6; }
.timer-circle {
  fill: none;
  stroke: var(--color-accent-2);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 163.36;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.15s linear, stroke 0.3s ease;
}
.timer-circle--warning { stroke: var(--color-incorrect); }
.timer-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem;
}

.question-card { margin-top: 6px; }
.question-enunciado {
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.5;
  margin-bottom: 20px;
}
.options-grid { display: grid; gap: 12px; }
.option-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 16px 18px;
  border-radius: var(--radius-m);
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-size: 1rem;
  font-weight: 700;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.option-card:hover:not(:disabled) {
  transform: translateX(4px);
  border-color: var(--color-accent-2);
  box-shadow: var(--shadow-soft);
}
.option-card:disabled { cursor: default; }
.option-card__letter {
  width: 34px; height: 34px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-alt);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}
.option-card--correct {
  border-color: var(--color-correct);
  background: rgba(76,175,125,0.14);
}
.option-card--correct .option-card__letter { background: var(--color-correct); color: #fff; }
.option-card--incorrect {
  border-color: var(--color-incorrect);
  background: rgba(232,92,74,0.14);
  animation: shake 0.4s ease;
}
.option-card--incorrect .option-card__letter { background: var(--color-incorrect); color: #fff; }

.option-card--imagen {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.option-card--imagen .option-card__letter {
  align-self: flex-start;
}
.option-card__img {
  width: 100%;
  max-width: 220px;
  height: auto;
  border-radius: var(--radius-s);
  align-self: center;
  background: #fff;
  border: 1px solid var(--color-border);
}

/* ---------- Feedback (overlay) ---------- */
.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(2px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}
.screen--feedback-open .feedback-overlay { display: flex; }
.feedback-panel {
  width: 100%;
  max-width: 620px;
  background: var(--color-surface);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 26px 26px 30px;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.2);
  animation: slideUp 0.35s cubic-bezier(.25,1.4,.5,1);
}
.feedback--correct { border-top: 6px solid var(--color-correct); }
.feedback--incorrect { border-top: 6px solid var(--color-incorrect); }
.feedback-icon { font-size: 2.4rem; }
.feedback-title { font-size: 1.4rem; margin-top: 6px; }
.feedback-text { color: var(--color-muted); margin-top: 8px; line-height: 1.5; font-weight: 600; }

/* ---------- Resultados ---------- */
.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 22px 0;
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  padding: 16px 10px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.stat-card__label { font-size: 0.7rem; font-weight: 800; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-card__value { font-family: var(--font-display); font-size: 1.5rem; margin-top: 4px; }

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 18px;
  margin-top: 10px;
}
.chart-box {
  background: var(--color-surface);
  border-radius: var(--radius-m);
  border: 1px solid var(--color-border);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}
.chart-box canvas { width: 100%; height: 220px; }
.chart-box h4 { font-size: 0.85rem; margin-bottom: 8px; color: var(--color-muted); }

.badges-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.badge-pill {
  background: var(--color-bg-alt);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-weight: 800;
  font-size: 0.85rem;
}

/* ---------- Diploma ---------- */
.certificate-wrap {
  background: var(--color-surface);
  border-radius: var(--radius-m);
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.certificate-wrap canvas { width: 100%; height: auto; border-radius: 8px; }

/* ---------- Ranking ---------- */
.ranking-row {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-m);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  margin-bottom: 8px;
  font-weight: 700;
}
.ranking-row__pos { text-align: center; font-size: 1.1rem; }
.ranking-row__score { color: var(--color-accent-1); }
.ranking-row__pct { color: var(--color-muted); font-size: 0.85rem; }
.ranking-row--admin {
  grid-template-columns: 44px 1fr auto auto auto;
}
.empty-state { color: var(--color-muted); text-align: center; padding: 30px 0; font-weight: 700; }

/* ---------- Panel docente ---------- */
.docente-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.docente-table-wrap { overflow-x: auto; border-radius: var(--radius-m); border: 1px solid var(--color-border); }
table.docente-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; background: var(--color-surface); }
table.docente-table th, table.docente-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}
table.docente-table th { background: var(--color-bg-alt); font-weight: 800; }
.btn-mini {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-weight: 700;
  font-size: 0.78rem;
  margin-right: 6px;
}
.btn-mini--danger { color: var(--color-incorrect); border-color: var(--color-incorrect); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 20px;
}
.modal--open { display: flex; }
.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-l);
  padding: 26px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-card);
}
.modal-box .field { margin-bottom: 12px; }

/* ---------- Panel de accesibilidad ---------- */
.a11y-panel {
  position: fixed;
  top: 0; right: -320px;
  width: 300px; height: 100%;
  background: var(--color-surface);
  box-shadow: -10px 0 30px rgba(0,0,0,0.15);
  z-index: 70;
  padding: 24px;
  transition: right 0.3s ease;
  overflow-y: auto;
}
.panel--open { right: 0 !important; }
.a11y-option { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--color-border); }
.switch { position: relative; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--color-border);
  border-radius: var(--radius-pill); transition: background 0.2s ease;
}
.switch-track::after {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.2s ease;
  box-shadow: var(--shadow-soft);
}
.switch input:checked + .switch-track { background: var(--color-accent-2); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--color-ink);
  color: var(--color-bg);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: var(--shadow-card);
}
.toast--show { opacity: 1; transform: translateY(0); }
.toast--badge { background: var(--color-accent-5); color: var(--color-ink); }
.toast--warning { background: var(--color-incorrect); color: #fff; }
.toast--success { background: var(--color-correct); color: #fff; }

/* ---------- Confeti / fuegos artificiales ---------- */
#confettiLayer {
  position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -20px;
  border-radius: 2px;
  animation-name: confettiFall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}
.firework-spark {
  position: absolute;
  width: 6px; height: 6px;
  border-radius: 50%;
  animation: fireworkBurst 1s ease-out forwards;
}

footer.app-footer {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.75rem;
  padding: 20px 0 6px;
}
