/* ============================================================
   MOSTRA — Sistema de Diseño
   HK Grotesk local · Paleta 4 tonos · Sin separadores
   ============================================================ */


/* ── TIPOGRAFÍA LOCAL: HK Grotesk ───────────────────────── */
@font-face {
  font-family: 'HK Grotesk';
  src: url('fonts/HKGrotesk-Light.woff2') format('woff2'),
       url('fonts/HKGrotesk-Light.woff')  format('woff');
  font-weight: 300; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'HK Grotesk';
  src: url('fonts/HKGrotesk-Light.woff2') format('woff2'),
       url('fonts/HKGrotesk-Light.woff')  format('woff');
  /* 400 apunta al mismo archivo Light — evita síntesis del navegador */
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'HK Grotesk';
  src: url('fonts/HKGrotesk-Medium.woff2') format('woff2'),
       url('fonts/HKGrotesk-Medium.woff')  format('woff');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'HK Grotesk';
  src: url('fonts/HKGrotesk-SemiBold.woff2') format('woff2'),
       url('fonts/HKGrotesk-SemiBold.woff')  format('woff');
  font-weight: 600; font-style: normal; font-display: swap;
}


/* ── VARIABLES ──────────────────────────────────────────── */
:root {
  --blanco:   #fafafa;
  --negro:    #323232;
  --gris-med: #5a5a5a;
  --gris-cla: #999999;
  --quinto:   #d9d9d9;
  --hover-bg: #f2f2f2;

  --font: 'HK Grotesk', system-ui, sans-serif;

  --text-2xs:  0.62rem;
  --text-xs:   0.72rem;
  --text-sm:   0.82rem;
  --text-base: 0.94rem;
  --text-xl:   1.5rem;

  --sp-2xs:  4px;
  --sp-xs:   8px;
  --sp-sm:  12px;
  --sp-md:  20px;
  --sp-lg:  32px;
  --sp-xl:  52px;

  --alto-header:  57px;
  --ancho-drawer: 30vw;

  --t:      0.12s ease;
  --t-med:  0.22s ease;
  --t-slow: 0.30s ease;
}


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


/* [hidden] nunca sobreescrito por reglas de display */
[hidden] { display: none !important; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-weight: 400;
  background: var(--blanco);
  color: var(--negro);
  line-height: 1.5;
}

img    { display: block; max-width: 100%; }
a      { color: inherit; text-decoration: none; }
button { background: none; border: none; font: inherit; color: inherit; }
input  { font: inherit; color: inherit; background: none; border: none; outline: none; }
ul, ol { list-style: none; }
table  { border-collapse: collapse; width: 100%; }


/* ── ACCESIBILIDAD ──────────────────────────────────────── */

/* 3.1 · Focus visible — navegación por teclado */
:focus-visible {
  outline: 2px solid var(--negro);
  outline-offset: 3px;
}
/* Los inputs no necesitan outline extra — tienen el estilo del buscador */
input:focus-visible { outline: none; }

/* 3.2 · Cards accesibles por teclado */
.obra-card:focus-visible {
  outline: 2px solid var(--negro);
  outline-offset: 2px;
}
.obra-card:focus-visible .obra-card-imagen img {
  transform: scale(1.04);
}

/* Filas de tabla navegables por teclado */
.lista-tabla tr[data-codigo] {
  cursor: pointer;
  outline: none;
}
.lista-tabla tr[data-codigo]:focus-visible td {
  background: var(--quinto);
  outline: none;  /* el fondo ya indica el foco */
}
.lista-tabla tr[data-codigo]:focus-visible {
  outline: 2px solid var(--negro);
  outline-offset: -2px;
}

/* 3.x · Texto solo para lectores de pantalla */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}




/* ── PANTALLA DE CARGA ──────────────────────────────────── */
#preloader {
  position: fixed;
  inset: 0;
  background: var(--blanco);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.55s ease;
}
#preloader.saliendo {
  opacity: 0;
  pointer-events: none;
}
.loader-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--quinto);
  border-top: 2px solid var(--negro);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}


/* ── CONTENIDO — fade de entrada ────────────────────────── */
.app-contenido {
  opacity: 0;
  transition: opacity 0.55s ease;
}
.app-contenido--visible { opacity: 1; }


/* ── VISTAS ─────────────────────────────────────────────── */
.vista {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--alto-header));
  background: var(--blanco);
}
.vista--catalogo {
  transition: padding-right var(--t-slow);
  padding-right: 0;
}
.catalogo--drawer-abierto .vista--catalogo {
  padding-right: var(--ancho-drawer);
}


