:root {
  --color-primary: #8B4513;
  --color-primary-dark: #5C2E00;
  --color-primary-light: #CD853F;
  --color-gold: #C5933C;
  --color-cream: #FFF8E7;
  --color-card: #FFFDF5;
  --color-text: #3E2723;
  --color-text-light: #6D4C41;
  --color-accent: #5B7B4A;
  --color-border: #DEB887;
  --color-overlay: rgba(62, 39, 35, 0.55);
  --shadow-sm: 0 1px 4px rgba(62, 39, 35, 0.08);
  --shadow-md: 0 4px 16px rgba(62, 39, 35, 0.12);
  --shadow-lg: 0 8px 32px rgba(62, 39, 35, 0.18);
  --radius: 12px;
  --font-heading: Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --color-primary: #B8652A;
  --color-primary-dark: #8B4513;
  --color-primary-light: #D4945A;
  --color-gold: #C5933C;
  --color-cream: #111111;
  --color-card: #1E1E1E;
  --color-text: #E0D5C5;
  --color-text-light: #A09880;
  --color-accent: #6B8B5A;
  --color-border: #4A4030;
  --color-overlay: rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-cream);
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(205, 133, 63, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(139, 69, 19, 0.04) 0%, transparent 50%);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
}

/* ----- Header ----- */
.header {
  background-color: var(--color-primary-dark);
  background-image:
    linear-gradient(180deg, rgba(62, 39, 35, 0.55) 0%, rgba(62, 39, 35, 0.25) 100%),
    url('images/headerPueblo.jpg'),
    url('images/headerCitadela.png');
  background-size: cover, 50% 100%, 50% 100%;
  background-position: center, left center, right center;
  background-repeat: no-repeat, no-repeat, no-repeat;
  color: #fff;
  text-align: center;
  min-height: 45vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem 3rem;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 15%;
  bottom: 15%;
  left: 50%;
  width: 2px;
  background: var(--color-gold);
  opacity: 0.4;
  z-index: 0;
  transform: translateX(-50%);
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--color-gold) 0px,
    var(--color-gold) 14px,
    transparent 14px,
    transparent 18px
  );
}

.header-title {
  font-family: var(--font-heading);
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: fadeDown 0.8s ease-out;
}

.header-subtitle {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  opacity: 0.85;
  margin-top: 0.35rem;
  font-style: italic;
  font-weight: 400;
}

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

/* ----- Navigation ----- */
.nav {
  background: var(--color-card);
  border-bottom: 2px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  transition: background-color 0.3s, border-color 0.3s;
}

.nav-links {
  display: flex;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.75rem 3.5rem 0.75rem 1rem;
  max-width: 960px;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}

.nav-link {
  text-decoration: none;
  color: var(--color-text);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus {
  background: var(--color-primary);
  color: #fff;
  outline: none;
}

/* ----- Theme toggle ----- */
.theme-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 101;
  background: none;
  border: 2px solid var(--color-primary-light);
  color: var(--color-text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--color-primary-light);
  color: #fff;
  border-color: var(--color-primary);
}

.theme-toggle::before {
  content: '\263E';
}

[data-theme="dark"] .theme-toggle::before {
  content: '\2609';
}

/* ----- Main ----- */
.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2.5rem 1rem;
}

/* ----- Section cards ----- */
.gallery-section {
  margin-bottom: 2.5rem;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  container-type: inline-size;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease, background-color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.gallery-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--color-primary-dark);
  padding: 1.25rem 1.5rem 0.5rem;
  position: relative;
}

.section-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background: var(--color-gold);
  margin-top: 0.5rem;
  border-radius: 2px;
}

/* ----- Carousel ----- */
.carousel {
  position: relative;
  padding: 0 0 1rem;
}

.carousel-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow-x: auto;
  overflow-y: hidden;
  background: #f0e8d8;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.carousel-viewport::-webkit-scrollbar {
  display: none;
}

.carousel-track {
  display: flex;
  height: 100%;
}

.carousel-slide {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  object-fit: cover;
  display: block;
  scroll-snap-align: start;
  cursor: zoom-in;
}

/* ---- Carousel arrows ---- */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: var(--color-overlay);
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  backdrop-filter: blur(2px);
}

.carousel:hover .carousel-btn,
.carousel-btn:focus-visible {
  opacity: 1;
}

.carousel-btn:hover {
  background: var(--color-primary);
  transform: translateY(-50%) scale(1.08);
}

.carousel-btn:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.carousel-prev { left: 1rem; }
.carousel-next { right: 1rem; }

.gallery-section:has(.carousel-slide:only-child) .carousel-btn {
  display: none;
}

/* ---- Carousel footer (dots + counter) ---- */
.carousel-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem 0;
  flex-wrap: wrap;
}

.carousel-dots {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: center;
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-primary-light);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}

.carousel-dot:hover {
  border-color: var(--color-primary);
}

.carousel-dot.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  transform: scale(1.25);
}

.carousel-counter {
  font-size: 0.85rem;
  color: var(--color-text-light);
  font-family: var(--font-heading);
  white-space: nowrap;
}

/* ----- Lightbox ----- */
#lightbox {
  border: none;
  padding: 0;
  background: transparent;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
}

#lightbox[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox::backdrop {
  background: rgba(0, 0, 0, 0.9);
}

.lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  background: none;
  color: #fff;
  border: none;
  font-size: 2.75rem;
  cursor: pointer;
  line-height: 1;
  z-index: 10;
  transition: opacity 0.2s;
  opacity: 0.7;
}

.lightbox-close:hover {
  opacity: 1;
}

/* ----- Footer ----- */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-light);
  font-size: 0.85rem;
  border-top: 1px solid var(--color-border);
  max-width: 960px;
  margin: 0 auto;
  transition: border-color 0.3s;
}

/* ----- Container queries ----- */
@container (max-width: 600px) {
  .carousel-viewport {
    aspect-ratio: 4 / 3;
  }

  .carousel-btn {
    width: 38px;
    height: 38px;
    font-size: 1rem;
    opacity: 1;
    background: var(--color-overlay);
  }

  .carousel-prev { left: 0.5rem; }
  .carousel-next { right: 0.5rem; }

  .section-title {
    font-size: 1.3rem;
    padding: 1rem 1rem 0.4rem;
  }

  .carousel-footer {
    gap: 0.75rem;
  }
}

@container (max-width: 400px) {
  .carousel-viewport {
    aspect-ratio: 1 / 1;
  }
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
  .header {
    min-height: 30vh;
    padding: 3rem 1rem 2rem;
  }

  .header-title {
    font-size: 1.9rem;
  }

  .header-subtitle {
    font-size: 1rem;
  }

  .nav-links {
    padding: 0.6rem 3.5rem 0.6rem 0.75rem;
    justify-content: flex-start;
  }

  .theme-toggle {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .main {
    padding: 1.5rem 0.75rem;
  }

  .lightbox-btn {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .lightbox-prev { left: 0.75rem; }
  .lightbox-next { right: 0.75rem; }

  .lightbox-close {
    font-size: 2.25rem;
    top: 0.5rem;
    right: 0.75rem;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 1.5rem;
  }

  .nav-link {
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
  }
}
