/* ==========================================================================
   Eclipse 2026 — Sistema de diseño
   Una interfaz moderna e inmersiva para el simulador del eclipse total de Sol
   ========================================================================== */

/* ---------- Tokens de diseño ---------- */
:root {
  --bg-deep: #030309;
  --bg: #06060f;
  --panel-bg: rgba(14, 16, 32, 0.72);
  --panel-bg-solid: #0d0f1e;
  --panel-border: rgba(140, 160, 255, 0.14);
  --panel-border-hover: rgba(240, 170, 70, 0.5);

  --accent: #f5a623;
  --accent-bright: #ffce6b;
  --accent-hot: #ff6a3d;
  --corona: #7db4ff;
  --corona-soft: #a9c8ff;
  --danger: #ff5470;
  --success: #4ade80;

  --text: #eef0ff;
  --text-dim: #8b8db0;
  --text-faint: #5a5c78;

  --grad-solar: linear-gradient(135deg, #ffce6b 0%, #f5a623 45%, #ff6a3d 100%);
  --grad-corona: linear-gradient(135deg, #a9c8ff 0%, #7db4ff 100%);
  --grad-title: linear-gradient(90deg, #ffce6b, #f5a623 40%, #ff8a5b 70%, #a9c8ff);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --shadow-panel: 0 18px 50px -12px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--panel-border);
  --shadow-glow: 0 0 24px -4px rgba(245, 166, 35, 0.55);

  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

button, select, .fab, .phase-marker {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, select { user-select: none; -webkit-user-select: none; }

::selection { background: rgba(245, 166, 35, 0.35); color: #fff; }

/* ---------- Barras de desplazamiento personalizadas ---------- */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(140, 160, 255, 0.22);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(245, 166, 35, 0.5); }

/* ---------- Estructura de la aplicación ---------- */
#app { width: 100%; height: 100%; position: relative; }

#render-canvas { width: 100%; height: 100%; display: block; }

#ui-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
#ui-overlay > * { pointer-events: auto; }

/* ==========================================================================
   Barra superior
   ========================================================================== */
#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) calc(22px + env(safe-area-inset-right, 0px)) 14px calc(22px + env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(3, 3, 9, 0.85) 0%, rgba(3, 3, 9, 0.35) 60%, transparent 100%);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 8px rgba(245, 166, 35, 0.6));
}
.brand-mark .corona {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 206, 107, 0.0) 40%, rgba(255, 206, 107, 0.55) 58%, rgba(255, 138, 91, 0.15) 72%, transparent 78%);
  animation: pulse-corona 4s var(--ease) infinite;
}
.brand-mark .sun {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--grad-solar);
  box-shadow: 0 0 14px rgba(245, 166, 35, 0.8);
}
.brand-mark .moon {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #05050c;
  transform: translateX(-38%);
  animation: transit 9s var(--ease) infinite;
}
@keyframes pulse-corona {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}
@keyframes transit {
  0% { transform: translateX(-70%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(70%); }
}

.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand-text h1 .title-grad {
  background: var(--grad-title);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text .subtitle {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 2px;
}
.brand-text .subtitle .date { color: var(--accent-bright); font-weight: 600; }

/* ---------- Selector de ubicación ---------- */
#location-selector { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

#location-selector button,
#location-selector input,
#location-selector select {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: var(--font-body);
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
#location-selector input { width: 132px; cursor: text; }
#location-selector input::placeholder { color: var(--text-faint); }
#location-selector select { max-width: 128px; }
#location-selector button:hover,
#location-selector select:hover {
  border-color: var(--panel-border-hover);
  background: rgba(245, 166, 35, 0.14);
  box-shadow: var(--shadow-glow);
}
#location-selector button:active { transform: translateY(1px) scale(0.98); }
#location-selector select option { background: var(--panel-bg-solid); color: var(--text); }

#btn-gps { color: var(--corona-soft); }

/* ==========================================================================
   Panel de información
   ========================================================================== */
#info-panel {
  position: absolute;
  top: 78px;
  right: 16px;
  width: 288px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-panel);
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.panel-head .panel-title {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-head .panel-title::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: blink 2.4s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

#btn-collapse-panel {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  width: 26px; height: 26px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: all 0.2s var(--ease);
}
#btn-collapse-panel:hover { color: var(--accent-bright); border-color: var(--panel-border-hover); }

/* ---------- Distintivo de fase ---------- */
.phase-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  transition: all 0.5s var(--ease);
}
.phase-badge .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.phase-badge.phase-none { color: var(--text-dim); }
.phase-badge.phase-partial { color: var(--accent-bright); border-color: rgba(245, 166, 35, 0.4); background: rgba(245, 166, 35, 0.1); }
.phase-badge.phase-total {
  color: #fff;
  border-color: rgba(255, 106, 61, 0.7);
  background: linear-gradient(135deg, rgba(255, 106, 61, 0.28), rgba(245, 166, 35, 0.18));
  box-shadow: 0 0 26px -6px rgba(255, 106, 61, 0.8);
  animation: total-glow 2s ease-in-out infinite;
}
.phase-badge.phase-annular { color: var(--corona-soft); border-color: rgba(125, 180, 255, 0.5); background: rgba(125, 180, 255, 0.12); }
@keyframes total-glow {
  0%, 100% { box-shadow: 0 0 26px -6px rgba(255, 106, 61, 0.8); }
  50% { box-shadow: 0 0 34px -2px rgba(255, 206, 107, 0.95); }
}

