/* ==========================================================================
   Constellation graph (characters as stars, relationships as light-lines)
   ========================================================================== */

.constellation {
  position: absolute; inset: 0;
  background:
    radial-gradient(130% 100% at 50% -10%, var(--night-raised), var(--night));
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.constellation.is-panning,
.constellation:active { cursor: grabbing; }
.constellation::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,.5), transparent 60%),
    radial-gradient(1.3px 1.3px at 70% 30%, rgba(231,201,116,.5), transparent 60%),
    radial-gradient(1px 1px at 40% 75%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1.2px 1.2px at 88% 68%, rgba(231,201,116,.45), transparent 60%),
    radial-gradient(1px 1px at 25% 55%, rgba(255,255,255,.35), transparent 60%);
  opacity: .7;
}

.constellation svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: none;
}
.constellation-hit { pointer-events: all; }

/* edges */
.edge { stroke: var(--night-line); stroke-width: 1.4; transition: stroke .2s, stroke-width .2s; }
.edge.is-active { stroke: var(--gold); stroke-width: 2; }
.edge-hit { stroke: transparent; stroke-width: 16; cursor: pointer; }
.edge-label {
  font-family: var(--font-ui); font-size: 10px; fill: var(--night-text-soft);
  paint-order: stroke; stroke: var(--night); stroke-width: 3px;
  text-anchor: middle; pointer-events: none;
}
/* Marker tip: open trail + star. context-stroke tracks the edge (incl. active gold). */
.edge-arrow {
  fill: none;
  stroke: var(--night-line);
  stroke: context-stroke;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.edge-arrow-star {
  fill: var(--night-line);
  fill: context-stroke;
}

/* nodes */
.node { cursor: pointer; }
.node__halo { fill: var(--gold-glow); opacity: 0; transition: opacity .25s; }
.node:hover .node__halo, .node.is-selected .node__halo { opacity: 1; }
.node__star { fill: url(#nodeStar); transition: transform .2s; transform-box: fill-box; transform-origin: center; }
.node:hover .node__star { transform: scale(1.12); }
.node.is-protagonist .node__ring { stroke: var(--gold-bright); stroke-width: 2; fill: none; }
.node.is-ai .node__ring { stroke: var(--ai-accent); stroke-width: 2; fill: none; stroke-dasharray: 3 3; }
.node__label {
  font-family: var(--font-display); font-size: 15px; font-weight: 600;
  fill: var(--night-text); text-anchor: middle;
  paint-order: stroke; stroke: var(--night); stroke-width: 4px;
}
.node.is-selected .node__label { fill: var(--gold-bright); }
.node__role {
  font-family: var(--font-ui); font-size: 10px; fill: var(--night-text-soft);
  text-anchor: middle; paint-order: stroke; stroke: var(--night); stroke-width: 3px;
}

/* floating hint + controls over the canvas */
.canvas-hud {
  position: absolute; left: 16px; top: 14px; z-index: 2;
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
.canvas-hud h3 { color: var(--night-text); font-size: 20px; }
.canvas-hud p { color: var(--night-text-soft); font-family: var(--font-ui); font-size: 12px; margin: 0; }

.canvas-actions {
  position: absolute; right: 16px; top: 14px; z-index: 2;
  display: flex; gap: 8px;
}
.canvas-legend {
  position: absolute; left: 16px; bottom: 14px; z-index: 2;
  display: flex; gap: 16px; flex-wrap: wrap;
  background: rgba(23,29,51,.6); border: 1px solid var(--night-line);
  border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(4px);
  pointer-events: none;
}
.canvas-legend .lg {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 11px; color: var(--night-text-soft);
}
.canvas-legend .swatch { width: 12px; height: 12px; border-radius: 50%; }
.canvas-legend .swatch.proto { border: 2px solid var(--gold-bright); }
.canvas-legend .swatch.ai { border: 2px dashed var(--ai-accent); }
.canvas-legend .swatch.star { background: var(--gold); }

.constellation-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 2; text-align: center; padding: 24px;
}
.constellation-empty .empty h2 { color: var(--night-text); }
.constellation-empty .empty p { color: var(--night-text-soft); }

/* Outfit sub-grid in character editor */
.outfit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.subsection {
  border: 1px dashed var(--parchment-edge); border-radius: 12px;
  padding: 14px; margin: 6px 0 16px;
}
.subsection > legend, .subsection > .subhead {
  font-family: var(--font-ui); font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--gold-deep); padding: 0 6px;
}

/* ==========================================================================
   Entry tree (generation constellation)
   ========================================================================== */
.modal--wide:has(.etree-shell) { max-width: min(1100px, 96vw); width: 96vw; }
.modal__body--etree { padding: 0 !important; overflow: hidden !important; max-height: min(72vh, 640px); }

.etree-shell {
  display: grid; grid-template-columns: 1.4fr 1fr; min-height: min(68vh, 600px);
}
.etree-main { position: relative; min-height: 420px; background: #a98c58; }
/* An aged astrologer's chart: darker, more stained parchment than the editor.
   Reuses the shared paper fibre/grain/stain noise over a deep tan base, then a
   heavy corner vignette so the sheet reads as old, weathered vellum. */
.etree-canvas, .entry-tree {
  position: absolute; inset: 0;
  background-color: #b69a67;
  background-image:
    var(--paper-fibre),
    var(--paper-grain),
    var(--paper-stain),
    radial-gradient(115% 105% at 50% 40%, rgba(224, 201, 150, 0.5), rgba(150, 116, 60, 0) 55%),
    radial-gradient(150% 138% at 50% 46%, transparent 28%, rgba(86, 61, 27, 0.52) 74%, rgba(46, 31, 13, 0.8) 100%),
    radial-gradient(42% 36% at 9% 11%, rgba(64, 43, 18, 0.36), transparent 60%),
    radial-gradient(40% 36% at 92% 90%, rgba(56, 37, 15, 0.42), transparent 60%),
    linear-gradient(180deg, rgba(46, 31, 13, 0.36), transparent 15%, transparent 85%, rgba(46, 31, 13, 0.42));
  background-size: 240px 240px, 140px 140px, 700px 700px, auto, auto, auto, auto, auto;
  background-repeat: repeat, repeat, repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
  overflow: hidden; cursor: grab;
  touch-action: none;
}
.entry-tree:active,
.entry-tree.is-panning { cursor: grabbing; }
/* Faint dark flecks / foxing spots instead of bright stars. */
.entry-tree::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 18% 22%, rgba(58, 39, 17, .34), transparent 60%),
    radial-gradient(1.2px 1.2px at 72% 34%, rgba(70, 48, 20, .28), transparent 60%),
    radial-gradient(1.7px 1.7px at 44% 78%, rgba(50, 33, 13, .3), transparent 60%),
    radial-gradient(1.2px 1.2px at 84% 66%, rgba(60, 40, 18, .26), transparent 60%);
  opacity: .5;
}
.entry-tree svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: none;
}
.etree-hit {
  pointer-events: all;
  touch-action: none;
}

