/* ============================================
   DESIGN SYSTEM — Artículo Académico Web
   Paleta inspirada en arte indígena sudamericana
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600&family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&display=swap');

/* === CSS Custom Properties === */
:root {
  /* Palette — warm earth tones */
  --color-bg:          #1a1714;
  --color-bg-elevated: #231f1b;
  --color-bg-card:     #2a2520;
  --color-bg-quote:    #2e2822;
  --color-surface:     #352e27;
  --color-border:      #4a3f35;
  --color-border-light:#3d342b;

  --color-text:        #e8e0d4;
  --color-text-muted:  #a89b8a;
  --color-text-dim:    #7a6e5f;

  --color-accent:      #c4814a;  /* terracotta */
  --color-accent-warm: #d4944f;
  --color-accent-hot:  #e0a35a;
  --color-accent-glow: rgba(196, 129, 74, 0.15);
  --color-accent-deep: #a0673a;

  --color-ochre:       #c9a84c;  /* golden ochre */
  --color-ochre-dim:   rgba(201, 168, 76, 0.12);

  --color-rust:        #b85c38;  /* deep rust */
  --color-sage:        #7a9a6d;  /* muted sage */

  /* Typography */
  --font-display: 'Cormorant Garamond', 'Georgia', serif;
  --font-body:    'Source Sans 3', 'Segoe UI', system-ui, sans-serif;

  /* Spacing */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Layout */
  --content-width: 780px;
  --sidebar-width: 260px;

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-smooth: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.35);
  --shadow-lg:  0 8px 30px rgba(0,0,0,0.4);
  --shadow-xl:  0 16px 50px rgba(0,0,0,0.5);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.8;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection {
  background: var(--color-accent);
  color: var(--color-bg);
}

/* === Reading Progress Bar === */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), var(--color-ochre));
  z-index: 1000;
  transition: width 100ms linear;
}

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26, 23, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-sm) var(--space-xl);
  transition: var(--transition-smooth);
}

.site-header.scrolled {
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: calc(var(--content-width) + var(--sidebar-width) + var(--space-3xl));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.header-brand {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-accent);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.header-brand span {
  color: var(--color-text-muted);
  font-weight: 400;
}

.header-nav {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  scrollbar-width: none;
}

.header-nav::-webkit-scrollbar {
  display: none;
}

.header-nav a {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: var(--transition-fast);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--color-accent);
  background: var(--color-accent-glow);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-xs);
}

/* === Main Layout === */
.main-layout {
  max-width: calc(var(--content-width) + var(--sidebar-width) + var(--space-3xl));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  gap: var(--space-3xl);
  padding: 0 var(--space-xl);
  position: relative;
}

/* === Sidebar TOC === */
.sidebar {
  position: relative;
}

.toc {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding: var(--space-lg) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.toc-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border-light);
}

.toc-list {
  list-style: none;
}

.toc-list li {
  margin-bottom: 2px;
}

.toc-list a {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text-dim);
  text-decoration: none;
  padding: 5px var(--space-sm);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: var(--transition-fast);
  line-height: 1.4;
}

.toc-list a:hover {
  color: var(--color-text);
  border-left-color: var(--color-border);
  background: rgba(255,255,255,0.02);
}

.toc-list a.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  background: var(--color-accent-glow);
  font-weight: 500;
}

.toc-list .toc-sub {
  padding-left: var(--space-md);
}

/* === Hero Section === */
.hero {
  padding: var(--space-4xl) 0 var(--space-3xl);
  border-bottom: 1px solid var(--color-border-light);
  margin-bottom: var(--space-3xl);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  margin-bottom: var(--space-lg);
}

.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 32px;
  height: 2px;
  background: var(--color-accent);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: var(--space-lg);
  letter-spacing: -0.01em;
  max-width: 700px;
}

.hero h1 .highlight {
  color: var(--color-accent-warm);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md) var(--space-xl);
  margin-bottom: var(--space-xl);
}

.hero-meta-item {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.hero-meta-item .label {
  color: var(--color-text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-meta-item .value {
  font-weight: 500;
}

.hero-abstract {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.abstract-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.abstract-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--color-accent), transparent);
}

.abstract-card h3 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: var(--space-sm);
}

.abstract-card p {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  line-height: 1.7;
  font-style: italic;
}

/* === Article Content === */
.article-content {
  padding-bottom: var(--space-4xl);
}

.article-content section {
  margin-bottom: var(--space-3xl);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 600ms ease, transform 600ms ease;
}

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

/* Section headings */
.article-content h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-accent);
  display: inline-block;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

.article-content h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-accent-warm);
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  line-height: 1.35;
}

.article-content h4 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-ochre);
  margin-top: var(--space-xl);
  margin-bottom: var(--space-md);
}

/* Paragraphs */
.article-content p {
  font-size: 1.02rem;
  line-height: 1.85;
  margin-bottom: var(--space-md);
  color: var(--color-text);
  text-align: justify;
  hyphens: auto;
}

/* === Blockquote / Citations === */
.myth-quote {
  background: var(--color-bg-quote);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-xl) 0;
  position: relative;
  overflow: hidden;
}

.myth-quote::before {
  content: '"';
  position: absolute;
  top: -10px;
  left: 12px;
  font-family: var(--font-display);
  font-size: 5rem;
  color: var(--color-accent);
  opacity: 0.12;
  line-height: 1;
}

.myth-quote p {
  font-style: italic;
  font-size: 0.98rem;
  color: var(--color-text-muted);
  line-height: 1.75;
  position: relative;
  z-index: 1;
}

.myth-quote .quote-source {
  font-style: normal;
  font-size: 0.82rem;
  color: var(--color-text-dim);
  margin-top: var(--space-sm);
  display: block;
}