/* ---------- Indicador de oscurecimiento ---------- */
.gauge-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 6px;
}
.gauge {
  position: relative;
  width: 92px;
  height: 92px;
  flex: 0 0 auto;
}
.gauge svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.gauge .track { fill: none; stroke: rgba(255, 255, 255, 0.07); stroke-width: 8; }
.gauge .fill {
  fill: none;
  stroke: url(#gaugeGrad);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.35s var(--ease);
  filter: drop-shadow(0 0 5px rgba(245, 166, 35, 0.6));
}
.gauge .gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.gauge .gauge-value { font-family: var(--font-display); font-size: 1.28rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.gauge .gauge-unit { font-size: 0.6rem; color: var(--text-dim); letter-spacing: 0.1em; text-transform: uppercase; }

.gauge-meta { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.gauge-meta .meta-row { display: flex; flex-direction: column; gap: 1px; }
.gauge-meta .meta-label { font-size: 0.64rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; }
.gauge-meta .meta-value { font-family: var(--font-display); font-size: 1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.gauge-meta .meta-value.accent { color: var(--accent-bright); }

/* ---------- Cuenta atrás ---------- */
.countdown {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(125, 180, 255, 0.08);
  border: 1px solid rgba(125, 180, 255, 0.18);
  margin-bottom: 14px;
}
.countdown .cd-label { font-size: 0.66rem; color: var(--corona-soft); text-transform: uppercase; letter-spacing: 0.12em; line-height: 1.3; }
.countdown .cd-label strong { display: block; color: var(--text); font-size: 0.74rem; letter-spacing: 0.02em; }
.countdown .cd-time {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 0 12px rgba(125, 180, 255, 0.6);
}
.countdown.cd-hot { background: rgba(255, 106, 61, 0.12); border-color: rgba(255, 106, 61, 0.4); }
.countdown.cd-hot .cd-label { color: var(--accent-bright); }
.countdown.cd-hot .cd-time { text-shadow: 0 0 14px rgba(255, 106, 61, 0.8); }

/* ---------- Secciones de información ---------- */
.info-section { margin-top: 14px; }
.info-section > h3 {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}
.info-section > h3 .ico { font-size: 0.9rem; opacity: 0.9; }
.info-section > h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(245, 166, 35, 0.3), transparent); }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; font-size: 0.8rem; }
.info-grid .label { color: var(--text-dim); }
.info-grid .value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

#info-panel.collapsed .info-section,
#info-panel.collapsed .gauge-wrap,
#info-panel.collapsed .phase-badge,
#info-panel.collapsed .countdown { display: none; }

/* ==========================================================================
   Línea de tiempo
   ========================================================================== */
#timeline-container {
  padding: 12px calc(24px + env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) calc(24px + env(safe-area-inset-left, 0px));
  background: linear-gradient(0deg, rgba(3, 3, 9, 0.9) 0%, rgba(3, 3, 9, 0.4) 65%, transparent 100%);
}

