/*
 * Guardianes de las Danzas Colombianas
 * Estilos globales: paleta infantil, regiones, animaciones y layout responsive.
 */

:root {
  --ink: #1b2540;
  --paper: #fff9f0;
  --accent: #ff6b4a;
  --accent-2: #4cc9f0;
  --success: #2ecc71;
  --warning: #f4c430;
  --shadow: 0 12px 40px rgba(27, 37, 64, 0.18);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
  /* Regiones */
  --caribe: #00b4d8;
  --pacifico: #7b2cbf;
  --andina: #e63946;
  --llanera: #f4a261;
  --amazonia: #2a9d8f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(14px, 2.2vw, 18px);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  transition: background-color 0.6s ease;
}

/* Fondos dinámicos por región */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.bg-base {
  background: linear-gradient(165deg, #ffe5f0 0%, #e0f7ff 45%, #fff5e6 100%);
}

.bg-pattern {
  opacity: 0.35;
  background-image: radial-gradient(circle at 20% 30%, rgba(255, 107, 74, 0.25) 0%, transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(76, 201, 240, 0.3) 0%, transparent 40%),
    radial-gradient(circle at 50% 80%, rgba(244, 196, 48, 0.2) 0%, transparent 50%);
}

body.region-caribe .bg-base {
  background: linear-gradient(160deg, #caf0f8 0%, #ffedd8 100%);
}
body.region-pacifico .bg-base {
  background: linear-gradient(160deg, #e0c3fc 0%, #8ec5fc 100%);
}
body.region-andina .bg-base {
  background: linear-gradient(160deg, #ffd6e0 0%, #c8e7ff 100%);
}
body.region-llanera .bg-base {
  background: linear-gradient(160deg, #ffe8cc 0%, #fff1bf 100%);
}
body.region-amazonia .bg-base {
  background: linear-gradient(160deg, #d8f3dc 0%, #b7e4c7 100%);
}
body.region-finale .bg-base {
  background: linear-gradient(160deg, #fff9c4 0%, #ffd6e8 50%, #cdeffd 100%);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 249, 240, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid rgba(27, 37, 64, 0.08);
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-icon {
  font-size: 1.4rem;
  animation: bounce-soft 2.2s ease-in-out infinite;
}

.progress-cluster {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.stars-inline {
  display: flex;
  gap: 0.15rem;
  font-size: 1.25rem;
}

.points {
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), #ff9f1c);
  color: #fff;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
}

.btn-icon {
  border: none;
  background: #fff;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-icon:hover {
  transform: scale(1.06);
}
.btn-icon:active {
  transform: scale(0.96);
}

.sound-toggle[aria-pressed="false"] .sound-on {
  display: none;
}
.sound-toggle[aria-pressed="true"] .sound-off {
  display: none;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 3rem;
  min-height: calc(100dvh - 120px);
}

.footer-note {
  text-align: center;
  font-size: 0.75rem;
  color: rgba(27, 37, 64, 0.55);
  padding: 0.5rem 1rem 1rem;
}

.footer-note p {
  margin: 0;
}

/* --- Pantallas comunes --- */
.screen {
  animation: fade-in 0.45s ease both;
}

.screen-inner {
  background: rgba(255, 255, 255, 0.88);
  border-radius: var(--radius-xl);
  padding: clamp(1rem, 4vw, 2rem);
  box-shadow: var(--shadow);
  border: 4px solid rgba(255, 255, 255, 0.9);
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.75rem);
  line-height: 1.1;
  text-align: center;
  margin: 0 0 0.5rem;
  color: var(--ink);
  text-shadow: 3px 3px 0 rgba(76, 201, 240, 0.35);
}

.hero-sub {
  text-align: center;
  font-size: 1.05rem;
  max-width: 36ch;
  margin: 0 auto 1.25rem;
  color: rgba(27, 37, 64, 0.75);
}

.tambo-showcase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.tambo-figure {
  width: min(220px, 55vw);
  height: min(220px, 55vw);
  position: relative;
  animation: float-y 3s ease-in-out infinite;
}

.tambo-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 14px 0 rgba(27, 37, 64, 0.08));
}

.speech-bubble {
  position: relative;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  max-width: min(420px, 92vw);
  font-size: 0.95rem;
  box-shadow: 8px 8px 0 rgba(27, 37, 64, 0.12);
}
.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -14px;
  left: 50%;
  transform: translateX(-50%);
  border: 12px solid transparent;
  border-top-color: var(--ink);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 52px;
  min-width: 160px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 8px 0 rgba(27, 37, 64, 0.15);
}
.btn:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 rgba(27, 37, 64, 0.12);
}

.btn-primary {
  background: linear-gradient(180deg, #ff8a65, var(--accent));
  color: #fff;
  border: 3px solid #ff8a65;
}

.btn-secondary {
  background: linear-gradient(180deg, #74c0fc, var(--accent-2));
  color: #fff;
  border: 3px solid #74c0fc;
}

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
}

.btn-gold {
  background: linear-gradient(180deg, #ffe066, var(--warning));
  color: var(--ink);
  border: 3px solid #ffe066;
}

/* Mapa */
.map-wrap {
  margin-top: 1rem;
}

.map-title {
  font-family: var(--font-display);
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}
.map-legend span {
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(27, 37, 64, 0.08);
}

.colombia-map {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: block;
}

.region-hit {
  cursor: pointer;
  transition: opacity 0.2s ease, filter 0.2s ease;
  stroke: rgba(27, 37, 64, 0.25);
  stroke-width: 1.5;
}
.region-hit:hover:not(.locked) {
  filter: brightness(1.08);
}
.region-hit.locked {
  cursor: not-allowed;
  opacity: 0.45;
}
.region-hit:focus {
  outline: 3px solid var(--accent-2);
  outline-offset: 2px;
}

.region-label {
  font-family: var(--font-display);
  font-size: 11px;
  fill: #1b2540;
  pointer-events: none;
  text-anchor: middle;
}

/* Barra de progreso global */
.global-progress {
  margin: 1rem auto 0;
  max-width: 420px;
}
.global-progress label {
  display: block;
  font-weight: 800;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.global-progress .bar {
  height: 18px;
  border-radius: 999px;
  background: rgba(27, 37, 64, 0.1);
  overflow: hidden;
  border: 3px solid rgba(27, 37, 64, 0.12);
}
.global-progress .fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--success));
  transition: width 0.5s ease;
}

/* Nivel / actividad */
.level-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.level-badge {
  font-family: var(--font-display);
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.85rem;
}

.activity-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1rem;
  border: 3px solid rgba(27, 37, 64, 0.08);
  margin-bottom: 1rem;
}

.activity-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}

.hint {
  font-size: 0.9rem;
  color: rgba(27, 37, 64, 0.7);
  margin: 0 0 0.75rem;
}

/* Opciones tipo trivia */
.options-grid {
  display: grid;
  gap: 0.6rem;
}
@media (min-width: 600px) {
  .options-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.option-btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 3px solid rgba(27, 37, 64, 0.12);
  background: #f8fafc;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.option-btn:hover {
  border-color: var(--accent-2);
  transform: translateY(-2px);
}
.option-btn.correct {
  border-color: var(--success);
  background: #e8f8ef;
}
.option-btn.wrong {
  border-color: #e63946;
  background: #ffe5e5;
}
.option-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

/* Memoria */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  max-width: 420px;
  margin: 0 auto;
}
.memory-card {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 3px solid rgba(27, 37, 64, 0.15);
  background: linear-gradient(145deg, #fff, #e2e8f0);
  font-size: clamp(1.4rem, 5vw, 2rem);
  cursor: pointer;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}
.memory-card.flipped,
.memory-card.matched {
  background: #fff;
  border-color: var(--accent-2);
}
.memory-card.matched {
  opacity: 0.55;
  pointer-events: none;
}

/* Puzzle */
.puzzle-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 300px;
  margin: 0 auto;
  background: rgba(27, 37, 64, 0.08);
  padding: 6px;
  border-radius: var(--radius-md);
}
.puzzle-tile {
  aspect-ratio: 1;
  border-radius: 10px;
  border: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.4rem;
  cursor: pointer;
  color: #fff;
  transition: transform 0.12s ease;
}
.puzzle-tile:active {
  transform: scale(0.95);
}

