/* ==========================================================================
   Observatorio Manuel Foster — Simulaciones astronómicas
   Shared design system + simulation chrome.

   Design tokens mirror the main observatoriofoster.com stylesheet so the
   simulations sit seamlessly inside the site. Originals (NAAP / ClassAction)
   are © University of Nebraska–Lincoln Astronomy Education group and are used
   here under their non-profit educational reuse permission; these are clean
   native HTML5 re-implementations, not the original Flash assets.
   ========================================================================== */

:root {
  /* --- Foster palette --- */
  --bg-0: #06081c;
  --bg-1: #0b0f2b;
  --bg-2: #121636;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text-0: #f5f4f1;
  --text-1: #c8c7d1;
  --text-2: #8b8c9c;
  --text-3: #5a5d72;
  --gold: #d4a64b;
  --gold-bright: #f4c842;
  --gold-soft: rgba(212, 166, 75, 0.14);
  --blue: #5e8eff;
  --blue-soft: rgba(94, 142, 255, 0.15);
  --plum: #6c5dd3;

  /* --- simulation-specific accents --- */
  --sun: #ffd24a;
  --sun-glow: rgba(255, 210, 74, 0.55);
  --moon-lit: #e9e6dc;
  --moon-dark: #20233f;
  --earth: #3f7bd6;
  --earth-land: #5fa86b;
  --night: #060818;
  --ray: rgba(255, 210, 74, 0.65);

  --f-display: 'Literata', 'Times New Roman', serif;
  --f-body: 'Inter', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', 'Menlo', monospace;

  --max: 1240px;
  --gutter: clamp(20px, 4vw, 48px);
  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 180ms;
  --t-med: 320ms;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--f-body);
  background: var(--bg-0);
  color: var(--text-1);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Deep-space gradient wash behind everything */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1200px 800px at 75% -5%, rgba(108, 93, 211, 0.18), transparent 60%),
    radial-gradient(1000px 700px at 8% 110%, rgba(94, 142, 255, 0.12), transparent 55%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 50%, var(--bg-0) 100%);
}

a { color: var(--gold); text-decoration: none; }

/* ---------- STARFIELD ---------- */
.starfield {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.85;
}

/* ---------- LAYOUT ---------- */
.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding-inline: var(--gutter);
}

/* ==========================================================================
   SITE HEADER — shared with observatoriofoster.com (sticky on the sims)
   ========================================================================== */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 18px 0;
  background: rgba(6, 8, 28, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: background var(--t-med) var(--ease),
              padding var(--t-med) var(--ease),
              border-color var(--t-med) var(--ease);
}
.nav.scrolled {
  background: rgba(6, 8, 28, 0.85);
  padding: 12px 0;
  border-bottom-color: var(--border);
}
.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-0);
  flex-shrink: 0;
}
.nav-brand:hover { color: var(--gold-bright); }
.nav-logo {
  width: 55px;
  height: 55px;
  object-fit: contain;
  flex-shrink: 0;
}
.nav-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-line-1 {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-2);
}
.brand-line-2 {
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.nav-links {
  display: flex;
  gap: 32px;
  list-style: none;
}
.nav-links a {
  font-size: 14px;
  color: var(--text-1);
  font-weight: 400;
  position: relative;
  padding: 4px 0;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--t-med) var(--ease);
}
.nav-links a:hover { color: var(--text-0); }
.nav-links a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ---------- LANGUAGE TOGGLE ---------- */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}
.lang-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-2);
  padding: 5px 9px;
  border-radius: 100px;
  transition: color var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
  background: transparent;
  font-weight: 500;
}
.lang-btn:hover { color: var(--text-0); }
.lang-btn.active {
  color: var(--gold);
  background: var(--gold-soft);
  font-weight: 600;
}

