/* ==========================================================================
   MAD.CEO · Control
   base.css — Reinicio, tipografía y utilidades generales.
   ========================================================================== */

/* --- Tipografías autoalojadas (las mismas de mad.ceo) ---------------------- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/playfair-display-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/playfair-display-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Playfair Display';
  font-style: italic;
  font-weight: 400 900;
  font-display: swap;
  src: url('../fonts/playfair-display-latin-wght-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}

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

* { margin: 0; }

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

body {
  min-height: 100dvh;
  /* Respeta el notch y la barra de gestos en los teléfonos. */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  overflow-x: hidden;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente);
  font-size: var(--t-base);
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: -0.003em;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

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

/* En Windows con modo oscuro, las opciones nativas heredan el color del
   sistema si no se fija explícitamente. */
select option {
  background-color: var(--superficie);
  color: var(--texto);
}

/* Toque en móvil: sin retardo de doble tap ni destello gris de Android. */
a, button, summary, label, [role='button'], input, select, textarea {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(144, 224, 239, 0.16);
}

h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.018em;
  text-wrap: balance;
}

/* Titulares de presencia: la serif de la marca. */
.display {
  font-family: var(--fuente-display);
  font-weight: 600;
  letter-spacing: -0.012em;
}
.display em { font-style: italic; font-weight: 500; color: var(--marca-texto); }

h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }
h4 { font-size: var(--t-md); }

p { text-wrap: pretty; }

a {
  color: var(--enlace);
  text-decoration: none;
  transition: color var(--v-rapida) var(--ease-suave);
}
a:hover { color: var(--enlace-hover); }

code, kbd, samp, .num, .mono {
  font-family: var(--fuente-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

code {
  background: var(--superficie-3);
  border: 1px solid var(--borde);
  border-radius: var(--r-xs);
  padding: 0.1em 0.38em;
}

hr {
  border: 0;
  border-top: 1px solid var(--borde);
  margin: var(--e-6) 0;
}

ul, ol { padding-left: 1.15rem; }

/* --- Foco visible --------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--enfoque);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
:focus:not(:focus-visible) { outline: none; }

/* --- Barras de desplazamiento -------------------------------------------- */

* { scrollbar-width: thin; scrollbar-color: var(--borde-fuerte) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--borde-fuerte);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: var(--r-pill);
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--texto-3); background-clip: content-box; }

/* --- Selección ------------------------------------------------------------ */

::selection {
  background: var(--marca);
  color: var(--sobre-marca);
}

/* --- Utilidades ----------------------------------------------------------- */

.visualmente-oculto {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.saltar-al-contenido {
  position: fixed;
  top: var(--e-3);
  left: var(--e-3);
  z-index: var(--z-saltar);
  transform: translateY(-160%);
  background: var(--enlace);
  color: var(--texto-inv);
  padding: 0.6rem 1rem;
  border-radius: var(--r-md);
  font-weight: 500;
  transition: transform var(--v-media) var(--ease);
}
.saltar-al-contenido:focus { transform: translateY(0); color: var(--texto-inv); }

.texto-tenue { color: var(--texto-3); }
.texto-suave { color: var(--texto-2); }
.texto-marca { color: var(--marca-texto); }
.texto-pequeno { font-size: var(--t-sm); }
.texto-mini { font-size: var(--t-xs); }
.ta-der { text-align: right; }
.ta-cen { text-align: center; }
.negrita { font-weight: 600; }
.mayusculitas {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--texto-3);
}
.nowrap { white-space: nowrap; }
.sin-margen { margin: 0; }
.ancho-completo { width: 100%; }

.pila { display: flex; flex-direction: column; gap: var(--e-3); }
.pila--sm { gap: var(--e-2); }
.pila--xs { gap: 0.1rem; }
.pila--lg { gap: var(--e-5); }
.fila { display: flex; align-items: center; gap: var(--e-3); flex-wrap: wrap; }
.fila--entre { justify-content: space-between; }
.fila--fin { justify-content: flex-end; }
.fila--sm { gap: var(--e-2); }
.fila--apretada { flex-wrap: nowrap; }

.rejilla { display: grid; gap: var(--e-4); }
.rejilla--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rejilla--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rejilla--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rejilla--auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

@media (max-width: 1100px) {
  .rejilla--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rejilla--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .rejilla--2,
  .rejilla--3,
  .rejilla--4 { grid-template-columns: minmax(0, 1fr); }
}

/* --- Grano analógico: fijo y sin eventos, no cuesta repintados ------------- */

.grano {
  position: fixed;
  inset: 0;
  z-index: var(--z-grano);
  pointer-events: none;
  opacity: var(--grano-opacidad);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-tema='claro'] .grano { mix-blend-mode: multiply; filter: invert(1); }

/* --- Tema: mostrar/ocultar según modo ------------------------------------- */

:root[data-tema='oscuro'] .solo-claro { display: none; }
:root[data-tema='claro'] .solo-oscuro { display: none; }

/* --- Animaciones compartidas ---------------------------------------------- */

@keyframes aparecer {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes aparecer-suave {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes escalar-entrada {
  from { opacity: 0; transform: translateY(14px) scale(0.975); }
  to   { opacity: 1; transform: none; }
}

@keyframes pulso-suave {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

@keyframes brillo-cargando {
  from { background-position: -420px 0; }
  to   { background-position: 420px 0; }
}

@keyframes girar {
  to { transform: rotate(360deg); }
}
