/* ==========================================================================
   Corpus Constellation — instrument styles
   ==========================================================================
   Namespaced beneath .archive-instrument--constellation. Consumes only the
   foundation tokens. Register colours are defined here as custom properties
   so the host can retune them; colour is never the sole carrier of meaning
   (register and status are always present as text in the dossier, legend,
   index, and exports).

   One deliberate exception to "amber emphasis / green traversal": nothing.
   Green appears only on the active journey path and live signals.
   ========================================================================== */

.archive-instrument--constellation {
  --cc-reg-primary: #f0e7d3;
  --cc-reg-transcript: #d9b46a;
  --cc-reg-web-archive: #9fb2bd;
  --cc-reg-commentary: #b0a087;
  --cc-reg-interpretation: #8b93a6;
  --cc-reg-theory-fiction: #c97f4e;
  --cc-void-fill: #050607;
  position: relative;
}

/* --- Header (server-rendered) -------------------------------------------- */

.archive-instrument--constellation .cc-kicker {
  font-family: var(--instrument-font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--instrument-amber);
  margin: 0 0 10px;
}

.archive-instrument--constellation .cc-title {
  font-family: var(--instrument-font-serif);
  font-weight: 400;
  font-size: clamp(30px, 4.5cqw, 52px);
  line-height: 1.06;
  margin: 0 0 14px;
  color: var(--instrument-ink);
}

.archive-instrument--constellation .cc-lede {
  font-size: clamp(16px, 1.6cqw, 19px);
  max-width: 62ch;
  margin: 0 0 8px;
}

.archive-instrument--constellation .cc-standfirst {
  font-family: var(--instrument-font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--instrument-muted);
  margin: 0 0 18px;
}

.archive-instrument--constellation .cc-noscript-note {
  font-family: var(--instrument-font-mono);
  font-size: 13px;
  color: var(--instrument-muted);
  border: 1px dashed var(--instrument-rule);
  padding: 10px 14px;
  max-width: 68ch;
}

/* --- App shell ------------------------------------------------------------ */

.archive-instrument--constellation .cc-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.archive-instrument--constellation .cc-main {
  min-width: 0;
}

.archive-instrument--constellation .cc-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

.archive-instrument--constellation .cc-toolbar-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.archive-instrument--constellation .cc-toolbar-spacer {
  flex: 1 1 auto;
}

