/* =============================================================
   Historia y Protección del Patrimonio Cultural de La Pobla del Duc
   Hoja de estilos principal
   -------------------------------------------------------------
   Índice
   1. Variables (custom properties)
   2. Reset y base
   3. Tipografía
   4. Layout: contenedores y secciones
   5. Textura y detalles arquitectónicos
   6. Botones
   7. Cabecera y navegación
   8. Hero principal y hero de página interior
   9. Migas de pan (breadcrumb)
   10. Componentes de contenido
       - Etiquetas de sección / eyebrow
       - Tarjetas de destino
       - Mapa y ubicación
       - Tarjetas de valores
       - Línea de tiempo
       - Indicador y capítulos
       - Layout dividido texto + imagen
       - Figuras y pies de foto
       - Rejilla de problemas
       - Tarjetas de propuestas numeradas
       - Cita destacada
       - Equipo
       - Fuentes / bibliografía
       - Del boceto a la web
   11. Lightbox
   12. Botón "volver arriba"
   13. Pie de página
   14. Utilidades y animaciones
   15. Responsive
   16. Preferencias de movimiento reducido
   ============================================================= */

/* ============================ 1. VARIABLES ============================ */
:root {
  /* Paleta de color */
  --olive: #344238;
  --charcoal: #252A28;
  --clay: #A35E42;
  --sand: #E8DDCB;
  --stone: #D5D0C5;
  --gold: #B38B4D;
  --ivory: #F7F4ED;
  --white: #FFFFFF;

  /* Tokens semánticos */
  --bg: var(--ivory);
  --bg-alt: var(--sand);
  --bg-deep: var(--olive);
  --text: var(--charcoal);
  --text-soft: #55605a;
  --text-invert: #f3efe6;
  --accent: var(--clay);
  --accent-2: var(--gold);
  --brand: var(--olive);

  /* Líneas y sombras */
  --line: rgba(37, 42, 40, 0.14);
  --line-strong: rgba(37, 42, 40, 0.28);
  --shadow-sm: 0 1px 2px rgba(37, 42, 40, 0.06), 0 2px 6px rgba(37, 42, 40, 0.05);
  --shadow-md: 0 4px 14px rgba(37, 42, 40, 0.10), 0 12px 30px rgba(37, 42, 40, 0.07);
  --shadow-lg: 0 10px 30px rgba(37, 42, 40, 0.16), 0 24px 60px rgba(37, 42, 40, 0.12);

  /* Tipografía */
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", "Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Escala tipográfica fluida */
  --fs-display: clamp(2.5rem, 1.4rem + 4.6vw, 4.4rem);
  --fs-h1: clamp(2.1rem, 1.4rem + 3vw, 3.4rem);
  --fs-h2: clamp(1.7rem, 1.2rem + 2vw, 2.6rem);
  --fs-h3: clamp(1.3rem, 1.05rem + 1vw, 1.7rem);
  --fs-lead: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  --fs-body: clamp(1rem, 0.97rem + 0.15vw, 1.08rem);
  --fs-small: 0.9rem;
  --fs-eyebrow: 0.8rem;

  /* Layout */
  --content-max: 1200px;
  --wide-max: 1320px;
  --narrow-max: 780px;
  --nav-h: 74px;
  --radius: 6px;
  --radius-lg: 12px;

  /* Espaciado */
  --space-section: clamp(3.5rem, 2rem + 6vw, 7rem);
  --gap: clamp(1.5rem, 1rem + 2vw, 3rem);
}

/* ============================ 2. RESET Y BASE ============================ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 1rem);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

a { color: var(--accent); }

ul, ol { margin: 0; padding: 0; }

button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 3px;
}

/* Enlace para saltar al contenido (accesibilidad) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1200;
  background: var(--olive);
  color: var(--white);
  padding: 0.75rem 1.25rem;
  border-radius: 0 0 var(--radius) 0;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ============================ 3. TIPOGRAFÍA ============================ */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: 1.12;
  color: var(--olive);
  margin: 0 0 0.5em;
  letter-spacing: 0.01em;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-weight: 600; }
h4 { font-size: 1.15rem; }

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: var(--text-soft);
  font-weight: 400;
}

