/* =========================================
   CONDADO DE CASTILLA - MAIN STYLESHEET
   Project 2026: Visual Excellence Edition
   ========================================= */

/* =========================================
   1. Variables & Design Tokens
   ========================================= */
:root {
  /* Colors - Project 2026 Refinement */
  --condado-primario: #2e0840;
  /* Deeper, more regal purple */
  --condado-secundario: #b8860b;
  /* Antique Gold */
  --condado-acento: #ffd700;
  /* Bright Gold */
  --condado-gold-gradient: linear-gradient(135deg, #b8860b 0%, #ffd700 50%, #b8860b 100%);
  /* Gold Leaf */

  --condado-fondo-base: #fdfbf7;
  /* Off-white/Cream */
  --condado-blanco-alabastro: #f0e6d2;
  /* Alabaster */
  --condado-negro-carbon: #1a1a1a;
  /* Charcoal */
  --condado-rojo-sangre: #8a0303;
  /* Deep Red */
  --condado-purpura-imperial: #4a0d67;
  /* Legacy support */
  --condado-oro-viejo: #b8860b;
  /* Legacy support */

  /* RGB Values for Transparency */
  --condado-primario-rgb: 46, 8, 64;
  --condado-negro-carbon-rgb: 26, 26, 26;

  /* Typography - Fluid Scale */
  --font-heading: 'Cinzel', serif;
  --font-body: 'Lora', serif;

  --fs-h1: clamp(2.5rem, 5vw + 1rem, 4.5rem);
  --fs-h2: clamp(2rem, 4vw + 0.5rem, 3.5rem);
  --fs-h3: clamp(1.5rem, 3vw, 2.5rem);
  --fs-body: clamp(1rem, 1vw + 0.5rem, 1.2rem);

  /* Effects */
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.05);
  --shadow-3d: 0 20px 40px rgba(0, 0, 0, 0.1);
  --glass-blur: blur(10px);
  --glow-gold: 0 0 20px rgba(255, 215, 0, 0.6);
  --glow-active: 0 0 15px rgba(255, 215, 0, 0.8);
}

/* =========================================
   2. Global Reset & Base Styles
   ========================================= */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--condado-negro-carbon);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  background-color: var(--condado-fondo-base);
  background-image: url('../assets/img/bg-alabaster.png');
  background-blend-mode: multiply;
  background-attachment: fixed;
  background-size: cover;
  transition: background 0.5s ease, color 0.5s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
  /* Prevent horizontal scroll */
}

/* Global Texture Overlay (Project 2026) */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--condado-primario);
  margin-bottom: 1rem;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

