/* =========================================================
   05 · Scale — powers-of-ten zoom (owner: Agent E)
   Everything is scoped under #scale; classes are prefixed scale-.
   ========================================================= */
#scale {
  --accent: var(--violet);
  --scale-hud-clear: 86px;           /* keeps the ruler above the fixed #hud pill */
  --scale-side: clamp(64px, 7vw, 112px);
  --scale-right: clamp(16px, 8.5vw, 130px); /* clears the chapter nav dots */
  padding-bottom: clamp(60px, 10vh, 120px);
}

#scale .scale-intro { padding-bottom: clamp(28px, 5vh, 56px); }
#scale .scale-hints { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
#scale .scale-hints .chip { color: var(--ink-2); }

/* ---------- the tall track + sticky stage ---------- */
#scale .scale-track { position: relative; }
#scale .scale-stage {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  overflow: hidden; outline: none;
  background: #04050a;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
#scale .scale-stage:focus-visible { box-shadow: inset 0 0 0 2px var(--violet); }
#scale .scale-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ---------- live readout ---------- */
#scale .scale-readout {
  position: absolute; top: clamp(18px, 4.5vh, 44px); left: var(--scale-side);
  max-width: min(44vw, 560px); pointer-events: none; z-index: 2;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.8);
}
#scale .scale-pow {
  font-family: var(--f-display); font-weight: 700; line-height: 0.95; letter-spacing: -0.02em;
  font-size: clamp(2.6rem, 1.3rem + 4.8vw, 6.2rem);
  display: flex; align-items: baseline; gap: 0.16em; color: var(--ink);
}
#scale .scale-pow__base sup {
  font-family: var(--f-mono); font-weight: 600; font-size: 0.42em; letter-spacing: 0;
  vertical-align: top; position: relative; top: -0.08em; margin-left: 0.05em;
  display: inline-block; min-width: 4.4ch; color: var(--violet);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(155, 123, 255, 0.55), 0 2px 18px rgba(0, 0, 0, 0.9);
}
#scale .scale-pow__unit { font-size: 0.4em; font-weight: 500; color: var(--ink-2); }
#scale .scale-human {
  margin-top: 12px; font-family: var(--f-mono); font-size: var(--step-1); line-height: 1.25; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
#scale .scale-human small { font-size: 0.58em; color: var(--ink-3); }
#scale .scale-human sup, #scale .scale-light sup { font-size: 0.66em; line-height: 0; }
#scale .scale-light { margin-top: 6px; font-size: var(--step--1); color: var(--ink-2); }
#scale .scale-light b { color: var(--ink); font-weight: 600; }

/* ---------- jump-to rail ---------- */
#scale .scale-rail {
  position: absolute; left: clamp(10px, 1.6vw, 26px); top: 56%; transform: translateY(-50%);
  height: min(54vh, 580px); margin: 0; padding: 0; list-style: none; z-index: 3;
  display: flex; flex-direction: column; justify-content: space-between;
}
#scale .scale-rail li { display: block; flex: 1 1 0; min-height: 0; }
#scale .scale-rail__btn {
  appearance: none; -webkit-appearance: none; background: none; border: 0; margin: 0; padding: 0 6px 0 0;
  height: 100%; min-height: 12px; display: flex; align-items: center; gap: 9px; cursor: pointer;
  color: var(--ink-3); font-family: var(--f-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 4px;
}
#scale .scale-rail__tick {
  display: block; width: 10px; height: 1.5px; background: currentColor; border-radius: 2px;
  transition: width 0.3s var(--ease-out), background-color 0.3s, box-shadow 0.3s;
}
#scale .scale-rail__lab {
  opacity: 0; transform: translateX(-4px); white-space: nowrap; pointer-events: none;
  transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
  text-shadow: 0 1px 10px #000, 0 0 2px #000;
}
#scale .scale-rail__btn:hover, #scale .scale-rail__btn:focus-visible { color: var(--ink); }
#scale .scale-rail__btn:hover .scale-rail__lab, #scale .scale-rail__btn:focus-visible .scale-rail__lab { opacity: 1; transform: none; }
#scale .scale-rail__btn:focus-visible { outline: 1px solid var(--violet); outline-offset: 1px; }
#scale .scale-rail__btn.is-active { color: var(--violet); }
#scale .scale-rail__btn.is-active .scale-rail__tick { width: 24px; background: var(--violet); box-shadow: 0 0 10px var(--violet); }
#scale .scale-rail__btn.is-active .scale-rail__lab { opacity: 1; transform: none; color: var(--ink); }

