/* Quarters — Design System for Historic Spanish Barrios
   Theme: Layered heritage, contemplative travel, living memory of Spanish cities.
   Motifs: Stone, light/shadow in narrow streets, wrought iron, azulejo fragments, palimpsest walls.
*/

:root {
  --cream: #F8F1E3;
  --parchment: #F1E8D8;
  --stone: #4A4037;
  --warm-stone: #5C5045;
  --burgundy: #6B2D3C;
  --deep-burgundy: #4F1F2B;
  --gold: #C5A26F;
  --aged-gold: #A17D4A;
  --terracotta: #8B4635;
  --olive: #4F513E;
  --dark: #2C2522;
  --ink: #1F1916;
  --shadow: rgba(44, 37, 34, 0.12);
  --soft-shadow: rgba(75, 64, 55, 0.08);

  --font-display: 'Alegreya', Georgia, serif;
  --font-body: 'Work Sans', system-ui, -apple-system, sans-serif;

  --space-xs: 4px;
  --space-sm: 10px;
  --space-md: 18px;
  --space-lg: 28px;
  --space-xl: 44px;
  --space-2xl: 68px;

  --radius: 4px;
  --radius-lg: 9px;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--dark);
  line-height: 1.72;
  font-size: 15.5px;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.18;
  color: var(--burgundy);
}
h1 { font-size: clamp(2.1rem, 6.2vw, 3.6rem); letter-spacing: -0.6px; }
h2 { font-size: clamp(1.65rem, 4.1vw, 2.35rem); }
h3 { font-size: 1.32rem; }
h4 { font-size: 1.1rem; color: var(--warm-stone); }

p { margin-bottom: 1.1em; }
a { color: var(--burgundy); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
}

/* Header & Navigation — Heritage feel, dignified */
header {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(248, 241, 227, 0.97);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(75, 64, 55, 0.1);
}
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 0;
}
.logo {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 700;
  color: var(--burgundy);
  letter-spacing: -0.6px;
}
.nav-links {
  display: flex;
  gap: 30px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: var(--stone);
  font-weight: 500;
  font-size: 14.5px;
  transition: color 0.2s ease;
  position: relative;
}
.nav-links a:hover,
.nav-links a.active {
  color: var(--burgundy);
}
.nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--burgundy);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 26px;
  color: var(--stone);
  cursor: pointer;
  padding: 4px;
}

/* Hero — Immersive but restrained, like arriving at dawn in an old quarter */
.hero, .page-hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  background-size: cover;
  background-position: center;
  color: white;
}
.hero::after, .page-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(44,37,34,0.42) 0%,
    rgba(44,37,34,0.58) 48%,
    rgba(44,37,34,0.72) 100%
  );
}
.hero-content, .page-hero .container {
  position: relative;
  z-index: 2;
  max-width: 720px;
}
.hero h1 {
  font-size: clamp(2.65rem, 8vw, 4.1rem);
  color: white;
  margin-bottom: 18px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.35);
}
.hero p, .page-hero p {
  font-size: 1.1rem;
  max-width: 580px;
  opacity: 0.95;
  margin-bottom: 32px;
}

.page-hero {
  min-height: 420px;
  height: auto;
}
.page-hero h1 {
  font-size: clamp(2rem, 5.8vw, 2.95rem);
  margin-bottom: 10px;
}

/* Buttons — Ink and paper, tactile */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 28px;
  background: var(--burgundy);
  color: white;
  font-weight: 500;
  font-size: 14.5px;
  border-radius: var(--radius);
  border: 1px solid var(--deep-burgundy);
  letter-spacing: 0.25px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  background: var(--deep-burgundy);
  transform: translateY(-1px);
  text-decoration: none;
}
.btn-outline {
  background: transparent;
  border: 2px solid white;
  color: white;
}
.btn-outline:hover {
  background: white;
  color: var(--burgundy);
  border-color: white;
}
.btn-small {
  padding: 8px 18px;
  font-size: 13.5px;
}
.btn-terracotta {
  background: var(--terracotta);
  border-color: #6F3528;
}
.btn-terracotta:hover {
  background: #6F3528;
}

/* Sections */
section {
  padding: var(--space-2xl) 0;
}
.section-header {
  margin-bottom: var(--space-xl);
}
.section-header.centered {
  text-align: center;
}
.section-header h2 {
  margin-bottom: 8px;
}
.section-header p {
  color: var(--warm-stone);
  max-width: 620px;
  margin: 0 auto;
}