h1 {
  font-size: var(--fs-h1);
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h2 {
  font-size: var(--fs-h2);
  font-weight: 700;
  border-bottom: 2px solid var(--condado-secundario);
  display: inline-block;
  padding-bottom: 0.5rem;
  margin-bottom: 2rem;
}

h3 {
  font-size: var(--fs-h3);
}

a {
  color: var(--condado-primario);
  text-decoration: none;
  transition: color 0.3s ease;
}

a:hover {
  color: var(--condado-secundario);
}

/* Dark Mode Overrides */
body.dark-mode {
  background-color: #1a0525;
  background-image: url('../assets/img/bg-dark-parchment.png');
  /* Ensure this exists or fallback */
  color: #e0d8c0;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
  color: var(--condado-acento);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* =========================================
   3. Layout & Container
   ========================================= */
.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.section {
  padding: 4rem 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* =========================================
   4. Header & Navigation
   ========================================= */
/* Header Controls (Fixed Top Right) */
.header-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 15px;
  z-index: 10000;
  transition: top 0.4s ease;
}

.icon-raven {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--condado-secundario);
  color: var(--condado-primario);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

body.dark-mode .icon-raven {
  background: rgba(0, 0, 0, 0.4);
  color: var(--condado-acento);
  border-color: var(--condado-acento);
}

.icon-raven:hover {
  transform: translateY(-3px) scale(1.1);
  box-shadow: var(--glow-gold);
  background: var(--condado-primario);
  color: #fff;
  border-color: #fff;
}

/* Language Bar */
.language-bar {
  position: relative;
  width: 100%;
  height: 0;
  overflow: hidden;
  background: var(--condado-primario);
  border-bottom: 2px solid var(--condado-secundario);
  z-index: 10002;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

body.lang-open .language-bar {
  height: 70px;
}

body.lang-open .header-controls {
  top: 90px;
}

.close-lang-bar {
  position: absolute;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.close-lang-bar:hover {
  transform: rotate(90deg);
  color: var(--condado-acento);
}

/* Sidebar Navigation */
.sidebar {
  position: fixed;
  top: 0;
  right: -350px;
  width: 320px;
  height: 100vh;
  background: rgba(74, 13, 103, 0.95);
  backdrop-filter: blur(20px);
  z-index: 9999;
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 3px solid var(--condado-secundario);
  box-shadow: -10px 0 50px rgba(0, 0, 0, 0.5);
  padding: 100px 30px 30px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
}

body.dark-mode .sidebar {
  background: rgba(20, 10, 5, 0.95);
}

.sidebar.sidebar-visible {
  right: 0;
}

.logo-link img {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid var(--condado-secundario);
  margin-bottom: 2rem;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.logo-link img:hover {
  transform: rotate(5deg) scale(1.05);
}

.nav-links {
  list-style: none;
  width: 100%;
  text-align: center;
  padding: 0;
}

.nav-links li {
  margin-bottom: 1rem;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.4s ease;
}

.sidebar.sidebar-visible .nav-links li {
  opacity: 1;
  transform: translateX(0);
}

/* Staggered animation for nav items */
.sidebar.sidebar-visible .nav-links li:nth-child(1) {
  transition-delay: 0.1s;
}

.sidebar.sidebar-visible .nav-links li:nth-child(2) {
  transition-delay: 0.15s;
}

.sidebar.sidebar-visible .nav-links li:nth-child(3) {
  transition-delay: 0.2s;
}

.sidebar.sidebar-visible .nav-links li:nth-child(4) {
  transition-delay: 0.25s;
}

.sidebar.sidebar-visible .nav-links li:nth-child(5) {
  transition-delay: 0.3s;
}

.nav-links a {
  color: #e0d8c0;
  font-size: 1.2rem;
  font-weight: bold;
  display: block;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.nav-links a:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--condado-secundario);
  color: var(--condado-acento);
  transform: translateX(5px);
  box-shadow: 0 0 10px rgba(184, 134, 11, 0.2);
}

.nav-group-header {
  color: var(--condado-secundario);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(184, 134, 11, 0.3);
  padding-bottom: 5px;
  opacity: 0.8;
}

/* =========================================
   5. Hero Section
   ========================================= */
.hero {
  width: 100%;
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  position: relative;
  transition: padding-top 0.4s ease;
}

.parallax-hero {
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  overflow: hidden;
}

/* Specific Hero Backgrounds */
.hero-lugares {
  background-image: linear-gradient(rgba(var(--condado-primario-rgb), 0.7), rgba(var(--condado-negro-carbon-rgb), 0.85)), url('../assets/img/hero_lugares_background.jpg');
  background-size: cover;
  background-position: center;
}

.hero-personajes {
  background-image: linear-gradient(rgba(var(--condado-primario-rgb), 0.7), rgba(var(--condado-negro-carbon-rgb), 0.85)), url('../assets/img/hero_personajes_background.jpg');
  background-size: cover;
  background-position: center;
}

.hero-blog {
  background-image: linear-gradient(rgba(var(--condado-primario-rgb), 0.7), rgba(var(--condado-negro-carbon-rgb), 0.85)), url('../assets/img/hero_blog_background.jpg');
  background-size: cover;
  background-position: center;
}

.hero-historia {
  background-image: linear-gradient(rgba(var(--condado-primario-rgb), 0.7), rgba(var(--condado-negro-carbon-rgb), 0.85)), url('../assets/img/hero_historia_background.jpg');
  background-size: cover;
  background-position: center;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, transparent 0%, var(--condado-fondo-base) 90%);
  z-index: 1;
  pointer-events: none;
}

.hero-content {
  max-width: 900px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.4);
  padding: 3rem;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(5px);
  box-shadow: var(--shadow-soft);
}

body.dark-mode .hero-content {
  background: rgba(0, 0, 0, 0.4);
  border-color: rgba(255, 215, 0, 0.1);
}

.hero-escudo {
  width: 200px;
  height: auto;
  margin-bottom: 2rem;
  filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.3));
  transition: transform 0.5s ease;
}

.hero-escudo:hover {
  transform: scale(1.1) rotate(-5deg);
}

