/* =====================================================================
   orrery.css — 04 · THE KELVIN SYSTEM survey map  (prefix: orr-)
   Mount: #orrery. Everything is scoped to .orr-* classes or #orrery.
   ===================================================================== */

.orr-root {
  --orr-h: 640px;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: clamp(14px, 1.6vw, 22px);
  align-items: stretch;
  color: var(--text);
}
@media (max-width: 1023.98px) {
  .orr-root { grid-template-columns: minmax(0, 1fr); --orr-h: 520px; }
}
@media (max-width: 640px) {
  .orr-root { --orr-h: 420px; }
}

/* ------------------------------------------------------------ stage */
.orr-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  background:
    radial-gradient(58% 50% at 50% 52%, rgba(255, 150, 70, 0.05), transparent 72%),
    linear-gradient(180deg, rgba(10, 13, 18, 0.74), rgba(7, 9, 12, 0.88));
  container-type: inline-size;
  container-name: orr-stage;
}
.orr-corner {
  position: absolute; z-index: 4; width: 12px; height: 12px; pointer-events: none;
  border-color: var(--silver); border-style: solid; opacity: 0.85;
}
.orr-corner--tr { top: -1px; right: -1px; border-width: 1px 1px 0 0; }
.orr-corner--bl { bottom: -1px; left: -1px; border-width: 0 0 1px 1px; }

.orr-view {
  position: relative;
  /* grows with the row if the dossier ever runs taller than the stage,
     so the map fills the space instead of leaving a gap above the index */
  flex: 1 0 auto;
  height: var(--orr-h);
  overflow: hidden;
}
.orr-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.orr-canvas.is-pointer { cursor: pointer; }

