/* ═══════════════════════════════════════════════════════════════
   TEMPLO — styles.css
   Identidad militar: oro sobre negro, tipografía Oswald de estarcido.
   Tailwind cubre el layout; aquí van los tokens y las piezas con firma.
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg-primary: #121212;
  --bg-card: #1a1a1a;
  --bg-elevated: #222222;
  --border: #2a2a2a;
  --border-accent: #3a3a30;
  --text-primary: #e0ddd4;
  --text-secondary: #8a8878;
  --text-muted: #5a5a50;
  --gold: #C4A555;
  --gold-dim: #8B7A3E;
  --gold-glow: rgba(196, 165, 85, 0.15);
  --olive: #6B7A2E;
  --olive-dim: #4a5520;
  --olive-glow: rgba(107, 122, 46, 0.15);
  --green-done: #5A6E28;
  --red-miss: #6E2828;
  --red-danger: #8B3030;

  /* --- Alias para los componentes ya existentes (mismos nombres que usaba
         la versión funcional). Apuntan a la paleta militar de arriba, así
         todo adopta el nuevo diseño sin reescribir cada clase. --- */
  --ink:        var(--bg-primary);
  --ink-2:      #141414;
  --surface:    var(--bg-card);
  --surface-2:  var(--bg-elevated);
  --gold-light: #E8D48B;
  --gold-deep:  var(--gold-dim);
  --olive-light:#8a9a3e;
  --olive-deep: var(--olive-dim);
  --text:       var(--text-primary);
  --muted:      var(--text-secondary);
  --line:       var(--border);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg-primary); color: var(--text-primary); }
body { font-family: 'Inter', sans-serif; -webkit-font-smoothing: antialiased; }

.font-display { font-family: 'Oswald', sans-serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

/* --- Animaciones --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes flameFlicker { 0%,100% { transform: scaleY(1) rotate(-1deg); opacity: .9; } 50% { transform: scaleY(1.08) rotate(1deg); opacity: 1; } }
@keyframes pulseNum { 0% { transform: scale(1); } 50% { transform: scale(1.08); color: var(--gold); } 100% { transform: scale(1); } }
.anim-fadeIn { animation: fadeIn .35s ease forwards; }
.anim-pop { animation: pop .3s ease forwards; }
.flame-flicker { animation: flameFlicker 1.6s ease-in-out infinite; transform-origin: center bottom; }
.pulse-num { animation: pulseNum .18s ease; }

/* --- Botones militares (firma) ---
   Filo recto, mayúsculas, espaciado amplio, acento dorado. */
.btn-mil {
  position: relative; width: 100%; padding: 14px 18px; border: none; cursor: pointer;
  font-family: 'Oswald', sans-serif; font-weight: 600; font-size: 15px;
  text-transform: uppercase; letter-spacing: .14em;
  background: var(--gold); color: #1a1a1a; border-radius: 4px;
  border-bottom: 3px solid var(--gold-dim); transition: all .12s;
}
.btn-mil:hover { background: #d4b565; }
.btn-mil:active { transform: translateY(3px); border-bottom-width: 0; }
.btn-mil:disabled { opacity: .45; cursor: not-allowed; }

.btn-mil-outline {
  position: relative; width: 100%; padding: 13px 18px; cursor: pointer;
  font-family: 'Oswald', sans-serif; font-weight: 600; font-size: 14px;
  text-transform: uppercase; letter-spacing: .14em;
  background: transparent; color: var(--gold);
  border: 1.5px solid var(--border-accent); border-radius: 4px; transition: all .12s;
}
.btn-mil-outline:hover { background: var(--olive-glow); border-color: var(--olive-dim); }
.btn-mil-outline:active { transform: translateY(2px); }
.btn-mil-outline.danger { color: #c46060; border-color: var(--red-danger); }
.btn-mil-outline.danger:hover { background: rgba(139,48,48,.12); }

.btn-done { background: var(--olive) !important; color: var(--text-primary) !important; border-bottom-color: var(--olive-dim) !important; }

/* Botón oliva (secundario militar, para acciones tácticas) */
.btn-mil-olive {
  position: relative; width: 100%; padding: 14px 18px; border: none; cursor: pointer;
  font-family: 'Oswald', sans-serif; font-weight: 600; font-size: 15px;
  text-transform: uppercase; letter-spacing: .14em;
  background: var(--olive); color: #e0ddd4; border-radius: 4px;
  border-bottom: 3px solid var(--olive-dim); transition: all .12s;
}
.btn-mil-olive:hover { background: #7a8c35; }
.btn-mil-olive:active { transform: translateY(3px); border-bottom-width: 0; }

/* Card con borde oliva (seleccionada/activa) */
.card-active { border-color: var(--olive) !important; }

/* Barra de progreso oliva */
.progress-olive { background: var(--olive) !important; }

/* --- Inputs --- */
.mil-input, .mil-select {
  width: 100%; padding: 11px 13px; font-size: 16px; font-family: 'Inter', sans-serif;
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1.5px solid var(--border); border-radius: 4px; transition: border-color .15s;
}
.mil-input:focus, .mil-select:focus { outline: none; border-color: var(--olive); }
.mil-input::placeholder { color: var(--text-muted); }
.mil-select { -webkit-appearance: none; appearance: none; cursor: pointer; }

.mil-label { font-family: 'Oswald', sans-serif; font-size: 11px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: var(--text-secondary); }
.section-label { font-family: 'Oswald', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: var(--olive); }

/* --- Range slider --- */
input[type=range].mil-range { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: var(--border); border-radius: 999px; outline: none; }
input[type=range].mil-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--gold); cursor: pointer; }
input[type=range].mil-range::-moz-range-thumb { width: 18px; height: 18px; border: none; border-radius: 50%; background: var(--gold); cursor: pointer; }

/* --- Card --- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; border-left: 2px solid var(--olive-dim); }

/* --- Toast --- */
.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%) translateY(20px);
  background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-accent);
  padding: 11px 18px; border-radius: 6px; font-size: 13px; font-weight: 500; z-index: 9999;
  opacity: 0; transition: all .25s; max-width: 88%; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Scroll --- */