strong { color: var(--olive); }

/* Enlaces dentro de contenido: subrayado (no dependen solo del color) */
.prose a,
.rich a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}
.prose a:hover,
.rich a:hover { color: var(--olive); }

/* ============================ 4. LAYOUT ============================ */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 0.5rem + 2.5vw, 2.5rem);
}
.container--wide { max-width: var(--wide-max); }
.container--narrow { max-width: var(--narrow-max); }

.section { padding-block: var(--space-section); }
.section--tight { padding-block: clamp(2.5rem, 1.5rem + 4vw, 4.5rem); }
.section--alt { background-color: var(--bg-alt); }
.section--stone { background-color: var(--stone); }
.section--deep {
  background-color: var(--olive);
  color: var(--text-invert);
}
.section--deep h1,
.section--deep h2,
.section--deep h3 { color: var(--white); }

.section-head { max-width: 60ch; margin-bottom: clamp(1.75rem, 1rem + 2vw, 3rem); }
.section-head--center { margin-inline: auto; text-align: center; }

main { display: block; }

/* ============================ 5. TEXTURA Y DETALLES ============================ */
/* Textura de papel/archivo sutil, generada solo con CSS (SVG en data URI) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

/* Línea arquitectónica fina bajo etiquetas de sección */
.rule {
  width: 54px;
  height: 2px;
  background: var(--gold);
  border: 0;
  margin: 0 0 1.1rem;
}
.section-head--center .rule,
.rule--center { margin-inline: auto; }

/* ============================ 6. BOTONES ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.6rem;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  line-height: 1.2;
  min-height: 48px;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn--primary {
  background: var(--clay);
  color: var(--white);
  border-color: var(--clay);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: #8f4f36; border-color: #8f4f36; box-shadow: var(--shadow-md); }

.btn--secondary {
  background: transparent;
  color: var(--olive);
  border-color: var(--line-strong);
}
.btn--secondary:hover { border-color: var(--olive); background: rgba(52, 66, 56, 0.06); }

/* Variantes sobre fondo oscuro */
.on-dark .btn--secondary,
.btn--ghost-light {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.5);
}
.on-dark .btn--secondary:hover,
.btn--ghost-light:hover { border-color: var(--white); background: rgba(255, 255, 255, 0.12); }

.btn__icon { width: 1em; height: 1em; flex: none; }

/* ============================ 7. CABECERA Y NAVEGACIÓN ============================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--ivory);
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.25s ease, background-color 0.25s ease;
}
.site-header.is-scrolled {
  box-shadow: var(--shadow-sm);
  background: rgba(247, 244, 237, 0.96);
  backdrop-filter: saturate(1.1) blur(6px);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--nav-h);
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--olive);
  flex: none;
}
.nav-logo {
  height: 46px;
  width: auto;
  border-radius: 4px;
}
.nav-wordmark { display: flex; flex-direction: column; line-height: 1.05; }
.nav-wordmark__title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--olive);
}
.nav-wordmark__sub {
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 0.2rem + 0.9vw, 1.6rem);
}
.nav-links a {
  position: relative;
  display: inline-block;
  padding: 0.4rem 0.1rem;
  text-decoration: none;
  color: var(--charcoal);
  font-weight: 500;
  font-size: 0.96rem;
  letter-spacing: 0.01em;
  transition: color 0.2s ease;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--clay);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.nav-links a:hover { color: var(--olive); }
.nav-links a:hover::after { transform: scaleX(1); }
.nav-links a.is-active { color: var(--olive); font-weight: 600; }
.nav-links a.is-active::after { transform: scaleX(1); background: var(--gold); }

/* Selector de idioma (inyectado por i18n.js) */
.nav-brand { margin-right: auto; }
.primary-nav { order: 1; }
.lang-switch {
  order: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.55rem 0.28rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--white);
}
.lang-switch__icon { width: 18px; height: 18px; color: var(--olive); flex: none; }
.lang-select {
  border: 0;
  background: transparent;
  color: var(--charcoal);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  padding: 0.1rem 0.1rem;
  max-width: 8.5rem;
}
.lang-select:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 3px; }

