@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,700;1,400;1,700&family=Jost:wght@400;500;700&display=swap');

/* ─── Custom Color Palette ────────────────────────────────────────────────── */
:root {
  /* Thesis Palette */
  --thesis-blue-dark:   #4a648a; /* Un poco más apagado/grisáceo que el original */
  --thesis-brown:       #8a553a;
  --thesis-red-dark:    #8a3a3d;
  --thesis-terracotta:  #997172;
  --thesis-beige:       #b39a82;
  --thesis-beige-light: #f4f1ee;
  --thesis-blue-light:  #c5ddfa;
  --thesis-grey-dark:   #2a2a2a;

  /* Material Theme Overrides - Common */
  --md-primary-fg-color:           var(--thesis-red-dark) !important;
  --md-primary-fg-color--dark:     #6a2d2f !important;
  --md-accent-fg-color:            var(--thesis-blue-dark) !important;
  
  --md-typeset-a-color:            var(--thesis-blue-dark) !important;
}

/* ─── Global Color Fixes (Force) ────────────────────────────────────────── */
[data-md-color-scheme] {
  --md-accent-fg-color: var(--thesis-blue-dark) !important;
  --md-accent-fg-color--transparent: rgba(74, 100, 138, 0.1) !important;
}

/* Active navigation links -> Muted Thesis Blue */
.md-nav__link--active,
.md-nav__link:focus,
.md-nav__link:hover,
.md-nav__item--active > .md-nav__link {
  color: var(--thesis-blue-dark) !important;
}

/* TOC (Right side) indicator line -> Muted Thesis Blue */
.md-nav--secondary .md-nav__link--active,
.md-nav--secondary .md-nav__item--active > .md-nav__link {
  border-left: .15rem solid var(--thesis-blue-dark) !important;
  color: var(--thesis-blue-dark) !important;
  padding-left: 0.75rem !important;
}

/* ─── Light Mode Specific ────────────────────────────────────────────────── */
[data-md-color-scheme="default"] {
  --md-default-bg-color:           var(--thesis-beige-light) !important;
  --md-default-bg-color--light:    #ffffff !important;
  --md-typeset-color:              var(--thesis-grey-dark) !important;
}

[data-md-color-scheme="default"] body,
[data-md-color-scheme="default"] .md-content,
[data-md-color-scheme="default"] .md-nav {
  background-color: var(--thesis-beige-light) !important;
}

/* ─── Dark Mode Specific ─────────────────────────────────────────────────── */
[data-md-color-scheme="slate"] {
  /* We keep material defaults for dark mode background, 
     but we can still use our thesis primary/accent colors */
  --md-primary-fg-color:           var(--thesis-red-dark) !important;
  --md-typeset-color:              #e0e0e0 !important; /* Lighter text for dark mode */
}

/* Force Header and Tabs Color (Both Modes) */
.md-header, 
.md-tabs {
  background-color: var(--thesis-red-dark) !important;
}

/* ─── Typography ───────────────────────────────────────────────────────────── */

/* Body text -> EB Garamond */
.md-typeset {
  font-family: 'EB Garamond', serif;
  font-size: 1.0rem; 
  line-height: 1.6;
}

/* Titles -> Jost Bold Uppercase */
.md-typeset h1 {
  font-family: 'Jost', sans-serif !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em;
  font-size: 1.8rem;
}

/* Subtitles -> Jost Medium Uppercase */
.md-typeset h2, 
.md-typeset h3, 
.md-typeset h4 {
  font-family: 'Jost', sans-serif !important;
  font-weight: 500 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.03em;
  font-size: 1.3rem;
}

/* UI Elements (Tabs, TOC, Nav) -> Jost Uppercase */
.md-tabs__link,
.md-nav__link {
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* TOC (Right side) specifically */
.md-nav--secondary .md-nav__link {
  font-size: 0.75rem;
  font-weight: 400;
}

/* ─── Iframe charts ─────────────────────────────────────────────────────────
   Ensures Plotly iframes fill the content column and display without
   visible borders or scroll artefacts across themes.
   ─────────────────────────────────────────────────────────────────────────── */
iframe {
  display: block;
  width: 100%;
  border: none;
  border-radius: 6px;
  background: transparent;
}

[data-md-color-scheme="default"] iframe {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}

[data-md-color-scheme="slate"] iframe {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.40);
}

/* ─── Content width ──────────────────────────────────────────────────────────
   Widen the content area so charts and maps have more horizontal space.
   ─────────────────────────────────────────────────────────────────────────── */
.md-grid {
  max-width: 1400px;
}

/* ─── Table improvements ─────────────────────────────────────────────────────
   Tighter font for data tables inside chart and results pages.
   ─────────────────────────────────────────────────────────────────────────── */
.md-typeset table:not([class]) {
  font-size: 0.85rem;
}