/* ── HEADER ─────────────────────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--sp-lg);
  height: var(--alto-header);
  position: sticky;
  top: 0;
  background: var(--blanco);
  z-index: 50;
}

.logo img {
  height: 36px;
  width: auto;
  display: block;
}

.header-nav {
  display: flex;
  align-items: center;
}

/* Los dos grupos de nav son flex rows con gap.
   El swap entre catálogo y ficha lo maneja JS con hidden. */
#nav-catalogo,
#nav-ficha {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
}

/* Slot compartido para ⓘ y X: mismo tamaño, btn-icon se superponen.
   Solo uno está visible a la vez — JS alterna hidden entre ellos. */
.header-info-slot {
  position: relative;
  width: 34px;
  height: 34px;
}
.header-info-slot .btn-icon {
  position: absolute;
  inset: 0;
}

/* Botones de icono del header */
.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  color: var(--negro);
  transition: color var(--t);
}
.btn-icon:hover { color: var(--gris-cla); }

/* X del panel info — giro en hover, igual que otros cierres */
#btn-cerrar-info svg {
  transition: transform 0.35s ease;
  transform-origin: center;
}
#btn-cerrar-info:hover svg { transform: rotate(180deg); }

/* Hamburger se oculta cuando el drawer está abierto */
#btn-filtros { transition: opacity var(--t) var(--t-slow); }
.catalogo--drawer-abierto #btn-filtros {
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
}

/* ── X DEL DRAWER ───────────────────────────────────────── */
.filtro-cerrar-x {
  position: absolute;
  top:  calc((var(--alto-header) - 34px) / 2);
  left: calc(-1 * (34px + var(--sp-sm)));
  color: var(--negro);
  z-index: 201;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t);
}
.filtros-drawer--abierto .filtro-cerrar-x {
  opacity: 1;
  pointer-events: auto;
  transition: opacity var(--t) var(--t-slow);
}
.filtro-cerrar-x svg {
  transition: transform 0.35s ease;
  transform-origin: center;
}
.filtro-cerrar-x:hover svg { transform: rotate(180deg); }


/* ── BOTÓN VOLVER ───────────────────────────────────────── */
.btn-volver {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gris-cla);
  transition: color var(--t);
  padding-block: 14px;   /* área táctil mínima 44px sin cambiar diseño visual */
}
.btn-volver:hover { color: var(--gris-med); }


/* ── GRILLA ÁREA ────────────────────────────────────────── */
.grilla-area { padding: var(--sp-lg); flex: 1; }


/* ── GRILLA DE OBRAS ────────────────────────────────────── */
.grilla {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-xl) var(--sp-md);
}


/* ── OBRA CARD ──────────────────────────────────────────── */
.obra-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}
.obra-card-imagen {
  aspect-ratio: 4 / 3;
  overflow: hidden;
}
.obra-card-imagen img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform var(--t-slow);
}
.obra-card:hover .obra-card-imagen img { transform: scale(1.04); }
.obra-card-info {
  display: flex;
  flex-direction: column;
  text-align: center;
}
.obra-card-tipologia {
  font-size: var(--text-2xs);
  color: var(--negro);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.obra-card-edad {
  font-size: var(--text-2xs);
  color: var(--gris-med);
  letter-spacing: 0.06em;
  margin-top: var(--sp-2xs);
}


/* ── VISTA LISTA ────────────────────────────────────────── */
.lista { overflow-x: auto; }
.lista-tabla th {
  font-size: var(--text-base);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gris-med);
  text-align: left;
  padding: var(--sp-sm) var(--sp-md) var(--sp-sm) 0;
  white-space: nowrap;
}
.lista-tabla td {
  font-size: var(--text-sm);
  color: var(--negro);
  padding: var(--sp-md) var(--sp-md) var(--sp-md) 0;
}
.lista-tabla tr { transition: background var(--t); }
.lista-tabla tr:hover td { background: var(--quinto); }
.td-codigo {
  font-size: var(--text-2xs);
  color: var(--gris-med);
  letter-spacing: 0.05em;
  white-space: nowrap;
}


