/* Competency Tree of Life — MVP. RPG talent-tree aesthetic, custom (NOT DSFR). */
:root {
  --bg: #0a0e17;
  --bg-2: #0e1420;
  --panel: #141b2b;
  --panel-2: #1a2334;
  --line: #26304a;
  --line-2: #37456b;
  --ink: #e8ecf5;
  --ink-dim: #9aa6c2;
  --ink-faint: #64708f;
  --gold: #f2c14e;
  --gold-2: #d9a534;
  --amber: #ff9d4d;
  --cyan: #4fd1e0;
  --violet: #a78bfa;
  --green: #5fd39a;
  --red: #ff6b6b;
  --heat-0: #2a3350;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0,0,0,.45);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 20% -10%, #16203a 0%, transparent 55%),
    radial-gradient(900px 600px at 100% 0%, #1a1530 0%, transparent 50%),
    var(--bg);
  font-size: 14px;
  line-height: 1.45;
}
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }

/* ---- header ------------------------------------------------------------ */
header.top {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20,27,43,.9), rgba(10,14,23,.7));
  position: sticky; top: 0; z-index: 40; backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand h1 {
  font-size: 18px; letter-spacing: .3px;
  background: linear-gradient(90deg, var(--gold), var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .tag { font-size: 12px; color: var(--ink-dim); max-width: 620px; }
header.top .spacer { flex: 1; }
.btn {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2);
  padding: 7px 12px; border-radius: 8px; font-size: 12.5px; transition: .15s;
}
.btn:hover { border-color: var(--gold-2); color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #241a00; border: none; font-weight: 650; }
.btn.primary:hover { filter: brightness(1.08); color: #241a00; }
.btn.ghost { background: transparent; }

/* ---- layout ------------------------------------------------------------ */
.layout { display: flex; align-items: flex-start; gap: 0; }
aside.side {
  width: 360px; flex: 0 0 360px; padding: 18px; height: calc(100vh - 59px);
  overflow-y: auto; border-right: 1px solid var(--line);
  position: sticky; top: 59px; background: var(--bg-2);
}
main.tree-wrap { flex: 1; min-width: 0; padding: 18px 20px 60px; overflow-x: auto; }

/* ---- sidebar cards ----------------------------------------------------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .7px; color: var(--gold); margin-bottom: 10px; }
.card h3 .sub { text-transform: none; letter-spacing: 0; color: var(--ink-faint); font-weight: 400; font-size: 11px; }

/* budget HUD */
.budget-main { display: flex; align-items: baseline; gap: 8px; }
.budget-main .big { font-size: 30px; font-weight: 700; color: var(--gold); font-variant-numeric: tabular-nums; }
.budget-main .of { color: var(--ink-dim); font-size: 15px; }
.budget-bar { height: 9px; border-radius: 6px; background: #0c1120; overflow: hidden; margin: 9px 0 6px; border: 1px solid var(--line); }
.budget-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--amber)); transition: width .25s; }
.budget-bar.over > span { background: linear-gradient(90deg, var(--red), #ff9b9b); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-dim); }
.chip.good { color: var(--green); border-color: #2f5f48; }
.chip.credit { color: var(--cyan); border-color: #245a63; }

/* stage select */
select.stage {
  width: 100%; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.switch { position: relative; width: 40px; height: 22px; flex: 0 0 40px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-sw { position: absolute; inset: 0; background: #2a3350; border-radius: 22px; transition: .2s; border: 1px solid var(--line-2); }
.slider-sw::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 2px; background: #cfd7ea; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider-sw { background: var(--gold-2); }
.switch input:checked + .slider-sw::before { transform: translateX(18px); background: #241a00; }
.toggle-row .lbl { font-size: 12.5px; }
.toggle-row .hint { font-size: 11px; color: var(--ink-faint); }

/* interest sliders */
.interest-grid { display: grid; gap: 9px; }
.i-row { display: grid; grid-template-columns: 96px 1fr 30px; align-items: center; gap: 8px; }
.i-row label { font-size: 11.5px; color: var(--ink-dim); }
.i-row output { font-size: 11px; color: var(--gold); text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 5px; border-radius: 4px; background: linear-gradient(90deg, var(--heat-0), var(--amber)); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 2px solid #241a00; cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); border: 2px solid #241a00; cursor: pointer; }

/* radial build chart */
.radial-wrap { display: flex; flex-direction: column; align-items: center; }
.build-name { text-align: center; margin-top: 8px; }
.build-name .nm { font-size: 17px; font-weight: 700; color: var(--gold); }
.build-name .dis { font-size: 10.5px; color: var(--ink-faint); font-style: italic; margin-top: 3px; line-height: 1.35; }
.build-name .empty { color: var(--ink-dim); font-size: 12.5px; }

/* tradeoff meters */
.meter { margin-top: 6px; }
.meter .lab { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-dim); margin-bottom: 3px; }
.meter .lab b { color: var(--ink); }
.meter .track { height: 7px; border-radius: 5px; background: #0c1120; border: 1px solid var(--line); overflow: hidden; }
.meter .fill { height: 100%; }
.meter.depth .fill { background: linear-gradient(90deg, var(--violet), #d6b3ff); }
.meter.breadth .fill { background: linear-gradient(90deg, var(--cyan), #a6f0f8); }

/* about list */
.about li { font-size: 11.5px; color: var(--ink-dim); margin-bottom: 5px; }
.about ul { margin: 0; padding-left: 16px; }

/* ---- trunk ------------------------------------------------------------- */
.section-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.section-title h2 { font-size: 13px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gold); }
.section-title .hint { font-size: 11.5px; color: var(--ink-faint); }
.trunk-band {
  background: linear-gradient(180deg, rgba(26,35,52,.6), rgba(20,27,43,.35));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 18px;
}
.trunk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }

/* ---- node card --------------------------------------------------------- */
.node {
  position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 9px; transition: border-color .15s, box-shadow .15s, transform .1s;
}
.node.heat { box-shadow: 0 0 0 1px rgba(255,157,77,.0); }
.node:hover { transform: translateY(-1px); }
.node.buyable { border-color: var(--line-2); }
.node.invested { border-color: var(--gold-2); }
.node.invested::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 3px; background: linear-gradient(180deg, var(--gold), var(--amber));
}
.node.locked { opacity: .5; }
.node.dormant { opacity: .6; border-style: dashed; }
.node .nlabel { font-size: 12.5px; font-weight: 600; line-height: 1.25; padding-right: 4px; }
.node .nmeta { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.k-tag { font-size: 9.5px; padding: 1px 5px; border-radius: 10px; border: 1px solid var(--line-2); color: var(--ink-faint); }
.k-routine { color: #8fb3c9; } .k-technical { color: #8fd3a0; } .k-complex { color: #c9a6ff; } .k-wicked { color: #ff9d9d; }

/* rank pips */
.pips { display: flex; gap: 3px; margin: 7px 0 6px; flex-wrap: wrap; }
.pip { width: 12px; height: 12px; border-radius: 3px; background: #0c1120; border: 1px solid var(--line-2); }
.pip.on { background: linear-gradient(180deg, var(--gold), var(--gold-2)); border-color: var(--gold-2); box-shadow: 0 0 6px rgba(242,193,78,.4); }
.pip.vestige { background: #2c3550; border-color: var(--line-2); }

/* node footer / actions */
.nfoot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
.cost-now { font-size: 11px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.cost-now b { color: var(--gold); }
.nbtns { display: flex; gap: 4px; }
.nbtn {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--ink); font-size: 15px; line-height: 1;
  display: grid; place-items: center; transition: .12s;
}
.nbtn:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.nbtn.buy:hover:not(:disabled) { background: rgba(242,193,78,.14); }
.nbtn:disabled { opacity: .3; cursor: not-allowed; }
.lock-reason { font-size: 10.5px; color: var(--red); margin-top: 5px; line-height: 1.3; }

/* badges */
.badge { font-size: 9px; padding: 1px 6px; border-radius: 10px; font-weight: 650; letter-spacing: .3px; text-transform: uppercase; }
.badge.seed { background: rgba(167,139,250,.16); color: var(--violet); border: 1px solid #4b3a7a; }
.badge.authored { background: rgba(95,211,154,.14); color: var(--green); border: 1px solid #2f5f48; }
.badge.comp { background: rgba(79,209,224,.14); color: var(--cyan); border: 1px solid #245a63; }
.badge.scaf { background: rgba(255,157,77,.14); color: var(--amber); border: 1px solid #6b4526; }

/* heat ring intensities (data-heat 0..5) */
.node[data-heat="1"] { box-shadow: 0 0 0 1px rgba(255,157,77,.10); }
.node[data-heat="2"] { box-shadow: 0 0 8px rgba(255,157,77,.14), 0 0 0 1px rgba(255,157,77,.18); }
.node[data-heat="3"] { box-shadow: 0 0 12px rgba(255,157,77,.22), 0 0 0 1px rgba(255,157,77,.28); }
.node[data-heat="4"] { box-shadow: 0 0 16px rgba(255,157,77,.30), 0 0 0 1px rgba(255,157,77,.40); }
.node[data-heat="5"] { box-shadow: 0 0 22px rgba(255,138,61,.42), 0 0 0 1px rgba(255,138,61,.55); }

/* ---- domains as columns ----------------------------------------------- */
.domains-scroll { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 10px; }
.domain-col { flex: 0 0 236px; width: 236px; background: rgba(20,27,43,.5); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.domain-col.locked-domain { opacity: .92; }
.dhead { margin-bottom: 10px; }
.dhead .dtitle { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.dhead .dname { font-size: 13.5px; font-weight: 700; }
.dhead .den { font-size: 10.5px; color: var(--ink-faint); }
.dhead .ddesc { font-size: 10.5px; color: var(--ink-dim); margin-top: 4px; line-height: 1.35; min-height: 28px; }

/* immersion track */
.imm { margin: 10px 0 12px; }
.imm .immhead { display: flex; justify-content: space-between; align-items: center; font-size: 10.5px; color: var(--ink-dim); margin-bottom: 5px; }
.imm .immval { color: var(--cyan); font-weight: 650; font-variant-numeric: tabular-nums; }
.imm-bar { position: relative; height: 12px; border-radius: 7px; background: #0a0f1c; border: 1px solid var(--line); overflow: visible; }
.imm-bar .immfill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 7px; background: linear-gradient(90deg, #2a7d8c, var(--cyan)); box-shadow: 0 0 8px rgba(79,209,224,.5); transition: width .2s; }
.gate-tick { position: absolute; top: -3px; width: 2px; height: 18px; background: var(--line-2); }
.gate-tick.passed { background: var(--gold); box-shadow: 0 0 5px var(--gold); }
.gate-lab { position: absolute; top: 15px; font-size: 8.5px; color: var(--ink-faint); transform: translateX(-50%); }
.gate-lab.passed { color: var(--gold); }
.imm-btns { display: flex; gap: 5px; margin-top: 20px; }
.imm-btns .nbtn { width: 26px; height: 22px; }
.imm-hint { font-size: 9.5px; color: var(--ink-faint); margin-top: 4px; }

/* tier rows */
.tier { position: relative; margin-bottom: 8px; }
.tier-lab { font-size: 9px; letter-spacing: .5px; color: var(--ink-faint); text-transform: uppercase; margin: 8px 0 5px; display: flex; align-items: center; gap: 6px; }
.tier-lab .gatechip { font-size: 8.5px; padding: 0 5px; border-radius: 8px; border: 1px solid var(--line-2); }
.tier-lab .gatechip.open { color: var(--gold); border-color: var(--gold-2); }
.tier-lab .gatechip.shut { color: var(--ink-faint); }
.tier-nodes { display: grid; gap: 7px; }

/* svg edge overlay inside a column */
.domain-col { position: relative; }
.edge-svg { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.edge-svg path { fill: none; }
.edge-prereq { stroke: var(--line-2); stroke-width: 1.5; }
.edge-prereq.active { stroke: var(--gold-2); stroke-width: 2; }
.domain-col .tier, .trunk-grid { position: relative; z-index: 2; }

/* toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--gold-2); color: var(--gold);
  padding: 9px 16px; border-radius: 8px; opacity: 0; transition: .25s; z-index: 80; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* synergy hint under a node */
.syn-line { font-size: 10px; color: var(--cyan); margin-top: 5px; line-height: 1.3; display: flex; gap: 4px; }
.syn-line .ic { color: var(--cyan); }

/* responsive */
@media (max-width: 1000px) {
  .layout { flex-direction: column; }
  aside.side { width: 100%; flex-basis: auto; position: static; height: auto; border-right: none; border-bottom: 1px solid var(--line); }
  main.tree-wrap { width: 100%; }
}

/* ===== Life-span (developmental) mechanic (§3.3.9) ===================== */
/* --- age-cursor timeline --- */
.timeline { display: flex; gap: 4px; margin: 2px 0 8px; }
.tl-seg {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 6px 3px; border-radius: 7px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink-dim);
  transition: .15s; position: relative;
}
.tl-seg:hover { border-color: var(--gold-2); color: var(--gold); }
.tl-seg .tl-name { font-size: 10px; line-height: 1.15; text-align: center; letter-spacing: .2px; }
.tl-seg .tl-pts { font-size: 9.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.tl-seg.active { border-color: var(--gold); color: var(--gold); background: rgba(242,193,78,.10); box-shadow: 0 0 0 1px var(--gold) inset; }
.tl-seg.active .tl-pts { color: var(--gold-2); }
/* age gradient cue: young=cyan(plastic) → old=amber(crystallized) */
.tl-seg.tl-wholelife .tl-name { color: var(--violet); }
.tl-seg.tl-growth::after, .tl-seg.tl-exploration::after,
.tl-seg.tl-maintenance::after, .tl-seg.tl-transmission::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: 2px; height: 2px; border-radius: 2px; opacity: .55;
}
.tl-seg.tl-growth::after, .tl-seg.tl-exploration::after { background: var(--cyan); }
.tl-seg.tl-maintenance::after, .tl-seg.tl-transmission::after { background: var(--amber); }
.tl-econ { font-size: 11px; color: var(--ink-faint); line-height: 1.35; padding: 4px 2px 2px; min-height: 30px; }
.tl-econ.on { color: var(--ink-dim); }

/* --- trajectory band (ranks by age of acquisition) --- */
.traj { margin-top: 12px; }
.traj-lab { font-size: 11px; color: var(--ink-dim); margin-bottom: 5px; }
.traj-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line-2); background: var(--panel-2); }
.traj-bar .tb { height: 100%; transition: width .25s; }
.traj-bar .tb.young { background: linear-gradient(90deg, var(--cyan), #6fe3ef); }
.traj-bar .tb.mid { background: linear-gradient(90deg, var(--gold), var(--gold-2)); }
.traj-bar .tb.old { background: linear-gradient(90deg, var(--amber), #ffb877); }
.traj-key { display: flex; gap: 12px; margin-top: 5px; font-size: 10.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.traj-key .k.young { color: var(--cyan); }
.traj-key .k.mid { color: var(--gold); }
.traj-key .k.old { color: var(--amber); }

/* --- node foundation badges --- */
.badge.fd-young { background: rgba(79,209,224,.14); color: var(--cyan); border: 1px solid #245a63; }
.badge.fd-mid { background: rgba(242,193,78,.12); color: var(--gold); border: 1px solid #6b5626; }
.badge.fd-late { background: rgba(255,107,107,.14); color: var(--red); border: 1px solid #6b2f2f; }
.badge.fd-open { background: rgba(95,211,154,.12); color: var(--green); border: 1px solid #2f5f48; }
.badge.fd-closed { background: rgba(100,112,143,.16); color: var(--ink-faint); border: 1px solid var(--line-2); }

/* --- age cost indicator + meta-learning line --- */
.age-ind { font-size: 10px; margin-left: 3px; font-weight: 700; }
.age-ind.cheap { color: var(--cyan); }
.age-ind.dear { color: var(--red); }
.meta-line { font-size: 10px; color: var(--green); margin-top: 4px; line-height: 1.3; display: flex; gap: 4px; }
.meta-line .ic { color: var(--green); }