.archive-instrument--constellation .cc-select {
  appearance: none;
  font-family: var(--instrument-font-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--instrument-ink);
  background: var(--instrument-panel);
  border: 1px solid var(--instrument-rule);
  padding: 9px 30px 9px 12px;
  min-height: 36px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 49%, var(--instrument-muted) 50%),
                    linear-gradient(-45deg, transparent 49%, var(--instrument-muted) 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

@media (max-width: 768px) {
  .archive-instrument--constellation .cc-select { min-height: 44px; }
}

/* --- The sky ---------------------------------------------------------------- */

.archive-instrument--constellation .cc-stage {
  position: relative;
  background: var(--instrument-glass);
  border: 1px solid var(--instrument-rule);
}

.archive-instrument--constellation .cc-sky {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;   /* reserved before data arrives: zero layout shift */
  touch-action: none;
}

.archive-instrument--constellation .cc-sky.cc-sky--panning {
  cursor: grabbing;
}

.archive-instrument--constellation .cc-plate-caption {
  font-family: var(--instrument-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--instrument-ink-faint);
  padding: 8px 12px;
  border-top: 1px solid var(--instrument-rule);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- SVG contents ------------------------------------------------------------ */

.archive-instrument--constellation .cc-graticule line {
  stroke: var(--instrument-rule);
  stroke-width: 0.5;
  opacity: 0.45;
}

.archive-instrument--constellation .cc-graticule text {
  font-family: var(--instrument-font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  fill: var(--instrument-ink-faint);
}

/* Void circle/text paint is inline (constellation.js reads --cc-void-fill and
   the ink tokens via getComputedStyle), so no fill/stroke rules belong here —
   they would be dead against the inline base. Hover/focus feedback comes from
   the void's dedicated .cc-node-focus ring element below. */

.archive-instrument--constellation .cc-void {
  cursor: pointer;
}

.archive-instrument--constellation .cc-void:hover .cc-node-focus {
  opacity: 0.5;
}

.archive-instrument--constellation .cc-edge {
  stroke: var(--instrument-rule);
  stroke-width: 0.8;
  opacity: 0.65;
  fill: none;
}

/* .cc-edge--touched is a state marker only: the touched accent is applied
   inline by highlightEdges(), because edge geometry carries inline base
   styles (for export fidelity) that any class rule here would lose to. */

.archive-instrument--constellation .cc-edge--refuted {
  stroke-dasharray: 3 4;
  stroke: var(--instrument-danger);
  opacity: 0.5;
}

.archive-instrument--constellation .cc-edge--unverified,
.archive-instrument--constellation .cc-edge--contested {
  stroke-dasharray: 2 4;
}

/* Nodes */

.archive-instrument--constellation .cc-node {
  cursor: pointer;
}

/* Node geometry (halo, core, ring, occlusion, strike, stamp) is painted with
   INLINE styles by constellation.js — the register palette above is read via
   getComputedStyle, and inline presentation makes exported plates
   self-contained. CSS below carries interaction states only. Do not add
   fill/stroke rules for node parts here: they would override the inline
   base and break both theming-by-token and exports. */

/* Focus + selection: a visible ring, never a vanished focus.
   Stars and dark regions share the same dedicated indicator element, so the
   ring works even where :focus fails to match (the mirrored class path). */
.archive-instrument--constellation .cc-node .cc-node-focus,
.archive-instrument--constellation .cc-void .cc-node-focus {
  fill: none;
  stroke: var(--instrument-focus);
  stroke-width: 1.4;
  opacity: 0;
}

.archive-instrument--constellation .cc-node:focus .cc-node-focus,
.archive-instrument--constellation .cc-node:focus-visible .cc-node-focus,
.archive-instrument--constellation .cc-node--focused .cc-node-focus,
.archive-instrument--constellation .cc-void:focus .cc-node-focus,
.archive-instrument--constellation .cc-void:focus-visible .cc-node-focus,
.archive-instrument--constellation .cc-void.cc-node--focused .cc-node-focus {
  opacity: 1;
}

.archive-instrument--constellation .cc-node:focus,
.archive-instrument--constellation .cc-node:focus-visible,
.archive-instrument--constellation .cc-void:focus,
.archive-instrument--constellation .cc-void:focus-visible {
  outline: none; /* SVG focus is drawn with .cc-node-focus / void stroke instead */
}

/* Selection recolours the ring via inline style in constellation.js
   (inline geometry styles would defeat a class rule here). */

.archive-instrument--constellation .cc-node--dim {
  opacity: 0.24;
}

.archive-instrument--constellation .cc-node-label {
  font-family: var(--instrument-font-mono);
  font-size: 13px;
  letter-spacing: 0.05em;
  fill: var(--instrument-ink);
  opacity: 0.85;
  /* Labels stay clickable: they are part of the node group, so clicking a
     star's name selects the star. */
}

.archive-instrument--constellation .cc-node-label--minor {
  opacity: 0;
}

.archive-instrument--constellation .cc-node:hover .cc-node-label--minor,
.archive-instrument--constellation .cc-node:focus .cc-node-label--minor,
.archive-instrument--constellation .cc-node:focus-visible .cc-node-label--minor {
  opacity: 0.9;
}

/* Hover/focus shimmer: user-initiated, one run, removed by reduced motion */
@keyframes cc-shimmer {
  0% { opacity: 0.2; }
  45% { opacity: 0.75; }
  100% { opacity: 0.45; }
}

.archive-instrument--constellation .cc-node--uncertain:hover .cc-node-halo,
.archive-instrument--constellation .cc-node--uncertain:focus .cc-node-halo {
  animation: cc-shimmer 620ms ease-out 1;
}

/* Journeys (guide routes): green is traversal-only */

.archive-instrument--constellation .cc-route-path {
  fill: none;
  stroke: var(--instrument-signal);
  stroke-width: 1.6;
  opacity: 0.9;
}

.archive-instrument--constellation .cc-route-path--animating {
  animation: cc-draw 1200ms ease-out 1 forwards;
}

@keyframes cc-draw {
  from { stroke-dashoffset: var(--cc-path-length, 2000); }
  to { stroke-dashoffset: 0; }
}

.archive-instrument--constellation .cc-waypoint circle {
  fill: var(--instrument-glass);
  stroke: var(--instrument-signal);
  stroke-width: 1.2;
}

.archive-instrument--constellation .cc-waypoint text {
  font-family: var(--instrument-font-mono);
  font-size: 11px;
  fill: var(--instrument-signal);
  text-anchor: middle;
  dominant-baseline: central;
}

/* Saved / composed constellations: amber documentary emphasis */

.archive-instrument--constellation .cc-const-path {
  fill: none;
  stroke: var(--instrument-amber-bright);
  stroke-width: 1.4;
  opacity: 0.95;
}

.archive-instrument--constellation .cc-const-path--machine {
  stroke-dasharray: 7 4;
}

.archive-instrument--constellation .cc-const-marker circle {
  fill: var(--instrument-glass);
  stroke: var(--instrument-amber-bright);
  stroke-width: 1.1;
}

.archive-instrument--constellation .cc-const-marker text {
  font-family: var(--instrument-font-mono);
  font-size: 10px;
  fill: var(--instrument-amber-bright);
  text-anchor: middle;
  dominant-baseline: central;
}

/* Paused (offscreen): halt any running path animation */
.archive-instrument--constellation.cc-paused * {
  animation-play-state: paused !important;
}

/* --- Dock ---------------------------------------------------------------------- */

.archive-instrument--constellation .cc-dock {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--instrument-rule) transparent;
}

.archive-instrument--constellation .cc-panel {
  background: var(--instrument-panel);
  border: 1px solid var(--instrument-rule);
  padding: 14px 16px;
}

/* The dock is a sticky bench with its own scroll (see .cc-dock); individual
   panels stay compact so several fit a viewport at once. */
.archive-instrument--constellation .cc-dock .cc-panel {
  flex: 0 0 auto;
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--instrument-rule) transparent;
}

@media (max-width: 900px) {
  .archive-instrument--constellation .cc-dock {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .archive-instrument--constellation .cc-dock .cc-panel {
    max-height: none;
  }
}

.archive-instrument--constellation .cc-panel-h {
  font-family: var(--instrument-font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--instrument-muted);
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.archive-instrument--constellation .cc-panel-h .cc-panel-h-extra {
  color: var(--instrument-amber);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0.06em;
}

.archive-instrument--constellation .cc-dossier-title {
  font-family: var(--instrument-font-serif);
  font-size: 22px;
  font-weight: 400;
  line-height: 1.15;
  margin: 0 0 8px;
  color: var(--instrument-ink);
}

.archive-instrument--constellation .cc-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.archive-instrument--constellation .cc-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 12px;
  font-size: 14px;
}

.archive-instrument--constellation .cc-meta dt {
  font-family: var(--instrument-font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--instrument-muted);
  align-self: center;
}

.archive-instrument--constellation .cc-meta dd {
  margin: 0;
  color: var(--instrument-ink);
}

.archive-instrument--constellation .cc-bar {
  position: relative;
  height: 4px;
  background: var(--instrument-rule);
  min-width: 90px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  width: 60%;
}

.archive-instrument--constellation .cc-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--instrument-amber);
  display: block;
}