/* Botón hamburguesa */
.nav-toggle {
  order: 3;
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 46px;
  height: 46px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.nav-toggle__bar {
  display: block;
  width: 22px;
  height: 2px;
  margin-inline: auto;
  background: var(--olive);
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================ 8. HERO ============================ */
.hero {
  position: relative;
  min-height: calc(100vh - var(--nav-h));
  min-height: calc(100svh - var(--nav-h));
  display: flex;
  align-items: center;
  color: var(--white);
  background-color: var(--olive);
  background-size: cover;
  background-position: center 60%;
  background-repeat: no-repeat;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(37, 42, 40, 0.45) 0%, rgba(37, 42, 40, 0.35) 45%, rgba(52, 66, 56, 0.78) 100%),
    radial-gradient(120% 90% at 50% 20%, rgba(37, 42, 40, 0.15), rgba(37, 42, 40, 0.6));
}
.hero__inner {
  position: relative;
  max-width: 900px;
  margin-inline: auto;
  text-align: center;
  padding-block: clamp(3rem, 8vh, 6rem);
}
.hero__eyebrow {
  display: inline-block;
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--sand);
  margin-bottom: 1.4rem;
  font-weight: 600;
}
.hero__title {
  color: var(--white);
  font-size: var(--fs-display);
  font-weight: 600;
  line-height: 1.06;
  margin-bottom: 1rem;
  text-wrap: balance;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.28);
}
.hero__subtitle {
  font-size: var(--fs-lead);
  max-width: 60ch;
  margin: 0 auto 2rem;
  color: rgba(255, 255, 255, 0.92);
}
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  justify-content: center;
}

/* Imagen específica del hero principal */
.hero--home { background-image: url("../images/sitio-refugios-area-acondicionada.jpg"); }

/* Indicador de scroll */
.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.scroll-cue__chevron {
  width: 22px;
  height: 22px;
  border-right: 2px solid rgba(255, 255, 255, 0.8);
  border-bottom: 2px solid rgba(255, 255, 255, 0.8);
  transform: rotate(45deg);
  animation: bob 1.8s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: rotate(45deg) translate(0, 0); }
  50% { transform: rotate(45deg) translate(4px, 4px); }
}

/* Hero de páginas interiores */
.page-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: clamp(280px, 44vh, 440px);
  color: var(--white);
  background-color: var(--olive);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.page-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(37, 42, 40, 0.35) 0%, rgba(37, 42, 40, 0.4) 40%, rgba(37, 42, 40, 0.82) 100%);
}
.page-hero__inner {
  position: relative;
  padding-block: clamp(2rem, 5vh, 3.5rem);
  max-width: 62ch;
}
.page-hero__title { color: var(--white); text-shadow: 0 2px 14px rgba(0, 0, 0, 0.3); }
.page-hero__intro {
  font-size: var(--fs-lead);
  color: rgba(255, 255, 255, 0.94);
  margin: 0;
}

/* Fondos de hero por página */
.page-hero--contexto { background-image: url("../images/guerra-civil-milicianos-grupo.jpg"); background-position: center 35%; }
.page-hero--refugios { background-image: url("../images/refugio-entrada-arco-primavera.jpg"); background-position: center 45%; }
.page-hero--aerodromo { background-image: url("../images/aerodromo-vista-aerea.jpg"); }
.page-hero--equipo { background-image: url("../images/refugio-entrada-camino.jpg"); background-position: center 55%; }
.page-hero--biblio { background-image: url("../images/refugio-interior-tunel.jpg"); background-position: center 60%; }

/* ============================ 9. MIGAS DE PAN ============================ */
.breadcrumb { margin-bottom: 1rem; }
.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}
.breadcrumb li { display: flex; align-items: center; gap: 0.5rem; color: rgba(255, 255, 255, 0.8); }
.breadcrumb li + li::before { content: "/"; color: rgba(255, 255, 255, 0.55); }
.breadcrumb a { color: var(--sand); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--white); font-weight: 600; }

/* ============================ 10. COMPONENTES ============================ */
/* Etiqueta de sección / eyebrow */
.eyebrow,
.section-label {
  display: inline-block;
  font-size: var(--fs-eyebrow);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.9rem;
}
.section--deep .section-label { color: var(--gold); }