.scroll-area { overflow-y: auto; -webkit-overflow-scrolling: touch; }
::-webkit-scrollbar { width: 0; height: 0; }

/* ═══ SAFE AREA & RESPONSIVE ═══ */

/* Nav: respeta el safe-area inferior (iPhone X+, Android con barra de gestos) */
.nav-safe {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Contenido que va detrás del nav fijo: 72px nav + safe-area */
.pb-nav {
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

/* Safe-area superior: evita que el contenido se meta detrás de la barra de estado */
.pt-safe {
  padding-top: env(safe-area-inset-top, 0px);
}

/* Overlays fullscreen: respeta safe-area en todos los bordes */
.overlay-safe {
  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);
}

/* Pantallas pequeñas (<360px): reducir padding y font-sizes */
@media (max-width: 359px) {
  .btn-mil { padding: 12px 14px; font-size: 13px; }
  .btn-mil-outline { padding: 11px 14px; font-size: 12px; }
  .mil-input, .mil-select { padding: 9px 11px; font-size: 14px !important; }
  .card { border-radius: 6px; }
}

/* Pantallas medianas (360-390px): ajustes menores */
@media (max-width: 390px) {
  .font-display.text-5xl { font-size: 2.5rem !important; }
}

/* Pantallas grandes (>430px): el contenido se centra con max-w-md mx-auto en cada pantalla */

/* Evita el zoom en inputs iOS */
@supports (-webkit-touch-callout: none) {
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], select, textarea {
    font-size: 16px !important;
  }
}

/* ═══ CONTADOR — CROSSFADE SUAVE ═══ */

/* El wrapper mantiene el espacio del número más grande */
.counter-wrap {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-width: 1.2em;
}

/* Número que ENTRA: escala desde 0.7, opacidad 0→1 */
.counter-enter {
  animation: counterIn .22s ease-out forwards;
}

/* Número que SALE: opacidad 1→0, se eleva y encoge */
.counter-exit {
  position: absolute;
  top: 0; left: 0; right: 0;
  text-align: center;
  animation: counterOut .2s ease-in forwards;
  pointer-events: none;
}

@keyframes counterIn {
  0%   { opacity: 0; transform: scale(0.7) translateY(8px); }
  60%  { opacity: 1; transform: scale(1.08) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes counterOut {
  0%   { opacity: 0.8; transform: scale(1) translateY(0); }
  100% { opacity: 0;   transform: scale(0.6) translateY(-12px); }
}

/* ═══ Extras para la versión fusionada ═══ */

/* Condecoraciones */
.medal { display:flex; flex-direction:column; align-items:center; text-align:center; gap:4px; }
.medal .ico { color: var(--gold); }
.medal.locked { opacity:.28; filter:grayscale(1); }
.medal .nm { font-family:'Oswald',sans-serif; font-size:11px; letter-spacing:.06em; color:var(--text-primary); }
.medal .ds { font-size:10px; line-height:1.2; color:var(--text-muted); }

/* Botón de selección (intensidad / modalidad / voz) */
.choice {
  padding:10px 12px; border-radius:4px; text-align:left; cursor:pointer;
  background: var(--bg-elevated); color: var(--text-primary);
  border:1.5px solid var(--border); transition:all .12s;
  font-family:'Inter',sans-serif; font-size:13px;
}
.choice:hover { border-color: var(--olive-dim); }
.choice.on { background: var(--gold); color:#1a1a1a; border-color: var(--gold); }
.choice .sub { display:block; font-size:11px; opacity:.7; margin-top:2px; }

/* Respeta a quien prefiere menos movimiento */
@media (prefers-reduced-motion: reduce) { *{animation:none !important; transition:none !important; } }

/* ═══ Animación de ejercicios (2 frames, fade respiración) ═══ */
.ex-a { animation: exFadeA 2s ease-in-out infinite; }
.ex-b { animation: exFadeB 2s ease-in-out infinite; }
@keyframes exFadeA { 0%,40%{opacity:1} 50%,90%{opacity:0} 100%{opacity:1} }
@keyframes exFadeB { 0%,40%{opacity:0} 50%,90%{opacity:1} 100%{opacity:0} }