/* HUD overlays */
.orr-hud { position: absolute; z-index: 2; margin: 0; pointer-events: none; }
.orr-hud--tl { top: 16px; left: 18px; display: grid; gap: 5px; }
.orr-hud-title { color: var(--text); }
.orr-hud-sub { font-size: 0.66rem; letter-spacing: 0.08em; color: var(--text-faint); text-transform: uppercase; }
.orr-hud--tr { top: 14px; right: 16px; display: flex; gap: 20px; text-align: right; }
.orr-hud--tr .readout__v { font-size: 0.86rem; }
.orr-hud--bl { bottom: 16px; left: 18px; color: var(--text-faint); font-size: 0.58rem; }
.orr-cam {
  position: absolute; z-index: 3; right: 14px; bottom: 12px;
  min-height: 34px; padding: 0 12px; font-size: 0.58rem;
  background: rgba(7, 9, 12, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

@container orr-stage (max-width: 560px) {
  .orr-hud--tl { top: 12px; left: 14px; }
  .orr-hud-title { font-size: 0.6rem; letter-spacing: 0.2em; }
  .orr-hud-title-x, .orr-hud-sub, .orr-hud--bl { display: none; }
  /* readouts become two inline rows so they never run into the title */
  .orr-hud--tr { top: 11px; right: 12px; flex-direction: column; align-items: flex-end; gap: 3px; }
  .orr-hud--tr .readout { display: flex; align-items: baseline; gap: 7px; }
  .orr-hud--tr .readout__k { font-size: 0.48rem; letter-spacing: 0.2em; }
  .orr-hud--tr .readout__v { font-size: 0.72rem; }
  .orr-cam { right: 10px; bottom: 10px; padding: 0 10px; font-size: 0.52rem; }
}

/* ------------------------------------------------------------ 3D view
   .orr-3dwrap is injected by orrery.js once the ASA3D scene is ready; it
   cross-fades over the 2D canvas (.is-3d), which is then parked (.is-3d-live). */
.orr-3dwrap {
  position: absolute; inset: 0; z-index: 1;
  opacity: 0;
  transition: opacity 1.1s var(--ease-out);
}
.orr-root.is-3d .orr-3dwrap { opacity: 1; }
/* inert while it is being prepared: the 2D map keeps its clicks, and the
   kit's (invisible) touch buttons stay out of reach and out of tab order */
.orr-root:not(.is-3d) .orr-3dwrap, .orr-root:not(.is-3d) .orr-3dwrap * { pointer-events: none !important; }
.orr-root:not(.is-3d) .orr-3dwrap .a3d-ui { visibility: hidden; }
.orr-root.is-3d .orr-canvas { opacity: 0; transition: opacity 0.9s var(--ease-out); }
.orr-root.is-3d-live .orr-canvas { visibility: hidden; }
.orr-3d { position: absolute; inset: 0; }
.orr-3d .a3d-canvas { cursor: grab; -webkit-tap-highlight-color: transparent; }
.orr-3d .a3d-canvas:active { cursor: grabbing; }
.orr-3d.is-pointer .a3d-canvas { cursor: pointer; }

/* kit chrome: its display rules beat the [hidden] attribute it toggles
   ("Done" + "Tap to interact" would both show) — honour hidden here */
#orrery .a3d-ui [hidden] { display: none !important; }
/* kit chrome: keep it clear of the HUD row along the bottom edge */
#orrery .orr-3d .a3d-hint { bottom: 54px; }
#orrery .orr-3d .a3d-tap { bottom: 54px; }
#orrery .orr-3d .a3d-done { top: auto; right: auto; left: 50%; bottom: 54px; transform: translateX(-50%); }

/* projected HTML overlay (labels, reticle, hold feedback) */
.orr-ov { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.orr-ov-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.orr-ov-svg > * { visibility: hidden; fill: none; stroke-width: 1; }
.orr-ov > span {
  position: absolute; left: 0; top: 0;
  visibility: hidden; white-space: nowrap; line-height: 1;
  will-change: transform;
}
.orr-ov-unc { stroke: rgba(255, 255, 255, 0.22); stroke-dasharray: 1.5 2.5; }
.orr-ov-bdot { fill: rgba(201, 167, 124, 0.6) !important; stroke: none; }
.orr-ov-hring { stroke: rgba(238, 241, 244, 0.55); }
.orr-ov-ret { stroke: var(--ignite); stroke-width: 1.1; stroke-linecap: square; }
.orr-ov-dia { fill: var(--ignite-hot) !important; stroke: none; }
.orr-ov-arc { stroke: rgba(255, 179, 92, 0.95); stroke-width: 1.5; }
.orr-ov-dash { stroke: rgba(255, 138, 42, 0.55); stroke-dasharray: 2 4; }
.orr-ov-desc { stroke: rgba(255, 179, 92, 0.6); stroke-dasharray: 1 3; }
.orr-ov-tri { fill: rgba(255, 179, 92, 0.95) !important; stroke: none; }
.orr-ov-lead { stroke: rgba(255, 138, 42, 0.8); }
.orr-ov-tag { font-size: 9px; font-weight: 500; letter-spacing: 0.06em; color: rgba(163, 170, 180, 0.5); text-shadow: 0 0 6px rgba(0, 0, 0, 0.9); }
.orr-ov-tag[data-tier="1"] { color: rgba(214, 216, 219, 0.62); }
.orr-ov-tag[data-tier="2"] { color: rgba(116, 196, 80, 0.75); }
.orr-ov-brg { font-size: 9px; color: rgba(163, 170, 180, 0.42); }
.orr-ov-hname, .orr-ov-cname {
  font-family: var(--f-display); font-size: 10px; letter-spacing: 0.16em; color: var(--text);
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.95), 0 0 2px rgba(0, 0, 0, 0.9);
}
.orr-ov-csub { font-size: 9px; font-weight: 500; letter-spacing: 0.06em; color: rgba(163, 170, 180, 0.9); text-shadow: 0 0 6px rgba(0, 0, 0, 0.95); }
.orr-ov-csub[data-tier="1"] { color: rgba(255, 179, 92, 0.92); }
.orr-ov-csub[data-tier="2"] { color: rgba(116, 196, 80, 0.95); }

/* 3D tool cluster: zoom · reset · orbit clock */
.orr-tools {
  position: absolute; z-index: 3; right: 14px; bottom: 56px;
  display: none; flex-direction: column;
  border: 1px solid var(--line-strong); border-radius: 2px;
  background: rgba(7, 9, 12, 0.72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.orr-root.is-3d .orr-tools { display: flex; }
.orr-tool {
  position: relative; display: grid; place-items: center;
  width: 34px; height: 34px;
  color: var(--text-dim);
  transition: color 0.3s, background 0.3s;
}
.orr-tool + .orr-tool { border-top: 1px solid var(--line); }
.orr-tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: square; }
.orr-tool[data-t="pause"][data-on="1"] svg { fill: currentColor; stroke-width: 0.8; }
.orr-tool:hover, .orr-tool:focus-visible { color: var(--ignite-hot); background: rgba(255, 138, 42, 0.08); }
.orr-tool:focus-visible { outline: 1px solid var(--ignite); outline-offset: -3px; }
.orr-tool[data-on="1"] { color: var(--ignite); }
.orr-tool--rate .mono { font-size: 0.62rem; letter-spacing: 0; }
.orr-tool-sep { height: 1px; background: var(--line-strong); }
.orr-tool-sep + .orr-tool { border-top: 0; }

@container orr-stage (max-width: 560px) {
  .orr-tools { right: 10px; bottom: 52px; }
  .orr-tool { width: 32px; height: 32px; }
  /* phones: the kit's touch chrome sits bottom-left, stacked just above the
     camera button row (side by side they collide below ≈380px of stage) and
     clear of the tool column on the right */
  #orrery .orr-3d .a3d-tap { left: 10px; bottom: 54px; transform: none; min-height: 34px; padding: 0 12px; font-size: 0.54rem; letter-spacing: 0.16em; }
  #orrery .orr-3d .a3d-done { left: 10px; bottom: 54px; transform: none; }
  #orrery .orr-3d .a3d-hint { display: none; }
}

/* ------------------------------------------------- body index (legend) */
.orr-legend {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
}
/* one row of eight only once every cell can hold "Homeworld" / "Companion"
   without ellipsis (≈ 97px per cell); below that, two rows of four */
@container orr-stage (min-width: 800px) {
  .orr-legend { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
.orr-body {
  position: relative;
  display: grid;
  align-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 56px;
  padding: 10px 12px 11px;
  text-align: left;
  background: var(--ink-950);
  transition: background 0.3s;
}
.orr-body::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px;
  background: var(--ignite);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.45s var(--ease-out);
}
.orr-body:hover { background: #0c1016; }
.orr-body[aria-pressed="true"] { background: #120e0a; }
.orr-body[aria-pressed="true"]::before { transform: scaleX(1); }
.orr-body:focus-visible { outline: 1px solid var(--ignite); outline-offset: -4px; }
.orr-body-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; }
.orr-body-des {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.64rem; color: var(--text-faint); white-space: nowrap; text-transform: uppercase;
}
.orr-body-des::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--orr-tint, var(--silver));
  box-shadow: 0 0 8px var(--orr-tint, var(--silver));
}
.orr-body-name {
  font-family: var(--f-body); font-weight: 700; font-size: 0.8rem; line-height: 1.2;
  color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color 0.3s;
}
.orr-body:hover .orr-body-name, .orr-body[aria-pressed="true"] .orr-body-name { color: var(--text); }
.orr-pips { display: inline-flex; gap: 2px; flex: none; }
.orr-pips i { width: 6px; height: 3px; background: rgba(255, 255, 255, 0.14); transition: background 0.4s; }
.orr-pips i.is-on { background: var(--signal); }

/* ------------------------------------------------------------ dossier */
.orr-dossier {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 18px 20px 16px;
}
.orr-dz-body { display: flex; flex-direction: column; gap: 13px; min-width: 0; }
.orr-dz-head {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

/* planet disc */
.orr-disc { position: relative; width: 96px; height: 96px; }
.orr-disc-cv {
  position: absolute; inset: 9px;
  width: calc(100% - 18px); height: calc(100% - 18px);
  border-radius: 50%;
  background: #06080b;
  transition: filter 1.2s var(--ease-out), opacity 0.6s;
}
.orr-disc[data-tier="0"] .orr-disc-cv { filter: blur(1.5px) saturate(0.3) brightness(0.88) contrast(0.92); }
.orr-disc-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; animation: orr-spin 60s linear infinite; }
.orr-disc-ring circle { fill: none; stroke: var(--line-strong); stroke-width: 0.6; }
.orr-disc-ring line { stroke: rgba(255, 255, 255, 0.22); stroke-width: 0.6; }
.orr-disc-ring line.orr-disc-tick--l { stroke: var(--orr-tint, var(--silver)); stroke-width: 0.9; }
.orr-disc-scan {
  position: absolute; inset: 9px; border-radius: 50%; overflow: hidden;
  opacity: 0; transition: opacity 0.25s; pointer-events: none;
}
.orr-disc-scan::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--ignite-hot);
  box-shadow: 0 0 10px var(--ignite), 0 -8px 14px rgba(255, 138, 42, 0.25);
  animation: orr-scanline 0.9s linear infinite;
}
.orr-dossier.is-holding .orr-disc-scan { opacity: 1; }
@keyframes orr-spin { to { transform: rotate(360deg); } }
@keyframes orr-scanline { from { transform: translateY(0); } to { transform: translateY(78px); } }

.orr-dz-id { min-width: 0; }
.orr-dz-kicker { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.orr-dz-kicker .label { font-size: 0.58rem; color: var(--text-faint); }
.orr-dz-des { font-size: 0.74rem; color: var(--orr-tint, var(--text-dim)); text-transform: uppercase; white-space: nowrap; }
.orr-dz-name {
  margin: 7px 0 4px;
  font-size: clamp(1.1rem, 1.35vw, 1.35rem);
  line-height: 1.12;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
}
.orr-dz-name.orr-decoding { font-family: var(--f-display); color: var(--text); font-size: clamp(1.1rem, 1.35vw, 1.35rem); }
.orr-dz-class { color: var(--text-dim); font-size: 0.84rem; line-height: 1.4; }
.orr-dz-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px; }
.orr-dz-meta .chip { padding: 5px 8px; font-size: 0.56rem; }
#orrery .orr-visit { min-height: 32px; padding: 0 12px; gap: 8px; font-size: 0.58rem; }
#orrery .orr-visit .btn__arrow { width: 12px; height: 12px; }

/* knowledge bar */
.orr-know-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.orr-know-tier { font-size: 0.72rem; color: var(--text); text-transform: uppercase; letter-spacing: 0.06em; }
.orr-kbar.segbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; width: 100%; }
.orr-kbar .segbar__seg { position: relative; width: auto; height: 6px; overflow: hidden; }
.orr-kbar .segbar__seg.is-off { opacity: 1; background: rgba(255, 255, 255, 0.08); }
.orr-seg-fill {
  position: absolute; inset: 0;
  background: var(--ignite);
  transform: scaleX(0); transform-origin: left;
}

