/* Page chrome only. Every colour and font here comes from a CSS custom
   property that theme.js sets at startup, so this file holds no style
   decisions of its own. */

* { box-sizing: border-box; }

/* Global, so any element can be toggled with classList.toggle('hidden').
   !important because the rules below set display on *id* selectors, which
   outrank a bare class: #controls { display: flex } beat this, so the scrubber
   and the hint sat on top of the loading screen for the whole download. A
   one-line utility that always wins is the point of having it. */
.hidden { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--font-size);
}

/* Two panes side by side. The right one animates its width so opening the
   subtree panel does not feel like a page jump; the canvases resize with it. */
#app {
  display: flex;
  height: 100%;
}

#left {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;      /* lets the flex item shrink below its canvas size */
}

/* No width transition. Animating the pane width would make the left canvas
   resize on every frame of the slide, and each of those costs a full rebuild of
   the cached tree layers. One instant layout change means exactly one
   ResizeObserver callback and one rebuild. */
#right {
  position: relative;
  flex: 0 0 var(--panel-width);
  width: var(--panel-width);
  border-left: 1px solid var(--hairline);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#right.collapsed {
  flex-basis: 0;
  width: 0;
  border-left-width: 0;
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- subtree panel ---- */

#panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: var(--panel-pad);
  padding-bottom: 8px;
  white-space: nowrap;
}

#panel-title {
  font-size: var(--font-size-large);
  font-weight: 500;
}

#panel-close {
  border: none;
  padding: 2px 4px;
  color: var(--inkMuted);
  font-size: var(--font-size-small);
}

#subtree {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: block;
}

#panel-warn {
  margin: 0 var(--panel-pad) 6px;
  padding: 8px 10px;
  border: 1px solid var(--oscillating);
  border-radius: var(--radius);
  font-size: var(--font-size-small);
  line-height: 1.5;
  color: var(--oscillating);
}

.warn-title {
  font-weight: 600;
  margin-bottom: 2px;
}

#panel-info,
#panel-legend {
  padding: 0 var(--panel-pad);
  font-size: var(--font-size-small);
  line-height: 1.5;
  color: var(--inkMuted);
}

#panel-info {
  min-height: 132px;   /* reserve room so hovering does not reflow the canvas */
  border-top: 1px solid var(--hairline);
  padding-top: 10px;
  margin-top: 8px;
}

#panel-legend {
  padding-top: 8px;
  padding-bottom: var(--panel-pad);
}

/* Shared by the panel legend and the colour key on the embedding, so a swatch
   means the same thing in both. */
.legend .swatch,
.legend .ring {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: -1px;
}

.legend .ring { border: 2px solid currentColor; }

.legend .row { margin-bottom: 2px; }

/* ---- overlays on the left pane ---- */

.overlay { position: absolute; z-index: 1; }

.center {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--inkMuted);
  letter-spacing: 0.08em;
}

/* ---- loading ---- */

#load-box {
  width: 220px;
  text-align: center;
}

#load-label {
  font-size: var(--font-size-small);
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

#load-track {
  height: 2px;
  border-radius: 1px;
  background: var(--hairline);
  overflow: hidden;
}

#load-fill {
  height: 100%;
  width: 0;
  background: var(--ink);
  /* eases the jump between chunks without lagging behind the real download */
  transition: width 120ms linear;
}

.card {
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: var(--panel-pad);
  backdrop-filter: blur(6px);
}

/* linfo only: the link back to the project page, a breadcrumb above the title.
   Over the loading screen too, so there is a way out before the blob arrives. */
#home {
  top: 9px;
  left: 32px;
  z-index: 2;
  font-size: var(--font-size-small);
  color: var(--inkMuted);
  text-decoration: none;
}
#home:hover { color: var(--ink); }

#titlebar {
  top: 28px;
  left: 32px;
  pointer-events: none;
}

#title {
  margin: 0;
  font-size: var(--font-size-large);
  font-weight: 500;
  letter-spacing: 0.02em;
}

#subtitle {
  margin: 4px 0 0;
  font-size: var(--font-size-small);
  color: var(--inkMuted);
}

/* Colour key, tucked under the title. No card behind it: the embedding's own
   margin is empty here, and a panel would read as a second piece of UI. */
#colorkey {
  top: 92px;
  left: 32px;
  pointer-events: none;
  font-size: var(--font-size-small);
  line-height: 1.5;
  color: var(--ink);
}

#colorkey-title {
  color: var(--inkMuted);
  margin-bottom: 6px;
}

#readout {
  top: 28px;
  right: 28px;
  width: 250px;
  font-size: var(--font-size-small);
  line-height: 1.55;
}

/* shared by the readout card and the panel info block */
.name {
  color: var(--ink);
  font-size: var(--font-size);
  word-break: break-all;
}

dl {
  margin: 8px 0 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
}

dt { color: var(--inkMuted); }
dd { margin: 0; color: var(--ink); }

.flag {
  margin-top: 8px;
  color: var(--uncertain);
}

.flag.warn { color: var(--oscillating); }

#controls {
  bottom: 26px;
  left: 32px;
  right: 32px;
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Time scrubber. Kept deliberately plain so it reads as an axis rather than as
   a piece of UI chrome competing with the plot. */
#scrub {
  flex: 0 1 320px;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--hairline);
  cursor: pointer;
}

#scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
  cursor: pointer;
}

#scrub::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
  cursor: pointer;
}

#clock {
  font-size: var(--font-size-small);
  color: var(--inkMuted);
  /* tabular figures so the number does not jitter as it counts up */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#clock b {
  color: var(--ink);
  font-weight: 500;
  margin-right: 8px;
}

button {
  font-family: inherit;
  font-size: var(--font-size-small);
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
}

button:hover { border-color: var(--inkMuted); }

#hint {
  font-size: var(--font-size-small);
  color: var(--inkMuted);
}
