/* AI-use notice: this file includes AI-generated content and code, reviewed by the team. */
/* ==========================================================================
   Atlalli · Independent 6-Region Selector Page & Dedicated Region Climate
   Data Page (Unified Reactive Glider Switchers, Auto-Hiding Centered Header,
   Speed-Adjustable Year Evolution, and Visual NASA Data Passport).
   ========================================================================== */

:root {
  --font-display: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-sans: "DM Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;

  /* Official Global Colors */
  --app-bg: #F9EFD4;
  --card-bg: #FFFBEF;
  --text-main: #1F3A36;
  --text-muted: #4B5F5A;
  --border-color: #E2D5B0;
  --more-rain: #2A5F8F;
  --less-rain: #C2410C;

  /* Default Regional Colors: Morelos */
  --reg-primary: #D51761;
  --reg-accent: #E1649E;
  --reg-soft: #F9DBDB;
  --reg-soft-border: #ebb5c2;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
}

/* AI-use notice: Official regional palettes with smooth CSS custom property transitions */
body[data-region="morelos"] {
  --reg-primary: #D51761;
  --reg-accent: #E1649E;
  --reg-soft: #F9DBDB;
  --reg-soft-border: #ebb5c2;
}

body[data-region="zacatecas"] {
  --reg-primary: #8E4A35;
  --reg-accent: #B2673D;
  --reg-soft: #F7EFE6;
  --reg-soft-border: #DEC6B0;
}

body[data-region="chiapas"] {
  --reg-primary: #1B8E96;
  --reg-accent: #D59625;
  --reg-soft: #DFEFE9;
  --reg-soft-border: #b5d8ce;
}

body[data-region="south_amazon"] {
  --reg-primary: #619F4D;
  --reg-accent: #2D6A4F;
  --reg-soft: #E9EED8;
  --reg-soft-border: #c6d6a7;
}

body[data-region="sahel"] {
  --reg-primary: #A97508;
  --reg-accent: #CD8F2C;
  --reg-soft: #F3E8CF;
  --reg-soft-border: #dfc796;
}

body[data-region="sonora"] {
  --reg-primary: #8C4A2F;
  --reg-accent: #DCBA89;
  --reg-soft: #EFE2D4;
  --reg-soft-border: #d9bfa6;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background-color: var(--app-bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.45s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: radial-gradient(var(--border-color) 1.15px, transparent 1.15px);
  background-size: 24px 24px;
  opacity: 0.55;
}

/* ==========================================================================
   Strict Independent Page Visibility Rules
   ========================================================================== */
body[data-page="selector"] #page-region-data {
  display: none !important;
}

body[data-page="selector"] #page-region-selector {
  display: block;
}

body[data-page="data"] #page-region-selector {
  display: none !important;
}

body[data-page="data"] #page-region-data {
  display: block;
}

/* ==========================================================================
   Auto-Hiding Top Navbar with Centered Reactive 2-Page Switcher
   ("Lo de region y view graphs que este en medio arriba pero que se oculta
    al ir bajando para que no estorbe")
   ========================================================================== */
.explorer-header {
  position: sticky;
  top: 0;
  z-index: 80;
  background-color: rgba(255, 251, 239, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1.5px solid var(--border-color);
  transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.explorer-header.nav-hidden {
  transform: translateY(-115%);
  opacity: 0;
  pointer-events: none;
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.58rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.brand-back {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text-main);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand-back img {
  width: 32px;
  height: 32px;
  display: block;
}

.back-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.28rem 0.75rem;
  border-radius: 999px;
  background-color: var(--app-bg);
  border: 1.5px solid var(--border-color);
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.brand-back:hover .back-pill {
  border-color: var(--reg-primary);
  color: var(--reg-primary);
  transform: translateX(-2px);
}

.header-right-spacer {
  justify-self: end;
}

/* Unified Single-Rectangle Centered Top Switcher with Sliding Glider */
.header-page-tabs {
  justify-self: center;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  background-color: var(--app-bg);
  padding: 4px;
  border-radius: 14px;
  border: 1.5px solid var(--border-color);
  box-shadow: inset 0 1px 2px rgba(31, 58, 54, 0.04);
}

.page-tabs-glider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 2);
  border-radius: 10px;
  background-color: var(--reg-soft);
  border: 1.5px solid var(--reg-primary);
  box-shadow: 0 3px 10px rgba(31, 58, 54, 0.09);
  transform: translateX(calc(var(--page-idx, 0) * 100%));
  transition:
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.35s ease,
    border-color 0.35s ease;
  pointer-events: none;
  z-index: 0;
}

.page-tab-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.44rem 1.15rem;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  white-space: nowrap;
  transition: color 0.22s ease, transform 0.18s ease;
}