/* data groups */
.orr-groups { display: grid; gap: 9px; }
.orr-grp-h {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line-strong);
  font-family: var(--f-display); font-size: 0.56rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--text-dim);
}
.orr-grp-n { font-size: 0.66rem; letter-spacing: 0.04em; color: var(--text-faint); }
.orr-grp-state { margin-left: auto; font-size: 0.5rem; letter-spacing: 0.18em; color: var(--text-faint); }
.orr-grp[data-state="known"] .orr-grp-state { color: var(--signal); }
.orr-grp[data-state="next"] .orr-grp-state { color: var(--ignite); }
.orr-grp[data-state="locked"] .orr-grp-t { color: var(--text-faint); }
.orr-grp .kv { margin: 0; }
.orr-grp .kv > div { display: grid; grid-template-columns: 7.7rem minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 5px 0; }
.orr-grp .kv dt { padding-top: 0; font-size: 0.54rem; letter-spacing: 0.13em; line-height: 1.5; }
.orr-grp .kv dd { min-width: 0; font-size: 0.82rem; line-height: 1.34; border-radius: 1px; }
.orr-grp .kv dd small { color: var(--text-faint); font-size: 0.78em; margin-left: 2px; }
.orr-unk-wrap { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; vertical-align: middle; }
.orr-unk-wrap .redact { min-width: 4ch; font-size: 0.7rem; line-height: 1.2; }
.orr-unk { font-size: 0.6rem; letter-spacing: 0.14em; color: var(--text-faint); }
.orr-decoding { font-family: var(--f-mono); font-size: 0.78rem; color: var(--ignite-hot); letter-spacing: 0.02em; }

