/* ==========================================================================
   base.css — Reset, Variables, Tipografía y Modos por Dispositivo
   Soporte nativo para: Desktop, Mobile y Smart TV (10-foot UI).
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  color-scheme: dark;

  /* Paleta base (Tema Oscuro por defecto) */
  --bg: #0a0b10;
  --bg-rgb: 10, 11, 16;
  --surface: #12141c;
  --surface-2: #1a1d28;
  --surface-3: #222634;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f2f3f7;
  --text-muted: #8b90a3;
  --accent: #7c5cff;
  --accent-hover: #9479ff;
  --accent-soft: rgba(124, 92, 255, 0.15);
  --rating: #f5c518;
  --danger: #ff5d5d;

  /* Tipografía y Escala Base */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-lg: clamp(1.125rem, 1vw + 0.9rem, 1.375rem);
  --fs-xl: clamp(1.375rem, 1.5vw + 1rem, 1.75rem);
  --fs-hero: clamp(2rem, 4vw + 1rem, 4rem);

  --lh-body: 1.5;
  --lh-heading: 1.1;
  --ls-heading: -0.02em;

  /* Espaciado */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;

  /* Radios */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Sombras */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);

  /* Transiciones */
  --tr-fast: 200ms ease;
  --tr-smooth: 400ms cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Dimensiones fijas de tarjeta (Desktop compacto: clamp(140px, 11vw, 185px)) */
  --card-w: clamp(140px, 11vw, 185px);
  --cards-gap: 14px;

  --container-max: 1440px;
  --container-px: clamp(16px, 4vw, 56px);

  --shimmer-from: var(--surface);
  --shimmer-mid: var(--surface-2);
}

/* Tema Claro */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-rgb: 248, 250, 252;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: rgba(15, 23, 42, 0.12);
  --text: #0f172a;
  --text-muted: #475569;
  --accent: #6b4df0;
  --accent-hover: #5a3fe0;
  --accent-soft: rgba(107, 77, 240, 0.12);
  --rating: #d97706;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shimmer-from: #e2e8f0;
  --shimmer-mid: #f1f5f9;
}

/* ==========================================================================
   Modo TV (Interfaz de 10 pies, 1920x1080 / 4K / 720p)
   ========================================================================== */
[data-device="tv"] {
  /* Escalado de fuente raíz relativo a la pantalla */
  font-size: clamp(16px, 1.04vw, 34px);
  cursor: none !important;

  --card-w: 16vw;
  --cards-gap: 1.2rem;
  --container-max: 100%;
  --container-px: 5vw; /* 5% overscan horizontal */

  /* Textos de alta legibilidad en TV (>= 1.1rem) */
  --fs-xs: 1.1rem;
  --fs-sm: 1.2rem;
  --fs-base: 1.25rem;
  --fs-lg: 1.6rem;
  --fs-xl: 2rem;
  --fs-hero: clamp(3.2rem, 3.8vw, 4.5rem);

  /* Desactivar efectos pesados de GPU/CPU en Smart TVs */
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.6);
}

[data-device="tv"] * {
  cursor: none !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

[data-device="tv"] *::-webkit-scrollbar {
  display: none !important;
}

/* Estilo de foco supremo para control remoto en TV */
[data-device="tv"] a:focus,
[data-device="tv"] button:focus,
[data-device="tv"] input:focus,
[data-device="tv"] .media-card:focus,
[data-device="tv"] [tabindex="0"]:focus {
  outline: 4px solid var(--accent) !important;
  outline-offset: 4px !important;
  transform: scale(1.08) !important;
  z-index: 50 !important;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.7) !important;
  transition: transform 150ms ease, box-shadow 150ms ease !important;
  will-change: transform;
}

/* ==========================================================================
   Modo Móvil (< 768px o pointer: coarse)
   ========================================================================== */
[data-device="mobile"] {
  --card-w: 46vw;
  --cards-gap: 12px;
  --container-px: 16px;

  --fs-hero: 1.9rem;
  --fs-xl: 1.35rem;
}

/* Reset y Base Global */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-family);
  font-size: 16px;
  color-scheme: dark;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

[data-theme="light"] {
  color-scheme: light;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--text);
  line-height: var(--lh-body);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Transiciones de tema habilitadas únicamente después del primer pintado */
.theme-ready body,
.theme-ready .site-header,
.theme-ready .site-footer {
  transition: background-color var(--tr-fast), color var(--tr-fast), border-color var(--tr-fast);
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

/* Evitar zoom automático indeseado en iOS */
[data-device="mobile"] input,
[data-device="mobile"] select,
[data-device="mobile"] textarea {
  font-size: 16px !important;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--lh-heading);
  letter-spacing: var(--ls-heading);
  font-weight: 700;
  color: var(--text);
}

/* Foco accesible para escritorio */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Transiciones Nativas entre Páginas (Cross-Document View Transitions)
   Elimina el parpadeo y recarga brusca tradicional de la web estilo Flutter/SPA.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  /* Mantener el menú superior 100% estático y libre de parpadeos */
  .site-header {
    view-transition-name: site-header;
  }

  .main-content {
    view-transition-name: main-content;
  }

  ::view-transition-old(main-content) {
    animation: 140ms cubic-bezier(0.4, 0, 1, 1) both fade-out;
  }

  ::view-transition-new(main-content) {
    animation: 200ms cubic-bezier(0, 0, 0.2, 1) both fade-slide-in;
  }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes fade-slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
