/* tools/plasma/_shared/viewer.css
 *
 * Unified design layer for the plasma viewers (mobile, live4k, holo).
 * Token-driven, component-vocabulary-only. Consumers (the .html viewers)
 * provide:
 *   - the canvas itself (#plasma) — render tech is per-viewer
 *   - the body markup using these classes
 *   - the Sora + IBM Plex Mono webfont links (consumers already pull these)
 *
 * The single design rule: at rest, only the simulation, a small brand
 * mark, the back link, and a status pill are visible. Diagnostics live
 * behind the (i) button → slide-in drawer.
 *
 * Mode is set via `data-mode="mobile|live4k|holo"` on the .viewer-root.
 * That toggles canvas sizing (mobile = centered square) and presence
 * of camera-preset row (holo only) and the conservation drawer group
 * (holo only).
 *
 * See docs/plans/PLASMA_VIEWERS_REDESIGN.md for the design rationale.
 */

:root {
  color-scheme: dark;

  /* palette — accents pulled from viridis (matches the simulation) */
  --bg:           #04060a;
  --fg:           #e6f0ff;
  --fg-dim:       hsl(214, 30%, 78%);
  --fg-mute:      hsl(214, 22%, 56%);
  --accent:       #FDE725;             /* viridis end (yellow). Sparing use only — reserved for "verified" / "live" */
  --accent-cool:  #21918C;             /* viridis mid (teal). Main interactive color */
  --accent-deep:  #3B528B;             /* viridis early (blue-violet). Decorative only */
  --err:          #ff7d6b;
  --warn:         #ffb84d;
  --ok:           #6f6;

  /* surfaces */
  --panel-bg:     hsla(218, 56%, 7%, 0.78);
  --panel-edge:   hsla(174, 65%, 35%, 0.28);
  --hairline:     hsla(214, 80%, 70%, 0.10);
  --shadow-text:  0 1px 12px rgba(0,0,0,0.96);

  /* type */
  --font-display: 'Sora', system-ui, -apple-system, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, Menlo, monospace;

  /* sizing */
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --radius:  4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-display); overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

/* ── viewer-root: the page container ─────────────────────────────────── */
.viewer-root {
  position: fixed; inset: 0;
}

/* ── canvas (full-bleed by default) ──────────────────────────────────── */
/* Position-fixed avoids any dependency on parent layout — the canvas
 * always fills the viewport regardless of how the chrome is structured. */
#plasma {
  position: fixed; inset: 0;
  display: block;
  width: 100vw; height: 100vh;
  background: var(--bg);
  filter: saturate(1.08) contrast(1.04);
  image-rendering: pixelated;
  z-index: 1;
}

/* mode=mobile: centered square (preserves iOS Safari fallback aesthetic) */
.viewer-root[data-mode="mobile"] #plasma {
  inset: auto;
  top: 50%; left: 50%;
  width:  min(100vw, 100vh);
  height: min(100vw, 100vh);
  transform: translate(-50%, -50%);
}

/* ── chrome: brand, back, status, details button ─────────────────────── */
/* Defaults to 0.85 opacity so it's legible on first paint without hover.
 * Lifts to 0.95 when the user actively engages the page. */
.viewer-mark, .viewer-back, .viewer-status, .viewer-details-btn {
  position: fixed; pointer-events: none;
  user-select: none;
  text-shadow: var(--shadow-text);
  opacity: 0.85;
  transition: opacity 220ms ease;
  z-index: 10;
}
.viewer-root:hover .viewer-mark,
.viewer-root:hover .viewer-back,
.viewer-root:hover .viewer-status,
.viewer-root:hover .viewer-details-btn { opacity: 0.95; }

.viewer-mark {
  top: var(--space-4); left: var(--space-4);
  font-family: var(--font-display);
  font-size: 13px; font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.viewer-mark .slash { color: var(--accent-cool); padding: 0 0.25em; }
.viewer-mark .sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px; font-weight: 400;
  color: var(--fg-mute);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

.viewer-back {
  bottom: var(--space-4); left: var(--space-4);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg-mute);
  text-decoration: none;
  pointer-events: auto;
}
.viewer-back:hover { color: var(--accent-cool); }

.viewer-status {
  bottom: var(--space-4); right: var(--space-4);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--fg-mute);
  display: flex; align-items: center; gap: var(--space-2);
}
.viewer-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: viewer-pulse 2.4s ease-in-out infinite;
}
@keyframes viewer-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

.viewer-details-btn {
  top: var(--space-4); right: var(--space-4);
  pointer-events: auto;
  width: 26px; height: 26px;
  border: 1px solid var(--accent-cool);
  border-radius: 50%;
  background: var(--panel-bg);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 12px; font-weight: 500;
  font-style: italic;
  cursor: pointer;
  display: grid; place-items: center;
  transition: opacity 220ms, background 220ms, transform 220ms;
}
.viewer-details-btn:hover {
  background: hsla(174, 65%, 35%, 0.22);
  transform: scale(1.05);
}