/* Drag vestuario */
.dress-stage {
  display: grid;
  gap: 1rem;
}
@media (min-width: 700px) {
  .dress-stage {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.dress-drop {
  min-height: 220px;
  border: 4px dashed rgba(27, 37, 64, 0.2);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.6);
  position: relative;
}
.dress-drop.filled {
  border-style: solid;
  border-color: var(--success);
}
.dress-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}
.dress-item {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  background: #fff;
  border: 3px solid rgba(27, 37, 64, 0.12);
  display: grid;
  place-items: center;
  font-size: 2rem;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.dress-item.dragging {
  opacity: 0.6;
}

/* Ritmo */
.rhythm-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 320px;
  margin: 0 auto;
}
.rhythm-btn {
  height: 88px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
  color: #fff;
  box-shadow: 0 6px 0 #5b21b6;
}
.rhythm-btn.active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #5b21b6;
}

/* Parejas / frases */
.phrase-slots,
.pair-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.phrase-chip,
.pair-chip {
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  border: 3px dashed rgba(27, 37, 64, 0.2);
  background: #fff;
  min-width: 100px;
  text-align: center;
  font-weight: 800;
  cursor: pointer;
}
.pair-chip.selected {
  border-color: var(--accent-2);
  background: #e7f5ff;
}

