/* ==========================================================================
   CACHIPAYESTÉREO 89.6 FM — SISTEMA DE DISEÑO · base.css
   "La señal que nace en la montaña"
   --------------------------------------------------------------------------
   Hoja base compartida por TODAS las páginas (sitio público y panel JSMM).
   Contiene: tokens (colores, tipografía, espacios, radios, sombras, tiempos),
   tema oscuro/claro, reset, tipografía fluida, layout y utilidades.
   Los componentes viven en components.css; lo específico de cada página en
   pages.css (público) o admin.css (panel).
   ========================================================================== */

/* --- 1. TOKENS (sistema visual estilo iOS) --------------------------------- */
:root {
  /* Colores de marca originales del logo (se conservan como referencia; el
     sitio ya no los usa directamente, los remapea cada tema abajo). */
  --logo-verde: #3a781d; --logo-amarillo: #ffb902; --logo-rojo: #de0000;
  --ink: #111111;
  --paper: #ffffff;

  /* Tipografía: SF Pro / San Francisco en Apple, con respaldo a la anterior */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "DM Sans", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  /* Escala tipográfica fluida (móvil 360 → escritorio 1440) */
  --fs-xs: clamp(.75rem, .73rem + .1vw, .8125rem);
  --fs-sm: clamp(.875rem, .85rem + .12vw, .9375rem);
  --fs-base: clamp(1rem, .97rem + .15vw, 1.0625rem);
  --fs-lg: clamp(1.125rem, 1.05rem + .35vw, 1.3125rem);
  --fs-xl: clamp(1.375rem, 1.2rem + .8vw, 1.75rem);
  --fs-2xl: clamp(1.75rem, 1.4rem + 1.6vw, 2.5rem);
  --fs-3xl: clamp(2.125rem, 1.5rem + 2.8vw, 3.75rem);
  --fs-4xl: clamp(2.75rem, 1.6rem + 5vw, 5.75rem);
  --fs-mega: clamp(7rem, 3rem + 22vw, 22rem);

  /* Espacios: más aire */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem; --sp-5: 1.5rem;
  --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4.5rem; --sp-9: 7rem;
  --section-y: clamp(4.5rem, 3.4rem + 5.5vw, 9rem);
  --gutter: clamp(1rem, .5rem + 2.2vw, 2rem);
  --container: 1200px;

  /* Radios muy redondeados (iOS) */
  --r-xs: 10px; --r-sm: 14px; --r-md: 20px; --r-lg: 28px; --r-xl: 38px; --r-pill: 999px;

  /* Movimiento con curvas iOS */
  --ease-ios: cubic-bezier(.32, .72, 0, 1);
  --ease-out: var(--ease-ios);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --ease-inout: cubic-bezier(.65, 0, .35, 1);
  --t-fast: 180ms; --t-base: 320ms; --t-slow: 600ms; --t-reveal: 650ms;

  --blur: saturate(180%) blur(20px);
  --player-h: 88px;
  --header-h: 76px;

  --ink-muted: var(--text-mute); --ink-soft: var(--text-soft); --linea: var(--line);
  --radius: var(--r-lg); --shadow-soft: var(--shadow-md);
}

/* --- 2. TEMA OSCURO (por defecto): fondo casi negro + acento ROJO ------------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f11;
  --bg-2: #121316;
  --surface: #16171a;
  --surface-2: #1c1d21;
  --surface-3: #25262b;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f5f5f7;
  --text-soft: #d1d1d6;
  --text-mute: #a1a1a8;           /* 7.4:1 sobre --bg */

  --accent: #e5262b;              /* fondos de botones, badges, barras */
  --accent-ink: #ffffff;          /* texto sobre rojo: 5.0:1 */
  --accent-text: #ff5459;         /* rojo para TEXTO sobre fondo oscuro: 5.9:1 */
  --hover: #22c55e;               /* verde de hover para texto/iconos/brillos: 8.4:1 */
  --hover-bg: #15803d;            /* verde de hover como FONDO con texto blanco: 5.0:1 */
  --hover-ink: #ffffff;
  --link: var(--accent-text);
  --firefly: 255, 214, 74;        /* luciérnagas amarillas (r,g,b) */

  --glass: rgba(22, 23, 26, .55);
  --glass-strong: rgba(22, 23, 26, .78);
  --glass-border: rgba(255, 255, 255, .1);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
  --shadow-md: 0 12px 34px -12px rgba(0, 0, 0, .55);
  --shadow-lg: 0 28px 70px -22px rgba(0, 0, 0, .7);
  --grain-opacity: 0;
}