.page-tab-btn:hover {
  color: var(--text-main);
}

.page-tab-btn:active {
  transform: scale(0.98);
}

.page-tab-btn.active {
  color: var(--text-main);
}

.tab-svg-icon {
  color: var(--reg-primary);
  flex-shrink: 0;
  transition: transform 0.3s ease, color 0.35s ease;
}

.page-tab-btn.active .tab-svg-icon {
  transform: rotate(-10deg) scale(1.06);
}

.active-region-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--reg-primary);
  flex-shrink: 0;
  transition: background-color 0.4s ease, transform 0.25s ease;
}

.page-tab-btn.active .active-region-dot {
  transform: scale(1.18);
}

/* ==========================================================================
   INDEPENDENT PAGE 1: STANDALONE 6-REGION SELECTOR PAGE
   - Fits comfortably in 100vh full-screen viewports
   - Card background dynamically shifts to the active region's soft palette
   - 3 Horizontal Top-Left + 3 Horizontal Bottom-Right connected by SVG lines
   - Sleek, compact Segmented Pill Dock for Climate Variables
   ========================================================================== */
.selector-page-wrap {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.9rem 1.5rem 1.8rem;
  min-height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.selector-standalone-card {
  background-color: var(--reg-soft);
  border: 2px solid var(--reg-primary);
  border-radius: var(--radius-lg);
  padding: 1.45rem 2.2rem 1.65rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.05rem;
  position: relative;
  overflow: hidden;
  box-shadow:
    0 16px 40px rgba(31, 58, 54, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition:
    background-color 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.48s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.48s ease;
}

/* Full-Bleed Animated Regional & Variable Background Scene across the Outer Card */
.card-bg-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.card-bg-scene svg {
  width: 100%;
  height: 100%;
  display: block;
}

.selector-top-center {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 680px;
  gap: 0.25rem;
}

.selector-eyebrow {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--reg-primary);
  background-color: rgba(255, 251, 239, 0.94);
  backdrop-filter: blur(4px);
  padding: 0.24rem 0.85rem;
  border-radius: 999px;
  border: 1.5px solid var(--reg-primary);
  transition: all 0.4s ease;
}

.selector-main-title {
  margin: 0.08rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  line-height: 1.08;
}

.selector-wheel-center {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0;
}

/* Stepped Constellation Stage: Translucent Frosted Glass Plate for the 6 Nodes */
.selector-constellation-stage {
  position: relative;
  width: 100%;
  max-width: 960px;
  height: 310px;
  margin: 0 auto;
  border-radius: 22px;
  background-color: rgba(255, 251, 239, 0.74);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(226, 213, 176, 0.88);
  box-shadow:
    0 10px 30px rgba(31, 58, 54, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  user-select: none;
  overflow: hidden;
  z-index: 1;
}

.constellation-bg-scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.constellation-bg-scene svg {
  width: 100%;
  height: 100%;
  display: block;
}

.constellation-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.constellation-line-halo {
  fill: none;
  stroke: rgba(255, 251, 239, 0.92);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.constellation-line-base {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.constellation-line-dash {
  fill: none;
  stroke: var(--reg-primary);
  stroke-width: 2.8;
  stroke-dasharray: 8 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.75;
  transition: stroke 0.45s ease;
}

.constellation-line-active {
  fill: none;
  stroke: var(--reg-primary);
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.98;
  transition: stroke 0.45s ease, d 0.45s ease;
}

/* Subtle Bottom-Left Region Coordinates & Climate Tag Pill */
.constellation-preview-pill {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  background-color: rgba(255, 251, 239, 0.94);
  backdrop-filter: blur(6px);
  border: 1.5px solid var(--reg-primary);
  border-radius: 999px;
  padding: 0.35rem 0.95rem;
  box-shadow: 0 6px 16px rgba(31, 58, 54, 0.10);
  transition: border-color 0.4s ease;
}

.constellation-preview-pill.bottom-left {
  left: 20px;
  bottom: 16px;
  pointer-events: none;
}

.preview-pill-meta {
  display: flex;
  flex-direction: column;
  text-align: left;
  line-height: 1.15;
}

.preview-pill-kicker {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.preview-pill-val {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-main);
}

/* 6 Enlarged Connected Region Medallion Nodes (126x126px, prominent and tactile!) */
.wheel-node {
  position: absolute;
  width: 126px;
  height: 126px;
  margin-left: -63px;
  margin-top: -63px;
  border-radius: 50%;
  background-color: rgba(255, 251, 239, 0.96);
  border: 3.5px solid var(--border-color);
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  box-shadow: 0 8px 24px rgba(31, 58, 54, 0.14);
  transition:
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.32s ease,
    box-shadow 0.32s ease,
    background-color 0.32s ease;
  z-index: 4;
}

.wheel-node:hover {
  transform: translateY(-3px) scale(1.07);
  border-color: var(--node-color, var(--reg-primary));
  box-shadow: 0 12px 28px rgba(31, 58, 54, 0.20);
}

.wheel-node.active {
  transform: scale(1.18);
  background-color: #FFFBEF;
  border-width: 4.5px;
  border-color: var(--node-color, var(--reg-primary));
  box-shadow:
    0 0 0 8px rgba(255, 251, 239, 0.92),
    0 16px 36px rgba(31, 58, 54, 0.26);
  z-index: 6;
}

.node-mini-svg {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  overflow: hidden;
  display: block;
  border: 1.5px solid rgba(31, 58, 54, 0.12);
  background-color: var(--card-bg);
}

.node-mini-svg svg {
  width: 100%;
  height: 100%;
  display: block;
}

.node-label {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.05;
  text-align: center;
  max-width: 106px;
}

.wheel-node.active .node-label {
  color: var(--node-color, var(--reg-primary));
}

/* ==========================================================================
   SLEEK, COMPACT, REACTIVE VARIABLE SWITCHER DOCK
   ("Tambien modifica la UI/UX de choose a climate variable, es incomodo a la
    vista, mejoralo bastante!")
   Used on BOTH the Region Selector Page and the Region Data Page!
   ========================================================================== */
.selector-bottom-variables {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding-top: 0.1rem;
}

.unified-var-switcher {
  position: relative;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  padding: 5px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: stretch;
  box-shadow:
    0 6px 20px rgba(31, 58, 54, 0.06),
    inset 0 1px 2px rgba(31, 58, 54, 0.03);
}

/* Solid Regional Sliding Glider Pill Inside the Variable Dock */
.var-switcher-glider {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 5px;
  width: calc((100% - 10px) / 3);
  border-radius: 12px;
  background-color: var(--reg-primary);
  box-shadow: 0 5px 15px rgba(31, 58, 54, 0.18);
  transform: translateX(calc(var(--var-idx, 0) * 100%));
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.38s ease,
    box-shadow 0.38s ease;
  pointer-events: none;
  z-index: 0;
}

.unified-var-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  border-radius: 12px;
  padding: 0.56rem 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  text-align: left;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Subtle divider lines between inactive segments */
.unified-var-btn:not(:last-child)::after {
  content: "";
  position: absolute;
  right: 0;
  top: 24%;
  bottom: 24%;
  width: 1px;
  background-color: var(--border-color);
  opacity: 0.7;
  transition: opacity 0.25s ease;
}

.unified-var-btn.active::after,
.unified-var-btn:hover::after {
  opacity: 0;
}

.unified-var-btn:hover {
  transform: translateY(-1px);
}

.unified-var-btn:active {
  transform: scale(0.98);
}

.uvar-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background-color: var(--app-bg);
  border: 1.5px solid var(--border-color);
  padding: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.3s ease,
    background-color 0.3s ease;
}

.unified-var-btn:hover .uvar-icon {
  transform: scale(1.05);
  border-color: var(--reg-primary);
}

.unified-var-btn.active .uvar-icon {
  background-color: #FFFBEF;
  border-color: rgba(255, 251, 239, 0.9);
  transform: scale(1.06);
}

.uvar-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.uvar-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.uvar-name {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.unified-var-btn.active .uvar-name {
  color: #FFFBEF;
}

.uvar-status {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  transition: color 0.25s ease;
}

.unified-var-btn.active .uvar-status {
  color: rgba(255, 251, 239, 0.92) !important;
}

.uvar-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  flex-shrink: 0;
}

.open-region-page-btn {
  appearance: none;
  margin-top: 0.1rem;
  border: none;
  background-color: var(--reg-primary);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 800;
  padding: 0.72rem 1.85rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  box-shadow: 0 8px 22px rgba(31, 58, 54, 0.16);
  transition: background-color 0.4s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.open-region-page-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 11px 26px rgba(31, 58, 54, 0.22);
}

.open-region-page-btn svg {
  transition: transform 0.2s ease;
}

.open-region-page-btn:hover svg {
  transform: translateX(3px);
}

/* ==========================================================================
   INDEPENDENT PAGE 2: REGION INFO, UNIFIED VARIABLE SWITCHER, GRAPH & STORIES
   ========================================================================== */
.data-page-wrap {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.4rem 1.5rem 5rem;
}

.single-variable-studio {
  display: flex;
  flex-direction: column;
  gap: 1.55rem;
}

/* Top Region Identity & Variable Switcher Card */
.region-data-top-banner {
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  box-shadow: 0 8px 26px rgba(31, 58, 54, 0.04);
}

.region-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.region-identity-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.region-mini-emblem {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid var(--reg-primary);
  overflow: hidden;
  flex-shrink: 0;
  background-color: var(--reg-soft);
  transition: border-color 0.4s ease;
}

.region-mini-emblem svg {
  width: 100%;
  height: 100%;
  display: block;
}

.region-identity-titles {
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
}

.region-identity-kicker {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--reg-primary);
}

.region-identity-h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.42rem, 2.3vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
  line-height: 1.12;
}

.region-identity-sub {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.region-overview-callout {
  margin: 0;
  padding: 0.72rem 1.15rem;
  border-radius: 14px;
  background-color: var(--reg-soft);
  border-left: 4px solid var(--reg-primary);
  color: var(--text-main);
  font-size: 0.92rem;
  line-height: 1.55;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.change-region-Action-btn {
  appearance: none;
  border: 2px solid var(--reg-primary);
  background-color: var(--reg-soft);
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 800;
  padding: 0.54rem 1.15rem;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.change-region-Action-btn:hover {
  background-color: var(--reg-primary);
  color: #ffffff;
  transform: translateY(-1px);
}

.status-wetting {
  color: var(--more-rain);
}

.status-drying,
.status-warming {
  color: var(--less-rain);
}

.status-borderline {
  color: #9a5b13;
}

.status-neutral {
  color: var(--text-muted);
}

/* ==========================================================================
   Full-Width Graph Card & Single-Rectangle Reactive Chart Mode Switcher
   ("Lo mismo para el selector de yearly trend, monthly, above/below")
   ========================================================================== */
.fullwidth-graph-card {
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(31, 58, 54, 0.05);
}

.studio-header {
  padding: 1.2rem 1.85rem;
  border-bottom: 1.5px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.studio-title-group {
  display: flex;
  align-items: center;
  gap: 0.95rem;
}

.studio-badge-svg {
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background-color: var(--reg-soft);
  border: 2px solid var(--reg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.35s ease, background-color 0.35s ease;
}

.studio-badge-svg svg {
  width: 34px;
  height: 34px;
}

.studio-question {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.1vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.studio-subtitle {
  margin: 0.16rem 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Single Unified Rectangle for Chart Modes with Sliding Glider */
.mode-pill-group {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  background-color: var(--app-bg);
  padding: 4px;
  border-radius: 14px;
  border: 1.5px solid var(--border-color);
  min-width: 520px;
}

.mode-glider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: 10px;
  background-color: var(--reg-primary);
  box-shadow: 0 4px 12px rgba(31, 58, 54, 0.15);
  transform: translateX(calc(var(--mode-idx, 0) * 100%));
  transition:
    transform 0.38s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.35s ease;
  pointer-events: none;
  z-index: 0;
}

.mode-pill-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.48rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  white-space: nowrap;
  transition: color 0.22s ease, transform 0.18s ease;
}

.mode-pill-btn:hover {
  color: var(--text-main);
}

.mode-pill-btn:active {
  transform: scale(0.97);
}

.mode-pill-btn.active {
  color: #ffffff;
}

.mode-pill-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.soft-regional-stage {
  background-color: var(--reg-soft);
  padding: 1.35rem 1.75rem 1.55rem;
  transition: background-color 0.4s ease;
}

.fullwidth-graph-frame {
  background-color: var(--card-bg);
  border: 2px solid var(--reg-soft-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.35rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.graph-top-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.graph-legend-items {
  display: flex;
  align-items: center;
  gap: 1.3rem;
  flex-wrap: wrap;
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text-main);
}

.g-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.g-swatch-line {
  width: 20px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.g-swatch-band {
  width: 16px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.live-hud-metrics {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.hud-pill {
  padding: 0.34rem 0.85rem;
  border-radius: 999px;
  background-color: var(--app-bg);
  border: 1px solid var(--border-color);
  font-family: var(--font-display);
  font-size: 0.81rem;
  font-weight: 800;
  color: var(--text-main);
}

.hud-pill.primary {
  background-color: var(--reg-primary);
  border-color: var(--reg-primary);
  color: #ffffff;
}

.graph-canvas-wrap {
  width: 100%;
  height: 450px;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid var(--border-color);
  cursor: ew-resize;
  user-select: none;
  position: relative;
}

.graph-canvas-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   Full-Width Year Evolution Scrubber Bar + Reactive Speed Selector
   ("Que se pueda ajustar la velocidad del play years")
   ========================================================================== */
.graph-year-evolution-bar {
  padding: 0.75rem 1.15rem;
  background-color: var(--reg-soft);
  border: 1.5px solid var(--reg-soft-border);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.play-evolution-btn {
  appearance: none;
  border: none;
  background-color: var(--reg-primary);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 800;
  padding: 0.56rem 1.2rem;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.play-evolution-btn:hover {
  transform: translateY(-1px);
  opacity: 0.94;
}

.play-evolution-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.evolution-slider-col {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.evolution-range-input {
  width: 100%;
  accent-color: var(--reg-primary);
  height: 7px;
  cursor: pointer;
}

.evolution-year-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Single-Rectangle Speed Control (0.5x | 1x | 2x | 4x) */
.evolution-speed-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.speed-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.speed-pill-group {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 3px;
  min-width: 172px;
}

.speed-glider {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / 4);
  border-radius: 7px;
  background-color: var(--reg-primary);
  transform: translateX(calc(var(--speed-idx, 1) * 100%));
  transition:
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.35s ease;
  pointer-events: none;
  z-index: 0;
}

.speed-pill-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 0.28rem 0.4rem;
  border-radius: 7px;
  cursor: pointer;
  text-align: center;
  transition: color 0.2s ease;
}

.speed-pill-btn:hover {
  color: var(--text-main);
}

.speed-pill-btn.active {
  color: #ffffff;
}

.evolution-active-badge {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  padding: 0.42rem 0.85rem;
  border-radius: 10px;
  min-width: 152px;
  text-align: center;
  flex-shrink: 0;
}

/* ==========================================================================
   3 Wide Full-Width Story Sections (Honest Scales, Zero Jargon, Super Clear)
   ========================================================================== */
.wide-stories-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.wide-story-section {
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.9rem 2.2rem;
  display: grid;
  grid-template-columns: 1fr 1.08fr;
  gap: 2.1rem;
  align-items: center;
}

.wide-story-copy {
  display: flex;
  flex-direction: column;
  gap: 0.82rem;
}

.wide-story-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.story-step-pill {
  padding: 0.28rem 0.8rem;
  border-radius: 999px;
  background-color: var(--reg-primary);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.story-tag-pill {
  padding: 0.28rem 0.8rem;
  border-radius: 999px;
  background-color: var(--reg-soft);
  border: 1px solid var(--reg-soft-border);
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 0.77rem;
  font-weight: 800;
}

.wide-story-headline {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.38rem, 2.1vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
  line-height: 1.22;
}

.wide-story-body {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text-muted);
  line-height: 1.62;
}

.story-key-takeaway-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.15rem;
}

.takeaway-chip {
  background-color: var(--app-bg);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  padding: 0.48rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.takeaway-chip-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.takeaway-chip-val {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
}

.inline-toggle-2005 {
  align-self: flex-start;
  appearance: none;
  border: 2px solid var(--reg-primary);
  background-color: var(--reg-soft);
  color: var(--reg-primary);
  font-family: var(--font-display);
  font-size: 0.83rem;
  font-weight: 800;
  padding: 0.48rem 1.1rem;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.18s ease;
}

.inline-toggle-2005:hover,
.inline-toggle-2005.active {
  background-color: var(--reg-primary);
  color: #ffffff;
}

.wide-story-art {
  width: 100%;
  height: 256px;
  background-color: var(--app-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.wide-story-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   EDITORIAL DATA SOURCE & SCIENTIFIC REFERENCE CARD
   (Respects the calm, refined scientific-atlas aesthetic of Atlalli)
   ========================================================================== */
.atlas-source-card {
  background-color: var(--card-bg);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2.2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 8px 26px rgba(31, 58, 54, 0.04);
}

.source-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-bottom: 1.05rem;
  border-bottom: 1px solid var(--border-color);
}

.source-heading-group {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.source-eyebrow {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--reg-primary);
}

.source-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.18rem, 1.8vw, 1.4rem);
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.source-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.source-action-btn {
  appearance: none;
  border: 1.5px solid var(--border-color);
  background-color: var(--app-bg);
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.46rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.source-action-btn:hover {
  border-color: var(--reg-primary);
  color: var(--reg-primary);
}

.source-action-btn.primary {
  background-color: var(--reg-soft);
  border-color: var(--reg-primary);
  color: var(--text-main);
}

.source-action-btn.primary:hover {
  background-color: var(--reg-primary);
  color: #ffffff;
}

.source-specs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.9rem;
}

.source-spec-item {
  background-color: var(--app-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.source-spec-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.source-spec-val {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.25;
}

.source-spec-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.source-citation-bar {
  background-color: var(--app-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.78rem 1.1rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.source-citation-bar strong {
  color: var(--text-main);
  font-weight: 700;
}

.source-doi-mono {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--reg-primary);
  text-decoration: none;
  white-space: nowrap;
}

.source-doi-mono:hover {
  text-decoration: underline;
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .header-inner {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .brand-back {
    justify-self: center;
  }
  .header-right-spacer {
    display: none;
  }
  .wide-story-section {
    grid-template-columns: 1fr;
    padding: 1.5rem;
  }
  .source-specs-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .mode-pill-group {
    min-width: 100%;
  }
}

@media (max-width: 780px) {
  .header-page-tabs {
    grid-template-columns: 1fr;
    width: 100%;
  }
  .page-tabs-glider {
    display: none;
  }
  .page-tab-btn.active {
    background-color: var(--reg-soft);
    border: 1.5px solid var(--reg-primary);
  }
  .unified-var-switcher {
    grid-template-columns: 1fr;
  }
  .var-switcher-glider {
    display: none;
  }
  .unified-var-btn.active {
    background-color: var(--reg-primary);
  }
  .unified-var-btn:not(:last-child)::after {
    display: none;
  }
  .mode-pill-group {
    grid-template-columns: 1fr;
  }
  .mode-glider {
    display: none;
  }
  .mode-pill-btn.active {
    background-color: var(--reg-primary);
  }
  .selector-constellation-stage {
    height: 230px;
  }
  .constellation-preview-pill {
    display: none;
  }
  .wheel-node {
    width: 74px;
    height: 74px;
    margin-left: -37px;
    margin-top: -37px;
  }
  .node-mini-svg {
    width: 34px;
    height: 34px;
  }
  .source-specs-grid {
    grid-template-columns: 1fr;
  }
  .graph-canvas-wrap {
    height: 340px;
  }
}
