/* ═══════════════════════════════════════════
 * RESET + CUSTOM PROPERTIES CANÓNICAS
 * El Faro · Preventor de Reparos Legales · Divergente
 * Toda la paleta vive aquí · cambiar una variable propaga al sitio entero
 * ═══════════════════════════════════════════ */

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

/* Fix universal · cualquier elemento con [hidden] debe ocultarse aunque tenga display:flex */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
}

button {
  cursor: pointer;
}

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

ul, ol {
  list-style: none;
}

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

:root {
  /* ═══ Paleta noche cálida ═══ */
  --noche: #060a14;
  --noche-suave: #0d1424;
  --noche-card: #131c30;
  --noche-glass: rgba(19, 28, 48, 0.7);
  --noche-profunda: #02040a;

  /* ═══ Acentos oro · tres tonos ═══ */
  --oro-foil: #d4a574;
  --oro-vivo: #f4c87a;
  --oro-luz: #ffe4a5;
  --bronce: #6b4f24;
  --bronce-vivo: #a87c3a;
  --filigrana: #4a3818;

  /* ═══ Cremas (textos) ═══ */
  --crema: #f0e6d0;
  --crema-suave: #b8ad95;
  --crema-tenue: rgba(240, 230, 208, 0.6);

  /* ═══ Cinco colores · uno por libro ═══ */
  --libro-1: #6b3a1a;
  --libro-2: #4a3525;
  --libro-3: #1e3a5f;
  --libro-4: #8b6f1f;
  --libro-5: #3d2a1a;

  /* ═══ Acentos funcionales ═══ */
  --error: #d96660;
  --exito: #7fb87a;

  /* ═══ Familias tipográficas ═══ */
  --fuente-display: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --fuente-titulo: 'Cinzel', Georgia, serif;
  --fuente-editorial: 'Cormorant Garamond', Georgia, serif;
  --fuente-cuerpo: 'Crimson Pro', Georgia, serif;
  --fuente-mono: ui-monospace, 'SF Mono', Menlo, Monaco, Consolas, monospace;

  /* ═══ Escalas tipográficas fluidas ═══ */
  --texto-xs: clamp(0.7rem, 0.7vw, 0.75rem);
  --texto-sm: clamp(0.85rem, 0.9vw, 0.95rem);
  --texto-base: clamp(1rem, 1.2vw, 1.1rem);
  --texto-md: clamp(1.1rem, 1.4vw, 1.25rem);
  --texto-lg: clamp(1.3rem, 1.8vw, 1.6rem);
  --texto-xl: clamp(1.8rem, 2.6vw, 2.3rem);
  --titulo-sec: clamp(2rem, 4vw, 3.2rem);
  --titulo-hero: clamp(2.5rem, 7vw, 5.2rem);

  /* ═══ Espaciado canónico ═══ */
  --espacio-xs: 0.5rem;
  --espacio-sm: 1rem;
  --espacio-md: 1.5rem;
  --espacio-lg: 2.5rem;
  --espacio-xl: 4rem;
  --espacio-xxl: 6rem;

  /* ═══ Bordes y radios ═══ */
  --radio-sm: 4px;
  --radio-md: 8px;
  --radio-lg: 12px;
  --borde-sutil: 1px solid rgba(212, 165, 116, 0.15);
  --borde-medio: 1px solid rgba(212, 165, 116, 0.3);
  --borde-fuerte: 1px solid var(--bronce);

  /* ═══ Sombras ═══ */
  --sombra-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --sombra-md: 0 10px 30px rgba(0, 0, 0, 0.5);
  --sombra-lg: 0 20px 60px rgba(0, 0, 0, 0.7);
  --sombra-oro: 0 0 30px rgba(244, 200, 122, 0.2);

  /* ═══ Transiciones canónicas ═══ */
  --ease-suave: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-rebote: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transicion-rapida: 0.2s var(--ease-suave);
  --transicion-base: 0.3s var(--ease-suave);
  --transicion-lenta: 0.6s var(--ease-suave);

  /* ═══ Z-index layers ═══ */
  --z-canvas: 0;
  --z-overlay: 1;
  --z-neblina: 2;
  --z-relampago: 3;
  --z-contenido: 10;
  --z-biblioteca: 50;
  --z-header: 60;
  --z-volver: 70;
  --z-toast: 100;
  --z-modal: 200;

  /* ═══ Pixel art scale (para canvas) ═══ */
  --px-scale: 6;
}

body {
  background: var(--noche);
  color: var(--crema);
  font-family: var(--fuente-cuerpo);
  font-size: var(--texto-base);
  line-height: 1.65;
}

@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;
  }
  #canvas-tormenta, #canvas-faro-3d {
    display: none;
  }
}

.visualmente-oculto {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
