/* spacetext — shared shell for locate.html (and, from Task 12, generate.html).
   Dark full-bleed sky, the floating left panel and the star labels. */

:root {
  --bg: #05070d;
  --fg: #dfe7f5;
  --muted: #8fa0bb;
  --accent: #9fc4ff;
  --panel-bg: rgba(10, 15, 25, 0.72);
  --panel-border: rgba(150, 180, 230, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

/* Full-window sky. Holds the WebGL canvas and the CSS2D label layer. */
.sky {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.sky canvas {
  display: block;
}

/* Drag-and-drop cue: js/locate.mjs toggles `body.is-dragging` while a file is
   dragged over the window. Sits above the labels but below the panel. */
body.is-dragging .sky::after {
  content: "Drop a puzzle JSON to load";
  position: absolute;
  inset: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(5, 7, 13, 0.55);
  border: 2px dashed var(--accent);
  border-radius: 12px;
  pointer-events: none;
}

/* The CSS2DRenderer's element. js/scene.mjs also sets its inline position and
   pointer-events, so labels stay clickable even without this rule.
   The CSS2DRenderer gives each visible label a z-index by depth (up to one per
   star), so the layer must be its own stacking context below the panel
   (`z-index: 1`, panel at 10) — otherwise labels can paint over the panel and
   swallow clicks on its controls. */
.label-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
}

/* One clickable label per named star. */
.star-label {
  pointer-events: auto;
  cursor: pointer;
  padding: 0 4px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--fg);
  white-space: nowrap;
  text-shadow: 0 0 3px #000, 0 0 6px #000;
  border-radius: 3px;
}

.star-label:hover,
.star-label:focus-visible {
  color: #fff;
  background: rgba(120, 170, 255, 0.25);
  outline: none;
}

/* Floating panel shell, left side (Task 10 adds the load/jump UI, Task 11 the
   Verify box). */
.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10;
  width: 260px;
  padding: 14px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.panel__title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.panel__system {
  margin: 0 0 8px;
  font-size: 13px;
}

.panel__system strong {
  color: #fff;
  font-weight: 600;
}

.panel__hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

/* Puzzle file picker (Task 10). */
.panel__load {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.panel__file {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-size: 11px;
  color: var(--fg);
}

/* Load result line: muted on success, red on failure. */
.panel__status {
  margin: 8px 0 0;
  min-height: 1em;
  font-size: 11px;
  color: var(--muted);
}

.panel__status--error {
  color: #ff9a9a;
}

.panel__error {
  margin: 8px 0 0;
  font-size: 11px;
  color: #ff9a9a;
}

/* --- Task 11: answer box and congratulations overlay ---------------------- */

/* Text input + Verify button, below the puzzle loader. */
.panel__verify {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}

.panel__verify-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel__verify-row {
  display: flex;
  gap: 6px;
}

.panel__answer {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg);
  background: rgba(5, 7, 13, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.panel__answer:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.panel__button {
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.panel__button:hover,
.panel__button:focus-visible {
  background: #fff;
  outline: none;
}

/* Congratulations overlay. Above the labels (1) and the panel (10): a found
   answer should not be interrupted by a stray jump. Dismissible, so the sky is
   never locked behind it. */
.congrats {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 7, 13, 0.72);
}

.congrats[hidden] {
  display: none;
}

.congrats__card {
  max-width: 320px;
  padding: 20px 24px;
  text-align: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
}

.congrats__title {
  margin: 0 0 8px;
  font-size: 16px;
  color: #fff;
}

.congrats__text {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
}

/* --- Task 12: Generate screen -------------------------------------------- */

/* Left: the preview stage (origin view + small elsewhere inset). Right: the
   control strip. Both fill the window height. */
.generate {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
}

.stage {
  position: relative;
  overflow: hidden;
}

/* The origin view fills the stage; js/generate.mjs appends its canvas here. */
.stage__view {
  position: absolute;
  inset: 0;
}

/* The elsewhere preview: the same cloud from an unrelated named star. */
.stage__elsewhere {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 300px;
  height: 200px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.stage__caption {
  position: absolute;
  z-index: 1;
  top: 10px;
  left: 12px;
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-shadow: 0 0 4px #000;
  pointer-events: none;
}

.stage__caption strong {
  color: var(--fg);
  letter-spacing: normal;
  text-transform: none;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
}

.controls__title {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.controls__group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Label on the left, live value on the right (range hint in the middle). */
.controls__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.controls__range {
  flex: 1 1 auto;
  font-size: 10px;
  letter-spacing: normal;
  text-transform: none;
}

.controls__value {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.controls__select,
.controls__text {
  width: 100%;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  color: var(--fg);
  background: rgba(5, 7, 13, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.controls__text {
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.controls__select:focus-visible,
.controls__text:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.controls__slider {
  width: 100%;
  accent-color: var(--accent);
}

.controls__origin {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.controls__origin strong {
  color: #fff;
  font-weight: 600;
}

/* Short note under a control, e.g. which characters the font can draw. */
.controls__hint {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

.controls__status {
  min-height: 1em;
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}

.controls__status--error {
  color: #ff9a9a;
}

.controls__note {
  margin: 0;
  font-size: 10px;
  line-height: 1.6;
  color: var(--muted);
}

/* The Download button shares .panel__button; grey it out with nothing to ship. */
.panel__button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.panel__button:disabled:hover {
  background: var(--accent);
}

/* "Gå til" star-jump form in the Locate panel. Mirrors the panel__verify-*
   row shape (label, input, button) so the panel stays visually consistent. */
.panel__goto {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}

.panel__goto-label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel__goto-row {
  display: flex;
  gap: 6px;
}

.panel__goto-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg);
  background: rgba(5, 7, 13, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.panel__goto-input:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* Five origin/text pair rows (generate.html). One radio per row selects the
   pair whose aim fills the origin preview; the selected row is outlined. */
.controls__pairs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.controls__pair {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.controls__pair--active {
  border-color: var(--accent);
}

.controls__pair-view {
  appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid var(--muted);
  border-radius: 50%;
  cursor: pointer;
}
.controls__pair-view:checked {
  border: 4px solid var(--accent);
  background: transparent;
}