/* actions */
.orr-actions { display: grid; gap: 7px; margin-top: auto; }
#orrery .orr-hold {
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  padding: 8px 16px;
  text-align: left;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  line-height: 1.35;
  color: var(--ignite-hot);
  border-color: rgba(255, 138, 42, 0.55);
  background: rgba(255, 138, 42, 0.04);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
#orrery .orr-hold::before {
  background: rgba(255, 138, 42, 0.26);
  transform: scaleX(var(--orr-p, 0));
  transition: none;
}
#orrery .orr-hold:hover, #orrery .orr-hold:focus-visible {
  color: var(--ignite-hot);
  border-color: var(--ignite);
  background: rgba(255, 138, 42, 0.08);
}
#orrery .orr-hold:hover::before, #orrery .orr-hold:focus-visible::before { transform: scaleX(var(--orr-p, 0)); }
#orrery .orr-hold.is-holding { border-color: var(--ignite-hot); box-shadow: 0 0 0 1px rgba(255, 138, 42, 0.25), 0 0 24px rgba(255, 138, 42, 0.12); }
.orr-hold-label { flex: 1 1 auto; min-width: 0; }
.orr-hold-key { flex: none; font-size: 0.62rem; letter-spacing: 0.1em; opacity: 0.8; text-transform: uppercase; }
.orr-ring, .orr-check { width: 20px; height: 20px; flex: none; }
.orr-ring { transform: rotate(-90deg); }
.orr-ring circle { fill: none; stroke-width: 1.5; }
.orr-ring-t { stroke: rgba(255, 138, 42, 0.3); }
.orr-ring-p { stroke: var(--ignite-hot); }
.orr-check { display: none; fill: none; stroke: currentColor; stroke-width: 1.4; }
#orrery .orr-hold.is-done,
#orrery .orr-hold.is-done:hover,
#orrery .orr-hold.is-done:focus-visible {
  color: var(--signal);
  border-color: rgba(116, 196, 80, 0.4);
  background: rgba(116, 196, 80, 0.05);
  cursor: default;
}
.orr-hold.is-done .orr-ring { display: none; }
.orr-hold.is-done .orr-check { display: block; }

