/* ============================================
   10 RAZONES — Doble interruptor
   Maestro: activa títulos | Por razón: activa contenido
   ============================================ */

:root {
  --bg: #030306;
  --bg-panel: #0a0a0f;
  --border: rgba(0, 229, 255, 0.15);
  --border-active: rgba(0, 229, 255, 0.5);
  --text: #e8eef2;
  --text-muted: #7a8490;
  --accent: #00e5ff;
  --accent-dim: rgba(0, 229, 255, 0.4);
  --glow: rgba(0, 229, 255, 0.25);
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'IBM Plex Sans', sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 229, 255, 0.4) var(--bg-panel);
}

/* Scrollbar global (donde aparezca el scroll principal) */
html::-webkit-scrollbar {
  width: 12px;
}
html::-webkit-scrollbar-track {
  background: var(--bg-panel);
}
html::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 255, 0.3);
  border-radius: 6px;
  border: 3px solid var(--bg-panel);
}
html::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}
html::-webkit-scrollbar-thumb:active {
  background: var(--accent);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: clamp(0.9375rem, 1.8vw, 1.0625rem);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

/* Bloquear scroll durante el loader */
body.loading-aprendeajedrez {
  overflow: hidden !important;
  height: 100vh !important;
  position: fixed !important;
  width: 100% !important;
}

/* --------------------------------------------
   LOADER — Precarga (sonidos) con tema cyan
   -------------------------------------------- */
@keyframes loaderBgPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.9; }
}
@keyframes loaderLogoGlow {
  0% { transform: scale(1); filter: drop-shadow(0 0 16px var(--accent-dim)); }
  100% { transform: scale(1.03); filter: drop-shadow(0 0 24px var(--accent)); }
}
@keyframes loaderTitleShine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes loaderBarGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(0, 229, 255, 0.4); }
  50% { box-shadow: 0 0 20px rgba(0, 229, 255, 0.7); }
}
@keyframes loaderFadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; pointer-events: none; }
}
@keyframes loaderGridLine {
  0% { opacity: 0.03; }
  50% { opacity: 0.08; }
  100% { opacity: 0.03; }
}

.loader-aprendeajedrez {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
  overflow: hidden;
}

.loader-aprendeajedrez.fade-out {
  animation: loaderFadeOut 0.6s var(--ease) forwards;
}

.loader-aprendeajedrez__bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, rgba(0, 229, 255, 0.08) 0%, transparent 55%);
  animation: loaderBgPulse 3s ease-in-out infinite;
}

.loader-aprendeajedrez__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  animation: loaderGridLine 2.5s ease-in-out infinite;
  pointer-events: none;
}

.loader-aprendeajedrez__content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 90vw;
}

.loader-aprendeajedrez__logo {
  width: 80px;
  height: 80px;
  margin-bottom: 1.5rem;
  animation: loaderLogoGlow 2s ease-in-out infinite alternate;
}
.loader-aprendeajedrez__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(0, 229, 255, 0.5));
}

.loader-aprendeajedrez__title {
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.35rem;
  background: linear-gradient(90deg, var(--text) 0%, var(--accent) 50%, var(--text) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: loaderTitleShine 3s ease-in-out infinite;
}

.loader-aprendeajedrez__sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.loader-aprendeajedrez__progress-wrap {
  width: min(280px, 85vw);
  height: 6px;
  background: var(--bg-panel);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
}

.loader-aprendeajedrez__progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 6px;
  transition: width 0.35s var(--ease);
  animation: loaderBarGlow 1.5s ease-in-out infinite;
}

.loader-aprendeajedrez__pct {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.loader-aprendeajedrez__msg {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  min-height: 1.25rem;
}

/* Fondo tecnológico (canvas) — detrás de todo el sitio */
.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.site-bg canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Piezas flotantes (caballo/peón) en el fondo */
.site-bg__pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.site-bg__piece {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
}
.site-bg__piece svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* --------------------------------------------
   BOOT — Interruptor maestro (activa títulos)
   -------------------------------------------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  transition: opacity 0.7s var(--ease), visibility 0.7s var(--ease);
}

.boot.is-off {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot__bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 40%, rgba(0, 229, 255, 0.04) 0%, transparent 60%);
  pointer-events: none;
}