/* ── camera presets (holo only) ──────────────────────────────────────── */
.viewer-presets {
  position: fixed;
  top: var(--space-4); left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.5;
  transition: opacity 220ms;
  text-shadow: var(--shadow-text);
  z-index: 10;
}
.viewer-root[data-mode="holo"] .viewer-presets { display: flex; }
.viewer-root:hover .viewer-presets { opacity: 0.95; }
.viewer-presets a {
  color: var(--fg-mute);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px dotted transparent;
  pointer-events: auto;
}
.viewer-presets a:hover { color: var(--accent-cool); border-bottom-color: var(--accent-cool); }
.viewer-presets a.active { color: var(--fg); border-bottom-color: var(--accent); }
.viewer-presets .sep { color: var(--fg-mute); opacity: 0.4; }

/* ── drawer (right-side slide-in for diagnostics) ────────────────────── */
.viewer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
  z-index: 15;
}
.viewer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.viewer-drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(22rem, 100vw - 2rem);
  height: 100vh;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
          backdrop-filter: blur(14px) saturate(1.2);
  border-left: 1px solid var(--panel-edge);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.32, 0.72, 0.24, 1);
  overflow-y: auto;
  padding: var(--space-6) var(--space-6) var(--space-4);
  z-index: 20;
  pointer-events: none;
}
.viewer-drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}

.drawer-close {
  position: absolute; top: var(--space-3); right: var(--space-4);
  background: none; border: none;
  color: var(--fg-mute);
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.drawer-close:hover { color: var(--fg); }

.drawer-title {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 500;
  margin: 0 0 var(--space-6);
  letter-spacing: 0.02em;
}
.drawer-title .accent { color: var(--accent-cool); }

/* drawer content blocks */
.group { margin-bottom: var(--space-6); }
.group-head {
  font-family: var(--font-display);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-mute);
  margin-bottom: var(--space-3);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--hairline);
}
/* mode visibility: conservation panel only on holo */
.viewer-root:not([data-mode="holo"]) ~ .viewer-drawer .group-conservation,
.viewer-root:not([data-mode="holo"]) .group-conservation { display: none; }

.row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
}
.row .l { color: var(--fg-mute); }
.row .v { color: var(--fg); text-align: right; }
.row .v.delta { color: var(--ok); font-size: 10px; opacity: 0.85; margin-left: 0.5em; }
.row .v.warn  { color: var(--warn); }
.row .v.fail  { color: var(--err); }

.hash {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--fg);
  word-break: break-all;
  line-height: 1.5;
  margin-top: 4px;
  padding: var(--space-2) var(--space-3);
  background: hsla(218, 56%, 12%, 0.6);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.verify-link {
  display: inline-flex; align-items: center;
  margin-top: var(--space-3);
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border: 1px solid hsla(56, 95%, 55%, 0.35);
  border-radius: var(--radius);
  transition: background 180ms;
}
.verify-link:hover { background: hsla(56, 95%, 55%, 0.10); }

.spark {
  display: block;
  width: 100%; height: 24px;
  margin: var(--space-2) 0;
  background: hsla(218, 56%, 12%, 0.5);
  border-radius: 2px;
}

.solver-blurb {
  font-family: var(--font-display);
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--fg-dim);
}
.solver-blurb code {
  font-family: var(--font-mono);
  color: var(--accent-cool);
  font-size: 10.5px;
}

/* ── viewer-modes: bottom-center navigation pill ─────────────────────── */
/* Sits along the bottom edge with the back-link (BL) and status (BR).
 * Clicks are real navigation between the three viewer URLs (mobile.html,
 * live4k.html, holo.html). The current page auto-highlights via JS that
 * reads location.pathname.
 */
.viewer-modes {
  position: fixed;
  bottom: var(--space-4); left: 50%;
  transform: translateX(-50%);
  display: flex;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 0.4rem 0.45rem;
  z-index: 12;
  opacity: 0.7;
  transition: opacity 220ms;
}
.viewer-modes:hover { opacity: 1; }
.viewer-modes a {
  color: var(--fg-mute);
  text-decoration: none;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  transition: color 180ms, background 180ms;
}
.viewer-modes a:hover { color: var(--fg); }
.viewer-modes a.active {
  color: var(--bg);
  background: var(--accent-cool);
}

/* ── empty-state placeholder: soft pulsing glyph until first beacon ──
 * Wrap the literal "…" in <span class="placeholder">…</span>. When the
 * JS does el.textContent = realValue, the wrapper is naturally
 * clobbered (textContent assignment replaces all children), so no JS
 * cleanup is needed on the success path.
 */
.placeholder {
  display: inline-block;
  animation: viewer-warming 1.4s ease-in-out infinite;
}
@keyframes viewer-warming {
  0%, 100% { opacity: 0.30; }
  50%      { opacity: 0.70; }
}

/* ── responsive: phone-sized → drawer becomes a bottom sheet ─────────── */
@media (max-width: 480px) {
  .viewer-drawer {
    top: auto; bottom: 0; right: 0; left: 0;
    width: 100%; height: 75vh;
    transform: translateY(100%);
    border-left: none; border-top: 1px solid var(--panel-edge);
    border-radius: 8px 8px 0 0;
  }
  .viewer-drawer.open { transform: translateY(0); }
}