.orr-actions-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.orr-hint { font-size: 0.6rem; color: var(--text-faint); letter-spacing: 0.04em; text-transform: uppercase; text-align: right; transition: color 0.35s; }
.orr-hint.is-nudge { color: var(--ignite-hot); }

.orr-motto {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 0.76rem; line-height: 1.5; color: var(--text-faint);
}
.orr-motto strong { color: var(--text-dim); font-weight: 700; }

/* ------------------------------------------------------------ mobile */
@media (max-width: 640px) {
  .orr-dossier { padding: 18px 16px 16px; gap: 14px; }
  .orr-dz-head { grid-template-columns: 84px minmax(0, 1fr); gap: 14px; }
  .orr-disc { width: 84px; height: 84px; }
  .orr-disc-cv, .orr-disc-scan { inset: 7px; }
  .orr-disc-cv { width: calc(100% - 14px); height: calc(100% - 14px); }
  .orr-body { min-height: 52px; padding: 9px 10px 10px; }
  .orr-body-name { font-size: 0.76rem; }
  .orr-grp .kv > div { grid-template-columns: 7rem minmax(0, 1fr); }
  .orr-grp .kv dt { font-size: 0.52rem; letter-spacing: 0.14em; }
  /* comfortable touch targets */
  #orrery .orr-visit { min-height: 40px; padding: 0 14px; }
}

/* narrow body index (phones inside the page gutters: ~328px of stage):
   tighter cells, smaller name, and the knowledge pips become a 3-segment
   rule along the bottom of each cell so "KV-1A" never collides with them */
@container orr-stage (max-width: 430px) {
  .orr-legend .orr-body { gap: 4px; min-height: 54px; padding: 9px 8px 14px; }
  .orr-legend .orr-body-des { font-size: 0.58rem; gap: 6px; }
  .orr-legend .orr-body-name { font-size: 0.7rem; }
  .orr-legend .orr-pips {
    position: absolute; left: 8px; right: 8px; bottom: 6px;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px;
  }
  .orr-legend .orr-pips i { width: auto; height: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .orr-disc-ring, .orr-disc-scan::after { animation: none; }
  /* the 2D→3D hand-over is a cut, not a fade */
  .orr-3dwrap, .orr-root.is-3d .orr-canvas { transition: none; }
}
