/* Iuris Tantum · Base: colores, encabezado, tarjetas, pestañas de modo, selección de temas y semáforo */

/* Fuentes locales (variables, subconjunto latino; licencia SIL OFL en fonts/) */
@font-face { font-family: 'Cinzel'; font-weight: 400 900; font-display: swap; src: url(../fonts/cinzel.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 100 900; font-display: swap; src: url(../fonts/inter.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 100 800; font-display: swap; src: url(../fonts/jetbrains-mono.woff2) format('woff2'); }

:root {
  --bg-void: #07080a;
  --bg-surface: #0f1117;
  --bg-card: #151922;
  --bg-card-hover: #1c2230;
  --bg-inset: #0a0c10;
  --border-subtle: #242b3b;
  --border-bright: #3d475f;
  --gold-primary: #fbbf24;
  --gold-bright: #fef08a;
  --gold-dark: #b45309;
  --gold-glow: rgba(251, 191, 36, 0.35);
  --text-high: #f9fafb;
  --text-mid: #9ca3af;
  --text-low: #8b93a3;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.25);
  --warning: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background-color: var(--bg-void);
  color: var(--text-high);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
  background-image: 
    radial-gradient(ellipse 65% 50% at 50% -10%, rgba(251, 191, 36, 0.08) 0%, transparent 80%),
    radial-gradient(circle at 90% 80%, rgba(180, 83, 9, 0.05) 0%, transparent 60%);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-void); }
::-webkit-scrollbar-thumb { background: #232a38; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

header {
  background: rgba(15, 17, 23, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.75rem 1.25rem;
  width: 100%;
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  min-width: 0;
  cursor: pointer;
}

/* Logotipo: imagen de cabecera (sello + nombre) */
.brand-text-block h1.wordmark { margin: 0; line-height: 0; }
.brand-text-block h1.wordmark img { display: block; height: 52px; width: auto; }

.hero-seal {
  display: block;
  width: 230px;
  height: 230px;
  margin: 0 auto 1.4rem;
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(251, 191, 36, 0.18), 0 18px 40px rgba(0, 0, 0, 0.6);
}

/* Al abrir: el sello plateado (boceto) se carga con un anillo dorado y se transforma en el de oro.
   El dorado está siempre pintado debajo (no demora la carga); el plateado se abre desde el centro. */
@property --hole { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
@property --load { syntax: "<percentage>"; inherits: false; initial-value: 0%; }

.hero-seal-stack {
  position: relative;
  width: max-content;
  margin: 0 auto 1.4rem;
  animation: sealIn 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.hero-seal-stack .hero-seal { margin: 0; }
.hero-seal-bn {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0b0d12;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(circle, transparent var(--hole), #000 calc(var(--hole) + 9%));
          mask-image: radial-gradient(circle, transparent var(--hole), #000 calc(var(--hole) + 9%));
  animation: bnReveal 0.9s 1.35s cubic-bezier(0.6, 0, 0.2, 1) forwards;
}
.hero-seal-ring {
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  pointer-events: none;
  background: conic-gradient(#fde68a, #fbbf24 var(--load), rgba(251, 191, 36, 0.1) 0);
  -webkit-mask-image: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
          mask-image: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2.5px));
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.8));
  animation: ringLoad 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards, ringOut 0.6s 1.35s ease-out forwards;
}
/* Destello dorado en el momento del cambio */
.hero-seal-stack::after {
  content: "";
  position: absolute;
  inset: -20%;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(255, 230, 150, 0.75) 0%, rgba(251, 191, 36, 0.25) 35%, transparent 65%);
  opacity: 0;
  animation: sealFlash 0.9s 1.35s ease-out;
}
.hero-seal-stack.revealed { animation: none; }
.hero-seal-stack.revealed .hero-seal-bn,
.hero-seal-stack.revealed .hero-seal-ring { display: none; }
.hero-seal-stack.revealed::after { animation: none; }

@keyframes bnReveal { to { --hole: 110%; } }
@keyframes ringLoad { to { --load: 100%; } }
@keyframes ringOut { to { opacity: 0; transform: scale(1.18); } }
@keyframes sealFlash { 0% { opacity: 0; transform: scale(0.7); } 30% { opacity: 1; } 100% { opacity: 0; transform: scale(1.25); } }
@keyframes sealIn {
  from { transform: scale(0.94) rotate(-6deg); }
  to { transform: scale(1) rotate(0); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-seal-stack { animation: none; }
  .hero-seal-bn, .hero-seal-ring, .hero-seal-stack::after { display: none; }
}

.scales-icon-box {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1b202c, #090b0f);
  border: 1.5px solid rgba(251, 191, 36, 0.55);
  border-radius: var(--radius-md);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.22);
  padding: 6px;
  position: relative;
}

.scales-svg {
  width: 100%;
  height: 100%;
  stroke: var(--gold-primary);
  fill: none;
  filter: drop-shadow(0 2px 5px rgba(251, 191, 36, 0.4));
}

.brand-text-block h1 {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ffffff;
  line-height: 1.15;
}

.brand-text-block h1 span {
  color: var(--gold-primary);
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.4);
}

.brand-text-block p {
  font-size: 0.7rem;
  color: var(--text-mid);
  letter-spacing: 0.05em;
  font-family: 'JetBrains Mono', monospace;
}

.nav-buttons {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.nav-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-mid);
  padding: 0.48rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

.nav-btn:active, .nav-btn:hover {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  background: var(--bg-card-hover);
}

.nav-btn.btn-nav-highlight {
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--gold-primary);
  background: rgba(251, 191, 36, 0.08);
}

main {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.main-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  box-shadow: 0 24px 50px -12px rgba(0, 0, 0, 0.75);
  position: relative;
  overflow: hidden;
  overflow: clip; /* recorta sin bloquear position: sticky en los botones */
  animation: cardAppear 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-primary), transparent);
}