.hero h1 {
  background: linear-gradient(45deg, var(--condado-primario), #2a063d);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(2px 2px 0px rgba(255, 255, 255, 0.5));
}

body.dark-mode .hero h1 {
  background: linear-gradient(45deg, var(--condado-acento), #b8860b);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(184, 134, 11, 0.5));
}

.hero-subtitle {
  color: var(--condado-secundario);
  font-size: 1.5rem;
  margin-top: 1rem;
}

/* =========================================
   6. Components & Cards
   ========================================= */

/* Imperial Frame */
.imperial-frame,
.section-frame {
  border: 2px solid var(--condado-oro-viejo);
  border-radius: 20px;
  padding: 4rem;
  margin: 4rem 0;
  width: 100%;
  max-width: 1200px;
  box-shadow: var(--shadow-3d);
  backdrop-filter: var(--glass-blur);
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  background: rgba(255, 255, 255, 0.6);
}

body.dark-mode .imperial-frame,
body.dark-mode .section-frame {
  background: rgba(20, 10, 5, 0.7);
  border-color: var(--condado-acento);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.imperial-frame:hover,
.section-frame:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  border-color: var(--condado-secundario);
}

.imperial-frame::before,
.imperial-frame::after,
.section-frame::before,
.section-frame::after {
  content: '❖';
  position: absolute;
  font-size: 2rem;
  color: var(--condado-secundario);
  opacity: 0.5;
}

.imperial-frame::before,
.section-frame::before {
  top: 10px;
  left: 10px;
}

.imperial-frame::after,
.section-frame::after {
  bottom: 10px;
  right: 10px;
}

/* Imperial Card (Glassmorphism) */
.imperial-card {
  background-color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(184, 134, 11, 0.3);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

body.dark-mode .imperial-card {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 215, 0, 0.2);
}

.imperial-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--condado-gold-gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s ease;
}

.imperial-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.cta-button,
.read-more {
  display: inline-block;
  padding: 15px 40px;
  background: transparent;
  color: var(--condado-primario);
  text-decoration: none;
  border-radius: 50px;
  font-weight: 900;
  font-family: var(--font-heading);
  border: 2px solid var(--condado-primario);
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
  position: relative;
  overflow: hidden;
  z-index: 1;
  margin-top: 1rem;
  cursor: pointer;
}

body.dark-mode .cta-button,
body.dark-mode .read-more {
  color: var(--condado-acento);
  border-color: var(--condado-acento);
}

.cta-button::before,
.read-more::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0%;
  height: 100%;
  background: var(--condado-primario);
  z-index: -1;
  transition: width 0.3s ease;
}

body.dark-mode .cta-button::before,
body.dark-mode .read-more::before {
  background: var(--condado-acento);
}

.cta-button:hover::before,
.read-more:hover::before {
  width: 100%;
}

.cta-button:hover,
.read-more:hover {
  color: #fff;
  box-shadow: 0 10px 20px rgba(74, 13, 103, 0.4);
  transform: translateY(-3px);
}

body.dark-mode .cta-button:hover,
body.dark-mode .read-more:hover {
  color: #000;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.cta-button.secondary {
  border-color: var(--condado-secundario);
  color: var(--condado-secundario);
}

.cta-button.secondary::before {
  background: var(--condado-secundario);
}

/* =========================================
   7. Timelines & Chronoscope
   ========================================= */
.chronoscope {
  position: relative;
  max-width: 800px;
  margin: 4rem auto;
  padding: 2rem 0;
}

.chronoscope::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: linear-gradient(to bottom, transparent, var(--condado-acento), transparent);
  transform: translateX(-50%);
}

.chrono-event {
  position: relative;
  width: 50%;
  padding: 2rem;
  box-sizing: border-box;
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s ease;
}

.chrono-event:nth-child(odd) {
  left: 0;
  text-align: right;
  padding-right: 3rem;
}

.chrono-event:nth-child(even) {
  left: 50%;
  text-align: left;
  padding-left: 3rem;
}

.chrono-event.visible {
  opacity: 1;
  transform: translateY(0);
}

.chrono-marker {
  position: absolute;
  top: 2.5rem;
  width: 20px;
  height: 20px;
  background: var(--condado-acento);
  border-radius: 50%;
  border: 4px solid var(--condado-fondo-base);
  box-shadow: 0 0 15px var(--condado-acento);
  z-index: 2;
}