/* Variant for shorter, inline quotes */
.myth-quote.compact {
  padding: var(--space-md) var(--space-lg);
}

.myth-quote.compact::before {
  font-size: 3rem;
  top: -5px;
  left: 8px;
}

/* === Map Figures === */
.map-figure {
  margin: var(--space-2xl) 0;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: var(--transition-smooth);
}

.map-figure:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent-deep);
}

.map-figure img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
  transition: var(--transition-smooth);
  background: #f5f0e8;
}

.map-figure img:hover {
  opacity: 0.92;
}

.map-caption {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border-light);
}

.map-caption .map-label {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 4px;
}

.map-caption p {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0;
  text-align: left;
}

.map-legend {
  margin-top: var(--space-sm);
  font-size: 0.82rem;
  color: var(--color-text-dim);
  line-height: 1.6;
}

/* === Lightbox === */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(10px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-smooth);
  cursor: zoom-out;
}

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

.lightbox-overlay img {
  max-width: 92%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  transform: scale(0.9);
  transition: transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lightbox-overlay.active img {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--color-text);
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.lightbox-close:hover {
  background: rgba(255,255,255,0.2);
}

/* === Footnotes === */
.footnote-ref {
  font-size: 0.75rem;
  color: var(--color-accent);
  cursor: help;
  position: relative;
  vertical-align: super;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition-fast);
}

.footnote-ref:hover {
  color: var(--color-accent-warm);
}

/* Tooltip */
.footnote-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.82rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  width: 320px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-fast);
  z-index: 500;
  font-style: normal;
  text-align: left;
  pointer-events: none;
}

.footnote-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-border);
}

.footnote-ref:hover .footnote-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Notes section */
.notes-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-top: var(--space-2xl);
}

.notes-section h2 {
  border-bottom-color: var(--color-ochre);
}

.notes-section ol {
  padding-left: var(--space-lg);
  counter-reset: note-counter;
  list-style: none;
}

.notes-section ol li {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-md);
  padding-left: var(--space-sm);
  position: relative;
  counter-increment: note-counter;
}

.notes-section ol li::before {
  content: counter(note-counter) ".";
  position: absolute;
  left: calc(-1 * var(--space-lg));
  color: var(--color-accent);
  font-weight: 600;
  font-size: 0.82rem;
}

/* === Bibliography === */
.bibliography-section {
  margin-top: var(--space-3xl);
}

.bibliography-section h2 {
  border-bottom-color: var(--color-sage);
}

.bib-list {
  list-style: none;
}

.bib-list li {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-md);
  padding-left: var(--space-lg);
  text-indent: calc(-1 * var(--space-lg));
}

.bib-list li .bib-author {
  font-weight: 600;
  color: var(--color-text);
}

.bib-list li .bib-year {
  color: var(--color-accent);
}

.bib-list li .bib-title {
  font-style: italic;
}

/* === Back to top === */
.back-to-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 44px;
  height: 44px;
  background: var(--color-accent);
  color: var(--color-bg);
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: var(--transition-smooth);
  z-index: 90;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--color-accent-warm);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* === Print / PDF styles === */
@media print {
  :root {
    --color-bg: #ffffff;
    --color-bg-elevated: #ffffff;
    --color-bg-card: #f8f6f2;
    --color-bg-quote: #f5f2ec;
    --color-text: #1a1714;
    --color-text-muted: #4a4035;
    --color-accent: #8b5e3c;
  }

  body {
    font-size: 11pt;
    line-height: 1.6;
    color: #1a1714;
    background: #fff;
  }

  .progress-bar,
  .site-header,
  .sidebar,
  .back-to-top,
  .lightbox-overlay,
  .menu-toggle {
    display: none !important;
  }

  .main-layout {
    display: block;
    max-width: 100%;
    padding: 0;
  }

  .article-content section {
    opacity: 1 !important;
    transform: none !important;
    page-break-inside: avoid;
  }

  .map-figure {
    page-break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .map-figure img {
    max-width: 100%;
  }

  .myth-quote {
    border-left-color: #8b5e3c;
    background: #f5f2ec;
  }

  .hero {
    padding: 0 0 var(--space-xl);
  }

  h1, h2, h3 {
    color: #1a1714;
    page-break-after: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}

/* === Responsive === */
@media (max-width: 1100px) {
  .main-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0 var(--space-lg);
  }

  .sidebar {
    display: none;
  }

  .sidebar.mobile-open {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    background: var(--color-bg-elevated);
    z-index: 200;
    padding: var(--space-4xl) var(--space-lg) var(--space-lg);
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
  }

  .sidebar.mobile-open .toc {
    position: static;
    max-height: none;
  }

  .menu-toggle {
    display: block;
  }
}

@media (max-width: 768px) {
  .hero h1 {
    font-size: 1.7rem;
  }

  .hero-abstract {
    grid-template-columns: 1fr;
  }

  .article-content h2 {
    font-size: 1.4rem;
  }

  .article-content h3 {
    font-size: 1.15rem;
  }

  .myth-quote {
    padding: var(--space-md) var(--space-lg);
    margin: var(--space-lg) 0;
  }

  .header-nav {
    display: none;
  }

  .hero-meta {
    flex-direction: column;
    gap: var(--space-sm);
  }
}

@media (max-width: 480px) {
  .hero h1 {
    font-size: 1.45rem;
  }

  .main-layout {
    padding: 0 var(--space-md);
  }

  .map-caption {
    padding: var(--space-sm) var(--space-md);
  }
}

/* === Sidebar overlay backdrop (mobile) === */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition-smooth);
}

.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* === Decorative separator === */
.section-divider {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-border), transparent);
  margin: var(--space-3xl) 0;
}

/* === Smooth fade-in animation for initial load === */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  animation: fadeInUp 800ms ease forwards;
}
