/* Atlas — mapa del cielo completo con Aladin Lite (CDS). Barra de búsqueda arriba, mapa, herramientas abajo.
   La interfaz propia de Aladin queda apagada; lo que sigue visible se ajusta a los tokens (abajo, "Aladin"). */
#atlas { display: flex; flex-direction: column; background: var(--bg); isolation: isolate; }
#atlas [hidden] { display: none !important; }

/* ---------- Botones de texto (mono) ---------- */
#atlas .at-row { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--s-1); row-gap: 0; min-width: 0; }
#atlas .at-row .label { margin-right: var(--s-2); color: var(--ink-3); }
#atlas .at-row button,
#atlas .at-search button,
#atlas .at-zoom button {
  min-height: 2.25rem; padding: 0 var(--s-2);
  background: none; border: 0; border-radius: 0;
  color: var(--ink-2);
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: var(--tracking-label); text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 0.35em; text-decoration-thickness: 1px;
  transition: color var(--t-fast) var(--ease-out), text-decoration-color var(--t-fast) var(--ease-out);
}
#atlas .at-row button:hover, #atlas .at-zoom button:hover { color: var(--ink); }
#atlas .at-row button[aria-pressed="true"] { color: var(--ink); text-decoration-color: var(--ink-2); }
#atlas .at-row button[data-state="off"] { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-3); cursor: default; }
#atlas .at-row button:disabled { color: var(--ink-3); cursor: default; }
#atlas .at-row button .at-note { margin-left: var(--s-1); color: var(--ink-3); text-transform: none; letter-spacing: 0; }

/* ---------- Barra superior: búsqueda + objetos de prueba ---------- */
#atlas .at-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-5);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--rule);
}
#atlas .at-search { display: flex; flex: 0 1 22rem; min-width: 0; border: 1px solid var(--rule-strong); }
#atlas .at-search:focus-within { border-color: var(--ink-3); }
#atlas .at-search input {
  flex: 1; min-width: 0; min-height: 2.25rem; padding: 0 var(--s-3);
  background: none; border: 0; border-radius: 0; outline: none;
  color: var(--ink); font-family: var(--font-mono); font-size: var(--fs-small);
  -webkit-appearance: none; appearance: none;
}
#atlas .at-search input::placeholder { color: var(--ink-3); }
#atlas .at-search input::-webkit-search-cancel-button { display: none; }
#atlas .at-search button { border-left: 1px solid var(--rule-strong); color: var(--ink); padding: 0 var(--s-4); }
#atlas .at-search button:hover { background: var(--ink); color: var(--bg); }
#atlas .at-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#atlas .at-targets { flex: 1 1 auto; }
#atlas .at-msg {
  flex-basis: 100%; max-width: none; margin-top: calc(-1 * var(--s-1));
  font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-2);
}

/* ---------- Mapa ---------- */
#atlas .at-view { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#atlas .at-map { position: absolute; inset: 0; background: var(--bg); }
#atlas:not(.is-ready) .at-map { visibility: hidden; }

#atlas .at-hud {
  position: absolute; z-index: 2;
  display: grid; gap: 2px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--rule);
  background: var(--bg);
  font-family: var(--font-mono); font-size: var(--fs-label); line-height: 1.45;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  pointer-events: none;
  max-width: calc(100% - 6rem);
}
#atlas .at-hud p { max-width: none; color: inherit; }
#atlas .at-hud .label { color: var(--ink-2); }
#atlas .at-hud [data-hud-count] { color: var(--ink-2); }
#atlas .at-hud [data-hud-note] b { font-weight: 400; color: var(--accent); }
#atlas .at-hud-tl { top: var(--s-4); left: var(--s-4); }
/* Aviso del cambio automático a 2MASS: una línea tenue con un botón de texto (el único punto del HUD que recibe clics). */
#atlas .at-hud .at-sxnote { color: var(--ink-3); }
#atlas .at-sxnote button {
  pointer-events: auto;
  padding: 0; margin-left: var(--s-1);
  background: none; border: 0; border-radius: 0;
  color: var(--ink-2); font: inherit; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.3em; text-decoration-thickness: 1px;
}
#atlas .at-sxnote button:hover { color: var(--ink); text-decoration-color: var(--ink-2); }
#atlas .at-hud-bl { bottom: var(--s-4); left: var(--s-4); }