.chrono-event:nth-child(odd) .chrono-marker {
  right: -10px;
}

.chrono-event:nth-child(even) .chrono-marker {
  left: -10px;
}

.chrono-date {
  font-family: var(--font-heading);
  color: var(--condado-acento);
  font-weight: 900;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.chrono-card {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  padding: 1.5rem;
  border: 1px solid rgba(184, 134, 11, 0.2);
  border-radius: 8px;
  box-shadow: var(--shadow-3d);
}

/* =========================================
   8. Blog & Article Styles
   ========================================= */
.blog-container {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.blog-card {
  background: var(--condado-blanco-alabastro);
  border: 1px solid var(--condado-oro-viejo);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s, box-shadow 0.3s;
  display: flex;
  flex-direction: column;
}

.blog-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.blog-img {
  height: 200px;
  object-fit: cover;
  width: 100%;
  border-bottom: 3px solid var(--condado-purpura-imperial);
}

.blog-content {
  padding: 20px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.blog-tag {
  display: inline-block;
  background: var(--condado-purpura-imperial);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-bottom: 10px;
  align-self: flex-start;
}

.blog-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  margin-bottom: 10px;
  color: var(--condado-negro-carbon);
}

.blog-excerpt {
  font-size: 0.95rem;
  color: #555;
  margin-bottom: 20px;
  line-height: 1.6;
  flex-grow: 1;
}

/* =========================================
   9. Footer
   ========================================= */
footer {
  background: linear-gradient(to top, #1a0525, var(--condado-primario));
  color: #fff;
  padding: 5rem 0;
  text-align: center;
  border-top: 5px solid var(--condado-secundario);
  width: 100%;
  margin-top: auto;
  position: relative;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('../assets/img/bg-old-book.png');
  opacity: 0.1;
  pointer-events: none;
}

/* Scroll to Top */
#scrollToTopBtn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: var(--condado-primario);
  color: #fff;
  border: 2px solid var(--condado-secundario);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9000;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

#scrollToTopBtn:hover {
  transform: translateY(-5px);
  box-shadow: var(--glow-gold);
  background: var(--condado-secundario);
}

/* =========================================
   10. Animations
   ========================================= */
@keyframes pulse-gold {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4);
  }

  70% {
    box-shadow: 0 0 0 15px rgba(255, 215, 0, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(255, 215, 0, 0);
  }
}

@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-15px);
  }

  100% {
    transform: translateY(0px);
  }
}

.floating-emblem {
  animation: float 6s ease-in-out infinite;
}

.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.8s cubic-bezier(0.5, 0, 0, 1);
}

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

/* =========================================
   11. Responsive Design
   ========================================= */
@media (max-width: 1024px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .imperial-frame,
  .section-frame {
    padding: 3rem;
    width: 95%;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  .header-controls {
    top: 20px;
    right: 20px;
    gap: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px;
    border-radius: 30px;
    backdrop-filter: blur(5px);
  }

  body.dark-mode .header-controls {
    background: rgba(0, 0, 0, 0.3);
  }

  .icon-raven {
    width: 48px;
    height: 48px;
  }

  .hero-content {
    padding: 1.5rem;
    width: 90%;
  }

  .imperial-frame,
  .section-frame {
    padding: 2rem 1rem;
    margin: 2rem 0;
    border-width: 1px;
    width: 95%;
  }

  .sidebar {
    width: 100%;
    right: -100%;
    padding-top: 120px;
  }

  .cta-button,
  .read-more {
    width: 100%;
    text-align: center;
    padding: 12px 20px;
  }

  /* Chronoscope Mobile */
  .chronoscope::before {
    left: 20px;
  }

  .chrono-event {
    width: 100%;
    padding-left: 50px;
    padding-right: 0;
    text-align: left;
  }

  .chrono-event:nth-child(odd) {
    left: 0;
  }

  .chrono-event:nth-child(odd) .chrono-marker,
  .chrono-event:nth-child(even) .chrono-marker {
    left: 10px;
    right: auto;
  }
}

/* =========================================
   12. Timeline (Historia Page)
   ========================================= */
.timeline-section {
  position: relative;
  padding: 4rem 0;
}

.timeline {
  list-style: none;
  padding: 0;
  position: relative;
  margin: 4rem 0;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--condado-gold-gradient);
  transform: translateX(-50%);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  margin-bottom: 4rem;
  width: 100%;
  display: flex;
  /* Removed justify-content: center to allow specific side positioning */
}

