/* ── tree.css — The Rooted Life: one organism, canopy above, roots below ── */

.tree-stage {
  position:relative;
  background:
    radial-gradient(120% 70% at 50% 8%,  var(--canopy-050) 0%, transparent 60%),
    radial-gradient(120% 70% at 50% 96%, var(--root-050)   0%, transparent 60%),
    var(--paper);
  border-bottom:1px solid var(--line);
  overflow:hidden;
}
.tree-stage.full { min-height:100svh; display:grid; place-items:center; }

.tree-svg { display:block; width:100%; height:auto; max-height:88svh; margin:0 auto; }

/* ── Trunk ──────────────────────────────────────────────────────────────── */
.t-trunk { fill:url(#trunkGrad); }

/* ── Limbs (boughs + roots share the mechanics) ─────────────────────────── */
.limb { fill:none; stroke-linecap:round; transition:stroke .35s var(--ease), opacity .35s var(--ease); }
.limb-bough { stroke:var(--canopy-500); opacity:.5; }
.limb-root  { stroke:var(--root-500);   opacity:.5; }

.limb-hit { fill:none; stroke:transparent; stroke-width:44; cursor:pointer; pointer-events:stroke; }

/* Sap: a gold overlay drawn along the limb, revealed by dashoffset. */
.sap { fill:none; stroke:var(--sap); stroke-linecap:round; opacity:0;
  stroke-dasharray:var(--len) var(--len); stroke-dashoffset:var(--len);
  filter:drop-shadow(0 0 5px color-mix(in srgb,var(--sap) 55%,transparent)); }

/* ── Tips: the labelled ends ────────────────────────────────────────────── */
.tip { cursor:pointer; }
.tip-dot { fill:var(--card); stroke-width:2.5; transition:r .3s var(--ease), fill .3s var(--ease); }
.tip-bough .tip-dot{ stroke:var(--canopy-500); }
.tip-root  .tip-dot{ stroke:var(--root-500); }

.tip-label { font-family:var(--font-body); font-size:19px; font-weight:600;
  fill:var(--ink); transition:fill .3s var(--ease); paint-order:stroke;
  stroke:var(--paper); stroke-width:5px; stroke-linejoin:round; }
.tip-sub { font-family:var(--font-body); font-size:13px; fill:var(--ink-3);
  paint-order:stroke; stroke:var(--paper); stroke-width:4px; stroke-linejoin:round; }

/* ── Active / dimmed states ─────────────────────────────────────────────── */
.tree-svg.has-focus .limb   { opacity:.16; }
.tree-svg.has-focus .tip    { opacity:.34; }
.tree-svg.has-focus .lit    { opacity:1; }
.tree-svg.has-focus .lit-2  { opacity:.62; }

.limb.lit   { stroke-width:calc(var(--w) * 1.18); }
.limb-bough.lit { stroke:var(--canopy-700); }
.limb-root.lit  { stroke:var(--root-700); }
:root[data-theme="dark"] .limb-bough.lit{ stroke:var(--canopy-300); }
:root[data-theme="dark"] .limb-root.lit { stroke:var(--root-300); }

.tip.lit .tip-dot{ fill:var(--sap-core); r:11; }
.tip.lit .tip-label{ fill:var(--ink); }

.sap.flow { opacity:.95; animation:sapUp 1.25s var(--ease) forwards; }
@keyframes sapUp { from{ stroke-dashoffset:var(--len); } to{ stroke-dashoffset:0; } }

/* Idle breath — a slow pulse through the whole organism. */
.tree-svg:not(.has-focus) .sap-idle { opacity:.5; animation:idleSap 9s linear infinite; }
@keyframes idleSap {
  0%   { stroke-dashoffset:var(--len); opacity:0; }
  22%  { opacity:.45; }
  72%  { opacity:.28; }
  100% { stroke-dashoffset:0; opacity:0; }
}

/* ── Soil line — "today" ────────────────────────────────────────────────── */
.soil-line { stroke:var(--soil); stroke-width:1.25; opacity:.32; stroke-dasharray:2 7; }
.soil-glow { fill:url(#soilGrad); }
.soil-cap  { font-family:var(--font-body); font-size:12px; letter-spacing:.16em;
  text-transform:uppercase; fill:var(--ink-3); }

/* ── The still point — where the trunk meets the soil ───────────────────── */
.still { cursor:pointer; }
.still-halo { fill:var(--sap); opacity:.10; transition:opacity .4s var(--ease), r .4s var(--ease); }
.still-ring { fill:none; stroke:var(--sap); stroke-width:1.4; opacity:.5;
  transition:opacity .4s var(--ease), r .4s var(--ease); }
.still-core { fill:var(--sap); opacity:.9; }
.still:hover .still-halo, .still:focus .still-halo { opacity:.24; r:36; }
.still:hover .still-ring, .still:focus .still-ring { opacity:.9; r:21; }
.still:focus { outline:none; }
.still:focus .still-core { fill:var(--sap-deep); }

/* It breathes, slowly, and never stops — the one thing always available. */
.still-ring { animation:stillBreath 7.5s ease-in-out infinite; transform-origin:500px 452px; }
@keyframes stillBreath {
  0%,100% { transform:scale(1);    opacity:.42; }
  50%     { transform:scale(1.22); opacity:.72; }
}
.tree-svg.has-focus .still { opacity:.35; }

@media (prefers-reduced-motion:reduce){ .still-ring{ animation:none; } }

/* ── Panel — opens when a limb or tip is chosen ─────────────────────────── */
.tree-panel {
  position:fixed; inset:auto 0 0 0; z-index:70;
  background:var(--card); border-top:1px solid var(--line);
  box-shadow:var(--sh-3); border-radius:var(--r-xl) var(--r-xl) 0 0;
  transform:translateY(102%); transition:transform .34s var(--ease);
  max-height:min(76svh,720px); overflow:auto;
}
.tree-panel.open{ transform:none; }
@media (min-width:900px){
  .tree-panel{ inset:0 0 0 auto; width:min(520px,42vw); border-radius:var(--r-xl) 0 0 var(--r-xl);
    border-top:0; border-left:1px solid var(--line); transform:translateX(102%); max-height:none; }
  .tree-panel.open{ transform:none; }
}
.tp-inner{ padding:1.6rem clamp(1.1rem,3vw,2rem) 2.4rem; }
.tp-close{ position:sticky; top:0; float:right; }
.tp-chips{ display:flex; align-items:center; gap:.5rem; flex-wrap:wrap; margin-bottom:.7rem; }
.tp-chip{ display:inline-flex; align-items:center; gap:.4rem; padding:.24rem .7rem;
  border-radius:999px; font-size:.8rem; font-weight:600; color:#fff; }
.tp-x{ color:var(--ink-3); font-size:.9rem; }
.tp-title{ font-family:var(--font-display); font-size:1.7rem; line-height:1.12; margin:.1rem 0 1rem; }

.tp-band{ padding:1rem 1.1rem; border-radius:var(--r-md); margin-bottom:.8rem; }
.tp-band h4{ font-family:var(--font-body); font-size:.7rem; letter-spacing:.14em;
  text-transform:uppercase; color:var(--ink-3); margin:0 0 .45rem; font-weight:700; }
.tp-band p{ margin:0; }
.tp-situation{ background:var(--canopy-100); }
.tp-seeing{ background:var(--sap-core); border:1px solid color-mix(in srgb,var(--sap) 34%,transparent); }
.tp-practice{ background:var(--root-100); }
.tp-practice ol{ margin:.4rem 0 0; padding-left:1.15rem; }
.tp-practice li{ margin-bottom:.4rem; }
.tp-dur{ font-size:.78rem; color:var(--ink-3); font-weight:600; }

/* Rows listing the connections from a chosen limb */
.tp-list{ display:flex; flex-direction:column; gap:.4rem; }
.tp-row{ display:flex; align-items:center; gap:.7rem; width:100%; text-align:left;
  padding:.7rem .8rem; border-radius:var(--r-md); border:1px solid var(--line);
  background:var(--card-2); color:inherit; font:inherit; cursor:pointer;
  transition:border-color .18s var(--ease), transform .18s var(--ease); }
.tp-row:hover{ border-color:var(--sap); transform:translateX(2px); }
.tp-row-title{ font-weight:600; font-size:.95rem; }

/* ── Legend beneath the tree ────────────────────────────────────────────── */
.tree-legend{ display:flex; justify-content:space-between; gap:1rem; flex-wrap:wrap;
  max-width:var(--wrap); margin:0 auto; padding:0 clamp(1rem,4vw,2rem) 2.2rem; }
.tl-col h4{ font-family:var(--font-body); font-size:.72rem; letter-spacing:.13em;
  text-transform:uppercase; color:var(--ink-3); margin:0 0 .5rem; }
.tl-hint{ color:var(--ink-3); font-size:.86rem; max-width:36ch; }

/* ── Reduced motion: keep the meaning, drop the movement ────────────────── */
@media (prefers-reduced-motion:reduce){
  .sap, .sap.flow, .tree-svg:not(.has-focus) .sap-idle { animation:none; }
  .sap.flow{ opacity:.9; stroke-dashoffset:0; }
  .tree-svg:not(.has-focus) .sap-idle{ opacity:0; }
  .tree-panel{ transition:none; }
}

/* ── Small screens: the tree stays legible, labels shrink ───────────────── */
@media (max-width:700px){
  .tip-label{ font-size:26px; }
  .tip-sub{ display:none; }
}