/* ── FICHA DE OBRA ──────────────────────────────────────── */
.ficha-body {
  display: grid;
  grid-template-columns: 3fr 2fr;
  flex: 1;
}
.ficha-visor {
  padding: var(--sp-xl);
  position: sticky;
  top: var(--alto-header);
  height: calc(100vh - var(--alto-header));
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
}
.ficha-imagen-principal {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ficha-imagen-principal img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}
.ficha-placeholder {
  width: 100%;
  height: 100%;
  background: var(--quinto);
}
.ficha-thumbs {
  display: flex;
  justify-content: center;   /* centrado horizontal */
  gap: var(--sp-xs);
  overflow-x: auto;
  scrollbar-width: none;
}
.ficha-thumbs::-webkit-scrollbar { display: none; }
.ficha-thumb {
  width: 56px;
  height: 42px;
  overflow: hidden;
  flex-shrink: 0;
  opacity: 0.4;
  transition: opacity var(--t);
}
.ficha-thumb:hover   { opacity: 0.7; }
.ficha-thumb--activo { opacity: 1; }
/* C: object-fit via CSS en vez de inline style — contain para no distorsionar obra */
.ficha-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ficha-datos {
  padding: var(--sp-xl);
  overflow-y: auto;
  scrollbar-width: none;
}
.ficha-datos::-webkit-scrollbar { display: none; }
.ficha-titulo {
  font-size: var(--text-xl);
  font-weight: 400;
  margin-bottom: var(--sp-lg);
  line-height: 1.2;
}
/* E: estado "sin título" via clase CSS en vez de inline style.fontStyle */
.ficha-titulo--sin-titulo {
  font-style: italic;
  color: var(--gris-med);
}
.ficha-tabla {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-xs) var(--sp-lg);
  margin-bottom: var(--sp-lg);
}
.ficha-tabla dt {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gris-cla);
  padding-top: 2px;
  white-space: nowrap;
}
.ficha-tabla dd { font-size: var(--text-sm); color: var(--negro); }
.ficha-tabla--registro {
  padding-top: var(--sp-lg);
  border-top: 1px solid var(--quinto);
}
.ficha-seccion { margin-bottom: var(--sp-lg); }
.ficha-seccion-titulo {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gris-cla);
  margin-bottom: var(--sp-xs);
}
.ficha-seccion-texto {
  font-size: var(--text-sm);
  color: var(--gris-med);
  line-height: 1.75;
}


/* ── DRAWER DE FILTROS ──────────────────────────────────── */
.filtros-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--ancho-drawer);
  height: 100vh;
  background: var(--hover-bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-slow);
  overflow: visible;
}
.filtros-drawer--abierto { transform: translateX(0); }

.filtros-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding-top: calc(var(--alto-header) - var(--sp-sm));
  padding-right: var(--sp-md);
  padding-bottom: var(--sp-md);
  padding-left: var(--sp-md);
  scrollbar-width: none;
}
.filtros-drawer-body::-webkit-scrollbar { display: none; }


/* ── TOOLBAR ────────────────────────────────────────────── */
.filtros-toolbar {
  display: flex;
  align-items: baseline;
  gap: var(--sp-sm);
  margin-bottom: var(--sp-lg);
}
.filtros-busqueda {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  flex: 1;
  padding-bottom: var(--sp-xs);
  min-width: 0;
}
.filtros-busqueda > svg { color: var(--negro); flex-shrink: 0; }
.filtros-busqueda input {
  flex: 1;
  font-size: var(--text-xl);
  color: var(--negro);
  min-width: 0;
}
.filtros-busqueda input::placeholder { color: var(--gris-cla); }

.filtros-busqueda-limpiar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  visibility: hidden;
  color: var(--gris-cla);
  transition: color var(--t);
}
.filtros-busqueda-limpiar:hover          { color: var(--gris-med); }
.filtros-busqueda-limpiar--visible       { visibility: visible; }
/* X del buscador — mismo giro en hover */
.filtros-busqueda-limpiar svg {
  transition: transform 0.35s ease;
  transform-origin: center;
}
.filtros-busqueda-limpiar:hover svg { transform: rotate(180deg); }

.vista-controles { display: flex; gap: var(--sp-md); flex-shrink: 0; }
.btn-vista {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--gris-cla);
  transition: color var(--t);
}
.btn-vista:hover   { color: var(--gris-med); }
.btn-vista--activo { color: var(--negro); }

/* X de cierre dentro del toolbar — solo visible en mobile */
.filtro-cerrar-toolbar {
  display: none;
  color: var(--negro);
  flex-shrink: 0;
}
.filtro-cerrar-toolbar svg {
  transition: transform 0.35s ease;
  transform-origin: center;
}
.filtro-cerrar-toolbar:hover svg { transform: rotate(180deg); }