.boot__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse 70% 50% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 70% 50% at 50% 50%, black 20%, transparent 70%);
  pointer-events: none;
}

/* Logo portada: enlace a Garri Pacheco */
.boot__logo {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.6);
  transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease), transform 0.3s var(--ease);
}

.boot__logo:hover {
  border-color: var(--accent-dim);
  box-shadow: 0 0 24px var(--glow), 0 0 48px rgba(0, 229, 255, 0.12);
  transform: scale(1.05);
}

.boot__logo:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

.boot__logo img {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.2));
  transition: filter 0.3s var(--ease);
}

.boot__logo:hover img {
  filter: drop-shadow(0 0 16px var(--glow));
}

@media (min-width: 600px) {
  .boot__logo { top: 2rem; left: 2rem; padding: 0.6rem; }
  .boot__logo img { width: 64px; height: 64px; }
}

.boot__content {
  position: relative;
  text-align: center;
  max-width: 420px;
}

.boot__title {
  font-family: var(--font-sans);
  font-size: clamp(2.25rem, 8vw, 3.5rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 0.75rem;
}

.boot__sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0 0 2.5rem;
}

/* Interruptor maestro */
.boot__switch {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  transition: color 0.3s var(--ease);
  touch-action: manipulation;
}

.boot__switch:hover {
  color: var(--accent);
}

.boot__switch[aria-pressed="true"] {
  color: var(--accent);
}

.boot__switch-track {
  display: flex;
  align-items: center;
  width: 64px;
  height: 32px;
  padding: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.boot__switch:hover .boot__switch-track {
  border-color: var(--accent-dim);
  box-shadow: 0 0 24px var(--glow);
}

.boot__switch-thumb {
  width: 22px;
  height: 22px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.4s var(--ease), background 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.boot__switch[aria-pressed="true"] .boot__switch-thumb {
  transform: translateX(32px);
  background: var(--accent);
  box-shadow: 0 0 20px var(--accent), 0 0 40px var(--glow);
}

.boot__switch[aria-pressed="true"] .boot__switch-track {
  border-color: var(--accent);
  box-shadow: 0 0 30px var(--glow);
}

.boot__switch-label {
  letter-spacing: 0.25em;
}

/* --------------------------------------------
   APP — Lista de razones (título + switch por razón)
   -------------------------------------------- */
.app {
  min-height: 100vh;
  position: relative;
  display: flex;
  flex-direction: column;
  transition: opacity 0.5s var(--ease);
}

.app.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.app-header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 1rem 1.5rem;
  background: rgba(3, 3, 6, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.app-header__inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.app-header__tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Interruptor "Volver al inicio" */
.app-header__switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.3s var(--ease);
}

.app-header__switch:hover {
  color: var(--accent);
}

.app-header__switch-track {
  display: flex;
  align-items: center;
  width: 40px;
  height: 22px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.app-header__switch:hover .app-header__switch-track {
  border-color: var(--accent-dim);
}

.app-header__switch-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
  transition: transform 0.35s var(--ease), background 0.35s var(--ease);
}

.app-header__switch[aria-pressed="false"] .app-header__switch-thumb {
  transform: translateX(0);
  background: var(--text-muted);
  box-shadow: none;
}

.app-header__switch[aria-pressed="true"] .app-header__switch-thumb {
  transform: translateX(18px);
}

.app-header__switch-label {
  letter-spacing: 0.1em;
}

.app-header__hint {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  width: 100%;
}

.app-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 229, 255, 0.4) var(--bg-panel);
}

/* Scrollbar a tono con la página (WebKit) */
.app-main::-webkit-scrollbar {
  width: 10px;
}
.app-main::-webkit-scrollbar-track {
  background: var(--bg-panel);
  border-radius: 5px;
  margin: 4px 0;
}
.app-main::-webkit-scrollbar-thumb {
  background: rgba(0, 229, 255, 0.25);
  border-radius: 5px;
  border: 2px solid var(--bg-panel);
}
.app-main::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dim);
}
.app-main::-webkit-scrollbar-thumb:active {
  background: var(--accent);
}

.reason-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.reason {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1rem;
  overflow: hidden;
  background: rgba(10, 10, 15, 0.5);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.reason.is-open {
  border-color: rgba(0, 229, 255, 0.3);
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.2), 0 0 40px var(--glow);
}