/* ---------- caption card ---------- */
#scale .scale-cap {
  position: absolute; top: clamp(18px, 4.5vh, 44px); right: var(--scale-right);
  width: min(360px, 32vw); padding: 18px 20px; z-index: 2;
  background: rgba(10, 12, 26, 0.62);
}
#scale .scale-cap[data-v="0"] { animation: scale-cap-a 0.55s var(--ease-out); }
#scale .scale-cap[data-v="1"] { animation: scale-cap-b 0.55s var(--ease-out); }
@keyframes scale-cap-a { from { opacity: 0.2; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes scale-cap-b { from { opacity: 0.2; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#scale .scale-cap__kicker { margin: 0 0 6px; font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--violet); }
#scale .scale-cap__name { margin: 0 0 6px; font-family: var(--f-display); font-weight: 500; font-size: var(--step-1); line-height: 1.15; }
#scale .scale-cap__size { margin: 0 0 10px; font-size: 12.5px; line-height: 1.45; color: var(--ink); }
#scale .scale-cap__fact { margin: 0; font-size: var(--step--1); line-height: 1.5; color: var(--ink-2); }
#scale .scale-cap sup { font-size: 0.7em; line-height: 0; }

/* ---------- "you are here" log ruler ---------- */
#scale .scale-ruler {
  position: absolute; left: var(--scale-side); right: var(--scale-right); bottom: var(--scale-hud-clear);
  height: 46px; z-index: 2;
}
#scale .scale-ruler__bar {
  position: absolute; left: 0; right: 0; top: 18px; height: 1px; cursor: pointer;
  background: linear-gradient(90deg, rgba(155, 123, 255, 0.2), rgba(155, 123, 255, 0.65) 50%, rgba(155, 123, 255, 0.2));
}
#scale .scale-ruler__bar::before { content: ""; position: absolute; left: -6px; right: -6px; top: -16px; bottom: -22px; }
#scale .scale-ruler__tick { position: absolute; top: -4px; width: 1px; height: 9px; margin-left: -0.5px; background: var(--line-strong); }
#scale .scale-ruler__tick b {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  font: 500 9.5px/1 var(--f-mono); color: var(--ink-3); white-space: nowrap;
}
#scale .scale-ruler__tick b sup { font-size: 0.85em; }
#scale .scale-ruler__tick--end b { transform: translateX(-100%); }
#scale .scale-ruler__dot { position: absolute; top: -1.5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: rgba(203, 188, 255, 0.75); }
#scale .scale-ruler__mid { position: absolute; top: -7px; width: 1px; height: 15px; margin-left: -0.5px; background: var(--amber); opacity: 0.75; }
#scale .scale-ruler__you {
  position: absolute; top: 25px; transform: translateX(-50%);
  font: 600 9px/1 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--lime); white-space: nowrap;
}
#scale .scale-ruler__here {
  position: absolute; top: -12px; left: 0; width: 2px; height: 25px; margin-left: -1px; border-radius: 2px;
  background: var(--violet); box-shadow: 0 0 12px var(--violet), 0 0 3px #fff; pointer-events: none;
}
#scale .scale-ruler__here em {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 5px;
  font: normal 600 9.5px/1 var(--f-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink); white-space: nowrap;
  text-shadow: 0 1px 8px #000;
}
#scale .scale-note {
  position: absolute; right: var(--scale-right); bottom: calc(var(--scale-hud-clear) + 54px); margin: 0; z-index: 2;
  font-size: 10px; letter-spacing: 0.06em; color: var(--ink-3); pointer-events: none; text-shadow: 0 1px 8px #000;
}

/* ---------- coda ---------- */
#scale .scale-coda { padding-top: clamp(48px, 9vh, 100px); }
#scale .scale-coda__lead { margin: 0; max-width: 62ch; font-size: var(--step-1); font-weight: 300; line-height: 1.5; color: var(--ink-2); }
#scale .scale-coda__lead b { color: var(--ink); font-weight: 500; }
#scale .scale-coda__lead sup { font-size: 0.6em; }
#scale .scale-coda__src { margin: 20px 0 0; max-width: 92ch; font-size: 11.5px; line-height: 1.65; color: var(--ink-3); }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  #scale { --scale-hud-clear: 78px; --scale-side: 16px; --scale-right: 16px; }
  #scale .scale-readout { left: 16px; right: 40px; top: 14px; max-width: none; }
  #scale .scale-pow { font-size: clamp(2.1rem, 10.5vw, 2.9rem); }
  #scale .scale-human { margin-top: 6px; font-size: 1rem; }
  #scale .scale-light { margin-top: 3px; font-size: 12px; }
  #scale .scale-rail { left: auto; right: 4px; top: 42%; height: 40vh; }
  #scale .scale-rail__lab { display: none; }
  #scale .scale-rail__btn { padding: 0 4px; justify-content: flex-end; }
  #scale .scale-rail__tick { width: 8px; }
  #scale .scale-rail__btn.is-active .scale-rail__tick { width: 16px; }
  #scale .scale-cap {
    top: auto; left: 12px; right: 12px; bottom: calc(var(--scale-hud-clear) + 54px);
    width: auto; padding: 12px 14px;
  }
  #scale .scale-cap__kicker { display: none; }
  #scale .scale-cap__name { font-size: 1.05rem; margin-bottom: 3px; }
  #scale .scale-cap__size { font-size: 11.5px; margin-bottom: 6px; }
  #scale .scale-cap__fact {
    font-size: 12.5px; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  }
  #scale .scale-ruler__tick:nth-child(even) b { display: none; }
  #scale .scale-ruler__tick--end b { display: block; }
  #scale .scale-note { display: none; }
}
@media (max-height: 560px) and (min-width: 761px) {
  #scale .scale-cap__fact { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  #scale .scale-rail { height: 46vh; }
}

@media (prefers-reduced-motion: reduce) {
  #scale .scale-cap[data-v] { animation: none; }
}