#phase-markers { position: relative; height: 22px; margin-bottom: 4px; }
.phase-marker {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--accent-bright);
  cursor: pointer;
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.2);
  transition: all 0.2s var(--ease);
  font-variant-numeric: tabular-nums;
}
.phase-marker:hover { color: #fff; background: rgba(245, 166, 35, 0.3); transform: translateX(-50%) translateY(-2px); }
.phase-marker.marker-max { color: #fff; background: rgba(255, 106, 61, 0.3); border-color: rgba(255, 106, 61, 0.5); }

/* Control deslizante */
#timeline {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg,
    rgba(125, 180, 255, 0.25) 0%,
    rgba(245, 166, 35, 0.45) 35%,
    rgba(255, 106, 61, 0.85) 50%,
    rgba(245, 166, 35, 0.45) 65%,
    rgba(125, 180, 255, 0.25) 100%);
  outline: none;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
#timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent) 60%, var(--accent-hot));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 14px rgba(245, 166, 35, 0.9), 0 2px 6px rgba(0, 0, 0, 0.6);
  cursor: grab;
  transition: transform 0.15s var(--ease);
}
#timeline::-webkit-slider-thumb:hover { transform: scale(1.18); }
#timeline::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.05); }
#timeline::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--accent) 60%, var(--accent-hot));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 14px rgba(245, 166, 35, 0.9);
  cursor: grab;
}

#time-display {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  margin: 8px 0 6px;
  font-variant-numeric: tabular-nums;
}
#local-time { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.02em; }
#utc-time { color: var(--text-dim); font-size: 0.8rem; }

#playback-controls { display: flex; align-items: center; gap: 8px; }
#playback-controls button,
#playback-controls select {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: var(--font-body);
  backdrop-filter: blur(12px);
  transition: all 0.2s var(--ease);
}
#playback-controls button:hover,
#playback-controls select:hover { border-color: var(--panel-border-hover); background: rgba(245, 166, 35, 0.14); box-shadow: var(--shadow-glow); }
#playback-controls button:active { transform: scale(0.95); }
#playback-controls select option { background: var(--panel-bg-solid); }

#btn-play {
  min-width: 46px;
  background: var(--grad-solar);
  color: #1a0e00;
  border: none;
  font-weight: 700;
  box-shadow: 0 0 18px -4px rgba(245, 166, 35, 0.8);
}
#btn-play:hover { filter: brightness(1.1); background: var(--grad-solar); }

#phase-jumps { display: flex; gap: 5px; margin-left: auto; }
#phase-jumps button { font-size: 0.7rem; padding: 5px 10px; font-weight: 600; letter-spacing: 0.03em; }

/* ==========================================================================
   Botones flotantes
   ========================================================================== */
.fab-group { position: absolute; left: 18px; bottom: 150px; display: flex; flex-direction: column; gap: 12px; }

.fab {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--accent-bright);
  font-size: 1.15rem;
  cursor: pointer;
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s var(--ease);
  box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.7);
}
.fab:hover { border-color: var(--panel-border-hover); background: rgba(245, 166, 35, 0.16); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.fab:active { transform: translateY(0) scale(0.94); }

/* Información emergente */
.fab::before {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-6px);
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s var(--ease);
}
.fab:hover::before { opacity: 1; transform: translateY(-50%) translateX(0); }

/* ==========================================================================
   Panel educativo
   ========================================================================== */
#education-panel {
  position: absolute;
  inset: 0;
  background: radial-gradient(1200px 600px at 70% -10%, rgba(245, 166, 35, 0.08), transparent 60%),
              rgba(4, 4, 12, 0.97);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  z-index: 100;
  animation: fade-in 0.35s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

#education-content { max-width: 820px; margin: 0 auto; padding: 56px 32px 80px; }