/* ─── Admonitions (Callouts) General Styles ────────────────────────────────── */
.md-typeset .admonition,
.md-typeset details {
  margin-top: 1.5rem;
  font-size: 1.0rem; 
  line-height: 1.6;
}

.md-typeset .admonition-title,
.md-typeset summary {
  font-family: 'Jost', sans-serif !important;
  font-weight: 700 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.9rem;
}

/* ─── Admonitions (Callouts) Custom Colors ─────────────────────────────────── */
.md-typeset .admonition.info {
  border-color: var(--thesis-blue-dark);
}
.md-typeset .info > .admonition-title,
.md-typeset .info > summary {
  background-color: rgba(58, 90, 137, 0.07);
  border-left-color: var(--thesis-blue-dark);
}
/* ... rest of the colors already applied ... */

.md-typeset .admonition.abstract {
  border-color: var(--thesis-brown);
}
.md-typeset .abstract > .admonition-title,
.md-typeset .abstract > summary {
  background-color: rgba(138, 85, 58, 0.1);
  border-left-color: var(--thesis-brown);
}

.md-typeset .admonition.success {
  border-color: var(--thesis-red-dark);
}
.md-typeset .success > .admonition-title,
.md-typeset .success > summary {
  background-color: rgba(138, 58, 61, 0.1);
  border-left-color: var(--thesis-red-dark);
}

.md-typeset .admonition.tip {
  border-color: var(--thesis-terracotta);
}
.md-typeset .tip > .admonition-title,
.md-typeset .tip > summary {
  background-color: rgba(153, 113, 114, 0.1);
  border-left-color: var(--thesis-terracotta);
}

/* ─── Leaflet map ────────────────────────────────────────────────────────────
   Map container and legend styles.
   ─────────────────────────────────────────────────────────────────────────── */
#map {
  z-index: 0; /* keep below MkDocs sticky header */
}

[data-md-color-scheme="default"] #map {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

[data-md-color-scheme="slate"] #map {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* Legend box rendered by Leaflet */
.map-legend {
  background: var(--md-default-bg-color, #fff);
  color: var(--md-default-fg-color, #000);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.8;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.25);
}

.map-legend span {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* Leaflet popup – inherit site font */
.leaflet-popup-content {
  font-family: var(--md-text-font, Inter, sans-serif);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ─── Fullscreen button — shared styles ──────────────────────────────────────
   Used by both the Leaflet map control and the chart iframe button.
   ─────────────────────────────────────────────────────────────────────────── */

/* Leaflet map fullscreen control (sits inside the Leaflet control bar) */
.leaflet-fullscreen-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  cursor: pointer;
  background: #fff;
  color: #333;
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
  transition: background 0.15s;
}

.leaflet-fullscreen-btn:hover {
  background: #f4f4f4;
}

/* When the Leaflet map container is in fullscreen */
.leaflet-container:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999;
}

/* ─── Chart iframe fullscreen ────────────────────────────────────────────────
   The JS wraps each <iframe> in .chart-fs-wrapper and injects a button.
   ─────────────────────────────────────────────────────────────────────────── */
.chart-fs-wrapper {
  position: relative;
  display: block;
}

/* Floating button — top-right corner, above the iframe */
.chart-fullscreen-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.88);
  color: #333;
  border: none;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
  transition: background 0.15s, opacity 0.15s;
  opacity: 0.6;
}

.chart-fs-wrapper:hover .chart-fullscreen-btn {
  opacity: 1;
}

.chart-fullscreen-btn:hover {
  background: #fff;
}

/* Fullscreen state: wrapper fills viewport, iframe fills wrapper */
.chart-fs-wrapper:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #000;
}

.chart-fs-wrapper:fullscreen iframe {
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}

/* Keep the button visible in fullscreen */
.chart-fs-wrapper:fullscreen .chart-fullscreen-btn {
  opacity: 1;
  background: rgba(255, 255, 255, 0.88);
}

/* ─── Footer ─────────────────────────────────────────────────────────────────
   Minimal single-line footer.
   ─────────────────────────────────────────────────────────────────────────── */
.md-footer-meta__inner {
  width: 100%;
}

.site-footer-inner {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  font-family: 'Jost', sans-serif;
  opacity: 0.65;
}

.site-footer-left {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.site-footer-title {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.site-footer-author {
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.site-footer-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  font-size: 0.72rem;
  text-align: right;
}

.site-footer-right a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.site-footer-right a:hover {
  opacity: 1;
}

@media (max-width: 600px) {
  .site-footer-inner {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .site-footer-left {
    align-items: center;
    text-align: center;
  }

  .site-footer-right {
    text-align: center;
  }
}

/* ─── Landing page grid cards ────────────────────────────────────────────────
   Ensure cards have a consistent minimum height on the home page.
   ─────────────────────────────────────────────────────────────────────────── */
.md-typeset .grid.cards > :is(ul, ol) > li,
.md-typeset .grid > .card {
  min-height: 180px;
}