/* X de cierre en ficha — solo visible en mobile, entre las flechas */
.btn-ficha-cerrar {
  display: none;
}
.btn-ficha-cerrar svg {
  transition: transform 0.35s ease;
  transform-origin: center;
}
.btn-ficha-cerrar:hover svg { transform: rotate(180deg); }


/* ── GRUPOS DE FILTRO ───────────────────────────────────── */
.filtro-grupo { padding: var(--sp-2xs) 0; }

.filtro-grupo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: var(--text-base);        /* categoría padre */
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gris-cla);
  margin-bottom: var(--sp-2xs);
  text-align: left;
  transition: color var(--t);
}
.filtro-grupo-header:hover               { color: var(--gris-med); }
.filtro-grupo-header[aria-expanded="true"] { color: var(--negro); }

.filtro-chevron {
  position: relative;
  display: inline-block;
  width: 12px;
  height: 9px;
  flex-shrink: 0;
}

.filtro-chevron::before,
.filtro-chevron::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 9px;
  background-color: currentColor;  /* hereda el color del botón padre */
  transition: transform 0.25s ease-in-out;
}

/* ∨ cerrado */
.filtro-chevron::before { transform: translate( 3px, 0) rotate( 45deg); }
.filtro-chevron::after  { transform: translate(-2px, 0) rotate(-45deg); }

/* ∧ abierto — translate se invierte, rotación igual */
.filtro-grupo-header[aria-expanded="true"] .filtro-chevron::before {
  transform: translate(-2px, 0) rotate( 45deg);
}
.filtro-grupo-header[aria-expanded="true"] .filtro-chevron::after {
  transform: translate( 3px, 0) rotate(-45deg);
}

/* ── OPCIONES DEL FILTRO — animación fluida ─────────────── */
/* max-height + opacity en vez de display: none/block.
   Apertura: más lenta (0.38s) para una entrada elegante.
   Cierre:   más rápido (0.28s) para que no se sienta pesado. */
.filtro-opciones {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 600px;
  opacity: 1;
  transition:
    max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    opacity    0.28s ease;
}
.filtro-opciones--cerrado {
  max-height: 0;
  opacity: 0;
  transition:
    max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    opacity    0.18s ease;
}

.filtro-opcion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-left: var(--sp-2xs);
  font-size: var(--text-sm);          /* subcategoría — menor que la categoría padre */
  font-weight: 500;
  text-align: left;
  color: var(--gris-cla);
  transition: color var(--t);
  text-transform: uppercase;
  padding: var(--sp-2xs) 0;
}
.filtro-opcion:hover   { color: var(--gris-med); }
.filtro-opcion--activo { color: var(--negro); font-weight: 500; }

.filtro-opcion-nombre { flex: 1; }
.filtro-opcion-conteo {
  font-size: var(--text-2xs);
  color: inherit;
  margin-left: var(--sp-sm);
}


/* ── FOOTER DEL DRAWER ──────────────────────────────────── */
.filtros-drawer-footer {
  padding: var(--sp-md);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
}
.filtros-seleccionados {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--negro);
}
.filtros-conteo {
  font-size: var(--text-xs);
  color: var(--gris-med);
  letter-spacing: 0.04em;
}
.filtros-limpiar {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gris-cla);
  text-align: left;
  transition: color var(--t);
}
.filtros-limpiar:hover { color: var(--gris-med); }


/* ── PANEL INFO — aparece debajo del header ─────────────── */
.panel-info {
  position: fixed;
  top: var(--alto-header);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--blanco);
  z-index: 500;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-slow);
}
.panel-info--abierto {
  opacity: 1;
  pointer-events: auto;
}

/* Contenedor interior: max-width + centrado */
.panel-info-cuerpo {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: var(--sp-xl);
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-xl) var(--sp-lg);
  min-height: 100%;
}

/* ── Columna editorial ── */
.panel-info-editorial {
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

.panel-info-epigrafe {
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gris-cla);
}

.panel-info-titulo {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--negro);
  max-width: 12ch;   /* K: controla el quiebre de línea tipográficamente */
}

.panel-info-bajada {
  font-size: var(--text-base);
  font-weight: 300;
  color: var(--gris-med);
  line-height: 1.75;
  max-width: 58ch;
}