.etree-edge {
  stroke: rgba(52, 35, 15, .58); stroke-width: 1.2;
  stroke-linecap: round;
  filter: url(#etreeSketch); /* hand-drawn wobble */
  pointer-events: none; /* edges aren't interactive — leave sky free for pan */
}
.etree-edge.is-active {
  stroke: var(--gold-deep); stroke-width: 1.9;
  filter: url(#etreeSketch) drop-shadow(0 1px 1px rgba(50, 34, 14, .3));
}

.etree-node { cursor: pointer; }
.etree-halo {
  fill: rgba(199, 155, 67, .3); opacity: 0; transition: opacity .2s;
  transform-box: fill-box; transform-origin: center;
}
.etree-node:hover .etree-halo, .etree-node.is-selected .etree-halo { opacity: 1; }
.etree-ring { stroke: transparent; stroke-width: 1.4; filter: url(#etreeSketchStar); }
.etree-node.is-head .etree-ring { stroke: var(--gold-deep); }
.etree-node.is-selected .etree-ring { stroke: var(--gold-deep); stroke-width: 2; }
.etree-node.is-root { cursor: pointer; }
.etree-node.is-root .etree-halo--root { fill: rgba(154, 122, 47, 0.26); opacity: 1; }
.etree-node.is-root.is-selected .etree-halo--root { fill: rgba(199, 155, 67, .4); opacity: 1; }
.etree-node.is-root .etree-ring--root {
  stroke: var(--gold-deep); stroke-width: 1.5; stroke-dasharray: 3 4;
  opacity: 0.9;
}
.etree-node.is-root .etree-label--root {
  fill: var(--gold-deep); font-weight: 700; letter-spacing: .06em;
}
/* Doodle stars: each node draws a one-stroke pentagram (see handStarPath in
   entryTree.js) with its own random jitter, inked in a single roughened stroke
   so no two look alike — like stars scrawled by hand across the chart. */
.etree-star {
  fill: none;
  stroke: rgba(74, 52, 24, .82); stroke-width: 1.7;
  stroke-linejoin: round; stroke-linecap: round;
  filter: url(#etreeSketchStar);
  transition: transform .2s; transform-box: fill-box; transform-origin: center;
}
.etree-node:hover .etree-star { transform: scale(1.12); }
.etree-node.is-active .etree-star { stroke: var(--gold-deep); }
.etree-node.is-root .etree-star--root { stroke: var(--gold-deep); stroke-width: 2; }
.etree-node.is-root:hover .etree-star--root { transform: scale(1.08); }
/* Current entry (head) glows brightly and radiates a soft, pulsing ring. */
.etree-node.is-head .etree-halo {
  fill: rgba(231, 201, 116, .5); opacity: 1;
  animation: etree-radiate 1.9s ease-out infinite;
}
.etree-node.is-head .etree-star {
  stroke: var(--gold-bright); stroke-width: 2;
  filter: url(#etreeSketchStar)
    drop-shadow(0 0 5px rgba(231, 201, 116, 1))
    drop-shadow(0 0 12px rgba(199, 162, 75, .9));
  animation: etree-head-glow 1.9s ease-in-out infinite;
}
@keyframes etree-radiate {
  0%   { transform: scale(.55); opacity: .6; }
  70%  { opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}
@keyframes etree-head-glow {
  0%, 100% {
    filter: url(#etreeSketchStar)
      drop-shadow(0 0 4px rgba(231, 201, 116, .9))
      drop-shadow(0 0 9px rgba(199, 162, 75, .6));
  }
  50% {
    filter: url(#etreeSketchStar)
      drop-shadow(0 0 7px rgba(231, 201, 116, 1))
      drop-shadow(0 0 18px rgba(199, 162, 75, .95));
  }
}
.etree-label {
  font-family: var(--font-display); font-size: 12.5px; font-weight: 600; fill: var(--ink-soft);
  text-anchor: middle; paint-order: stroke; stroke: rgba(228, 208, 162, .85); stroke-width: 3px;
}
.etree-node.is-active .etree-label { fill: var(--ink); }
.etree-node.is-head .etree-label { fill: var(--gold-deep); }
.etree-tip {
  font-family: var(--font-ui); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  fill: var(--gold-deep); text-anchor: middle;
  paint-order: stroke; stroke: rgba(228, 208, 162, .85); stroke-width: 3px;
}

.etree-hud {
  position: absolute; left: 16px; top: 14px; z-index: 2; pointer-events: none;
}
.etree-hud h3 { color: var(--ink); font-family: var(--font-display); font-size: 20px; margin: 0; }
.etree-hud p { color: var(--ink-soft); font-family: var(--font-ui); font-size: 12px; margin: 4px 0 0; max-width: 280px; }
/* Legend / status read as little parchment cartouches pinned to the chart. */
.etree-legend {
  position: absolute; left: 16px; bottom: 14px; z-index: 2;
  display: flex; gap: 14px; flex-wrap: wrap;
  background: rgba(233, 216, 175, .85); border: 1px solid var(--parchment-edge);
  border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(2px);
  box-shadow: 0 2px 8px rgba(50, 34, 14, .28);
}
.etree-legend .lg {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 11px; color: var(--ink-soft);
}
.etree-legend .swatch { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(46, 30, 12, .5); }
.etree-legend .swatch.active { background: var(--gold); }
.etree-legend .swatch.branch { background: #8a6a34; }
.etree-legend .swatch.head { border: 2px solid var(--gold-deep); background: transparent; }
.etree-legend .swatch.root {
  background: radial-gradient(circle, #f2e2b0 0%, var(--gold) 45%, var(--gold-deep) 100%);
}
.etree-status {
  position: absolute; right: 16px; bottom: 14px; z-index: 2;
  font-family: var(--font-ui); font-size: 11px; color: var(--ink-soft);
  background: rgba(233, 216, 175, .85); border: 1px solid var(--parchment-edge);
  border-radius: 10px; padding: 6px 10px;
  box-shadow: 0 2px 8px rgba(50, 34, 14, .28);
}
.etree-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  color: var(--ink-soft); z-index: 3;
}

/* Detail side panel: a touch more aged than the editor's parchment. */
.etree-detail {
  padding: 20px 22px; overflow-y: auto;
  background-color: var(--parchment-sunk);
  background-image: var(--paper-fibre), var(--paper-grain);
  background-size: 240px 240px, 140px 140px;
  background-repeat: repeat, repeat;
  border-left: 1px solid #c3aa7c;
}
.etree-detail__empty {
  height: 100%; min-height: 200px; display: flex; align-items: center; justify-content: center;
  color: var(--ink-faint); text-align: center; padding: 24px;
}
.etree-detail__head { display: flex; flex-wrap: wrap; gap: 6px; }
.etree-detail__prose {
  font-family: var(--font-body); font-size: 15px; line-height: 1.55; color: var(--ink);
  margin: 0; white-space: pre-wrap;
}
.etree-detail__actions { margin-top: 18px; display: flex; gap: 8px; }

@media (max-width: 820px) {
  .etree-shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .etree-main { min-height: 360px; }
  .etree-detail { border-left: none; border-top: 1px solid var(--parchment-edge); max-height: 240px; }
}

/* ==========================================================================
   LEGACY — original night-sky story constellation (superseded by the aged
   astrologer's-parchment look above). Kept for reference / easy rollback:
   restore by replacing the corresponding rules above with these, and revert
   the treeStar / treeStarDim / treeRootStar gradient stops in entryTree.js
   (see the note there). Not active.
   ==========================================================================

.etree-main { position: relative; min-height: 420px; background: var(--night); }
.etree-canvas, .entry-tree {
  position: absolute; inset: 0;
  background:
    radial-gradient(130% 100% at 50% -10%, var(--night-raised), var(--night));
  overflow: hidden; cursor: grab;
  touch-action: none;
}
.entry-tree::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 18% 22%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1.2px 1.2px at 72% 34%, rgba(231,201,116,.4), transparent 60%),
    radial-gradient(1px 1px at 44% 78%, rgba(255,255,255,.35), transparent 60%);
  opacity: .65;
}

.etree-edge {
  stroke: rgba(88, 100, 140, .45); stroke-width: 1.5;
  pointer-events: none;
}
.etree-edge.is-active {
  stroke: var(--gold); stroke-width: 2.2;
  filter: drop-shadow(0 0 4px var(--gold-glow));
}

.etree-halo { fill: var(--gold-glow); opacity: 0; transition: opacity .2s; }
.etree-ring { stroke: transparent; stroke-width: 1.5; }
.etree-node.is-head .etree-ring { stroke: var(--gold-bright); }
.etree-node.is-selected .etree-ring { stroke: var(--gold-bright); stroke-width: 2; }
.etree-node.is-root .etree-halo--root { fill: rgba(231, 201, 116, 0.22); opacity: 1; }
.etree-node.is-root.is-selected .etree-halo--root { fill: var(--gold-glow); opacity: 1; }
.etree-node.is-root .etree-ring--root {
  stroke: var(--gold-bright); stroke-width: 1.5; stroke-dasharray: 3 4;
  opacity: 0.85;
}
.etree-node.is-root .etree-star--root {
  filter: drop-shadow(0 0 6px rgba(231, 201, 116, 0.55));
}
.etree-node.is-root .etree-label--root {
  fill: var(--gold-bright); font-weight: 700; letter-spacing: .06em;
}
.etree-star { transition: transform .2s; transform-box: fill-box; transform-origin: center; }
.etree-label {
  font-family: var(--font-ui); font-size: 11px; fill: var(--night-text-soft);
  text-anchor: middle; paint-order: stroke; stroke: var(--night); stroke-width: 3px;
}
.etree-node.is-active .etree-label { fill: var(--gold-bright); }
.etree-tip {
  font-family: var(--font-ui); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  fill: var(--gold-bright); text-anchor: middle;
  paint-order: stroke; stroke: var(--night); stroke-width: 3px;
}

.etree-hud h3 { color: var(--night-text); font-size: 18px; margin: 0; }
.etree-hud p { color: var(--night-text-soft); font-family: var(--font-ui); font-size: 12px; margin: 4px 0 0; max-width: 280px; }
.etree-legend {
  position: absolute; left: 16px; bottom: 14px; z-index: 2;
  display: flex; gap: 14px; flex-wrap: wrap;
  background: rgba(23,29,51,.65); border: 1px solid var(--night-line);
  border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(4px);
}
.etree-legend .lg {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 11px; color: var(--night-text-soft);
}
.etree-legend .swatch { width: 12px; height: 12px; border-radius: 50%; }
.etree-legend .swatch.active { background: var(--gold); box-shadow: 0 0 8px var(--gold-glow); }
.etree-legend .swatch.branch { background: #8a94b0; }
.etree-legend .swatch.head { border: 2px solid var(--gold-bright); background: transparent; }
.etree-legend .swatch.root {
  background: radial-gradient(circle, #fff8e8 0%, var(--gold-bright) 45%, var(--gold-deep) 100%);
  box-shadow: 0 0 8px var(--gold-glow);
}
.etree-status {
  position: absolute; right: 16px; bottom: 14px; z-index: 2;
  font-family: var(--font-ui); font-size: 11px; color: var(--night-text-soft);
  background: rgba(23,29,51,.65); border: 1px solid var(--night-line);
  border-radius: 10px; padding: 6px 10px;
}
.etree-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  color: var(--night-text-soft); z-index: 3;
}
.etree-detail {
  padding: 20px 22px; overflow-y: auto; background: var(--parchment);
  border-left: 1px solid var(--parchment-edge);
}

   ========================================================================== */