#education-content .edu-hero { margin-bottom: 36px; }
#education-content .edu-kicker {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-bright);
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid rgba(245, 166, 35, 0.35);
  background: rgba(245, 166, 35, 0.08);
  margin-bottom: 16px;
}
#education-content h2 {
  font-family: var(--font-display);
  color: var(--text);
  margin: 40px 0 12px;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  scroll-margin-top: 30px;
}
#education-content .edu-hero h2 { font-size: 2.3rem; margin-top: 0; line-height: 1.1; }
#education-content .edu-hero h2 .grad {
  background: var(--grad-title);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#education-content p { max-width: 720px; line-height: 1.75; margin-bottom: 14px; color: #c9cbe4; font-size: 0.98rem; }
#education-content strong { color: var(--accent-bright); font-weight: 600; }
#education-content em { color: var(--corona-soft); font-style: normal; font-weight: 500; }

#education-content .edu-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin: 18px 0;
  backdrop-filter: blur(10px);
}
#education-content .edu-card h2 { margin-top: 0; font-size: 1.25rem; }

#education-content .fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 20px 0; }
#education-content .fact {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
}
#education-content .fact .fact-num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; background: var(--grad-solar); -webkit-background-clip: text; background-clip: text; color: transparent; }
#education-content .fact .fact-label { font-size: 0.74rem; color: var(--text-dim); margin-top: 4px; line-height: 1.4; }

#education-content .edu-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 10px;
}
#education-content .edu-toc a {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--panel-border);
  transition: all 0.2s var(--ease);
}
#education-content .edu-toc a:hover { color: var(--accent-bright); border-color: var(--panel-border-hover); background: rgba(245, 166, 35, 0.08); }

#btn-close-education {
  position: fixed;
  top: 20px;
  right: 24px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 1.4rem;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: all 0.2s var(--ease);
  z-index: 101;
}
#btn-close-education:hover { color: var(--accent-hot); border-color: var(--panel-border-hover); transform: rotate(90deg); }

/* ==========================================================================
   Mapa
   ========================================================================== */
#map-container { position: absolute; inset: 0; z-index: 90; animation: fade-in 0.3s var(--ease); }
#map { width: 100%; height: 100%; }
#btn-close-map {
  position: absolute;
  top: 18px;
  right: 22px;
  z-index: 91;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 1.4rem;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: all 0.2s var(--ease);
}
#btn-close-map:hover { color: var(--accent-hot); border-color: var(--panel-border-hover); transform: rotate(90deg); }

.map-legend {
  position: absolute;
  bottom: 22px;
  left: 22px;
  z-index: 91;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  backdrop-filter: blur(12px);
  font-size: 0.78rem;
}
.map-legend .legend-title { font-family: var(--font-display); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.66rem; color: var(--text-dim); margin-bottom: 8px; }
.map-legend .legend-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; color: var(--text); }
.map-legend .swatch { width: 16px; height: 10px; border-radius: 3px; }
.map-legend .swatch.path { background: rgba(245, 166, 35, 0.4); border: 1px solid var(--accent); }
.map-legend .swatch.line { background: repeating-linear-gradient(90deg, #ff5470 0 5px, transparent 5px 8px); }

/* ==========================================================================
   Pantalla de carga
   ========================================================================== */
.hidden { display: none !important; }

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: radial-gradient(900px 500px at 50% 40%, rgba(245, 166, 35, 0.06), transparent 60%), var(--bg-deep);
  z-index: 200;
  transition: opacity 0.6s var(--ease);
}
#loading.fade-out { opacity: 0; pointer-events: none; }

.loader-eclipse { position: relative; width: 120px; height: 120px; }
.loader-eclipse .le-corona {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 206, 107, 0) 42%, rgba(255, 206, 107, 0.7) 56%, rgba(255, 138, 91, 0.25) 70%, transparent 76%);
  animation: pulse-corona 2.6s var(--ease) infinite;
}
.loader-eclipse .le-sun {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: var(--grad-solar);
  box-shadow: 0 0 30px rgba(245, 166, 35, 0.9);
}
.loader-eclipse .le-moon {
  position: absolute;
  inset: 22px;
  border-radius: 50%;
  background: #04040a;
  animation: loader-transit 2.6s var(--ease) infinite;
}
@keyframes loader-transit {
  0% { transform: translateX(-90%); }
  50% { transform: translateX(0); }
  100% { transform: translateX(90%); }
}

