/* ==========================================================================
   base.css — Cimientos de la web de Cintia Barroso
   1. Tipografías locales (@font-face)
   2. Variables de diseño (paletas, tipos, espaciados, movimiento)
   3. Temas: claro / oscuro (global) y secciones .theme-light / .theme-dark
   4. Reset moderno
   5. Estilos base de elementos
   6. Utilidades
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Tipografías locales (autoalojadas: sin conexión a Google → RGPD)
   Licencia SIL Open Font License 1.1 (ver /assets/fonts/OFL-*.txt).
   Son fuentes VARIABLES: un solo archivo contiene todos los pesos del rango,
   por eso font-weight lleva dos valores (mínimo y máximo).
   Subconjunto "latin" (inglés y caracteres europeos occidentales, € incluido).
   -------------------------------------------------------------------------- */

/* Cormorant Garamond, solo cursiva: títulos grandes (pesos 300–500) */
@font-face {
  font-family: "Cormorant Garamond";
  src: url("../fonts/cormorant-garamond-italic.woff2") format("woff2");
  font-weight: 300 500;
  font-style: italic;
  font-display: swap;
}

/* Archivo, redonda: texto, menús y etiquetas (pesos 500–700) */
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo.woff2") format("woff2");
  font-weight: 500 700;
  font-style: normal;
  font-display: swap;
}


/* --------------------------------------------------------------------------
   2. Variables de diseño
   -------------------------------------------------------------------------- */
:root {
  /* Paleta CLARA: blanco roto cálido, casi papel fotográfico */
  --color-light-bg: #f7f4ee;
  --color-light-fg: #0d0d0d;
  --color-light-muted: #6e6c68;               /* gris cálido; contraste AA sobre el fondo */
  --color-light-line: rgba(13, 13, 13, 0.14); /* líneas finas de 1px */

  /* Paleta OSCURA: negro cálido, nunca puro */
  --color-dark-bg: #0d0c0a;
  --color-dark-fg: #f3efe7;
  --color-dark-muted: #8b8780;
  --color-dark-line: rgba(243, 239, 231, 0.16);

  /* Familias tipográficas (con fuentes de respaldo por si aún no han cargado) */
  --font-display: "Cormorant Garamond", "Times New Roman", Georgia, serif;
  --font-body: "Archivo", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;

  /* Pesos: la elegancia viene del tamaño, no del grosor */
  --weight-display: 300;  /* títulos en cursiva, finos */
  --weight-body: 600;     /* texto corrido */
  --weight-ui: 700;       /* menús, etiquetas, botones */

  /* Escala tipográfica fluida: clamp(mínimo, preferido según ancho, máximo) */
  --text-xs: 0.6875rem;                                  /* 11px: etiquetas pequeñas */
  --text-sm: 0.75rem;                                    /* 12px: menú, metadatos */
  --text-base: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem); /* 13–14px: texto */
  --text-lg: clamp(1.125rem, 0.95rem + 0.8vw, 1.75rem);    /* 18–28px: entradillas */
  --text-xl: clamp(1.75rem, 1.2rem + 2.4vw, 3.5rem);       /* 28–56px: títulos de sección */
  --text-2xl: clamp(2.5rem, 1.5rem + 4.5vw, 5rem);         /* 40–80px */
  --text-display: clamp(3.5rem, 1rem + 11vw, 11rem);       /* 56–176px: título principal */

  /* Interlineado y espaciado entre letras */
  --leading-display: 0.95;  /* títulos grandes muy compactos */
  --leading-snug: 1.15;
  --leading-normal: 1.6;
  --tracking-body: 0.04em;  /* texto pequeño en Archivo: un poco de aire */
  --tracking-ui: 0.06em;    /* mayúsculas de menús y etiquetas */
  --tracking-display: -0.01em;

  /* Espaciados fluidos */
  --space-2xs: clamp(0.25rem, 0.23rem + 0.10vw, 0.31rem);
  --space-xs: clamp(0.50rem, 0.46rem + 0.20vw, 0.63rem);
  --space-sm: clamp(0.75rem, 0.69rem + 0.30vw, 0.94rem);
  --space-md: clamp(1rem, 0.90rem + 0.50vw, 1.25rem);
  --space-lg: clamp(1.50rem, 1.30rem + 1vw, 2.25rem);
  --space-xl: clamp(2rem, 1.60rem + 2vw, 3.50rem);
  --space-2xl: clamp(3rem, 2.20rem + 4vw, 6rem);
  --space-3xl: clamp(4.50rem, 3rem + 7.50vw, 10rem);

  /* Márgenes laterales de página y ancho máximo del contenido */
  --gutter: clamp(1rem, 0.6rem + 1.8vw, 1.75rem);
  --max-width: 100rem;

  /* Altura del header (se usa para compensar el header fijo) */
  --header-height: clamp(3.5rem, 3.2rem + 1.2vw, 4.5rem);

  /* Movimiento: curvas de aceleración */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);    /* salida suave, tipo "expo" */
  --ease-in-out: cubic-bezier(0.7, 0, 0.2, 1);  /* arranque y frenada marcados */
  --duration-fast: 200ms;
  --duration-base: 400ms;
  --duration-slow: 800ms;
  --duration-theme: 500ms;                      /* cambio claro ↔ oscuro */

  /* Capas (z-index) */
  --z-header: 100;
  --z-menu: 90;
  --z-skip: 200;
}


