/* ==========================================================================
   SPLIT — LA CRÓNICA DEL PALACIO DE DIOCLECIANO Y EL ADRIÁTICO
   Diseño Web Galardonado | HSL & Variables CSS | Glassmorphism & Motion
   ========================================================================== */

:root {
  /* Tipografías */
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;

  /* Paleta de Colores "Adriático & Mármol" */
  --bg-dark: #071521;          /* Azul Noche Adriático Profundo */
  --bg-surface: #0e2233;       /* Azul Mármol Marino */
  --bg-card: #142c42;          /* Tarjeta Elevada */
  --bg-card-hover: #1b3854;    /* Tarjeta Hover */
  
  --text-main: #f4f9fc;        /* Blanco Mármol */
  --text-muted: #a2c1d4;       /* Azul Ceniza */
  --text-dim: #6b8ea6;         /* Texto Secundario */

  --accent-gold: #e6b89c;      /* Piedra de Brač Dorada */
  --accent-gold-bright: #f0c9b0;
  --accent-teal: #00a896;      /* Turquesa Adriático */
  --accent-teal-light: #2ec4b6;
  
  --border-subtle: rgba(162, 193, 212, 0.12);
  --border-gold: rgba(230, 184, 156, 0.3);

  /* Sombras y Elevación */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.65);
  --shadow-gold: 0 0 25px rgba(230, 184, 156, 0.15);

  /* Radios y Curvas */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;

  /* Transiciones */
  --ease-out: cubic-bezier(0.215, 0.61, 0.355, 1);
  --transition: all 0.35s var(--ease-out);
  --max-width: 1700px;
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
  scrollbar-gutter: stable;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.lightbox-open {
  overflow: hidden;
}

/* Utilidad para accesibilidad (lectores de pantalla) */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* Selección de texto y tipografía balanceada */
::selection {
  background: rgba(0, 168, 150, 0.35);
  color: #fff;
}

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

/* Link de Accesibilidad */
.skip-link {
  position: absolute;
  top: -60px;
  left: 1rem;
  background: var(--accent-teal);
  color: #fff;
  padding: 0.75rem 1.5rem;
  z-index: 9999;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 1rem;
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  background-color: #030a10;
  overflow: hidden;
}

.hero__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 35%;
  opacity: 0.65;
  filter: saturate(1.1) brightness(0.9);
  transform: scale(1.05);
  animation: heroZoom 25s infinite alternate ease-in-out;
  z-index: 1;
}

@keyframes heroZoom {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.hero__overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(7, 21, 33, 0.4) 0%, rgba(7, 21, 33, 0.85) 70%, var(--bg-dark) 100%),
              linear-gradient(to bottom, rgba(7, 21, 33, 0.5) 0%, transparent 40%, var(--bg-dark) 100%);
  z-index: 2;
}

.hero__content {
  position: relative;
  z-index: 3;
  max-width: 900px;
  animation: fadeInDown 1.2s var(--ease-out);
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-30px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  background: rgba(14, 34, 51, 0.65);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-full);
  color: var(--accent-gold);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-gold);
}

.hero__badge-dot {
  width: 7px;
  height: 7px;
  background-color: var(--accent-teal-light);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-teal-light);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

.hero__title {
  font-family: var(--font-serif);
  font-size: clamp(4rem, 12vw, 9.5rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 1.5rem;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  background: linear-gradient(180deg, #ffffff 30%, var(--accent-gold-bright) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero__lead {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 3.5vw, 2.2rem);
  font-style: italic;
  color: var(--accent-gold);
  margin-bottom: 1rem;
  font-weight: 400;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
}

.hero__sublead {
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  color: var(--text-muted);
  font-weight: 400;
  max-width: 650px;
  margin: 0 auto;
}

.hero__scroll {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-muted);
  transition: var(--transition);
}

.hero__scroll-indicator {
  width: 28px;
  height: 46px;
  border: 2px solid var(--border-gold);
  border-radius: 14px;
  position: relative;
}

.hero__scroll-indicator::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  width: 5px;
  height: 5px;
  margin-left: -2.5px;
  background-color: var(--accent-gold);
  border-radius: 50%;
  animation: scrollBall 2s infinite;
}

@keyframes scrollBall {
  0% { opacity: 0; transform: translateY(0); }
  50% { opacity: 1; }
  100% { opacity: 0; transform: translateY(18px); }
}