.loader-text { text-align: center; }
.loader-text .lt-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; letter-spacing: 0.02em; }
.loader-text .lt-title .grad { background: var(--grad-title); -webkit-background-clip: text; background-clip: text; color: transparent; }
.loader-text .lt-status { font-size: 0.82rem; color: var(--text-dim); margin-top: 8px; letter-spacing: 0.04em; }
.loader-text .lt-status::after { content: '...'; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ==========================================================================
   Aviso emergente
   ========================================================================== */
#toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-bg-solid);
  border: 1px solid var(--panel-border-hover);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 99px;
  font-size: 0.85rem;
  box-shadow: var(--shadow-glow);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s var(--ease);
  z-index: 300;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================================================================
   Adaptable a distintos dispositivos
   ========================================================================== */
@media (max-width: 900px) {
  #info-panel { width: 246px; }
}

@media (max-width: 768px) {
  #top-bar { padding: calc(10px + env(safe-area-inset-top, 0px)) calc(12px + env(safe-area-inset-right, 0px)) 10px calc(12px + env(safe-area-inset-left, 0px)); flex-wrap: wrap; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-text h1 { font-size: 0.95rem; }
  .brand-text .subtitle { font-size: 0.62rem; letter-spacing: 0.1em; }
  #location-selector { width: 100%; justify-content: flex-start; }
  #location-selector input { width: 90px; flex: 1; min-width: 0; }
  #location-selector select { max-width: 100px; }

  #info-panel {
    top: auto;
    bottom: 158px;
    right: calc(8px + env(safe-area-inset-right, 0px));
    width: 210px;
    padding: 12px;
    max-height: 40vh;
    font-size: 0.74rem;
  }
  .gauge { width: 72px; height: 72px; }
  .gauge .gauge-value { font-size: 1.05rem; }
  .countdown .cd-time { font-size: 1.05rem; }

  #timeline-container { padding: 8px calc(12px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(12px + env(safe-area-inset-left, 0px)); }
  #playback-controls { flex-wrap: wrap; }
  #phase-jumps { margin-left: 0; width: 100%; justify-content: flex-start; }

  .fab-group { bottom: 178px; left: calc(8px + env(safe-area-inset-left, 0px)); }
  .fab { width: 40px; height: 40px; }
  .fab::before { display: none; }

  #btn-close-education { top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); }
  #btn-close-map { top: calc(14px + env(safe-area-inset-top, 0px)); right: calc(14px + env(safe-area-inset-right, 0px)); }
  .map-legend { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); left: calc(14px + env(safe-area-inset-left, 0px)); padding: 9px 12px; font-size: 0.7rem; }

  #education-content { padding: 40px 18px 60px; }
  #education-content .edu-hero h2 { font-size: 1.7rem; }
}

@media (max-width: 420px) {
  .brand-text h1 { font-size: 0.85rem; }
  .brand-text .subtitle { font-size: 0.56rem; }
  #location-selector button,
  #location-selector input,
  #location-selector select { padding: 7px 10px; font-size: 0.8rem; }
  #info-panel { width: 184px; padding: 10px; bottom: 168px; }
  .gauge { width: 62px; height: 62px; }
  .gauge .gauge-value { font-size: 0.95rem; }
  .info-grid { font-size: 0.72rem; gap: 4px 6px; }
  #utc-time { display: none; }
  #time-display { justify-content: center; }
  .phase-marker { font-size: 0.58rem; padding: 1px 4px; }
  #education-content .fact-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  #education-content .fact .fact-num { font-size: 1.25rem; }
}

@media (max-height: 480px) and (orientation: landscape) {
  #info-panel { top: 64px; bottom: 132px; max-height: none; }
  .fab-group { bottom: 148px; }
  #education-content { padding: 28px 24px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}