.prose { max-width: 68ch; }
.prose p + p { margin-top: 0; }

/* Nota / etiqueta visual pequeña */
.tagline {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--olive);
  padding: 0.9rem 1.3rem;
  border-left: 3px solid var(--gold);
  background: rgba(179, 139, 77, 0.08);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---- Tarjetas de destino (portadas) ---- */
.destination-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap);
}
.destination-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.destination-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.destination-card__media {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--stone);
}
.destination-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}
.destination-card:hover .destination-card__media img { transform: scale(1.05); }
.destination-card__body { padding: clamp(1.3rem, 1rem + 1vw, 2rem); }
.destination-card__label {
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.destination-card__title { margin: 0.5rem 0 0.6rem; }
.destination-card__text { color: var(--text-soft); margin-bottom: 1.1rem; }
/* Enlace que cubre toda la tarjeta manteniendo texto accesible */
.stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}
.card-cta {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--clay);
  text-decoration: none;
}
.card-cta__arrow { transition: transform 0.25s ease; }
.destination-card:hover .card-cta__arrow { transform: translateX(4px); }

/* ---- Mapa y ubicación ---- */
.media-split {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(1.5rem, 1rem + 3vw, 4rem);
  align-items: center;
}
.map-frame {
  background: var(--white);
  padding: clamp(0.7rem, 0.4rem + 1vw, 1.1rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.map-frame img { border-radius: 3px; width: 100%; }
.map-stack { display: grid; gap: 1rem; }
.map-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.5rem; }

/* ---- Tarjetas de valores ---- */
.value-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}
.value-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: clamp(1.4rem, 1rem + 1vw, 2rem);
  box-shadow: var(--shadow-sm);
}
.value-card h3 { color: var(--olive); }
.value-card p { color: var(--text-soft); margin: 0; }

/* ---- Línea de tiempo ---- */
.timeline {
  list-style: none;
  display: grid;
  gap: 0;
  border-left: 2px solid var(--line-strong);
  margin-left: 0.5rem;
  padding-left: 1.8rem;
}
.timeline li {
  position: relative;
  padding-bottom: 1.7rem;
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: calc(-1.8rem - 7px);
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--clay);
  border: 3px solid var(--ivory);
  box-shadow: 0 0 0 1px var(--clay);
}
.timeline__year {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--olive);
  display: block;
}
.timeline__text { color: var(--text-soft); }
.section--alt .timeline li::before { border-color: var(--sand); }

/* ---- Indicador de capítulos ---- */
.chapter-nav {
  position: sticky;
  top: var(--nav-h);
  z-index: 500;
  background: rgba(247, 244, 237, 0.95);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.chapter-nav ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.5rem;
  padding-block: 0.9rem;
  counter-reset: chapter;
}
.chapter-nav a {
  counter-increment: chapter;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-soft);
  font-weight: 600;
  font-size: 0.92rem;
  transition: color 0.2s ease;
}
.chapter-nav a::before {
  content: counter(chapter);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  font-size: 0.82rem;
  color: var(--olive);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chapter-nav a:hover,
.chapter-nav a.is-current { color: var(--olive); }
.chapter-nav a.is-current::before {
  background: var(--clay);
  border-color: var(--clay);
  color: var(--white);
}

/* Desplazamiento de anclaje que respeta las barras fijas (cabecera + capítulos) */
.chapter { scroll-margin-top: calc(var(--nav-h) + 64px); }

/* Cabecera de capítulo */
.chapter-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.5rem; }
.chapter-head__num {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 1.5rem + 3vw, 3.6rem);
  color: var(--gold);
  line-height: 1;
  font-weight: 600;
}

/* ---- Layout dividido texto + imagen ---- */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.5rem, 1rem + 3vw, 4rem);
  align-items: center;
}
.split--reverse .split__media { order: -1; }
.split__text { max-width: 58ch; }
.split + .split { margin-top: clamp(2.5rem, 1.5rem + 4vw, 5rem); }

