/* ============================================================
   HISTORIA DE ESPAÑA — DESIGN SYSTEM
   Thematic, scholarly, heritage-focused
   ============================================================ */

:root {
  --gold: #C5A46E;
  --gold-dark: #A68B57;
  --deep-red: #4A1C12;
  --deep-red-light: #6B2C22;
  --cream: #F5F0E6;
  --cream-dark: #EDE4D8;
  --dark: #1C1611;
  --dark-elevated: #28221C;
  --ink: #2C2520;
  --sage: #5C6B4A;
  --terracotta: #8B5E3C;
  --stone: #8C8174;
  --parchment: #F8F4EB;
  
  /* Typography scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;
  --text-5xl: 3.25rem;
  
  --font-serif: 'Cinzel', 'Playfair Display', Georgia, serif;
  --font-display: 'Cinzel', Georgia, serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  
  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 15px -4px rgba(0,0,0,0.12);
  --shadow-lg: 0 20px 40px -15px rgba(0,0,0,0.18);
  --shadow-deep: 0 30px 70px -15px rgba(0,0,0,0.35);
}

/* Base resets */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  line-height: 1.72;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .heading-serif {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

h1 { font-size: clamp(2.25rem, 5vw, 3.6rem); }
h2 { font-size: clamp(1.65rem, 3.8vw, 2.35rem); }
h3 { font-size: clamp(1.25rem, 2.8vw, 1.5rem); }

p { margin-bottom: 1.1em; }
p:last-child { margin-bottom: 0; }

/* Reading containers */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (min-width: 768px) { .container { padding: 0 2rem; } }

/* Navigation — Heritage style */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(28,22,17,0.96);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(197,164,110,0.12);
  padding: 0.85rem 0;
  transition: all 0.25s ease;
}
.nav.scrolled { box-shadow: 0 4px 20px rgba(0,0,0,0.2); }

.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: #F5F0E6;
  text-decoration: none;
  letter-spacing: 0.5px;
}
.logo span { color: var(--gold); }

.nav-links {
  display: flex;
  gap: 1.85rem;
  list-style: none;
}
.nav-links a {
  color: #F5F0E6;
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  padding: 0.35rem 0;
  position: relative;
  transition: color 0.2s ease;
}
.nav-links a:hover { color: var(--gold); }
.nav-links a.active {
  color: var(--gold);
}
.nav-links a.active:after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--gold);
}

.nav-actions { display: flex; align-items: center; gap: 0.85rem; }

/* Buttons — tactile, classical */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.45rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 50px;
  text-decoration: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
  min-height: 44px;
  white-space: nowrap;
}
.btn-gold {
  background: var(--gold);
  color: var(--deep-red);
  box-shadow: 0 2px 8px rgba(197,164,110,0.35);
}
.btn-gold:hover {
  background: #D8B77F;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(197,164,110,0.45);
}
.btn-outline {
  background: transparent;
  color: #F5F0E6;
  border: 1.5px solid #F5F0E6;
}
.btn-outline:hover {
  background: #F5F0E6;
  color: var(--deep-red);
}
.btn-small { padding: 0.45rem 1.1rem; font-size: 0.82rem; min-height: 38px; }
.btn-block { width: 100%; }

/* Cards */
.card {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1), box-shadow 0.3s;
  border: 1px solid var(--cream-dark);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* Section rhythm */
section { padding: 4.5rem 0; }
@media (max-width: 768px) { section { padding: 3rem 0; } }

.section-title {
  font-family: var(--font-display);
  color: var(--deep-red);
  margin-bottom: 0.35rem;
  position: relative;
  display: inline-block;
}
.section-title:after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 0;
  width: 52px;
  height: 2.5px;
  background: linear-gradient(to right, var(--gold), var(--terracotta));
}
.section-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--terracotta);
  margin-bottom: 0.4rem;
}