.timeline-icon {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 80px;
  height: 80px;
  background: var(--condado-fondo-base);
  border: 4px solid var(--condado-secundario);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: 0 0 20px rgba(184, 134, 11, 0.4);
  overflow: hidden;
}

.timeline-icon img {
  width: 50%;
  /* Slightly smaller for better fit */
  height: auto;
  object-fit: contain;
}

.timeline-content {
  width: 45%;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 15px;
  border: 1px solid var(--condado-oro-viejo);
  box-shadow: var(--shadow-soft);
  position: relative;
  backdrop-filter: blur(5px);
  transition: transform 0.3s ease;
}

/* Odd Items (Left Side) */
.timeline-item:nth-child(odd) {
  justify-content: flex-start;
}

.timeline-item:nth-child(odd) .timeline-content {
  margin-left: auto;
  /* Push towards center */
  margin-right: 60px;
  /* Gap from center line (40px half-icon + 20px gap) */
  text-align: right;
}

/* Even Items (Right Side) */
.timeline-item:nth-child(even) {
  justify-content: flex-end;
}

.timeline-item:nth-child(even) .timeline-content {
  margin-right: auto;
  /* Push towards center? No, flex-end puts it at right. */
  /* Actually, if we want it close to center, we don't need margin-right: auto. 
     We need it to NOT be at the far right edge if the container is huge.
     But container is max-width 1400px.
     Let's just use margin-left for gap.
  */
  margin-left: 60px;
  /* Gap from center line */
  text-align: left;
}

body.dark-mode .timeline-content {
  background: rgba(20, 10, 5, 0.8);
  border-color: var(--condado-acento);
}

.timeline-content h3 {
  color: var(--condado-primario);
  margin-top: 0;
}

body.dark-mode .timeline-content h3 {
  color: var(--condado-acento);
}

/* Timeline Responsive */
@media (max-width: 768px) {
  .timeline::before {
    left: 30px;
  }

  .timeline-item {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 3rem;
  }

  /* Reset odd/even specific styles for mobile */
  .timeline-item:nth-child(odd),
  .timeline-item:nth-child(even) {
    justify-content: flex-start;
  }

  .timeline-item:nth-child(odd) .timeline-content,
  .timeline-item:nth-child(even) .timeline-content {
    margin: 0;
    margin-left: 80px;
    /* Space for icon */
    text-align: left;
    width: calc(100% - 80px);
  }

  .timeline-icon {
    left: 30px;
    width: 60px;
    height: 60px;
    transform: translateX(-50%);
  }
}

/* Robust Grid Fix for Alfoz Towns */
.towns-grid-container {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 2rem;
  width: 100%;
  margin: 2rem 0;
  padding: 1rem;
}

.town-card-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 1.5rem;
  text-align: center;
  text-decoration: none;
  background-color: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--condado-oro-viejo);
  border-radius: 8px;
  transition: all 0.3s ease;
  float: none;
  position: relative;
  color: var(--condado-primario);
  font-family: var(--font-heading);
  font-weight: bold;
}

.town-card-link:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  border-color: var(--condado-secundario);
  color: var(--condado-secundario);
}

body.dark-mode .town-card-link {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--condado-acento);
  color: var(--condado-acento);
}

/* =========================================
   13. Theme Switcher Styles
   ========================================= */