.panel-info-texto {
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  border-top: 1px solid var(--quinto);
  padding-top: var(--sp-lg);
}
.panel-info-texto p {
  font-size: var(--text-sm);
  color: var(--gris-med);
  line-height: 1.8;
  max-width: 62ch;
}

/* ── Columna de estadísticas ── */
.panel-info-stats {
  padding-top: 0;
}
.panel-info-stats dl {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2xs);
}
.panel-info-stats dt {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gris-cla);
}
/* Separación entre grupos: solo aplica al dt que sigue a un dd */
.panel-info-stats dd + dt {
  margin-top: 18px;
}
.panel-info-stats dd {
  font-size: var(--text-xl);
  font-weight: 300;
  color: var(--negro);
  letter-spacing: -0.01em;
}

/* ── Responsive mobile ── */
@media (max-width: 768px) {
  .panel-info-cuerpo {
    grid-template-columns: 1fr;
    padding: var(--sp-lg) var(--sp-md);
    gap: var(--sp-xl);
  }
  .panel-info-titulo {
    font-size: clamp(1.8rem, 8vw, 2.5rem);
  }
  .panel-info-stats dl {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-lg) var(--sp-md);
  }
}


/* ── TOOLTIP MINIATURA — VISTA LISTA ────────────────────── */
.lista-tooltip {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  width: 140px;
  height: 140px;
  opacity: 0;
  transition: opacity var(--t);
  background: transparent;
  overflow: hidden;
}
.lista-tooltip--visible { opacity: 1; }
.lista-tooltip-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: transparent;
}


/* ── RESPONSIVE — MOBILE ────────────────────────────────── */
@media (max-width: 768px) {

  /* ── Header nav: gap más ajustado en mobile ── */
  #nav-catalogo,
  #nav-ficha {
    gap: var(--sp-sm);
  }

  /* ── Layout general ── */
  .grilla-area { padding: var(--sp-md); }
  .header      { padding: 0 var(--sp-md); }

  /* Logo: max-width para viewports muy estrechos */
  .logo img { max-width: clamp(80px, 40vw, 150px); }

  /* ── Grilla: 2 columnas desde 320px ── */
  .grilla {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: var(--sp-lg) var(--sp-sm);
  }

  /* Textos de tarjeta: mínimo legible */
  .obra-card-tipologia,
  .obra-card-edad { font-size: var(--text-xs); }

  /* ── Drawer de filtros ── */
  .filtros-drawer {
    width: 100%;
    overflow: hidden;
    height: 100vh;          /* fallback navegadores antiguos */
    height: 100dvh;         /* dvh = dynamic viewport height, corrige bug iOS Safari */
  }

  /* X lateral (desktop) queda oculta en mobile */
  .filtro-cerrar-x { display: none; }

  /* X dentro del toolbar: reemplaza el toggle de vista */
  .filtro-cerrar-toolbar { display: flex; }
  .vista-controles { display: none; }

  /* Drawer body: padding superior ajustado para mobile */
  .filtros-drawer-body {
    padding-top: var(--sp-lg);
  }

  /* Footer del drawer: siempre visible, no queda cortado */
  .filtros-drawer-footer {
    border-top: 1px solid var(--quinto);
    padding: var(--sp-md);
  }

  /* Touch targets mínimos 44px en todos los botones del drawer */
  .filtro-grupo-header {
    min-height: 44px;
  }
  .filtro-opcion {
    align-items: center;
  }
  .filtros-limpiar {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* ── Panel info ── */
  .panel-info { width: 100%; }

  /* ── Ficha de obra: layout vertical ── */
  .ficha-body { grid-template-columns: 1fr; }

  /* Imagen dinámica en lugar de altura fija */
  .ficha-visor {
    position: static;
    height: auto;
    min-height: unset;
    padding: var(--sp-md);
  }
  .ficha-imagen-principal {
    aspect-ratio: 4 / 3;
    min-height: 200px;
  }

  .ficha-datos { padding: var(--sp-lg) var(--sp-md); }

  /* ── Nav ficha en mobile: ← | X | → ── */
  /* Ocultar texto "← Catálogo", mostrar X entre flechas */
  .btn-volver { display: none; }
  .btn-ficha-cerrar { display: flex; }

  /* Touch targets en nav ficha */
  #btn-ficha-prev,
  #btn-ficha-next,
  .btn-ficha-cerrar {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── TABLET ─────────────────────────────────────────────── */
@media (max-width: 1024px) and (min-width: 769px) {
  .grilla { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
