
:root {
  --paper: #f3efe3;
  --white: #fffdf8;
  --ink: #24231f;
  --muted: #716e66;
  --red: #963f37;
  --line: #d9d2c5;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

/* CABECERA */

header {
  border-bottom: 1px solid var(--line);
  padding: 20px 6%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* LOGO */

.brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  line-height: 1;
}

.brand-logo {
  display: block;
  width: 280px;
  height: auto;
  max-height: 75px;
  object-fit: contain;
  object-position: left center;
}

/* NAVEGACIÓN */

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}

nav a {
  font-size: 13px;
  text-decoration: none;
}

nav a:hover {
  color: var(--red);
}

/* ESTRUCTURA GENERAL */

main {
  max-width: 1440px;
  margin: 0 auto;
  min-width: 0;
}

.hero {
  padding: 85px 8% 70px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 60px;
  align-items: end;
}

.eyebrow {
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 11px;
  font-weight: bold;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: normal;
  line-height: 1.12;
}

h1 {
  font-size: clamp(44px, 6vw, 82px);
  letter-spacing: -3px;
  margin: 18px 0;
  overflow-wrap: anywhere;
}

h2 {
  font-size: clamp(32px, 4vw, 48px);
  margin: 10px 0 20px;
}

h3 {
  font-size: 25px;
}

.hero p {
  font-size: 17px;
  color: var(--muted);
  max-width: 620px;
}

.hero-note {
  border-top: 2px solid var(--red);
  padding-top: 20px;
  font-family: var(--serif);
  font-size: 22px;
}

.hero-note .hero-note-small {
  font: 13px Arial, Helvetica, sans-serif;
  color: var(--muted);
}

/* BOTONES */

.button {
  display: inline-block;
  background: var(--red);
  color: white;
  padding: 13px 20px;
  text-decoration: none;
  margin-top: 16px;
  font-size: 13px;
  border: 0;
  cursor: pointer;
  font-family: inherit;
}

.button:hover {
  background: #713029;
}

/* SECCIONES */

.section {
  padding: 65px 6%;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 28px;
}

.section-heading p {
  max-width: 450px;
  color: var(--muted);
  font-size: 14px;
}

/* MAPA Y FILTROS */

.map-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.map-layout > * {
  min-width: 0;
}

.filters {
  min-width: 0;
  background: var(--white);
  padding: 24px;
  border: 1px solid var(--line);
  align-self: start;
}

.filters h3 {
  margin-top: 0;
}

.filter-label {
  display: block;
  font-size: 13px;
  margin: 18px 0 8px;
}

select,
input {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  font: inherit;
  border-radius: 0;
}

/* MAPA LEAFLET */

#map {
  display: block;
  position: relative;
  width: 100%;
  height: clamp(400px, 65vh, 570px);
  min-height: 350px;
  overflow: hidden;
  background: #e7e2d7;
  border: 1px solid var(--line);
  z-index: 1;
}

#map img {
  max-width: none !important;
  max-height: none !important;
}

#map .leaflet-pane,
#map .leaflet-tile,
#map .leaflet-marker-icon,
#map .leaflet-marker-shadow,
#map .leaflet-tile-container {
  position: absolute;
}

.leaflet-container {
  font-family: Arial, Helvetica, sans-serif;
}

.map-caption {
  color: var(--muted);
  font-size: 11px;
  margin-top: 10px;
}

/* LISTA DE LUGARES */

.results {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  max-height: 560px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 8px;
  align-content: start;
}

.results > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.place-link {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.place-link:hover {
  color: var(--red);
}

.place-link small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.empty-results {
  margin: 0;
  padding: 16px 0;
  color: var(--muted);
  font-size: 14px;
}

/* TARJETAS */

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--white);
}

.card-content {
  padding: 23px;
}

.card h3 {
  margin: 12px 0;
}

.card p {
  font-size: 14px;
  color: var(--muted);
}

.tag {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 4px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.text-link {
  color: var(--red);
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}

/* EXPOSICIÓN E HISTORIAS */

.story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 60px;
  align-items: start;
}

.story p {
  color: var(--muted);
  white-space: pre-line;
}

/* ITINERARIOS */

.route-list {
  list-style: none;
  padding: 0;
  counter-reset: stops;
}

.route-list li {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  counter-increment: stops;
  overflow-wrap: anywhere;
}

.route-list li::before {
  content: "0" counter(stops);
  color: var(--red);
  margin-right: 18px;
  font-size: 12px;
}

/* FUENTES GENERALES */