#atlas .at-zoom {
  position: absolute; z-index: 2; top: var(--s-4); right: var(--s-4);
  display: grid; border: 1px solid var(--rule); background: var(--bg);
}
#atlas .at-zoom button { min-width: 2.75rem; font-size: var(--fs-body); letter-spacing: 0; text-decoration: none; }
#atlas .at-zoom button + button { border-top: 1px solid var(--rule); }

#atlas .at-credit {
  position: absolute; z-index: 2; right: var(--s-4); bottom: var(--s-3);
  font-family: var(--font-mono); font-size: 0.625rem; letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--ink-3); pointer-events: none;
}

#atlas .at-tip {
  position: absolute; z-index: 3; top: 0; left: 0;
  display: grid; gap: 2px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  font-family: var(--font-mono); font-size: var(--fs-label); line-height: 1.45;
  color: var(--ink-2);
  white-space: nowrap;
  pointer-events: none;
}
#atlas .at-tip .t-name { color: var(--ink); text-transform: uppercase; letter-spacing: var(--tracking-label); }
#atlas .at-tip .t-dim { color: var(--ink-3); }

/* Puerta de entrada: una línea y dos botones */
#atlas .at-intro {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-content: center; justify-items: center; gap: var(--s-5);
  padding: var(--gutter);
  text-align: center;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  transition: opacity var(--t-base) var(--ease-out);
}
#atlas .at-intro.is-out { opacity: 0; pointer-events: none; }
#atlas .at-intro .label { color: var(--ink-2); max-width: 46ch; text-wrap: balance; }
#atlas .at-intro-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); }
#atlas .at-intro .btn { background: var(--bg); cursor: pointer; }
#atlas .at-intro .btn:hover { background: var(--ink); color: var(--bg); }

#atlas .at-state {
  position: absolute; z-index: 5; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(26rem, calc(100% - 2 * var(--s-4)));
  background: var(--bg);
}
/* Carga del mapa: el campo dibujado, no una caja. La línea gira (transform) y cada estrella se enciende a su paso (opacity). */
#atlas .at-state.state-loading { border: 0; padding: 0; background: none; justify-items: center; text-align: center; width: auto; }
#atlas .at-state.state-loading .label::after { content: none; }
#atlas .at-sk { width: min(15rem, 56vw); height: auto; overflow: visible; }
#atlas .at-sk-f { fill: none; stroke: var(--rule-strong); stroke-width: 1px; vector-effect: non-scaling-stroke; }
#atlas .at-sk-i { fill: none; stroke: var(--rule); stroke-width: 1px; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
#atlas .at-sk-x { fill: none; stroke: var(--ink-3); stroke-width: 1px; vector-effect: non-scaling-stroke; }
#atlas .at-sk-s { transform-box: view-box; transform-origin: 50% 50%; animation: at-sk-rot 6s linear infinite; }
#atlas .at-sk-s line { stroke: var(--ink-2); stroke-width: 1px; vector-effect: non-scaling-stroke; }
#atlas .at-sk-w { fill: var(--ink); opacity: 0.05; }
#atlas .at-sk-d circle { fill: var(--ink); opacity: 0.18; animation: at-sk-dot 6s linear infinite both; }
@keyframes at-sk-rot { to { transform: rotate(360deg); } }
@keyframes at-sk-dot { 0% { opacity: 0.9; } 50%, 100% { opacity: 0.18; } }
@media (prefers-reduced-motion: reduce) { #atlas .at-sk-s, #atlas .at-sk-d circle { animation: none; } }

/* ---------- Herramientas inferiores ---------- */
#atlas .at-tools {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-5);
  padding: var(--s-1) var(--s-4);
  border-top: 1px solid var(--rule);
}
#atlas .at-tools [data-tour] { color: var(--ink); text-decoration-color: var(--rule-strong); }

/* ---------- Las 102 bandas de SPHEREx: acción principal de la capa, al pie del mapa ---------- */
#atlas .at-lam {
  --trk: 2.25rem;
  position: absolute; z-index: 5; left: 0; right: 0; bottom: 0;
  display: grid; gap: var(--s-1);
  padding: var(--s-3) var(--s-4) var(--s-2);
  border-top: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  container-type: inline-size;
}
#atlas .at-lam-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); min-width: 0; }
#atlas .at-lam .btn { min-height: 2.75rem; padding: 0 var(--s-4); background: var(--bg); border-radius: 0; cursor: pointer; white-space: nowrap; }
#atlas .at-lam .btn:hover { background: var(--ink); color: var(--bg); }
#atlas .at-lam .btn[aria-pressed="true"] { border-color: var(--ink-2); }
#atlas .at-lam-title { color: var(--ink-2); }
#atlas .at-lam-out {
  font-family: var(--font-mono); font-size: var(--fs-label); font-variant-numeric: tabular-nums;
  color: var(--ink); white-space: nowrap;
}
#atlas .at-lam-out .at-lam-h { display: none; color: var(--ink-2); }
/* Range nativo: pista hairline y pulgar cuadrado (10px; las marcas de detector se corren medio pulgar). */
#atlas .at-lam-track { min-width: 0; }
#atlas .at-lam input {
  display: block; width: 100%; height: var(--trk); margin: 0; padding: 0;
  background: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