/* Exploración */
.explore-scene {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 220px;
  background: linear-gradient(180deg, #b7e4c7, #52b788);
}
.hotspot {
  position: absolute;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(255, 255, 255, 0.35);
  cursor: pointer;
  animation: pulse-ring 2s ease-in-out infinite;
}
.hotspot[data-found="true"] {
  background: rgba(46, 204, 113, 0.5);
  animation: none;
}

/* Símbolos */
.symbol-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-width: 360px;
  margin: 0 auto;
}
.symbol-btn {
  height: 72px;
  border-radius: var(--radius-md);
  border: 3px solid rgba(27, 37, 64, 0.12);
  font-size: 1.75rem;
  background: #fff;
  cursor: pointer;
}
.symbol-btn.ok {
  border-color: var(--success);
}
.symbol-btn.bad {
  border-color: #e63946;
}

/* Medallas */
.medals-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1rem 0;
}
.medal {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.75rem;
  background: #fff;
  border: 4px solid rgba(27, 37, 64, 0.1);
  opacity: 0.35;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.medal.earned {
  opacity: 1;
  transform: scale(1.08) rotate(-6deg);
  border-color: var(--warning);
  box-shadow: var(--shadow);
}

/* Modal diploma / overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  padding: 1rem;
  animation: fade-in 0.35s ease both;
}
.overlay-card {
  background: #fff;
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  text-align: center;
  border: 5px solid var(--warning);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  position: relative;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.diploma-seal {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

/* Fuegos artificiales (CSS) */
.celebration-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.celebration-layer.on {
  opacity: 1;
}
.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: firework-burst 1.4s ease-out forwards;
}

/* Toast motivacional */
.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 120;
  background: var(--ink);
  color: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Animaciones */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes float-y {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}
@keyframes bounce-soft {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}
@keyframes pulse-ring {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(255, 255, 255, 0);
  }
}
@keyframes firework-burst {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0);
    opacity: 0;
  }
}

/* Transición entre pantallas */
.screen.transition-out {
  animation: fade-out 0.3s ease both;
}
@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* Accesibilidad: foco visible */
button:focus-visible,
.region-hit:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* Tablet / touch: botones más grandes */
@media (max-width: 768px) {
  .btn {
    width: 100%;
    max-width: 320px;
  }
  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