/* Cards — Architectural plates / old field notes */
.card, .guide-card, .article {
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 8px 24px var(--soft-shadow);
  border: 1px solid rgba(75, 64, 55, 0.06);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover, .guide-card:hover, .article:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px var(--shadow);
}
.card img, .guide-card img, .article img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid rgba(75,64,55,0.06);
}
.card-content, .guide-card .content, .article-content {
  padding: 22px 24px 24px;
}
.card h3, .guide-card h3, .article h3 {
  margin-bottom: 7px;
  color: var(--ink);
}
.card .meta, .location, .article .meta {
  font-size: 12.5px;
  color: var(--aged-gold);
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.card p, .guide-card p, .article p {
  font-size: 14.8px;
  color: var(--stone);
  margin-bottom: 18px;
}

/* Special layout: The Palimpsest — layered time */
.layers {
  display: grid;
  gap: 22px;
}
.layer {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 20px;
  background: white;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  border-left: 5px solid var(--burgundy);
}
.layer-year {
  font-family: var(--font-display);
  font-size: 1.55rem;
  color: var(--burgundy);
  line-height: 1;
}
.layer-content h4 {
  margin-bottom: 6px;
  font-size: 1.02rem;
}
.layer-content p {
  margin: 0;
  font-size: 14.5px;
}

/* Voices from the street — niche oral history style */
.voices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.voice {
  background: var(--parchment);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(197, 162, 111, 0.2);
}
.voice q {
  font-style: italic;
  display: block;
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 15px;
}
.voice .attribution {
  font-size: 13px;
  color: var(--warm-stone);
}

/* Filters — Atlas style */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 28px;
}
.filter-btn {
  padding: 7px 18px;
  background: white;
  border: 1px solid #D4C9B3;
  border-radius: 50px;
  font-size: 13.5px;
  color: var(--stone);
  cursor: pointer;
  transition: all 0.2s;
}
.filter-btn.active,
.filter-btn:hover {
  background: var(--burgundy);
  color: white;
  border-color: var(--burgundy);
}

/* Timeline refined for heritage */
.timeline {
  max-width: 780px;
  margin: 0 auto;
  position: relative;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 38px;
  top: 28px;
  bottom: 28px;
  width: 2px;
  background: #D4C9B3;
}
.timeline-item {
  display: flex;
  gap: 26px;
  margin-bottom: 46px;
  position: relative;
}
.timeline-year {
  width: 76px;
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--burgundy);
  text-align: right;
  padding-top: 4px;
}
.timeline-content {
  flex: 1;
  background: white;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 18px var(--soft-shadow);
}
.timeline-content h4 { margin-bottom: 5px; }

/* Practical info boxes */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 22px;
}
.info-box {
  background: white;
  padding: 26px 26px 22px;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 20px var(--soft-shadow);
}
.info-box h3 {
  color: var(--burgundy);
  margin-bottom: 12px;
  font-size: 1.1rem;
}

/* Forms */
form {
  background: white;
  padding: 30px;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 26px var(--soft-shadow);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13.5px;
  margin-bottom: 6px;
  color: var(--warm-stone);
}
input, select, textarea {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #D4C9B3;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 15px;
  background: white;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44, 37, 34, 0.78);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal-content {
  background: white;
  width: 100%;
  max-width: 760px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.modal-header {
  padding: 20px 24px;
  background: var(--cream);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(75,64,55,0.08);
}
.modal-header h3 {
  margin: 0;
  font-size: 1.35rem;
}
.modal-body {
  padding: 26px 24px 30px;
  line-height: 1.75;
}
.modal-close {
  font-size: 32px;
  line-height: 1;
  color: var(--stone);
  cursor: pointer;
  user-select: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark);
  color: white;
  padding: 13px 24px;
  border-radius: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
  display: none;
  z-index: 3000;
  font-size: 14.5px;
}

/* Footer */
footer {
  background: var(--dark);
  color: #E8D9B8;
  padding: 54px 0 28px;
  font-size: 14px;
}
footer a {
  color: #E8D9B8;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr;
  gap: 46px;
}
.footer-col h4 {
  font-family: var(--font-display);
  font-size: 15.5px;
  margin-bottom: 14px;
  color: white;
}
.footer-bottom {
  margin-top: 52px;
  padding-top: 22px;
  border-top: 1px solid rgba(232, 217, 184, 0.18);
  text-align: center;
  font-size: 12.5px;
  opacity: 0.6;
}

/* Responsive */
@media (max-width: 900px) {
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 64px;
    right: 18px;
    background: var(--cream);
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 30px var(--shadow);
    min-width: 180px;
  }
  .nav-links.show {
    display: flex;
  }
  .hamburger {
    display: block;
  }
  .hero, .page-hero {
    min-height: 460px;
  }
  .hero h1 {
    font-size: 2.35rem;
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

@media (max-width: 640px) {
  .hero h1 { font-size: 2.05rem; }
  .page-hero { min-height: 340px; }
  .form-row { grid-template-columns: 1fr; }
  .layer { grid-template-columns: 82px 1fr; gap: 14px; }
  .timeline::before { left: 22px; }
  .timeline-year { width: 52px; font-size: 1rem; }
}

/* Utility */
.text-center { text-align: center; }
.subtle { color: var(--warm-stone); font-size: 14.2px; }
.divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #D4C9B3, transparent);
  margin: 40px 0;
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  background: var(--parchment);
  color: var(--aged-gold);
  border-radius: 2px;
  margin-right: 6px;
  letter-spacing: 0.3px;
}

/* Accessibility */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}