/* ─────────────────────────────────────────────────────────────────────────
   Battery — consumer view.
   One screen. One battery. Three numbers.
   ──────────────────────────────────────────────────────────────────────── */

:root {
  /* Warm, paper-like stage. Neutral with a hint of cream. */
  --bg:        oklch(0.985 0.004 80);
  --bg-2:      oklch(0.965 0.006 80);
  --ink:       oklch(0.16 0.02 60);
  --ink-2:     oklch(0.45 0.02 60);
  --ink-3:     oklch(0.65 0.015 60);
  --hair:      oklch(0.88 0.01 60);

  /* Status — barely-there tints, not full colors. */
  --good:      oklch(0.72 0.10 145);
  --charge:    oklch(0.72 0.10 145);
  --discharge: oklch(0.62 0.13 30);
  --warn:      oklch(0.72 0.16 65);

  /* One display face, one text face. */
  --display: 'Fraunces', 'Cooper Hewitt', 'New York', ui-serif, Georgia, serif;
  --text:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;
}

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500&family=Inter:wght@400;500&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  user-select: none;
}

#root { height: 100vh; width: 100vw; overflow: hidden; }

/* ── Stage ──────────────────────────────────────────────────────────── */
.stage {
  position: relative;
  height: 100%; width: 100%;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
}
.stage:active { cursor: grabbing; }

/* a soft, very subtle vignette to push the battery forward */
.stage::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 55%, transparent 40%, oklch(0.96 0.005 80) 100%);
  pointer-events: none;
}

/* ── The battery hero ───────────────────────────────────────────────── */
.hero {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(28px, 5vh, 56px);
  z-index: 2;
  transition: transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1),
              opacity   320ms ease;
  will-change: transform, opacity;
}

/* zoom levels: 0 = pack, 1 = cells, 2 = single cell */
.zoom-0 .hero { transform: scale(1); }
.zoom-1 .hero { transform: scale(0.0); opacity: 0; pointer-events: none; }
.zoom-2 .hero { transform: scale(0.0); opacity: 0; pointer-events: none; }

/* the pack itself — a tall, rounded rectangle with a subtle 3-quarter feel */
.pack {
  position: relative;
  width: clamp(140px, 18vw, 240px);
  height: clamp(280px, 48vh, 460px);
  filter: drop-shadow(0 30px 50px oklch(0.16 0.02 60 / 0.18))
          drop-shadow(0 6px 14px oklch(0.16 0.02 60 / 0.12));
}
.pack svg { width: 100%; height: 100%; display: block; }

/* tint cycle when charging / discharging — extremely subtle */
.tint-charge .pack    .pack-fluid { fill: color-mix(in oklch, var(--charge) 35%, oklch(0.85 0.01 60)); }
.tint-discharge .pack .pack-fluid { fill: color-mix(in oklch, var(--discharge) 25%, oklch(0.85 0.01 60)); }

/* ── The three numbers ──────────────────────────────────────────────── */
.readout {
  display: flex; align-items: baseline; gap: clamp(36px, 6vw, 96px);
  font-family: var(--display);
  font-feature-settings: "ss01", "tnum";
}
.readout .num {
  display: flex; align-items: baseline;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.readout .num .v {
  font-weight: 300;
  font-size: clamp(56px, 9vw, 132px);
  line-height: 0.9;
  color: var(--ink);
}
.readout .num .u {
  font-family: var(--text);
  font-weight: 400;
  font-size: clamp(13px, 1vw, 16px);
  color: var(--ink-3);
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.readout .sep {
  width: 1px; height: clamp(36px, 4vh, 56px);
  background: var(--hair);
  align-self: center;
}

/* ── Caption — just a name, just a state ────────────────────────────── */
.caption {
  position: absolute; bottom: clamp(28px, 5vh, 56px);
  left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  z-index: 2; pointer-events: none;
}
.caption .name {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(15px, 1.2vw, 18px);
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.caption .state {
  font-family: var(--text);
  font-size: clamp(11px, 0.85vw, 12.5px);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  display: flex; align-items: center; gap: 8px;
}
.caption .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-3);
}
.tint-charge    .caption .dot { background: var(--charge); animation: pulse 1.6s ease-in-out infinite; }
.tint-discharge .caption .dot { background: var(--discharge); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.85); }
}

/* ── Time scrub hint — only visible while dragging ──────────────────── */
.time-stage {
  position: absolute; top: clamp(28px, 5vh, 56px);
  left: 50%; transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(11px, 0.9vw, 13px);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity 220ms ease;
  pointer-events: none;
  z-index: 3;
}
.scrubbing .time-stage { opacity: 1; }
.time-stage .delta { color: var(--ink-2); margin-left: 8px; }