.sources {
  background: #eae4d8;
}

/* PIE DE PÁGINA */

footer {
  padding: 30px 6%;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 12px;
  color: var(--muted);
}

/* VENTANAS DE LAS FICHAS */

dialog {
  max-width: 680px;
  width: calc(100% - 32px);
  max-height: 85vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 30px;
}

dialog::backdrop {
  background: #171510aa;
}

.dialog-close {
  float: right;
  padding: 8px 12px;
  cursor: pointer;
}

#detail-content {
  clear: both;
  overflow-wrap: anywhere;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  color: var(--muted);
}

/* =========================================
   TIPOGRAFÍA DE TODA LA FICHA
   Misma fuente, distintos tamaños y pesos
   ========================================= */

/* Título principal */

#detail-content h2 {
  font-family: var(--sans);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: normal;
  color: var(--ink);
  margin: 10px 0 20px;
}

/* Subtítulos */

#detail-content h3 {
  font-family: var(--sans);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: normal;
  color: var(--ink);
  margin: 28px 0 10px;
}

/* Categoría */

#detail-content .eyebrow {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--red);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* Párrafos */

#detail-content p {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  color: var(--muted);
  margin: 0 0 16px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* Etiquetas: Dirección, Periodo, Lugar, Data, etc. */

#detail-content strong,
#detail-content b {
  font-family: var(--sans);
  font-weight: 700;
  color: var(--ink);
}

/* Relato, personas y textos multilínea */

#detail-content .story-text,
#detail-content .personas-text,
#detail-content .sources-text {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  color: var(--muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* LISTA DE FUENTES */

#detail-content ul {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  color: var(--muted);
  padding-left: 24px;
  margin: 0 0 20px;
  list-style-type: disc;
}

#detail-content li {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  color: var(--muted);
  margin-bottom: 6px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* GALERÍA FOTOGRÁFICA */

.photo-gallery {
  margin: 28px 0;
}

#detail-content .photo-gallery h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

#detail-content .gallery-intro {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 18px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.gallery-item {
  display: block;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: zoom-in;
  text-align: left;
  color: var(--ink);
  font: inherit;
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e7e2d7;
}

.gallery-item:hover {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}

.gallery-item:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

#detail-content .gallery-caption {
  display: block;
  padding: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink);
  overflow-wrap: anywhere;
}

#detail-content .gallery-empty {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  color: var(--muted);
  border: 1px dashed var(--line);
  padding: 16px;
}

/* ESTADO DOCUMENTAL */

#detail-content .map-caption {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--muted);
  margin-top: 16px;
}

/* VISOR AMPLIADO DE FOTOGRAFÍAS */

#photo-dialog {
  width: min(1000px, calc(100% - 24px));
  max-width: 1000px;
  padding: 20px;
  border: 1px solid var(--line);
}

.photo-viewer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.photo-viewer-top button,
.photo-navigation button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 9px 13px;
}

.photo-viewer-top button:hover,
.photo-navigation button:hover {
  background: var(--paper);
}

#photo-large {
  display: block;
  width: 100%;
  max-height: 62vh;
  object-fit: contain;
  background: #e7e2d7;
}

#photo-caption {
  padding-top: 14px;
  overflow-wrap: anywhere;
}

#photo-caption h3 {
  font-family: var(--sans);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
  margin: 0 0 12px;
}

#photo-caption p {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
  color: var(--muted);
  margin: 5px 0;
}

#photo-caption strong,
#photo-caption b {
  font-family: var(--sans);
  font-weight: 700;
  color: var(--ink);
}

.photo-navigation {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.photo-navigation button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* TABLET Y MÓVIL */

@media (max-width: 800px) {
  header {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    gap: 15px;
  }

  .hero,
  .story {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .hero {
    padding-top: 55px;
  }

  .map-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .results {
    max-height: 360px;
  }

  #map {
    height: 420px;
    min-height: 350px;
  }

  .cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  footer {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .brand-logo {
    width: 210px;
    max-height: 58px;
  }

  .section {
    padding: 45px 5%;
  }

  .hero {
    padding: 45px 5%;
  }

  .filters {
    padding: 18px;
  }

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

  #photo-dialog {
    padding: 12px;
  }

  .photo-navigation button {
    padding: 8px;
    font-size: 13px;
  }

  dialog {
    padding: 20px;
  }

  #detail-content h2 {
    font-size: 26px;
  }

  #detail-content h3 {
    font-size: 19px;
  }
}

/* RESPETO AL MOVIMIENTO REDUCIDO */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