.hero__scroll-text {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-weight: 600;
  color: var(--accent-gold);
}

.hero__scroll:hover {
  color: #fff;
  transform: translateX(-50%) translateY(4px);
}

/* ==========================================================================
   STORY SECTION (NARRATIVA)
   ========================================================================== */
.story {
  padding: clamp(5rem, 12vw, 9rem) 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

.story__inner {
  max-width: 820px;
  margin: 0 auto;
}

.story__eyebrow {
  display: block;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--accent-teal-light);
  margin-bottom: 1rem;
  font-weight: 700;
}

.story__title {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 5.5vw, 3.8rem);
  line-height: 1.15;
  color: var(--text-main);
  margin-bottom: 2.5rem;
  font-weight: 500;
}

.story__body p {
  font-size: clamp(1.05rem, 2.2vw, 1.22rem);
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  line-height: 1.8;
  text-align: justify;
  text-justify: inter-word;
  text-wrap: pretty;
  hyphens: auto;
}

.story__body strong {
  color: var(--accent-gold);
  font-weight: 600;
}

/* ==========================================================================
   GALLERY SECTION & FILTROS
   ========================================================================== */
.gallery-section {
  padding: 2rem 0 8rem;
  max-width: var(--max-width);
  margin: 0 auto;
}

.gallery-section__header {
  text-align: center;
  max-width: 900px;
  margin: 0 auto 3.5rem;
  padding: 0 1.5rem;
}

.gallery-section__hint {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

/* Modo Sin JavaScript */
.no-js .filters,
.no-js .gallery-section__hint {
  display: none;
}

.noscript {
  max-width: 700px;
  margin: 1.5rem auto 0;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-gold);
  color: var(--text-muted);
  text-align: center;
}

/* Filtros Interactivos */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 2rem;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.filter-btn:hover {
  background: var(--bg-card-hover);
  color: #fff;
  border-color: var(--border-gold);
}

.filter-btn.active {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--accent-teal) 150%);
  color: #fff;
  border-color: var(--accent-teal-light);
  box-shadow: 0 4px 20px rgba(0, 168, 150, 0.3);
}

.filter-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.filter-btn[disabled]:hover {
  background: var(--bg-surface);
  color: var(--text-muted);
  border-color: var(--border-subtle);
  box-shadow: none;
}

.filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.filter-btn.active .filter-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* MASONRY: Rejilla en Cascada */
.gallery {
  column-count: 4;
  column-gap: 1.35rem;
  padding: 0 1.5rem;
  list-style: none;
}

.gallery-item {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin-bottom: 1.35rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-sm);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), opacity 0.4s ease;
  animation: galleryReveal 0.6s var(--ease-out) both;
}

@keyframes galleryReveal {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.gallery-item:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md), var(--shadow-gold);
  border-color: var(--border-gold);
}

.gallery-item__btn {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  text-align: inherit;
  cursor: zoom-in;
  -webkit-appearance: none;
  appearance: none;
  position: relative;
}

.gallery-item__btn:focus-visible {
  outline: 3px solid var(--accent-teal-light);
  outline-offset: 3px;
  border-radius: var(--radius-md);
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
  background-color: var(--bg-surface);
}

.gallery-item:hover img {
  transform: scale(1.04);
}

.gallery-item__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(7, 21, 33, 0.85) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.35s ease;
  display: flex;
  align-items: flex-end;
  padding: 1.25rem;
  pointer-events: none;
}

.gallery-item:hover .gallery-item__overlay,
.gallery-item:focus-within .gallery-item__overlay {
  opacity: 1;
}

.gallery-item__title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: #fff;
  line-height: 1.2;
}

/* Estado Vacío de la Galería */
.gallery-empty {
  break-inside: avoid;
  margin-bottom: 1.35rem;
  padding: 3rem 1.5rem;
  text-align: center;
  background: var(--bg-surface);
  border: 1px dashed var(--border-gold);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.gallery-empty small {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-dim);
}

/* ==========================================================================
   FOOTER (PIE DE PÁGINA)
   ========================================================================== */
.footer {
  background-color: #040c12;
  border-top: 1px solid var(--border-subtle);
  padding: 4rem 1.5rem 3rem;
  position: relative;
}

.footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.footer__title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  color: var(--accent-gold);
  margin-bottom: 0.35rem;
}

.footer__desc {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.footer__credit {
  color: var(--text-main);
  font-size: 0.95rem;
}

.footer__small {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-top: 0.25rem;
}

.footer__top-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  color: var(--accent-gold);
  transition: var(--transition);
  text-decoration: none;
}

.footer__top-btn:hover {
  background: var(--accent-teal);
  color: #fff;
  border-color: var(--accent-teal-light);
  transform: translateY(-3px);
}

/* ==========================================================================
   LIGHTBOX / VISOR INTERACTIVO
   ========================================================================== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease-out), visibility 0.4s var(--ease-out);
  padding: 1rem;
}

.lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(5, 15, 24, 0.96);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 1;
}

.lightbox__close,
.lightbox__nav {
  position: fixed;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10010;
  transition: var(--transition);
  backdrop-filter: blur(8px);
}

.lightbox__close:hover,
.lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: var(--accent-gold);
  color: var(--accent-gold-bright);
}

.lightbox__close {
  top: calc(1.5rem + env(safe-area-inset-top));
  right: calc(1.5rem + env(safe-area-inset-right));
  width: 48px;
  height: 48px;
}
.lightbox__close:hover {
  transform: rotate(90deg);
}

.lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
}

.lightbox__nav--prev { left: calc(1.5rem + env(safe-area-inset-left)); }
.lightbox__nav--next { right: calc(1.5rem + env(safe-area-inset-right)); }

.lightbox__nav--prev:hover { transform: translateY(-50%) translateX(-4px); }
.lightbox__nav--next:hover { transform: translateY(-50%) translateX(4px); }

.lightbox__stage {
  position: relative;
  z-index: 10005;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 5rem 7.5rem;
}

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s var(--ease-out);
  user-select: none;
}

.lightbox__img.loaded {
  opacity: 1;
  transform: scale(1);
}

/* Spinner de carga */
.lightbox__loader {
  position: absolute;
  width: 45px;
  height: 45px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-teal-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  opacity: 0;
  transition: opacity 0.2s;
}

.lightbox.loading .lightbox__loader {
  opacity: 1;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Info y Captions */
.lightbox__info {
  position: fixed;
  bottom: calc(5rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10010;
  text-align: center;
  width: 90%;
  max-width: 850px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.lightbox__info.loaded {
  opacity: 1;
}

.lightbox__title {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 2.5vw, 1.6rem);
  color: var(--accent-gold-bright);
  margin-bottom: 0.35rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.lightbox__caption {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  color: var(--text-main);
  line-height: 1.45;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.95);
}

.lightbox__bar {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10010;
  background: rgba(14, 34, 51, 0.8);
  border: 1px solid var(--border-gold);
  padding: 0.45rem 1.25rem;
  border-radius: var(--radius-full);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-gold);
}

.lightbox__counter {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  color: var(--accent-gold);
  font-feature-settings: "tnum";
}

/* ==========================================================================
   RESPONSIVE DESIGN (ADAPTABILIDAD TOTAL)
   ========================================================================== */
@media (max-width: 1400px) {
  .gallery {
    column-count: 3;
  }
}

@media (max-width: 900px) {
  .gallery {
    column-count: 2;
    column-gap: 1rem;
    padding: 0 1rem;
  }
  .gallery-item {
    margin-bottom: 1rem;
  }
  .lightbox__stage {
    padding: 3.5rem 1.25rem 6.5rem;
  }
  .lightbox__nav {
    display: none; /* Navegación táctil en móvil */
  }
  .lightbox__close {
    top: calc(1rem + env(safe-area-inset-top));
    right: calc(1rem + env(safe-area-inset-right));
    width: 42px;
    height: 42px;
  }
  .lightbox__info {
    bottom: calc(4.5rem + env(safe-area-inset-bottom));
    width: 92%;
  }
}

@media (max-width: 520px) {
  .gallery {
    column-count: 1;
  }
  .filters {
    gap: 0.5rem;
  }
  .filter-btn {
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
  }
}

/* Accesibilidad y Preferencias del Usuario */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .hero__badge,
  .lightbox__backdrop,
  .lightbox__close,
  .lightbox__nav,
  .lightbox__bar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

:focus-visible {
  outline: 3px solid var(--accent-teal-light);
  outline-offset: 3px;
}