/* --- 3. TEMA CLARO: fondo iOS + acento AMARILLO ----------------------------- */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-2: #ececf0;
  --surface: #ffffff;
  --surface-2: #f2f2f5;
  --surface-3: #e5e5ea;
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .16);
  --text: #111113;
  --text-soft: #3a3a3f;
  --text-mute: #5e5e66;           /* 6.0:1 */

  --accent: #f5c400;              /* SOLO como fondo (botones, chips, badges) */
  --accent-ink: #111111;          /* texto sobre amarillo: 11.5:1 */
  --accent-text: #7a5c00;         /* "amarillo" oscuro para TEXTO: 5.7:1 (#a37f00 daba 3.4:1) */
  --hover: #157a3a;               /* verde para texto/iconos: 5.1:1 */
  --hover-bg: #16a34a;
  --hover-ink: #ffffff;
  --link: var(--accent-text);
  --firefly: 229, 38, 43;         /* luciérnagas rojas */

  --glass: rgba(255, 255, 255, .6);
  --glass-strong: rgba(255, 255, 255, .82);
  --glass-border: rgba(0, 0, 0, .06);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .06);
  --shadow-md: 0 12px 30px -14px rgba(0, 0, 0, .18);
  --shadow-lg: 0 28px 60px -24px rgba(0, 0, 0, .25);
  --grain-opacity: 0;
}
/* Nota: blanco sobre #16a34a es 3.3:1 (AA solo para texto grande/negrita ≥14pt);
   los botones usan texto en negrita, y en claro el hover se oscurece a #15803d abajo. */
:root[data-theme="light"] { --hover-bg: #15803d; }

/* --- 3b. Remapeo de los colores antiguos al acento del tema ------------------
   Todo lo que antes era verde/amarillo/rojo pasa al acento (rojo en oscuro,
   amarillo en claro). Así ningún componente queda con colores viejos. */
:root {
  --verde: var(--accent); --amarillo: var(--accent); --rojo: var(--accent);
  --verde-lux: var(--accent-text); --rojo-lux: var(--accent-text);
  --verde-dark: var(--accent-text); --rojo-dark: var(--accent-text); --amarillo-dark: var(--accent-text);
  --grad-brand: linear-gradient(100deg, var(--accent), color-mix(in oklab, var(--accent) 70%, var(--text)));
  --grad-brand-lux: linear-gradient(100deg, var(--accent-text), color-mix(in oklab, var(--accent-text) 65%, var(--text)));
  --glow-amarillo: 0 10px 30px -10px color-mix(in oklab, var(--accent) 70%, transparent);
  --glow-verde: 0 10px 30px -10px color-mix(in oklab, var(--hover-bg) 70%, transparent);
  --glow-rojo: var(--glow-amarillo);
  --g0: var(--accent-text); --g1: var(--accent-text); --g2: var(--accent-text);
  --hill-1: var(--surface-3); --hill-2: var(--surface-2); --hill-3: var(--surface);
  --ok: var(--hover); --warn: var(--accent-text); --danger: var(--accent-text);
}

/* --- 4. RESET --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}
img, svg, video, canvas, iframe { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; }
h1, h2, h3, h4, p, dl, dd, figure, blockquote { margin: 0; }
[hidden] { display: none !important; }
body.is-locked { overflow: hidden; }

/* Grano sutil sobre toda la página (textura de papel / cinta) */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 9990; pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay;
}