/* --------------------------------------------------------------------------
   3. Temas
   a) Tema GLOBAL de la página: lo elige el visitante con el botón Light/Dark.
      Se guarda en el atributo data-theme de <html> (por defecto, claro).
      --page-* son los colores de "la página" según ese tema.
   b) Variables de trabajo que usan los componentes: --bg, --fg, --fg-muted,
      --line. Cada sección puede cambiarlas con una clase:
        .theme-light → sigue el tema elegido (claro u oscuro).
        .theme-dark  → SIEMPRE oscura (p. ej. el hero con vídeo).
   -------------------------------------------------------------------------- */
:root,
[data-theme="light"] {
  --page-bg: var(--color-light-bg);
  --page-fg: var(--color-light-fg);
  --page-muted: var(--color-light-muted);
  --page-line: var(--color-light-line);
  color-scheme: light; /* barras de scroll y controles nativos a juego */
}

[data-theme="dark"] {
  --page-bg: var(--color-dark-bg);
  --page-fg: var(--color-dark-fg);
  --page-muted: var(--color-dark-muted);
  --page-line: var(--color-dark-line);
  color-scheme: dark;
}

/* La página y las secciones "claras" usan el tema elegido */
body,
.theme-light {
  --bg: var(--page-bg);
  --fg: var(--page-fg);
  --fg-muted: var(--page-muted);
  --line: var(--page-line);
}

/* Secciones siempre oscuras */
.theme-dark {
  --bg: var(--color-dark-bg);
  --fg: var(--color-dark-fg);
  --fg-muted: var(--color-dark-muted);
  --line: var(--color-dark-line);
}

/* Las secciones pintan su propio fondo y color, con transición suave */
.theme-light,
.theme-dark {
  background-color: var(--bg);
  color: var(--fg);
  transition:
    background-color var(--duration-theme) var(--ease-in-out),
    color var(--duration-theme) var(--ease-in-out);
}


/* --------------------------------------------------------------------------
   4. Reset moderno
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

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

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

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

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

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

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

h1, h2, h3, h4 {
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

/* Si el usuario pide menos movimiento: sin animaciones, sin scroll suave
   y sin transición al cambiar de tema */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* --------------------------------------------------------------------------
   5. Estilos base
   -------------------------------------------------------------------------- */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-body);
  letter-spacing: var(--tracking-body);
  line-height: var(--leading-normal);
  background-color: var(--bg);
  color: var(--fg);
  transition:
    background-color var(--duration-theme) var(--ease-in-out),
    color var(--duration-theme) var(--ease-in-out);
}

/* Títulos: Cormorant Garamond en cursiva fina, muy grandes y compactos */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: var(--weight-display);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); line-height: var(--leading-snug); font-weight: 400; }
h4 { font-size: var(--text-lg); line-height: var(--leading-snug); font-weight: 400; }

/* Párrafos: ancho de línea cómodo de leer (unos 65 caracteres) */
p {
  max-width: 65ch;
}

/* Etiqueta pequeña en mayúsculas: menús, fichas de proyecto (Client, Role, Year…) */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-ui);
  letter-spacing: var(--tracking-ui);
  line-height: var(--leading-snug);
  text-transform: uppercase;
}

strong, b {
  font-weight: var(--weight-ui);
}

/* La cursiva usa la serif: da un toque editorial dentro del texto */
em, i {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.15em;    /* la serif es ópticamente más pequeña que la sans */
  letter-spacing: 0;
}

small {
  font-size: var(--text-xs);
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
}

/* Color del texto seleccionado con el ratón: invierte los colores de la sección */
::selection {
  background: var(--fg);
  color: var(--bg);
}

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

/* Foco visible y coherente para navegación con teclado */
:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}


/* --------------------------------------------------------------------------
   6. Utilidades
   -------------------------------------------------------------------------- */

/* Oculta visualmente pero sigue siendo legible para lectores de pantalla */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Enlace "saltar al contenido": aparece solo al recibir foco con teclado */
.skip-link {
  position: absolute;
  top: var(--space-xs);
  left: var(--space-xs);
  z-index: var(--z-skip);
  padding: var(--space-xs) var(--space-sm);
  background: var(--page-fg);
  color: var(--page-bg);
  font-size: var(--text-sm);
  font-weight: var(--weight-ui);
  text-transform: uppercase;
  letter-spacing: var(--tracking-ui);
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* Contenedor centrado con márgenes laterales fluidos */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}


/* --------------------------------------------------------------------------
   7. Superficies del navegador con los colores de la web
   (barra de scroll, cursor de escritura y casillas: nada con el azul por defecto)
   -------------------------------------------------------------------------- */
html {
  scrollbar-color: var(--page-muted) var(--page-bg);
  accent-color: var(--page-fg);
}

input,
textarea {
  caret-color: currentColor;
}


/* --------------------------------------------------------------------------
   8. Transición entre páginas (View Transitions entre documentos)
   Al cambiar de página, el contenido se funde mientras el header se queda
   quieto. Navegadores sin soporte: cambio normal e instantáneo.
   -------------------------------------------------------------------------- */
@view-transition {
  navigation: auto;
}

.site-header {
  view-transition-name: site-header; /* el header no participa en el fundido */
}

::view-transition-old(root) {
  animation: page-out 160ms var(--ease-out) both;
}

::view-transition-new(root) {
  animation: page-in 380ms var(--ease-out) both;
}

@keyframes page-out {
  to { opacity: 0; }
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(0.75rem); }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}