/* ---- Figuras y pies de foto ---- */
figure { margin: 0; }
.figure {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.figure > img { width: 100%; display: block; }
.figure figcaption,
.figcaption {
  font-size: var(--fs-small);
  color: var(--text-soft);
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  line-height: 1.45;
}
.figcaption strong { color: var(--olive); }

/* Esquema interpretativo (SVG en línea) */
.scheme { background: var(--ivory); padding: clamp(0.6rem, 0.4rem + 1vw, 1.4rem); }
.scheme-svg { width: 100%; height: auto; display: block; }

/* Etiqueta de recreación / propuesta visual */
.media-flag {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--white);
  background: var(--clay);
  padding: 0.3rem 0.7rem;
  border-radius: 3px;
  margin-bottom: 0.6rem;
}
.figure--flagged { position: relative; }
.figure--flagged .media-flag {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  z-index: 2;
  margin: 0;
  box-shadow: var(--shadow-sm);
}

/* ---- Rejilla de problemas ---- */
.problem-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
}
.problem-grid li {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1rem 1.1rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--clay);
  border-radius: var(--radius);
  font-weight: 600;
  color: var(--olive);
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}
.problem-grid li svg { width: 20px; height: 20px; flex: none; color: var(--clay); }

/* ---- Tarjetas de propuestas numeradas ---- */
.proposal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: var(--gap);
  counter-reset: proposal;
}
.proposal-card {
  position: relative;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.5rem, 1.1rem + 1vw, 2.2rem);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.proposal-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.proposal-card__num {
  counter-increment: proposal;
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
  display: block;
  margin-bottom: 0.6rem;
}
.proposal-card__num::before { content: counter(proposal, decimal-leading-zero); }
.proposal-card h3 { margin-bottom: 0.5rem; }
.proposal-card p { color: var(--text-soft); margin: 0; }
.proposal-card__media {
  margin-top: 1.2rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}

/* ---- Cita destacada ---- */
.pullquote {
  border-left: 4px solid var(--gold);
  padding: clamp(1.2rem, 1rem + 1vw, 2rem) clamp(1.4rem, 1rem + 2vw, 2.6rem);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.pullquote p {
  font-family: var(--font-serif);
  font-size: clamp(1.4rem, 1.1rem + 1.4vw, 2rem);
  line-height: 1.35;
  color: var(--olive);
  font-style: italic;
  margin: 0;
}
.section--deep .pullquote {
  background: rgba(255, 255, 255, 0.06);
  border-left-color: var(--gold);
}
.section--deep .pullquote p { color: var(--white); }

/* ---- Equipo ---- */
.team-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(1.1rem, 3.2vw, 2.2rem);
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 720px;
}
.team-portrait { margin: 0; }
.team-portrait__fig {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.team-portrait__img {
  display: block;
  width: clamp(112px, 22vw, 150px);
  height: clamp(112px, 22vw, 150px);
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  background: var(--sand);
  border: 3px solid var(--gold);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.team-portrait__img:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.team-portrait__name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--olive);
  text-align: center;
}

/* Fotografía de grupo del equipo */
.team-photo { max-width: 720px; margin-inline: auto; }
.team-photo img { width: 100%; height: auto; border-radius: var(--radius-lg); }

/* Marcador de foto de equipo (fácil de reemplazar) */
.photo-placeholder {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 0.8rem;
  min-height: clamp(220px, 34vw, 360px);
  padding: 2rem;
  background:
    repeating-linear-gradient(45deg, rgba(52, 66, 56, 0.04) 0 14px, transparent 14px 28px),
    var(--sand);
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text-soft);
}
.photo-placeholder svg { width: 46px; height: 46px; color: var(--gold); }
.photo-placeholder p { margin: 0; font-weight: 600; color: var(--olive); }
.photo-placeholder span { font-size: var(--fs-small); }

/* Valores de motivación */
.motivation-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}
.motivation-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.4rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.motivation-card__icon {
  flex: none;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(163, 94, 66, 0.12);
  color: var(--clay);
}
.motivation-card__icon svg { width: 22px; height: 22px; }
.motivation-card h3 { font-size: 1.15rem; margin: 0 0 0.2rem; }
.motivation-card p { margin: 0; color: var(--text-soft); font-size: 0.95rem; }

