/* Telescope Field Finder — app shell styling.
   Night (red/red-orange) mode is the default (FR-12); the palette is driven by
   CSS custom properties and switched with `data-theme` on <body>, so the same
   rules render dim reds at night or a light theme in the day, using touch-sized
   targets throughout (FR-8, FR-12, NFC-5). */

/* Night palette (default). */
:root,
[data-theme='night'] {
  --bg: #0a0402;
  --panel-bg: rgba(20, 8, 2, 0.82);
  --panel-border: #3a1508;
  --text: #ff8a55;
  --text-dim: #b05a30;
  --accent: #ff4a22;
  --accent-fg: #1a0500;
  --input-bg: #160803;
  --input-border: #5a2410;
  --thumb: #ff6a3a;
  --track: #3a1508;
  --error: #ffd0a0;
  --shadow: 0 0 18px rgba(0, 0, 0, 0.6);
}

/* Day palette. */
[data-theme='day'] {
  --bg: #f4f1ea;
  --panel-bg: rgba(255, 253, 248, 0.9);
  --panel-border: #cfc7b6;
  --text: #2a2a2a;
  --text-dim: #6a6a6a;
  --accent: #1f5fb0;
  --accent-fg: #ffffff;
  --input-bg: #ffffff;
  --input-border: #bbb;
  --thumb: #1f5fb0;
  --track: #d8d8d8;
  --error: #8a1f10;
  --shadow: 0 0 18px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
}

#chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Prevent pinch-zoom / scroll gestures on the chart (T-4.5). */
  touch-action: none;
  user-select: none;
}

/* Overlay control panel (right edge on wide screens, bottom on narrow/touch). */
#panel {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: min(340px, 92vw);
  max-height: 100%;
  overflow-y: auto;
  padding: 14px;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 720px) {
  #panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--panel-border);
    max-height: 46vh;
  }
}

#title {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: 0.04em;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.head-btns {
  display: flex;
  gap: 8px;
}

/* Collapse / show controls + debug button. */
#panel-collapse,
#debug {
  min-width: 44px;
  min-height: 44px;
  font-size: 1.05rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

/* The hide-panel icon is a single bold dash; render it larger than the rest. */
#panel-collapse {
  font-size: 2rem;
  line-height: 1;
}

/* Floating button shown when the panel is collapsed. */
#panel-show {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  width: 52px;
  height: 52px;
  font-size: 1.4rem;
  color: var(--accent-fg);
  background: var(--accent);
  border: none;
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  touch-action: manipulation;
}

#panel-show[hidden] {
  display: none;
}

/* Panel is collapsed: hide the body and the whole panel off-screen. */
body.panel-collapsed #panel {
  transform: translateX(105%);
  pointer-events: none;
}

#panel {
  transition: transform 0.22s ease;
}

@media (max-width: 720px) {
  body.panel-collapsed #panel {
    transform: translateY(105%);
  }
}

#target-form {
  display: flex;
  gap: 8px;
}

#target-input {
  flex: 1;
  min-height: 46px;
  padding: 0 12px;
  font-size: 1rem;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}

#go {
  min-width: 56px;
  min-height: 46px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-fg);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

#error {
  margin: 8px 0 0;
  color: var(--error);
  font-size: 0.92rem;
}

#target-label {
  margin: 10px 0 0;
  font-size: 0.95rem;
  color: var(--text-dim);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control.row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.control label,
.control summary {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Sliders are the primary interaction: large, track-and-thumb touch targets. */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 44px;
  background: transparent;
  touch-action: none;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px;
  height: 30px;
  margin-top: -12px;
  border-radius: 50%;
  background: var(--thumb);
  border: 2px solid var(--panel-bg);
  cursor: pointer;
}

input[type='range']::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
}

input[type='range']::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--thumb);
  border: 2px solid var(--panel-bg);
  cursor: pointer;
}

.value {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

/* FOV mark on the zoom slider (T-5.4): an upward-pointing triangle *below* the
   track at the marked FOV; tapping it jumps back to that FOV. It sits clear of
   the slider so it never blocks dragging the thumb. */
.slider-wrap {
  position: relative;
  margin-bottom: 16px; /* room for the marker triangle below the track */
}

.fov-marker {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translateX(-50%);
  width: 26px;
  height: 16px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1;
}

.fov-marker::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 10px solid var(--accent);
}

.fov-marker:active::before {
  border-bottom-color: var(--thumb);
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#set-mark {
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.85rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

#set-mark:active {
  background: var(--input-bg);
}

#theme {
  width: 24px;
  height: 24px;
  accent-color: var(--accent);
}

/* Legend (T-4.7): symbols differ by shape first, colour second. */
#legend-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
  margin-top: 4px;
}

#legend-grid canvas {
  width: 22px;
  height: 22px;
}

#legend-grid span {
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* Loading overlay. */
#loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

#loading[hidden] {
  display: none;
}

#loading-text {
  font-size: 1.1rem;
  color: var(--text-dim);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Debug-log popup. */
#debug-popup {
  position: absolute;
  inset: 10px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#debug-popup[hidden] {
  display: none;
}

#debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-border);
}

#debug-close {
  min-width: 44px;
  min-height: 44px;
  font-size: 1rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
}

#debug-content {
  flex: 1;
  margin: 0;
  padding: 10px 14px;
  overflow: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}
