/**
 * base.css — Estilos base y reset global: Mallorca Solar Green
 *
 * Importa tokens.css y define los estilos fundamentales:
 * reset, tipografía base, utilidades de layout y grain overlay.
 */

/* ─── TOKENS ──────────────────────────────────────────────────────────── */
@import 'tokens.css';

/* ─── GOOGLE FONTS ────────────────────────────────────────────────────── */
/* Fraunces: serif variable óptico con eje wght 100-900 y opsz 9-144 */
/* Inter Tight: sans-serif compacto, pesos 400, 500, 600 */
/* JetBrains Mono: monoespaciado diseñado para legibilidad de datos */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,100..900;1,9..144,100..900&family=Inter+Tight:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');


/* ─── RESET ───────────────────────────────────────────────────────────── */

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

/* Prevenir desbordamiento horizontal no deseado */
html,
body {
  overflow-x: hidden;
}


/* ─── HTML ────────────────────────────────────────────────────────────── */

html {
  /* Scroll suave para toda la página */
  scroll-behavior: smooth;
  /* Base 100% para que 1rem = 16px por defecto del navegador */
  font-size: 100%;
  /* Indicar al navegador que usamos tema claro */
  color-scheme: light;
  /* Tamaño de scroll: el viewport incluye las barras de scroll */
  scrollbar-gutter: stable;
}


/* ─── BODY ────────────────────────────────────────────────────────────── */

body {
  font-family: var(--font-body);
  background-color: var(--bone);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  /* Suavizado de fuentes para pantallas de alta densidad */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Evitar que el texto se redimensione en móvil al rotar */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}


/* ─── TIPOGRAFÍA ──────────────────────────────────────────────────────── */

h1 {
  font-family: var(--font-display);
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: 700;
  /* Tracking negativo para titulares grandes: más editorial */
  letter-spacing: -0.02em;
}

h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: 600;
}

h3 {
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  font-weight: 600;
}

h4 {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.3;
}

h5,
h6 {
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.4;
}

p {
  line-height: var(--lh-body);
}

/* Separación entre párrafos consecutivos */
p + p {
  margin-top: var(--s-2);
}

strong,
b {
  font-weight: 600;
}

em,
i {
  font-style: italic;
}

small {
  font-size: var(--fs-small);
}

/* Código inline */
code {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  background: var(--mist);
  padding: 0.1em 0.35em;
}

/* Bloques de código */
pre {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  line-height: var(--lh-mono);
  background: var(--ink);
  color: var(--bone);
  padding: var(--s-3);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* Lista base */
ul,
ol {
  padding-left: var(--s-3);
  line-height: var(--lh-body);
}

li + li {
  margin-top: var(--s-1);
}


/* ─── ENLACES ─────────────────────────────────────────────────────────── */

a {
  /* Hereda el color del contenedor para máxima flexibilidad */
  color: inherit;
  text-decoration: none;
}


/* ─── MULTIMEDIA ──────────────────────────────────────────────────────── */

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

/* Las imágenes dentro de elementos con dimensiones fijas no se distorsionan */
img {
  height: auto;
}


/* ─── FORMULARIOS (reset base) ────────────────────────────────────────── */

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

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


/* ─── TABLAS ──────────────────────────────────────────────────────────── */

table {
  border-collapse: collapse;
  width: 100%;
}

th,
td {
  padding: var(--s-1) var(--s-2);
  text-align: left;
  border-bottom: var(--border);
}

th {
  font-family: var(--font-mono);
  font-size: var(--fs-small);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}


/* ─── SELECCIÓN DE TEXTO ──────────────────────────────────────────────── */

/* Sol sobre tinta: selección llamativa y reconocible */
::selection {
  background-color: var(--sun);
  color: var(--ink);
}

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


/* ─── FOCO ────────────────────────────────────────────────────────────── */

/* Sólo visible al navegar con teclado, no con ratón */
:focus-visible {
  outline: 2px solid var(--sun);
  outline-offset: 3px;
}

/* Eliminar el foco por defecto para usuarios de ratón */
:focus:not(:focus-visible) {
  outline: none;
}


/* ─── SCROLLBAR ───────────────────────────────────────────────────────── */

/* Scrollbar personalizada en navegadores WebKit */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bone);
}

::-webkit-scrollbar-thumb {
  background: var(--stone);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink);
}


/* ─── CONTENEDORES DE LAYOUT ──────────────────────────────────────────── */

/* Contenedor principal: 1440px máximo, centrado */
.container {
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--s-4);
  padding-right: var(--s-4);
}

@media (max-width: 768px) {
  .container {
    padding-left: var(--s-3);
    padding-right: var(--s-3);
  }
}

/* Contenedor estrecho para columnas editoriales */
.container--narrow {
  max-width: var(--container-narrow);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--s-4);
  padding-right: var(--s-4);
}

@media (max-width: 768px) {
  .container--narrow {
    padding-left: var(--s-3);
    padding-right: var(--s-3);
  }
}

/* Contenedor ancho para secciones full-bleed */
.container--wide {
  max-width: var(--container-wide);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--s-4);
  padding-right: var(--s-4);
}


/* ─── UTILIDAD MONO ───────────────────────────────────────────────────── */

/* Para etiquetas técnicas, datos, referencias */
.font-mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  line-height: var(--lh-mono);
}

/* Clase display para titulares en Fraunces */
.font-display {
  font-family: var(--font-display);
}


/* ─── UTILIDADES GENERALES ────────────────────────────────────────────── */

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

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }

.color-stone { color: var(--stone); }
.color-sun   { color: var(--sun); }
.color-green { color: var(--green); }

.mt-auto { margin-top: auto; }


/* ─── GRAIN OVERLAY ───────────────────────────────────────────────────── */

/**
 * Textura de grano fotográfico aplicada como overlay fijo sobre toda la página.
 * Aporta la sensación táctil de papel o impresión analógica característica
 * de la estética editorial mediterránea. Opacity muy baja para que sea sutil.
 *
 * Técnica: SVG inline con feTurbulence (fractalNoise) como data URI.
 * position:fixed + pointer-events:none = puramente cosmético, no interfiere.
 */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--z-grain);
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 300px 300px;
}