/* ---- Fuentes / bibliografía ---- */
.source-group { margin-bottom: clamp(2.5rem, 1.5rem + 3vw, 4rem); }
.source-list { display: grid; gap: 1rem; }
.source-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.source-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.source-card__type {
  align-self: flex-start;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  background: rgba(163, 94, 66, 0.1);
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
}
.source-card__title { font-size: 1.2rem; margin: 0.2rem 0 0; }
.source-card__title a { color: var(--olive); text-decoration: none; }
.source-card__title a:hover { text-decoration: underline; text-decoration-color: var(--clay); }
.source-card__desc { color: var(--text-soft); font-size: 0.95rem; margin: 0; }
.source-card__url {
  font-size: 0.82rem;
  color: var(--text-soft);
  word-break: break-word;
  font-family: var(--font-sans);
}

/* Grupo de fuentes editable / vacío */
.source-empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-soft);
  font-size: 0.95rem;
}

.note-box {
  margin-top: 2rem;
  padding: 1.1rem 1.4rem;
  background: rgba(52, 66, 56, 0.06);
  border-left: 3px solid var(--olive);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.92rem;
  color: var(--text-soft);
}

/* Indicador de enlace externo */
.external { white-space: nowrap; }
.external::after {
  content: "";
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  margin-left: 0.28em;
  vertical-align: -0.02em;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M14 5h5v5M19 5l-8 8M17 13v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M14 5h5v5M19 5l-8 8M17 13v5a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---- Del boceto a la web ---- */
.sketch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.2rem;
}
.sketch-card {
  background: var(--white);
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transform: rotate(-0.6deg);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.sketch-card:nth-child(even) { transform: rotate(0.7deg); }
.sketch-card:hover { transform: rotate(0) scale(1.02); box-shadow: var(--shadow-md); }
.sketch-card img { border-radius: 3px; width: 100%; }
.sketch-card figcaption { font-size: var(--fs-small); color: var(--text-soft); padding: 0.5rem 0.3rem 0.2rem; }

/* Galería de refugios */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}
.gallery__item {
  position: relative;
  display: block;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--stone);
  cursor: zoom-in;
  box-shadow: var(--shadow-sm);
}
.gallery__item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 0.5s ease;
}
.gallery__item:hover img { transform: scale(1.06); }
.gallery__item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(37, 42, 40, 0.35));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.gallery__item:hover::after { opacity: 1; }

/* Bloque de imagen ancho a página completa */
.fullwidth-figure { margin: 0; }
.fullwidth-figure img {
  width: 100%;
  max-height: 70vh;
  object-fit: cover;
}

/* ============================ 11. LIGHTBOX ============================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 3rem);
  background: rgba(30, 34, 32, 0.92);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lightbox__figure {
  max-width: min(1100px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.lightbox__img {
  max-width: 100%;
  max-height: 82vh;
  width: auto;
  margin-inline: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--charcoal);
}
.lightbox__caption {
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  font-size: 0.9rem;
  max-width: 70ch;
  margin-inline: auto;
}
.lightbox__close {
  position: absolute;
  top: clamp(0.8rem, 2vw, 1.5rem);
  right: clamp(0.8rem, 2vw, 1.5rem);
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  color: var(--white);
  font-size: 1.5rem;
  line-height: 1;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.24); }

/* ============================ 12. VOLVER ARRIBA ============================ */
.back-to-top {
  position: fixed;
  right: clamp(1rem, 3vw, 2rem);
  bottom: clamp(1rem, 3vw, 2rem);
  z-index: 900;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  background: var(--olive);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, background-color 0.2s ease;
}
.back-to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--clay); }
.back-to-top svg { width: 22px; height: 22px; }

/* ============================ 13. PIE DE PÁGINA ============================ */
.site-footer {
  background: var(--olive);
  color: var(--text-invert);
  padding-block: clamp(3rem, 2rem + 3vw, 4.5rem) 2rem;
}
.site-footer a { color: var(--sand); }
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: clamp(1.8rem, 1rem + 3vw, 3.5rem);
  padding-bottom: 2.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}