/* Historical strata visual motif */
.strata {
  position: relative;
}
.strata-layer {
  padding: 1.1rem 1.35rem;
  border-left: 4px solid var(--gold);
  background: white;
  margin-bottom: 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.strata-layer:last-child { margin-bottom: 0; }

/* Expert note boxes */
.expert-note {
  background: var(--parchment);
  border-left: 4px solid var(--gold);
  padding: 1.1rem 1.35rem;
  font-size: 0.95rem;
  color: #444;
  margin: 1.25rem 0;
}
.expert-note strong {
  color: var(--deep-red);
  display: block;
  margin-bottom: 0.3rem;
}

/* Primary source callout */
.primary-source {
  background: #1C1611;
  color: #EDE4D8;
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius);
  font-style: italic;
  position: relative;
}
.primary-source:before {
  content: '«';
  font-size: 3.5rem;
  position: absolute;
  left: 0.75rem;
  top: -0.1rem;
  opacity: 0.15;
  line-height: 1;
  font-family: var(--font-serif);
}
.primary-source cite {
  display: block;
  margin-top: 0.85rem;
  font-style: normal;
  font-size: 0.8rem;
  color: var(--gold);
  letter-spacing: 0.5px;
}

/* Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.75rem;
}
.filter-btn {
  background: white;
  border: 1px solid #D9D0C2;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  color: #444;
}
.filter-btn.active, .filter-btn:hover {
  background: var(--deep-red);
  color: white;
  border-color: var(--deep-red);
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(28,22,17,0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}
.modal.active { display: flex; }
.modal-content {
  background: white;
  max-width: 860px;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-deep);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-header {
  padding: 1.35rem 1.65rem;
  background: var(--dark);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { margin: 0; font-size: 1.45rem; }
.modal-close {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 1.75rem 1.65rem; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--deep-red);
  color: white;
  padding: 0.85rem 1.65rem;
  border-radius: 50px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 3000;
  font-size: 0.92rem;
}
.toast.show { display: flex; }

/* Responsive typography helpers */
@media (max-width: 768px) {
  .container { padding: 0 1.25rem; }
  .nav-links { gap: 1.35rem; }
  section { padding: 2.5rem 0; }
}

/* Mobile nav */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 8px;
  margin-right: -8px;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: #F5F0E6;
  transition: 0.25s;
}
@media (max-width: 900px) {
  .nav-links {
    position: fixed;
    top: 64px;
    left: -100%;
    width: 100%;
    height: calc(100vh - 64px);
    background: var(--dark);
    flex-direction: column;
    padding: 2rem 1.5rem;
    transition: left 0.35s ease;
    gap: 1.1rem;
  }
  .nav-links.active { left: 0; }
  .hamburger { display: flex; }
}

/* Image treatment */
.img-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s ease;
}
.card:hover .img-cover { transform: scale(1.035); }

/* Historical fact grid */
.fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  margin: 1.35rem 0;
}
.fact-item {
  background: var(--parchment);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
}
.fact-item .label {
  font-size: 0.7rem;
  color: var(--terracotta);
  display: block;
  margin-bottom: 0.15rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Internal link style */
a.internal {
  color: var(--deep-red);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a.internal:hover { color: var(--gold-dark); }

/* Footer */
footer {
  background: var(--dark);
  color: #C7B9A3;
  padding: 3.25rem 0 1.75rem;
  font-size: 0.9rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1.4fr;
  gap: 2.5rem;
}
@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.85rem; }
}
.footer-col h4 {
  color: var(--gold);
  font-family: var(--font-display);
  margin-bottom: 0.95rem;
  font-size: 0.98rem;
}
.footer-col a {
  color: #C7B9A3;
  text-decoration: none;
  display: block;
  margin-bottom: 0.4rem;
}
.footer-col a:hover { color: var(--gold); }
.footer-bottom {
  margin-top: 2.75rem;
  padding-top: 1.35rem;
  border-top: 1px solid rgba(197,164,110,0.18);
  font-size: 0.8rem;
  opacity: 0.85;
}

/* Scroll reveal base */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: all 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Unique: Layered history indicator */
.history-layer {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 1px;
  background: rgba(197,164,110,0.12);
  color: var(--deep-red);
  padding: 2px 10px;
  border-radius: 20px;
}

/* Print-friendly for resources */
@media print {
  .nav, .btn, footer { display: none !important; }
  body { background: white; color: black; }
}