/* --- 5. TIPOGRAFÍA ----------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.02em;
  text-wrap: balance;
}
h1 { font-size: var(--fs-4xl); font-weight: 800; letter-spacing: -.035em; }
h2 { font-size: var(--fs-3xl); letter-spacing: -.03em; }
h3 { font-size: var(--fs-xl); letter-spacing: -.015em; line-height: 1.15; }
h4 { font-size: var(--fs-lg); }
p { text-wrap: pretty; }
.lead { font-size: var(--fs-lg); color: var(--text-soft); max-width: 60ch; }
.muted { color: var(--text-mute); }
.small { font-size: var(--fs-sm); }
.text-center { text-align: center; }
strong { font-weight: 700; }

/* Palabra destacada con el degradado del logo (los h1/h2 del sitio usan esta clase) */
.text-verde-dark, .text-gradient {
  background: var(--grad-brand-lux);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  padding-inline: .02em;
}
:root[data-theme="light"] .text-verde-dark, :root[data-theme="light"] .text-gradient {
  background: linear-gradient(100deg, var(--verde-dark) 0%, color-mix(in oklab, var(--amarillo) 80%, var(--rojo)) 55%, var(--rojo) 100%);
  -webkit-background-clip: text; background-clip: text;
}

::selection { background: var(--accent); color: var(--accent-ink); }

/* --- 6. LAYOUT -------------------------------------------------------------- */
.container { width: min(100% - var(--gutter) * 2, var(--container)); margin-inline: auto; }
.section { position: relative; padding-block: var(--section-y); }
.section--tight { padding-block: clamp(2rem, 1.5rem + 3vw, 4.5rem); }
.section--alt { background: var(--bg-2); }
.grid { display: grid; gap: clamp(1rem, .6rem + 1.4vw, 1.75rem); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-4); } .mt-4 { margin-top: var(--sp-6); }
.mb-0 { margin-bottom: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden-sm { display: inline; } .hidden-lg { display: none; }
@media (max-width: 720px) { .hidden-sm { display: none; } .hidden-lg { display: inline; } }

/* Accesibilidad: enlace "Saltar al contenido" y foco visible estilizado */
.skip-link {
  position: fixed; left: 1rem; top: -4rem; z-index: 10000;
  padding: .75rem 1.1rem; border-radius: var(--r-sm);
  background: var(--accent); color: var(--accent-ink); font-weight: 700;
  transition: top var(--t-fast) var(--ease-out);
}
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 3px solid var(--hover); outline-offset: 3px; border-radius: 8px; }

/* --- 7. REVELADO AL HACER SCROLL (bidireccional) ---------------------------- */
/* Solo se oculta si hay JS (clase js-anim en <html>); si algo falla, nada queda
   invisible. Entran ANTES de llegar a la pantalla (rootMargin positivo) y salen
   cuando ya quedaron lejos, al bajar y al subir. Solo transform/opacity/filter. */
.js-anim .reveal {
  opacity: 0;
  transform: translate3d(0, 26px, 0);
  transition: opacity var(--t-reveal) var(--ease-ios), transform var(--t-reveal) var(--ease-ios), filter var(--t-reveal) var(--ease-ios);
  transition-delay: calc(min(var(--rd, 0), 6) * 60ms);
}
.js-anim .reveal--left { transform: translate3d(-30px, 0, 0); }
.js-anim .reveal--right { transform: translate3d(30px, 0, 0); }
.js-anim .reveal--scale { transform: scale(.94); }
.js-anim .reveal--blur { transform: translate3d(0, 14px, 0); filter: blur(10px); }
.js-anim .reveal--curtain { transform: scale(.97); }
.js-anim .reveal.is-in { opacity: 1; transform: none; filter: none; }
/* Al salir no hay retardo escalonado: desaparecen todos juntos y rápido */
.js-anim .reveal:not(.is-in) { transition-delay: 0s; transition-duration: 380ms; }
.reveal.is-done { transition-delay: 0s; }
.d-1{--rd:0}.d-2{--rd:1}.d-3{--rd:2}.d-4{--rd:3}.d-5{--rd:4}.d-6{--rd:5}.d-7{--rd:6}.d-8{--rd:7}