#atlas .at-lam input::-webkit-slider-runnable-track { height: 1px; background: var(--rule-strong); border: 0; }
#atlas .at-lam input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 0.625rem; height: 0.625rem; margin-top: calc(-0.3125rem + 0.5px);
  background: var(--ink); border: 0; border-radius: 0;
}
#atlas .at-lam input::-moz-range-track { height: 1px; background: var(--rule-strong); border: 0; }
#atlas .at-lam input::-moz-range-progress { height: 1px; background: var(--rule-strong); }
#atlas .at-lam input::-moz-range-thumb { width: 0.625rem; height: 0.625rem; background: var(--ink); border: 0; border-radius: 0; }
#atlas .at-lam input:hover::-webkit-slider-runnable-track { background: var(--ink-3); }
#atlas .at-lam input:hover::-moz-range-track { background: var(--ink-3); }
/* Los 6 detectores: un corchete hairline bajo la pista por rango de λ. En angosto, solo la etiqueta del activo. */
#atlas .at-dets { position: relative; height: 1.25rem; margin: calc(0.4375rem - var(--trk) / 2) 0.3125rem 0; pointer-events: none; }
#atlas .at-det { position: absolute; top: 0; height: 100%; left: calc(var(--a) * 100%); width: calc((var(--b) - var(--a)) * 100%); }
#atlas .at-det::before {
  content: ''; position: absolute; top: 0; left: 1px; right: 1px; height: 5px;
  border: 1px solid var(--rule-strong); border-bottom: 0;
}
#atlas .at-det.is-on::before { border-color: var(--ink-2); }
#atlas .at-det-l {
  position: absolute; top: 8px; left: 1px; display: none;
  font-family: var(--font-mono); font-size: 0.6875rem; line-height: 1.25; white-space: nowrap;
  color: var(--ink-2);
}
#atlas .at-det.is-r .at-det-l { left: auto; right: 1px; }
#atlas .at-det.is-on .at-det-l { display: block; }
#atlas .at-det-h::before { content: ' · '; }
@container (min-width: 52rem) {
  #atlas .at-dets { height: 2.25rem; }
  #atlas .at-dets .at-det .at-det-l { display: grid; left: 1px; right: 1px; text-align: center; overflow: hidden; color: var(--ink-3); }
  #atlas .at-det-l span { overflow: hidden; text-overflow: ellipsis; }
  #atlas .at-dets .at-det.is-on .at-det-l { color: var(--ink); }
  #atlas .at-det-h::before { content: none; }
  #atlas .at-lam-out .at-lam-h { display: inline; }
}
/* El HUD inferior y el crédito suben por encima de la barra (--lam-h la mide atlas.js). */
#atlas.has-lam .at-hud-bl { bottom: calc(var(--lam-h, 7rem) + var(--s-3)); }
#atlas.has-lam .at-credit { bottom: calc(var(--lam-h, 7rem) + var(--s-2)); }
#atlas.has-lam .at-intro { bottom: var(--lam-h, 7rem); }

/* ---------- Aladin: su DOM, con nuestros tokens ---------- */
#atlas .aladin-container { background: var(--bg) !important; border-radius: 0 !important; font-family: var(--font-mono) !important; }
#atlas .aladin-logo-container,
#atlas .aladin-location,
#atlas .aladin-fov,
#atlas .aladin-status-bar,
#atlas .aladin-measurement-div,
#atlas .aladin-context-menu,
#atlas .aladin-toolbar,
#atlas .aladin-stack-box,
#atlas .aladin-layersControl-container,
#atlas .aladin-fullscreenControl,
#atlas .aladin-share-control,
#atlas .aladin-zoomControl { display: none !important; }
#atlas .aladin-popup-container,
#atlas .aladin-box,
#atlas .aladin-dialog {
  background: var(--bg) !important; color: var(--ink-2) !important;
  border: 1px solid var(--rule-strong) !important; border-radius: 0 !important; box-shadow: none !important;
  font-family: var(--font-mono) !important; font-size: var(--fs-label) !important;
}
#atlas .aladin-popup-arrow { display: none !important; }
#atlas .aladin-btn, #atlas .aladin-input { border-radius: 0 !important; box-shadow: none !important; font-family: var(--font-mono) !important; }