.reason__head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.25rem 1rem;
  min-height: 3.5rem;
}

.reason__num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 0.15rem;
}

.reason__title {
  font-family: var(--font-sans);
  font-size: clamp(1rem, 2.2vw, 1.2rem);
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  margin: 0;
  flex: 1;
  letter-spacing: -0.01em;
}

/* Interruptor por razón (contenido) */
.reason__switch {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin: -4px -4px -4px 0;
  border-radius: 6px;
  transition: background 0.2s var(--ease);
}

.reason__switch:hover {
  background: rgba(0, 229, 255, 0.08);
}

.reason__switch-track {
  display: flex;
  align-items: center;
  width: 44px;
  height: 24px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.reason__switch:hover .reason__switch-track {
  border-color: var(--accent-dim);
}

.reason__switch-thumb {
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.35s var(--ease), background 0.35s var(--ease), box-shadow 0.35s var(--ease);
}

.reason__switch[aria-pressed="true"] .reason__switch-thumb {
  transform: translateX(20px);
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.reason__switch[aria-pressed="true"] .reason__switch-track {
  border-color: var(--accent);
}

/* Contenido desplegable */
.reason__content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.5s var(--ease-out), opacity 0.4s var(--ease);
}

.reason__content.is-visible {
  max-height: 1200px;
  opacity: 1;
}

.reason__content p {
  margin: 0;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.75;
}

/* Footer — fijo al pie de la vista; la lista crece sin empujarlo */
.app-footer {
  flex-shrink: 0;
  padding: 1.5rem 1.5rem 2rem;
  border-top: 1px solid var(--border);
  background: rgba(3, 3, 6, 0.85);
  backdrop-filter: blur(8px);
}
.app-footer .app-footer__frame {
  max-width: 800px;
  margin: 0 auto;
}

.app-footer__frame {
  text-align: center;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(10, 10, 15, 0.6);
}

.app-footer__title {
  font-family: var(--font-sans);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.app-footer__text {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
}

.app-footer__btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  padding: 0.875rem 1.5rem;
  border-radius: 6px;
  text-decoration: none;
  transition: box-shadow 0.3s var(--ease), transform 0.3s var(--ease);
}

.app-footer__btn:hover {
  box-shadow: 0 0 30px var(--glow), 0 0 60px rgba(0, 229, 255, 0.15);
  transform: translateY(-1px);
}

/* --------------------------------------------
   Lang switcher ES/EN — sliding pill, tech style
   -------------------------------------------- */
.lang-switcher {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  min-width: 120px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(10, 10, 15, 0.7);
  padding: 3px;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 0 1px rgba(0, 229, 255, 0.06), 0 4px 16px rgba(0, 0, 0, 0.3);
}

.lang-switcher__pill {
  position: absolute;
  left: 3px;
  top: 3px;
  bottom: 3px;
  width: calc(50% - 3px);
  border-radius: 8px;
  background: rgba(0, 229, 255, 0.15);
  box-shadow: 0 0 16px var(--glow), inset 0 0 0 1px rgba(0, 229, 255, 0.2);
  transition: transform 0.35s var(--ease);
  pointer-events: none;
  z-index: 0;
}

.lang-switcher[data-lang="en"] .lang-switcher__pill {
  transform: translateX(100%);
}

.lang-switcher__option {
  flex: 1;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.lang-switcher__option:hover {
  color: var(--text);
}

.lang-switcher__option[aria-pressed="true"] {
  color: var(--accent);
  text-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

.lang-switcher__option:focus {
  outline: none;
}

.lang-switcher__option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Switcher in app header: smaller, no bottom margin */
.app-header__inner .lang-switcher {
  margin-bottom: 0;
  margin-left: auto;
  min-width: 100px;
  height: 36px;
}

.app-header__inner .lang-switcher__option {
  font-size: 0.75rem;
}

/* --------------------------------------------
   Responsive
   -------------------------------------------- */
@media (max-width: 600px) {
  .boot__title { font-size: 1.875rem; }
  .app-header__inner { flex-direction: column; align-items: flex-start; }
  .reason__head {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .reason__title { min-width: 0; }
  .reason__switch { margin-left: auto; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .boot, .reason__content, .reason__switch-thumb {
    transition-duration: 0.01ms !important;
  }
  .reason__content.is-visible { max-height: none; }
}