/* ---------- HAMBURGER + MOBILE MENU ---------- */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.nav-toggle span {
  width: 22px;
  height: 1.5px;
  background: var(--text-0);
  transition: all var(--t-fast) var(--ease);
}
.nav-toggle.open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(6, 8, 28, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med) var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-menu.open {
  opacity: 1;
  pointer-events: auto;
}
.mobile-menu-inner ul {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
  list-style: none;
}
.mobile-menu-inner a {
  font-family: var(--f-display);
  font-size: 28px;
  color: var(--text-0);
}
.mobile-menu-inner .btn {
  font-family: var(--f-body);
  font-size: 16px;
}

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 22px;
  border-radius: 100px;
  font-family: var(--f-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all var(--t-med) var(--ease);
  border: 1px solid transparent;
  white-space: nowrap;
  color: var(--text-0);
  background: transparent;
}
.btn-primary { background: var(--gold); color: #0a0a16; font-weight: 600; }
.btn-primary:hover { background: var(--gold-bright); transform: translateY(-2px); box-shadow: 0 12px 30px -8px rgba(244, 200, 66, 0.45); }
.btn-ghost { border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--gold-bright); border-color: var(--gold); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ---------- SECTION HEADER (gallery) ---------- */
.section-header { text-align: center; max-width: 760px; margin: 0 auto clamp(40px, 6vw, 72px); }
.section-tag {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 22px;
  padding: 6px 14px;
  border: 1px solid var(--gold-soft);
  border-radius: 100px;
  background: var(--gold-soft);
}
.section-title {
  font-family: var(--f-display);
  font-size: clamp(2.1rem, 5vw, 3.6rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
  color: var(--text-0);
}
.section-lead { font-size: clamp(1rem, 1.6vw, 1.12rem); line-height: 1.65; color: var(--text-1); max-width: 640px; margin: 0 auto; }

/* ---------- GALLERY GRID ---------- */
.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
  padding-bottom: clamp(60px, 9vw, 120px);
}
.sim-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--t-med) var(--ease);
  position: relative;
  color: inherit;
}
.sim-card:hover {
  transform: translateY(-6px);
  border-color: var(--border-strong);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.55);
}
.sim-card-thumb {
  aspect-ratio: 16 / 10;
  width: 100%;
  display: block;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
.sim-card-body { padding: 22px 24px 26px; display: flex; flex-direction: column; flex: 1; }
.sim-card-tag {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.sim-card-title {
  font-family: var(--f-display);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-0);
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.sim-card-desc { color: var(--text-2); font-size: 0.9rem; line-height: 1.55; margin-bottom: 18px; }
.sim-card-cta {
  margin-top: auto;
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: gap var(--t-fast) var(--ease);
}
.sim-card:hover .sim-card-cta { gap: 12px; }

/* ==========================================================================
   SIMULATION PAGE LAYOUT
   ========================================================================== */
.sim-page { padding: clamp(24px, 4vw, 44px) 0 clamp(48px, 7vw, 90px); }

.sim-intro { max-width: 760px; margin: 0 auto clamp(28px, 4vw, 44px); text-align: center; }
.sim-intro .section-tag { margin-bottom: 18px; }
.sim-intro h1 {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--text-0);
  margin-bottom: 14px;
}
.sim-intro p { color: var(--text-1); font-size: clamp(0.98rem, 1.5vw, 1.08rem); }

/* Stage + controls layout */
.sim-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 900px) {
  .sim-shell { grid-template-columns: 1fr; }
}

.sim-stage {
  position: relative;
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-2), var(--bg-0) 75%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 320px;
}
.sim-stage canvas { display: block; width: 100%; height: auto; touch-action: none; }

.sim-stage-label {
  position: absolute;
  top: 14px; left: 16px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  pointer-events: none;
}

/* Controls panel */
.sim-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.panel-group { display: flex; flex-direction: column; gap: 12px; }
.panel-group > h3 {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-2);
  font-weight: 500;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Playback row */
.playback { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.icon-btn {
  width: 44px; height: 44px;
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-0);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold-bright); background: var(--surface-3); }
.icon-btn.primary { background: var(--gold); border-color: var(--gold); color: #0a0a16; }
.icon-btn.primary:hover { background: var(--gold-bright); }
.icon-btn svg { width: 18px; height: 18px; }

/* Sliders */
.control { display: flex; flex-direction: column; gap: 8px; }
.control-label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  font-size: 0.86rem;
  color: var(--text-1);
}
.control-label .val {
  font-family: var(--f-mono);
  font-size: 0.82rem;
  color: var(--gold-bright);
  letter-spacing: 0.02em;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--gold) 0%, var(--gold) var(--fill, 50%), var(--surface-3) var(--fill, 50%), var(--surface-3) 100%);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid var(--bg-0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 2px solid var(--bg-0);
  cursor: pointer;
}