.archive-instrument--constellation .cc-dossier-summary {
  font-size: 15px;
  margin: 0 0 10px;
}

.archive-instrument--constellation .cc-dossier-note {
  font-size: 13.5px;
  color: var(--instrument-muted);
  border-left: 2px solid var(--instrument-amber);
  padding-left: 10px;
  margin: 0 0 12px;
}

.archive-instrument--constellation .cc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archive-instrument--constellation .cc-list li {
  font-size: 13.5px;
  line-height: 1.45;
  border-top: 1px solid var(--instrument-rule);
  padding-top: 8px;
}

.archive-instrument--constellation .cc-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.archive-instrument--constellation .cc-rel-verb {
  font-family: var(--instrument-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--instrument-amber);
}

.archive-instrument--constellation .cc-inline-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--instrument-ink);
  text-decoration: underline;
  text-decoration-color: rgba(232, 227, 216, 0.35);
  text-underline-offset: 3px;
  cursor: pointer;
}

.archive-instrument--constellation .cc-inline-btn:hover {
  color: var(--instrument-amber-bright);
}

.archive-instrument--constellation .cc-claim {
  font-size: 13px;
  color: var(--instrument-muted);
  margin: 4px 0 0;
}

.archive-instrument--constellation .cc-claim .cc-claim-id {
  font-family: var(--instrument-font-mono);
  font-size: 11px;
  color: var(--instrument-amber);
}

/* Legend */

.archive-instrument--constellation .cc-legend-grid {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 6px 10px;
  align-items: center;
  font-size: 13px;
}

.archive-instrument--constellation .cc-legend-grid svg {
  display: block;
}

.archive-instrument--constellation .cc-legend-note {
  font-size: 12.5px;
  color: var(--instrument-muted);
  margin: 10px 0 0;
}

/* Machine origin banner: proposals are never allowed to look canonical */

.archive-instrument--constellation .cc-machine-banner {
  font-family: var(--instrument-font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--instrument-ink);
  background: rgba(197, 138, 42, 0.14);
  border: 1px dashed var(--instrument-amber);
  padding: 8px 10px;
  margin: 0 0 12px;
}

/* Compose */