/* ── Issue card ─────────────────────────────────────────────────────── */
.issue {
  position: absolute;
  bottom: clamp(96px, 14vh, 160px);
  left: 50%; transform: translateX(-50%);
  max-width: min(420px, 80vw);
  background: oklch(1 0 0 / 0.9);
  backdrop-filter: blur(18px);
  border: 1px solid var(--hair);
  border-radius: 14px;
  padding: 14px 18px;
  display: flex; gap: 12px; align-items: flex-start;
  z-index: 4;
  box-shadow: 0 12px 28px oklch(0.16 0.02 60 / 0.10);
}
.issue .glyph {
  width: 26px; height: 26px; border-radius: 50%;
  background: color-mix(in oklch, var(--warn) 25%, transparent);
  border: 1px solid var(--warn);
  display: flex; align-items: center; justify-content: center;
  color: var(--warn);
  font-weight: 600; font-size: 14px; font-family: var(--display);
  flex-shrink: 0;
}
.issue .body { flex: 1; font-family: var(--text); }
.issue .head { font-size: 13.5px; color: var(--ink); font-weight: 500; margin-bottom: 2px; }
.issue .desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.issue .desc em { font-style: normal; color: var(--ink); }

/* ── Cell-pack zoom level ───────────────────────────────────────────── */
.cells-stage {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 360ms ease 0ms, transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: scale(1.4);
}
.zoom-1 .cells-stage { opacity: 1; pointer-events: auto; transform: scale(1); transition-delay: 60ms; }
.zoom-2 .cells-stage { opacity: 0; pointer-events: none; transform: scale(2.2); }

.cell-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: clamp(8px, 1vw, 14px);
  padding: clamp(20px, 3vh, 36px);
}
.cell-cap-row { display: flex; gap: clamp(8px, 1vw, 14px); justify-content: center; }
.cell-frame {
  width: clamp(38px, 4.5vw, 60px);
  height: clamp(110px, 14vh, 170px);
  position: relative;
  cursor: pointer;
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cell-frame:hover { transform: translateY(-3px); }
.cell-frame svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 8px 12px oklch(0.16 0.02 60 / 0.12)); }
.cell-frame .num { position: absolute; top: 6px; left: 0; right: 0; text-align: center; font-family: var(--text); font-size: 9.5px; color: var(--ink-3); letter-spacing: 0.1em; }
.cell-frame.warn svg .can-body { stroke: var(--warn); stroke-width: 1.4; }
.cell-frame.warn svg .can-fluid { fill: color-mix(in oklch, var(--warn) 50%, oklch(0.92 0.01 60)); }
.cell-frame.warn .num { color: var(--warn); font-weight: 600; }

/* ── Single-cell zoom ───────────────────────────────────────────────── */
.cell-detail {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(28px, 5vh, 48px);
  opacity: 0; pointer-events: none;
  transform: scale(1.4);
  transition: opacity 320ms ease, transform 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.zoom-2 .cell-detail { opacity: 1; pointer-events: auto; transform: scale(1); transition-delay: 80ms; }
.cell-detail .label {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(13px, 1vw, 15px);
  color: var(--ink-3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.cell-detail .value {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(72px, 11vw, 160px);
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 0.9;
}
.cell-detail .value .u {
  font-family: var(--text);
  font-weight: 400;
  font-size: clamp(14px, 1vw, 18px);
  color: var(--ink-3);
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.cell-detail .history svg { display: block; }
.cell-detail .neighbors {
  display: flex; gap: clamp(28px, 4vw, 48px);
  font-family: var(--text); font-size: 12px; color: var(--ink-3);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.cell-detail .neighbors button {
  background: transparent; border: 0;
  font-family: inherit; font-size: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--ink-3); cursor: pointer; padding: 6px 8px;
}
.cell-detail .neighbors button:hover { color: var(--ink); }

/* ── Hint glyphs ────────────────────────────────────────────────────── */
.hint {
  position: absolute; bottom: clamp(20px, 3vh, 32px);
  font-family: var(--text);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 320ms ease;
  display: flex; align-items: center; gap: 14px;
}
.hint.hide { opacity: 0; }
.hint .pip { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0.6; }

.hint-back {
  position: absolute; top: clamp(24px, 3vh, 36px); left: clamp(24px, 3vw, 40px);
  background: transparent; border: 0;
  font-family: var(--text); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3); cursor: pointer; padding: 8px 10px;
  opacity: 0; transition: opacity 240ms ease;
}
.zoom-1 .hint-back, .zoom-2 .hint-back { opacity: 1; }
.hint-back:hover { color: var(--ink); }

/* a tiny developer escape hatch — only on Option-click of the name */
.about-tag {
  position: absolute; bottom: 14px; right: 16px;
  font-family: var(--text); font-size: 10px; letter-spacing: 0.14em;
  color: oklch(0.85 0.01 60);
  pointer-events: none;
}

/* loading state */
.boot {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(15px, 1.2vw, 18px);
  color: var(--ink-3);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* ── Source toggle pill (top-right) ─────────────────────────────────── */
.src-pill {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 50;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  background: oklch(1 0 0 / 0.55);
  color: var(--ink-2);
  border: 0.5px solid var(--hair);
  border-radius: 999px;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background 180ms ease, color 180ms ease;
}
.src-pill:hover { background: oklch(1 0 0 / 0.85); color: var(--ink); }

/* ── CAN no-cells notice ────────────────────────────────────────────── */
.cells-empty {
  font-family: var(--text);
  font-size: clamp(13px, 1.1vw, 16px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
}