/* Theme Menu */
.theme-menu {
  position: fixed;
  top: 80px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid var(--condado-secundario);
  border-radius: 15px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10001;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.theme-menu.active {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

body.dark-mode .theme-menu {
  background: rgba(20, 10, 5, 0.95);
  border-color: var(--condado-acento);
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  color: var(--condado-primario);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  border: 1px solid transparent;
}

body.dark-mode .theme-option {
  color: var(--condado-acento);
}

.theme-option:hover {
  background: rgba(184, 134, 11, 0.1);
  border-color: var(--condado-secundario);
}

.theme-preview {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--condado-secundario);
  background-size: cover;
}

/* Theme Classes */

/* 1. Mármol Negro */
body.theme-marmol-negro {
  background-image: url('../assets/img/bg_marmol_negro.png');
  background-color: #1a1a1a;
  color: #e0e0e0;
  --condado-texto-principal: #e0e0e0;
}

body.theme-marmol-negro .imperial-card,
body.theme-marmol-negro .imperial-frame {
  background: rgba(0, 0, 0, 0.7);
  border-color: #a0a0a0;
}

body.theme-marmol-negro h1,
body.theme-marmol-negro h2,
body.theme-marmol-negro h3 {
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* 2. Pergamino Oscuro */
body.theme-pergamino-oscuro {
  background-image: url('../assets/img/bg_pergamino_oscuro.png');
  background-color: #2c1e12;
  color: #f0e6d2;
  --condado-texto-principal: #f0e6d2;
}

body.theme-pergamino-oscuro .imperial-card,
body.theme-pergamino-oscuro .imperial-frame {
  background: rgba(44, 30, 18, 0.8);
  border-color: var(--condado-oro-viejo);
}

/* 3. Pergamino Clásico */
body.theme-pergamino {
  background-image: url('../assets/img/bg_pergamino.png');
  background-color: #fdfbf7;
  color: #2e0840;
}

/* 4. Dark Imperial */
body.theme-imperial-dark {
  background-image: url('../assets/img/bg-dark-imperial.png');
  background-color: #1a0525;
  color: #e0d8c0;
}

/* 5. Libro Antiguo */
body.theme-libro-antiguo {
  background-image: url('../assets/img/bg-old-book.png');
  background-color: #3e2723;
  color: #efebe9;
}

body.theme-libro-antiguo .imperial-card {
  background: rgba(62, 39, 35, 0.85);
  border-color: #d7ccc8;
}

/* =========================================
   14. Electric Frame & Mobile Optimizations
   ========================================= */

/* Electric Pulse Animation */
@keyframes electric-pulse {
  0% {
    box-shadow: 0 0 5px var(--condado-acento), 0 0 10px var(--condado-secundario);
    border-color: var(--condado-acento);
  }

  50% {
    box-shadow: 0 0 20px var(--condado-acento), 0 0 30px var(--condado-secundario);
    border-color: #fff;
  }

  100% {
    box-shadow: 0 0 5px var(--condado-acento), 0 0 10px var(--condado-secundario);
    border-color: var(--condado-acento);
  }
}

/* Apply to Buttons */
.cta-button,
.read-more,
.town-card-link {
  position: relative;
  transition: all 0.3s ease;
}

.cta-button:hover,
.read-more:hover,
.town-card-link:hover {
  animation: electric-pulse 1.5s infinite alternate;
  transform: translateY(-3px) scale(1.02);
  z-index: 10;
}

/* Mobile Menu Optimizations */
@media (max-width: 768px) {
  .header-controls {
    gap: 15px;
    /* More space between buttons */
  }

  .header-controls button {
    width: 48px;
    /* Larger touch target */
    height: 48px;
    font-size: 1.4rem;
    /* Larger icons */
    background: rgba(255, 255, 255, 0.9);
    /* Better visibility */
    backdrop-filter: blur(5px);
  }

  body.dark-mode .header-controls button {
    background: rgba(0, 0, 0, 0.6);
  }

  /* Theme Menu on Mobile */
  .theme-menu {
    width: 90vw;
    left: 5vw;
    right: auto;
    top: 80px;
    transform: translateY(-10px);
  }

  .theme-menu.active {
    transform: translateY(0);
  }

  .theme-option {
    padding: 12px 15px;
    /* Larger touch area */
    font-size: 1rem;
  }
}

/* Mobile Menu Fixes & Utilities */
@media (max-width: 768px) {
  .header-controls {
    top: 10px;
    right: 10px;
    gap: 8px;
  }

  .icon-raven {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

.bg-alabastro {
  background-color: var(--condado-blanco-alabastro);
  background-image: url('../assets/img/bg-alabaster.png');
  background-blend-mode: multiply;
  color: var(--condado-negro-carbon);
}

/* Menu Alabastro Style */
.menu-alabastro .header-controls button {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--condado-secundario);
  color: var(--condado-primario);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.menu-alabastro .header-controls button:hover {
  background: var(--condado-primario);
  color: #fff;
}

.menu-alabastro .sidebar {
  background: rgba(240, 230, 210, 0.95);
  /* Light Alabaster */
  border-left: 3px solid var(--condado-secundario);
}

.menu-alabastro .nav-links a {
  color: var(--condado-primario);
}

.menu-alabastro .nav-links a:hover {
  background: rgba(46, 8, 64, 0.1);
  color: var(--condado-rojo-sangre);
}