.archive-instrument--constellation .cc-input,
.archive-instrument--constellation .cc-textarea {
  width: 100%;
  font-family: var(--instrument-font-mono);
  font-size: 13px;
  color: var(--instrument-ink);
  background: var(--instrument-glass);
  border: 1px solid var(--instrument-rule);
  padding: 8px 10px;
  margin: 0 0 10px;
}

.archive-instrument--constellation .cc-textarea {
  min-height: 60px;
  resize: vertical;
  font-family: var(--instrument-font-serif);
  font-size: 14px;
}

.archive-instrument--constellation .cc-field-label {
  display: block;
  font-family: var(--instrument-font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--instrument-muted);
  margin: 0 0 4px;
}

.archive-instrument--constellation .cc-compose-hint {
  font-size: 13px;
  color: var(--instrument-muted);
  margin: 0 0 10px;
}

.archive-instrument--constellation .cc-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* --- Fallback text index ---------------------------------------------------------- */

.archive-instrument--constellation .cc-index {
  margin-top: 22px;
  border: 1px solid var(--instrument-rule);
  padding: 0;
}

.archive-instrument--constellation .cc-index-summary {
  font-family: var(--instrument-font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--instrument-muted);
  padding: 12px 16px;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.archive-instrument--constellation .cc-index-summary:hover {
  color: var(--instrument-amber-bright);
}

.archive-instrument--constellation .cc-index[open] .cc-index-summary {
  border-bottom: 1px solid var(--instrument-rule);
}

.archive-instrument--constellation .cc-index-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--instrument-rule);
}

.archive-instrument--constellation .cc-index-section:last-child {
  border-bottom: 0;
}

.archive-instrument--constellation .cc-index-h {
  font-family: var(--instrument-font-mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--instrument-amber);
  font-weight: 400;
  margin: 0 0 8px;
}

.archive-instrument--constellation .cc-index-h3 {
  font-family: var(--instrument-font-serif);
  font-size: 17px;
  font-weight: 400;
  margin: 14px 0 4px;
  color: var(--instrument-ink);
}

.archive-instrument--constellation .cc-index-p {
  font-size: 14px;
  color: var(--instrument-muted);
  max-width: 70ch;
  margin: 0 0 8px;
}

.archive-instrument--constellation .cc-legend-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 0;
  font-size: 13.5px;
}

.archive-instrument--constellation .cc-legend-list dt {
  font-family: var(--instrument-font-mono);
  font-size: 12px;
  color: var(--instrument-ink);
}

.archive-instrument--constellation .cc-legend-list dd {
  margin: 0;
  color: var(--instrument-muted);
}

.archive-instrument--constellation .cc-fallback-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.archive-instrument--constellation .cc-fallback-title {
  display: block;
  color: var(--instrument-ink);
}

.archive-instrument--constellation .cc-fallback-title a,
.archive-instrument--constellation .cc-index a {
  color: var(--instrument-ink);
  text-decoration: underline;
  text-decoration-color: rgba(197, 138, 42, 0.5);
  text-underline-offset: 3px;
}

.archive-instrument--constellation .cc-index a:hover {
  color: var(--instrument-amber-bright);
}

.archive-instrument--constellation .cc-fallback-meta {
  display: block;
  font-family: var(--instrument-font-mono);
  font-size: 12px;
  color: var(--instrument-muted);
  letter-spacing: 0.03em;
}

.archive-instrument--constellation .cc-fallback-summary {
  display: block;
  font-size: 13.5px;
  color: var(--instrument-muted);
}

.archive-instrument--constellation .cc-fallback-note {
  display: block;
  font-size: 13px;
  color: var(--instrument-amber);
}

/* --- Responsive ---------------------------------------------------------------------- */

@media (max-width: 1280px) {
  .archive-instrument--constellation .cc-app {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  }
}

@media (max-width: 900px) {
  .archive-instrument--constellation .cc-app {
    grid-template-columns: 1fr;
  }
  .archive-instrument--constellation .cc-dock {
    order: 2;
  }
}

@media (max-width: 480px) {
  .archive-instrument--constellation .cc-panel { padding: 12px; }
  .archive-instrument--constellation .cc-meta { grid-template-columns: 1fr; gap: 2px; }
  .archive-instrument--constellation .cc-sky { aspect-ratio: 1 / 1; }
}

/* Fullscreen layouts */

.archive-instrument--constellation:fullscreen {
  background: var(--instrument-bg);
  padding: 18px;
  overflow: auto;
}

.archive-instrument--constellation:fullscreen .cc-sky,
.archive-instrument--constellation.ai-fullscreen-fallback .cc-sky {
  aspect-ratio: auto;
  height: min(74vh, 900px);
}
