/* ═══════════════════════════════════════════════════════════════════════════
   Star Map — Global Styles
   Design: Dark cosmic UI with glassmorphism controls
   Fonts: Cormorant Garamond (elegant serif) + Raleway (clean sans)
   ═══════════════════════════════════════════════════════════════════════════ */

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

:root {
  --bg:          #05050f;
  --panel:       rgba(10, 12, 30, 0.72);
  --panel-border:rgba(80, 100, 200, 0.22);
  --accent:      #5d7acd;
  --accent-light:#8aa0e0;
  --text:        #c8d4f0;
  --text-dim:    #7080a8;
  --input-bg:    rgba(255, 255, 255, 0.05);
  --input-border:rgba(120, 150, 220, 0.25);
  --radius:      12px;
  --transition:  0.25s ease;
}

html, body {
  height: 100%;
  font-family: 'Raleway', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── Cosmic background particles ───────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 40%, rgba(30,40,100,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 80% 60%, rgba(60,20,80,0.15) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 380px 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(5, 5, 20, 0.6);
  backdrop-filter: blur(12px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 36px; height: 36px;
  border: 1.5px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  background: radial-gradient(circle at 40% 40%, rgba(40,55,130,0.6), rgba(5,5,20,0.4));
  box-shadow: 0 0 10px rgba(93,122,205,0.25), inset 0 0 8px rgba(93,122,205,0.1);
}
.logo-icon::before {
  content: '✦';
  color: var(--accent);
  font-size: 11px;
  opacity: 0.85;
}

/* Planeta 1 — Júpiter (cálido, arriba-derecha) */
.lp {
  position: absolute;
  border-radius: 50%;
}
.lp1 {
  width: 7px; height: 7px;
  background: radial-gradient(circle at 35% 35%, #ffe8a0, #c8882a);
  box-shadow: 0 0 6px rgba(255,200,80,0.75);
  top: 4px; right: 4px;
}
/* Planeta 2 — Saturno (abajo-izquierda, con anillo) */
.lp2 {
  width: 5px; height: 5px;
  background: radial-gradient(circle at 35% 35%, #ede0b0, #a88840);
  box-shadow: 0 0 4px rgba(200,175,90,0.65);
  bottom: 5px; left: 5px;
}
.lp2::after {
  content: '';
  position: absolute;
  width: 10px; height: 4px;
  border: 1px solid rgba(210,185,90,0.55);
  border-radius: 50%;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-22deg);
}

.logo-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #fff;
}
.logo-name span {
  color: var(--accent-light);
  font-style: italic;
}
.logo-tag {
  font-family: 'Raleway', sans-serif;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 300;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  margin-left: 3px;
  opacity: 0.75;
}

.header-tagline {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ── Controls panel ─────────────────────────────────────────────────────────── */
.controls {
  grid-row: 2;
  overflow-y: auto;
  padding: 24px 20px;
  background: var(--panel);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--panel-border);
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
}
.controls::-webkit-scrollbar { width: 4px; }
.controls::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

.section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 4px; height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

/* ── Form elements ──────────────────────────────────────────────────────────── */
.field {
  margin-bottom: 14px;
}

label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Raleway', sans-serif;
  font-size: 0.875rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: rgba(93, 122, 205, 0.08);
}

input[type="date"],
input[type="time"] {
  color-scheme: dark;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235d7acd' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
select option { background: #0d0f28; }

textarea {
  resize: none;
  height: 60px;
  font-style: italic;
}

/* Date + Time row */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ── Location area ──────────────────────────────────────────────────────────── */
.location-row {
  display: flex;
  gap: 8px;
}
.location-row input { flex: 1; }

.btn-icon {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 14px;
  font-size: 1rem;
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

.location-status {
  font-size: 0.72rem;
  color: var(--accent-light);
  margin-top: 5px;
  min-height: 1em;
  padding-left: 2px;
}

/* Lat/Lon row */
.coords-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.coords-row input { font-size: 0.78rem; color: var(--text-dim); }

/* ── Toggle switches ────────────────────────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}
.toggle-row:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,0.04); }

.toggle-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-label {
  font-size: 0.82rem;
  color: var(--text);
}

.toggle-desc {
  font-size: 0.63rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  line-height: 1.4;
  max-width: 220px;
}

.toggle {
  position: relative;
  width: 40px; height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 22px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: all var(--transition);
}
.toggle input:checked + .toggle-slider {
  background: rgba(93, 122, 205, 0.25);
  border-color: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
  left: calc(100% - 17px);
  background: var(--accent-light);
}

/* ── Style picker ───────────────────────────────────────────────────────────── */
.style-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.style-btn {
  aspect-ratio: 1;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.style-btn:hover { transform: scale(1.06); }
.style-btn.active { border-color: #fff; box-shadow: 0 0 12px rgba(255,255,255,0.3); }
.style-btn span {
  position: absolute; bottom: 3px; left: 0; right: 0;
  font-size: 0.55rem; text-align: center; letter-spacing: 0.05em;
  color: rgba(255,255,255,0.8);
}

.swatch-cosmic    { background: radial-gradient(circle at 40% 40%, #0d1135, #030309); }
.swatch-golden    { background: radial-gradient(circle at 40% 40%, #251200, #080400); }
.swatch-celestial { background: radial-gradient(circle at 40% 40%, #001838, #000810); }
.swatch-ivory     { background: radial-gradient(circle at 40% 40%, #fffdf5, #e8e0cc); }
.swatch-ivory span { color: rgba(0,0,0,0.6) !important; }
.swatch-aurora    { background: radial-gradient(circle at 40% 40%, #001a0c, #000803); }

/* ── Download button ────────────────────────────────────────────────────────── */
.btn-download {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, rgba(93,122,205,0.8), rgba(80,45,140,0.8));
  border: 1px solid rgba(120, 150, 220, 0.5);
  border-radius: 10px;
  color: #fff;
  font-family: 'Raleway', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s;
  margin-top: 8px;
  position: relative;
  overflow: hidden;
}
.btn-download::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), transparent);
}
.btn-download:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(93,122,205,0.4);
  border-color: rgba(140, 170, 240, 0.7);
}
.btn-download:active { transform: translateY(0); }
.btn-download:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-download-sub {
  display: block;
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-top: 3px;
  text-transform: none;
}

/* ── Canvas area ────────────────────────────────────────────────────────────── */
.canvas-area {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* Subtle grid overlay on canvas area */
.canvas-area::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(80,100,200,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80,100,200,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

#starmap-canvas {
  max-width: 100%;
  max-height: calc(100vh - 74px);
  display: block;
  position: relative;
  z-index: 1;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 800px) {
  html, body { overflow: auto; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
  }
  .controls { grid-row: 3; border-right: none; border-top: 1px solid var(--panel-border); }
  .canvas-area { grid-row: 2; min-height: 70vw; }
  .style-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ── Info button (header) ────────────────────────────────────────────────────── */
.btn-info {
  background: none;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  color: var(--text-dim);
  font-family: 'Raleway', sans-serif;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 14px;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-info:hover {
  border-color: var(--accent);
  color: var(--accent-light);
  background: rgba(93,122,205,0.08);
}

/* ── Info Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 2, 15, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-box {
  background: rgba(8, 10, 28, 0.97);
  border: 1px solid rgba(80,100,220,0.28);
  border-radius: 18px;
  max-width: 640px;
  width: calc(100% - 48px);
  max-height: 82vh;
  overflow-y: auto;
  padding: 40px 44px 36px;
  position: relative;
  box-shadow:
    0 0 80px rgba(60,80,200,0.12),
    0 0 0 1px rgba(255,255,255,0.03) inset;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
  animation: modalIn 0.35s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.modal-box::-webkit-scrollbar { width: 4px; }
.modal-box::-webkit-scrollbar-thumb { background: var(--panel-border); border-radius: 2px; }

.modal-close {
  position: absolute;
  top: 18px; right: 22px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition);
  line-height: 1;
}
.modal-close:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.modal-header { margin-bottom: 28px; }
.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.04em;
  line-height: 1.2;
  margin-bottom: 6px;
}
.modal-subtitle {
  font-size: 0.68rem;
  letter-spacing: 0.20em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.modal-section { margin-bottom: 26px; }
.modal-section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-light);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}
.modal-section-icon {
  font-size: 0.9rem;
  opacity: 0.8;
}
.modal-section p {
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--text);
  opacity: 0.88;
}
.modal-section p + p { margin-top: 9px; }

.modal-eq {
  display: block;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--accent-light);
  background: rgba(93,122,205,0.07);
  border-left: 2px solid var(--accent);
  padding: 9px 16px;
  margin: 12px 0;
  border-radius: 0 6px 6px 0;
  letter-spacing: 0.03em;
}

.modal-ref {
  font-size: 0.73rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 10px;
}
.modal-ref strong {
  color: var(--accent-light);
  font-style: normal;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--panel-border);
  margin: 22px 0;
}

.modal-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding-top: 20px;
  border-top: 1px solid var(--panel-border);
  line-height: 1.8;
}
.modal-footer .heart { color: #e05555; }
.modal-footer .star-accent { color: var(--accent-light); }

/* ── Field hint ─────────────────────────────────────────────────────────────── */
.field-hint {
  font-size: 0.70rem;
  color: var(--text-dim);
  margin-top: 5px;
  padding: 5px 9px;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
  line-height: 1.4;
}
.field-hint strong {
  color: var(--accent-light);
  font-weight: 600;
}

/* ── Planet glow slider ─────────────────────────────────────────────────────── */
.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 2px;
}
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slider-val {
  font-size: 0.72rem;
  color: var(--text-dim);
  min-width: 34px;
  text-align: right;
}
.slider-row input[type="range"] {
  width: 88px;
  accent-color: var(--accent);
  cursor: pointer;
  height: 3px;
}

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.app { animation: fadeIn 0.5s ease both; }