.footer-brand__plate {
  display: inline-block;
  background: var(--ivory);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.footer-brand__plate img { height: 92px; width: auto; }
.footer-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--white);
  margin: 0 0 0.4rem;
  line-height: 1.2;
}
.footer-tagline { color: rgba(243, 239, 230, 0.85); max-width: 40ch; margin: 0; }
.footer-col h3 {
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.footer-col ul { list-style: none; display: grid; gap: 0.6rem; }
.footer-col a { text-decoration: none; color: rgba(243, 239, 230, 0.88); }
.footer-col a:hover { color: var(--white); text-decoration: underline; }

/* Zona reservada para logos institucionales */
.footer-logos {
  margin-top: 2.2rem;
  padding-top: 1.6rem;
}
.footer-logos__label {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(243, 239, 230, 0.7);
  margin-bottom: 0.9rem;
}
.footer-logos__slots { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: stretch; }
/* Placas para los logotipos institucionales (se ven bien sobre el pie oscuro) */
.logo-plate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  border-radius: 8px;
  padding: 9px 16px;
  box-shadow: var(--shadow-sm);
}
.logo-plate img { height: 42px; width: auto; max-width: 240px; object-fit: contain; display: block; }
.logo-slot {
  min-width: 150px;
  height: 68px;
  flex: 0 1 190px;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed rgba(243, 239, 230, 0.35);
  border-radius: var(--radius);
  color: rgba(243, 239, 230, 0.6);
  font-size: 0.75rem;
  padding: 0.4rem;
}
.footer-note {
  margin-top: 2.2rem;
  font-size: 0.85rem;
  color: rgba(243, 239, 230, 0.72);
  max-width: 75ch;
  line-height: 1.6;
}

/* ============================ 14. UTILIDADES Y ANIMACIONES ============================ */
.visually-hidden {
  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;
}
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.stack > * + * { margin-top: 1.1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.9rem; }
.actions--center { justify-content: center; }

/* Animaciones de aparición sutil.
   Solo se ocultan cuando JavaScript está activo (clase .js en <html>),
   de modo que sin JavaScript todo el contenido permanece visible. */
.js .reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  will-change: opacity, transform;
}
.js .reveal.is-visible { opacity: 1; transform: none; }
.reveal--delay-1 { transition-delay: 0.08s; }
.reveal--delay-2 { transition-delay: 0.16s; }
.reveal--delay-3 { transition-delay: 0.24s; }

/* ============================ 15. RESPONSIVE ============================ */
@media (max-width: 1040px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 940px) {
  :root { --nav-h: 66px; }

  .nav-wordmark__sub { display: none; }

  /* Sin JavaScript: la navegación se muestra como una lista apilada bajo la marca.
     flex: 0 0 100% (shrink 0) fuerza el salto a una nueva línea completa. */
  .nav { flex-wrap: wrap; }
  .primary-nav { flex: 0 0 100%; }
  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem clamp(1.1rem, 0.5rem + 2.5vw, 2.5rem) 1.2rem;
  }
  .nav-links li { border-bottom: 1px solid var(--line); }
  .nav-links li:last-child { border-bottom: 0; }
  .nav-links a {
    display: block;
    padding: 0.95rem 0.2rem;
    font-size: 1.05rem;
  }
  .nav-links a::after { display: none; }
  .nav-links a.is-active { color: var(--clay); }

  /* Con JavaScript: menú hamburguesa desplegable */
  .js .nav-toggle { display: flex; }
  .js .primary-nav {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-basis: auto;
    background: var(--ivory);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    transform: translateY(-12px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s ease;
  }
  .js .primary-nav.is-open { transform: translateY(0); opacity: 1; visibility: visible; }

  .destination-grid,
  .value-grid,
  .motivation-grid,
  .media-split,
  .split { grid-template-columns: 1fr; }
  .split--reverse .split__media { order: 0; }

  .problem-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .nav-wordmark__title { font-size: 1.05rem; }
  .nav-logo { height: 40px; }
  .hero { min-height: calc(100svh - var(--nav-h)); }
  .hero__actions .btn,
  .map-actions .btn { width: 100%; justify-content: center; }
  .problem-grid { grid-template-columns: 1fr; }
  .chapter-nav ol { gap: 0.3rem 1rem; }
  .chapter-nav a span { display: none; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-brand__plate img { height: 76px; }
}

/* ============================ 16. MOVIMIENTO REDUCIDO ============================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .scroll-cue__chevron { animation: none; }
}