@keyframes cardAppear {
  from { opacity: 0; transform: translateY(12px) scale(0.99); }
  to { opacity: 1; transform: translateY(0); }
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  background: var(--bg-inset);
  padding: 0.45rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.6rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-mid);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.7rem 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--gold-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-bright);
}

.badge-exam-pill {
  font-size: 0.65rem;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.05em;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.diagnostic-panel {
  background: linear-gradient(145deg, #0e1118 0%, #080a0e 100%);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1.8rem;
  position: relative;
}

.diagnostic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.diagnostic-title {
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.diagnostic-reset-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-low);
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.diagnostic-reset-btn:hover {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.semaphore-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.9rem;
}

.semaphore-item {
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.semaphore-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.semaphore-name {
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
}

.semaphore-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.light-green { background: #10b981; box-shadow: 0 0 8px #10b981; }
.light-yellow { background: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.light-red { background: #ef4444; box-shadow: 0 0 8px #ef4444; }
.light-gray { background: #4b5563; }

.semaphore-stats {
  font-size: 0.72rem;
  color: var(--text-mid);
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
}

.semaphore-bar-track {
  width: 100%;
  height: 4px;
  background: #1a202c;
  border-radius: 9999px;
  overflow: hidden;
}

.semaphore-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.semaphore-subhead {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-low);
  margin-top: 0.35rem;
}

.diagnostic-tip {
  background: rgba(251, 191, 36, 0.08);
  border-left: 3px solid var(--gold-primary);
  padding: 0.55rem 0.85rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.78rem;
  color: #e5e7eb;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.config-section-title {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-primary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.5rem;
}

.check-card, .radio-card {
  position: relative;
  display: block;
  cursor: pointer;
}

.check-card input, .radio-card input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.001;
  z-index: 2;
  cursor: pointer;
  margin: 0;
}

.card-label {
  display: flex;
  flex-direction: column;
  padding: 0.9rem 0.8rem;
  background: var(--bg-inset);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  position: relative;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.card-subtitle {
  font-size: 0.68rem;
  color: var(--text-mid);
  line-height: 1.35;
}

.indicator-box {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1.5px solid var(--border-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: transparent;
  background: #11141c;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.radio-card .indicator-box {
  border-radius: 50%;
  font-size: 9px;
}

.check-card input:checked + .card-label {
  border-color: var(--gold-primary);
  background: rgba(251, 191, 36, 0.09);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.16);
}

.check-card input:checked + .card-label .card-title {
  color: var(--gold-primary);
}

.check-card input:checked + .card-label .indicator-box {
  background: var(--gold-primary);
  border-color: var(--gold-primary);
  color: #07080a;
  font-weight: 900;
}

.radio-card input:checked + .card-label {
  border-color: var(--gold-primary);
  background: rgba(251, 191, 36, 0.09);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.16);
}

.radio-card input:checked + .card-label .card-title {
  color: var(--gold-primary);
}

.radio-card input:checked + .card-label .indicator-box {
  background: var(--gold-primary);
  border-color: var(--gold-primary);
  color: #07080a;
}

.exam-banner {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(245, 158, 11, 0.1) 100%);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  margin-bottom: 1.4rem;
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}

.exam-banner-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}

.exam-banner-text h4 {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fca5a5;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.exam-banner-text p {
  font-size: 0.78rem;
  color: #e5e7eb;
  line-height: 1.45;
}

.btn-master-action {
  background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
  color: #07080a;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-md);
  padding: 1.1rem 1.8rem;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 10px 25px rgba(251, 191, 36, 0.28);
  transition: all 0.2s ease;
  margin-top: 1rem;
  user-select: none;
  -webkit-user-select: none;
}

.btn-master-action:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

/* Aviso de versión nueva (Service Worker) */
.update-banner {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 301;
  max-width: 420px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  background: #1e2433; border: 1.5px solid var(--gold-primary); border-radius: var(--radius-md);
  color: #fff; padding: 0.6rem 0.6rem 0.6rem 1rem; font-size: 0.85rem; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.85);
}
.update-banner button {
  min-height: 44px; padding: 0 1rem; border: none; border-radius: var(--radius-md); cursor: pointer;
  background: var(--gold-primary); color: #0f1117; font: inherit; font-weight: 800;
}

/* Ícono de audio: dibujo de línea como los demás botones */
#soundIcon { display: inline-flex; line-height: 0; }