/* ---------- Móvil ---------- */
@media (max-width: 860px) {
  #atlas .at-bar { padding: var(--s-2) var(--s-3); gap: var(--s-1) var(--s-3); }
  #atlas .at-search { flex: 1 1 100%; }
  /* Filas de botones en una línea con desplazamiento propio: el mapa conserva su alto dentro de 62svh. */
  #atlas .at-targets, #atlas .at-tools {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none;
  }
  #atlas .at-targets::-webkit-scrollbar, #atlas .at-tools::-webkit-scrollbar { display: none; }
  #atlas .at-targets { flex: 1 1 100%; }
  #atlas .at-tools { padding: 0 var(--s-3); column-gap: var(--s-4); }
  #atlas .at-tools .at-row { flex-wrap: nowrap; flex: 0 0 auto; }
  #atlas .at-hud-tl { top: var(--s-3); left: var(--s-3); }
  /* El crédito ocupa su propia línea al pie; el HUD inferior sube por encima para no pisarlo. */
  #atlas .at-hud-bl { bottom: calc(var(--s-2) + 1.25rem); left: var(--s-3); }
  #atlas .at-zoom { top: var(--s-3); right: var(--s-3); }
  #atlas .at-hud { padding: var(--s-1) var(--s-2); max-width: calc(100% - 5rem); }
  #atlas .at-credit { right: var(--s-3); bottom: var(--s-2); }
  #atlas .at-lam { padding: var(--s-2) var(--s-3) var(--s-1); --trk: 2.75rem; }
  #atlas.has-lam .at-hud-bl { bottom: calc(var(--lam-h, 7rem) + var(--s-2) + 1.25rem); }
  /* La puerta de entrada queda sobre la barra de bandas: más compacta para caber en el mapa de 62svh. */
  #atlas .at-intro { gap: var(--s-3); padding: var(--s-2) var(--gutter); }
  #atlas .at-intro-btns { gap: var(--s-2); }
}
@media (max-width: 860px), (pointer: coarse) {
  #atlas .at-row button, #atlas .at-search button, #atlas .at-search input, #atlas .at-zoom button { min-height: 2.75rem; }
  #atlas .at-lam { --trk: 2.75rem; }
  #atlas .at-zoom button { min-width: 2.75rem; }
}

/* Trayectoria de objetos con movimiento propio: etiquetas por época y el punto que la recorre. */
#atlas .at-trail { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
#atlas .at-trail-l {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; line-height: 14px;
  color: var(--ink-2); background: rgba(11, 11, 12, 0.72); padding: 0 4px;
}
#atlas .at-trail-l.is-bg { color: var(--ink); }
#atlas .at-trail-l.is-now { color: var(--accent); }
#atlas .at-trail-l.is-mid { color: var(--ink-3); }
#atlas .at-trail-dot {
  position: absolute; left: 0; top: 0; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(217, 119, 75, 0.25); opacity: 0;
}

/* "Show me a patch": la acción principal de la fila de objetos, con hairline para distinguirla de los nombres. */
#atlas .at-row .at-patch { margin-right: var(--s-3); border: 1px solid var(--rule-strong); color: var(--ink); text-decoration: none; }
#atlas .at-row .at-patch:hover { background: var(--ink); color: var(--bg); }
/* Ir a la vitrina de las 102 bandas: un botón de texto al final de la cabecera de la barra. */
#atlas .at-lam .at-show {
  margin-left: auto; min-height: 2.25rem; padding: 0;
  background: none; border: 0; border-radius: 0; cursor: pointer;
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--ink-2); white-space: nowrap;
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 0.35em; text-decoration-thickness: 1px;
  transition: color var(--t-fast) var(--ease-out), text-decoration-color var(--t-fast) var(--ease-out);
}
#atlas .at-lam .at-show:hover { color: var(--ink); text-decoration-color: var(--ink-2); }
@media (max-width: 860px) {
  #atlas .at-lam .at-show { margin-left: 0; white-space: normal; text-align: left; min-height: 2.75rem; }
}