/* Segmented control / chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none;
  font-family: var(--f-body);
  font-size: 0.82rem;
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-1);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--gold); color: var(--text-0); }
.chip.active { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-bright); }

/* Toggle (checkbox) row */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 0.88rem; color: var(--text-1); }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  transition: all var(--t-fast) var(--ease);
}
.switch .track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 50%; transform: translateY(-50%);
  border-radius: 50%;
  background: var(--text-1);
  transition: all var(--t-fast) var(--ease);
}
.switch input:checked + .track { background: var(--gold-soft); border-color: var(--gold); }
.switch input:checked + .track::before { left: 21px; background: var(--gold-bright); }

/* Data readouts */
.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.readout { background: var(--bg-1); padding: 14px 16px; }
.readout .k { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin-bottom: 5px; }
.readout .v { font-family: var(--f-mono); font-size: 1.05rem; color: var(--text-0); letter-spacing: 0.01em; }
.readout .v small { color: var(--text-2); font-size: 0.7em; }

/* Helper note */
.sim-note {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--gold);
  border-radius: var(--radius);
  padding: 14px 16px;
}

/* Explanatory longform under the sim */
.sim-explain {
  max-width: 760px;
  margin: clamp(40px, 6vw, 72px) auto 0;
}
.sim-explain h2 {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--text-0);
  margin-bottom: 16px;
}
.sim-explain p { color: var(--text-1); margin-bottom: 16px; }
.sim-explain .credit { font-size: 0.82rem; color: var(--text-3); border-top: 1px solid var(--border); padding-top: 20px; margin-top: 28px; }
.sim-explain .credit a { color: var(--text-2); }

/* ==========================================================================
   SITE FOOTER — shared with observatoriofoster.com
   ========================================================================== */
.footer {
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  padding: 80px 0 32px;
  position: relative;
  z-index: 2;
  margin-top: clamp(50px, 8vw, 100px);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: 48px;
  margin-bottom: 60px;
}
.footer-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.footer-logo img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.footer-logo div { display: flex; flex-direction: column; line-height: 1.3; }
.footer-logo strong {
  font-family: var(--f-display);
  font-size: 18px;
  color: var(--text-0);
  font-weight: 500;
}
.footer-logo span {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-2);
  text-transform: uppercase;
}
.footer-brand p {
  font-size: 0.92rem;
  color: var(--text-1);
  line-height: 1.6;
  max-width: 360px;
}
.footer-col h5 {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 20px;
  font-weight: 500;
}
.footer-col ul { display: flex; flex-direction: column; gap: 12px; list-style: none; }
.footer-col a, .footer-col li {
  font-size: 0.9rem;
  color: var(--text-1);
}
.footer-col a:hover { color: var(--gold-bright); }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-2);
  flex-wrap: wrap;
  gap: 12px;
}
.footer-bottom p { margin: 0; }
.footer-credit { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; }

/* ---------- i18n visibility ---------- */
[data-lang-en] { display: none; }
html[lang="en"] [data-lang-es] { display: none; }
html[lang="en"] [data-lang-en] { display: revert; }

/* ---------- RESPONSIVE NAV / FOOTER (matches the main site) ---------- */
@media (max-width: 920px) {
  .nav-links { display: none; }
  .nav-toggle { display: inline-flex; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .footer-grid { grid-template-columns: 1fr; gap: 32px; }
  .footer-bottom { flex-direction: column; text-align: center; }
  /* Mobile nav bar = logo + brand + language toggle + hamburger (Reservar is
     in the hamburger menu), tightened so it fits on narrow phones. */
  .nav-actions .btn { display: none; }
  .nav-inner { gap: 14px; padding-inline: 16px; }
  .nav-logo { width: 46px; height: 46px; }
  .brand-line-1 { font-size: 9px; }
  .brand-line-2 { font-size: 16px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; }
}