/* Títulos palabra por palabra ([data-words], lo arma reveal en main.js) */
.js-anim .w { display: inline-block; opacity: 0; transform: translate3d(0, .5em, 0); filter: blur(6px);
  transition: opacity 600ms var(--ease-ios), transform 600ms var(--ease-ios), filter 600ms var(--ease-ios);
  transition-delay: calc(var(--wi, 0) * 55ms); }
.js-anim .is-in .w, .js-anim .w-in .w { opacity: 1; transform: none; filter: none; }

/* Parallax ligero de imágenes (lo mueve main.js con --py) */
.js-anim [data-img-parallax] img { transform: translate3d(0, var(--py, 0px), 0) scale(1.08); will-change: transform; }

/* --- 7b. PANTALLA DE CARGA ENTRE PÁGINAS ------------------------------------- */
.page-loader {
  position: fixed; inset: 0; z-index: 10001; display: grid; place-items: center;
  background: var(--bg); opacity: 1; visibility: visible;
  transition: opacity 520ms var(--ease-ios), visibility 0s linear 520ms;
  /* Seguro: si el JS no corre, se disuelve solo a los 6 s */
  animation: loader-failsafe 0s linear 6s forwards;
}
.page-loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; animation: none; }
.page-loader.is-leaving { opacity: 1; visibility: visible; transition: opacity 260ms var(--ease-ios); animation: none; }
.page-loader__inner { display: grid; justify-items: center; gap: 1.1rem; transition: transform 520ms var(--ease-ios); }
.page-loader.is-hidden .page-loader__inner { transform: scale(.94); }
.page-loader__logo { width: 64px; height: 64px; border-radius: 18px; box-shadow: var(--shadow-md); animation: loader-breathe 1.6s var(--ease-inout) infinite; }
.page-loader__bars { display: flex; align-items: flex-end; gap: 4px; height: 22px; }
.page-loader__bars i { width: 4px; height: 100%; border-radius: 3px; background: var(--accent); transform-origin: bottom; animation: loader-bar 1s var(--ease-inout) infinite; }
.page-loader__bars i:nth-child(2) { animation-delay: .12s; } .page-loader__bars i:nth-child(3) { animation-delay: .24s; }
.page-loader__bars i:nth-child(4) { animation-delay: .36s; } .page-loader__bars i:nth-child(5) { animation-delay: .48s; }
.page-loader__text { font-size: var(--fs-xs); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-mute); }
@keyframes loader-bar { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }
@keyframes loader-breathe { 50% { transform: scale(1.06); } }
@keyframes loader-failsafe { to { opacity: 0; visibility: hidden; pointer-events: none; } }

/* --- 8. TRANSICIONES ENTRE PÁGINAS (View Transitions API) ------------------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out 260ms var(--ease-out) both; }
::view-transition-new(root) { animation: vt-in 380ms var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }
/* El header y el reproductor "permanecen" entre páginas */
.site-header { view-transition-name: site-header; }
.player { view-transition-name: site-player; }
::view-transition-group(site-header), ::view-transition-group(site-player) { animation-duration: 0s; }
/* Alternativa donde no existe la API: fade simple al cargar */
@supports not (view-transition-name: x) {
  main { animation: page-fade .45s var(--ease-out) both; }
  @keyframes page-fade { from { opacity: 0; transform: translateY(8px); } }
}

/* --- 9. MOVIMIENTO REDUCIDO -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .js-anim .reveal, .js-anim .w { opacity: 1; transform: none; filter: none; clip-path: none; }
  .js-anim [data-img-parallax] img { transform: none; }
  .page-loader__logo, .page-loader__bars i { animation: none !important; }
  .marquee__track { animation: none !important; }
  .cursor { display: none !important; }
  @view-transition { navigation: none; }
}

@media (max-width: 900px) {
  .js-anim .reveal--left, .js-anim .reveal--right { transform: translate3d(0, 28px, 0); }
}
