/* ============================================================
   LHC Event Display — Open Data Visualizer
   Design system shared with HELIOS · Milky Way Explorer
   ============================================================ */

:root {
  --bg:             #02060a;
  --bg-panel:       rgba(6, 14, 24, 0.78);
  --bg-panel-solid: #060e18;
  --ink:            #d6e6f5;
  --ink-dim:        #6c8aa8;
  --ink-faint:      #aebbcc;
  --line:           rgba(0, 255, 204, 0.18);
  --line-strong:    rgba(0, 255, 204, 0.45);

  /* Accents — matching HELIOS colour palette */
  --amber:          #FD7A33;
  --amber-glow:     rgba(253, 122, 51, 0.55);
  --cyan:           #00FFCC;
  --cyan-glow:      rgba(0, 255, 204, 0.55);

  /* Particle colours */
  --c-electron: #00FFCC;
  --c-muon:     #ff4f88;
  --c-photon:   #ffe066;
  --c-chad:     #6effa6;
  --c-nhad:     #aebbcc;
  --c-jet:      #FD7A33;
  --c-met:      #b894ff;

  /* Legacy aliases used in component styles */
  --border:        var(--line);
  --border-strong: var(--line-strong);
  --text:          var(--ink);
  --text-dim:      var(--ink-dim);
  --text-bright:   #ffffff;
  --accent:        var(--cyan);
  --accent-warm:   var(--amber);
  --accent-hot:    var(--amber);

  --mono:   'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --serif:  'EB Garamond', 'Iowan Old Style', Georgia, serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#canvas-container { position: fixed; inset: 0; }
canvas { display: block; }

/* Vignette overlay */
.vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center,
    transparent 40%,
    rgba(2, 6, 10, 0.4) 80%,
    rgba(2, 6, 10, 0.9) 100%);
  z-index: 1;
}

/* Scan lines for CRT feel */
.scanlines {
  position: fixed; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 2px,
    rgba(0, 255, 204, 0.012) 2px,
    rgba(0, 255, 204, 0.012) 3px
  );
  z-index: 2;
  mix-blend-mode: screen;
}

/* ─── HUD corner bracket ──────────────────────────────────── */
.hud__corner {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--line-strong);
}
.hud__corner--tl { top: 0;    left: 0;   border-right: 0; border-bottom: 0; }
.hud__corner--tr { top: 0;    right: 0;  border-left: 0;  border-bottom: 0; }
.hud__corner--bl { bottom: 0; left: 0;   border-right: 0; border-top: 0; }
.hud__corner--br { bottom: 0; right: 0;  border-left: 0;  border-top: 0; }

/* ─── Panels ──────────────────────────────────────────────── */
.panel {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  z-index: 10;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.panel::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 8px; height: 8px;
  border-top: 1px solid var(--cyan);
  border-left: 1px solid var(--cyan);
}
.panel::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 8px; height: 8px;
  border-bottom: 1px solid var(--cyan);
  border-right: 1px solid var(--cyan);
}

/* ============================================================
   BRAND BADGE (top-left) — matches HELIOS signature
   ============================================================ */
.brand {
  position: fixed;
  top: 22px;
  left: 24px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  min-width: 240px;
}
.brand__mark img {
  display: block;
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 0 6px var(--cyan-glow));
}
.brand__name {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: #fffaf0;
}
.brand__sub {
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  margin-top: 5px;
  text-transform: uppercase;
}
.brand__sub a {
  color: var(--cyan);
  text-decoration: none;
  transition: color 0.15s ease;
}
.brand__sub a:hover { color: var(--ink); }

/* ============================================================
   EVENT INFO (top-right)
   ============================================================ */
#event-info {
  top: 20px; right: 20px;
  padding: 16px 20px;
  min-width: 280px;
}
#event-info .label {
  color: var(--ink-dim);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
#event-info .event-title {
  font-family: var(--serif);
  font-size: 18px;
  color: #fffaf0;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
#event-info .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-top: 1px dashed var(--line);
  font-size: 11px;
}
#event-info .row:first-of-type { border-top: none; }
#event-info .row .k {
  color: var(--ink-dim);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.1em;
}
#event-info .row .v {
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
#event-info .row .v .unit {
  color: var(--ink-dim);
  font-size: 9px;
  margin-left: 3px;
}

/* ============================================================
   BOTTOM-LEFT ROW — legend + camera controls
   ============================================================ */
.hud-row--bl {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  z-index: 10;
}
.hud-row--bl .panel {
  position: static;
}

/* ── Legend ─────────────────────────────────────────────── */
#legend {
  padding: 14px 18px;
  min-width: 240px;
}
#legend .title {
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
  font-size: 11px;
}
.legend-item:hover { color: var(--ink); }
.legend-item.muted { opacity: 0.3; }
.legend-item .swatch {
  width: 16px; height: 2px;
  margin-right: 10px;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}
.legend-item .swatch.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 14px;
  margin-left: 4px;
}
.legend-item .name { flex: 1; }
.legend-item .count {
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  font-size: 10px;
}

/* ============================================================
   CONTROLS (bottom-right)
   ============================================================ */
#controls {
  bottom: 20px; right: 20px;
  padding: 14px 16px;
  min-width: 280px;
}
#controls .title {
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.btn-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.btn {
  flex: 1;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-dim);
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover {
  background: rgba(0, 255, 204, 0.08);
  border-color: var(--cyan);
  color: var(--ink);
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  border-color: var(--amber);
  color: var(--amber);
}
.btn.primary:hover {
  background: var(--amber);
  color: #1a0800;
  box-shadow: 0 0 14px var(--amber-glow);
}
.btn.wide { flex: 2; }

/* Event selector pills */
.event-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 6px;
}
.pill {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}
.pill:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.pill.active {
  background: rgba(0, 255, 204, 0.1);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ============================================================
   PARTICLE LIST (left-center)
   ============================================================ */
#particle-list {
  position: fixed;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 220px;
  max-height: 50vh;
  padding: 12px 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#particle-list .title {
  padding: 0 16px 8px;
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
#particle-list .header-row {
  display: grid;
  grid-template-columns: 14px 1fr 50px 38px;
  gap: 6px;
  padding: 6px 16px 4px;
  font-size: 8px;
  color: var(--ink-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
#particle-list .body {
  overflow-y: auto;
  flex: 1;
  padding: 0 4px 0 0;
}
#particle-list .body::-webkit-scrollbar { width: 4px; }
#particle-list .body::-webkit-scrollbar-track { background: transparent; }
#particle-list .body::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

.particle-row {
  display: grid;
  grid-template-columns: 14px 1fr 50px 38px;
  gap: 6px;
  padding: 4px 16px;
  font-size: 10px;
  align-items: center;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s;
}
.particle-row:hover {
  background: rgba(0, 255, 204, 0.06);
  border-left-color: var(--cyan);
}
.particle-row .marker {
  width: 8px; height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 6px currentColor;
}
.particle-row .name { color: var(--ink); }
.particle-row .pt {
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.particle-row .eta {
  color: var(--ink-dim);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 9px;
}

/* ============================================================
   AXIS INDICATOR (bottom-center)
   ============================================================ */
#axis-indicator {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 9px;
  color: var(--ink-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
}
#axis-indicator .coords {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  padding: 6px 14px;
  backdrop-filter: blur(8px);
  font-variant-numeric: tabular-nums;
}
#axis-indicator .coords span { margin: 0 8px; }
#axis-indicator .coords .label { color: var(--ink-dim); }
#axis-indicator .coords .x { color: var(--amber); }
#axis-indicator .coords .y { color: #6effa6; }
#axis-indicator .coords .z { color: var(--cyan); }

/* ============================================================
   BOOT / LOADING SCREEN  (matches Galaxy Sim two-phase fade)
   ============================================================ */
.boot {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  /* phase 2: whole overlay fades — starts after bg is gone */
  transition: opacity 0.7s ease 0.6s, visibility 0s 1.4s;
}
.boot::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(0, 255, 204, 0.05), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(253, 122, 51, 0.04), transparent 60%),
    var(--bg);
  /* phase 1: background fades first */
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.boot.is-done::before { opacity: 0; }
.boot.is-done {
  opacity: 0;
  visibility: hidden;
}

.boot__frame {
  position: relative;
  z-index: 1;
  width: min(560px, 88vw);
  padding: 48px 44px;
  border: 1px solid var(--line);
  background: #020810;
}

.boot__brackets span {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid var(--amber);
  opacity: 0.7;
}
.boot__brackets span:nth-child(1) { top: -1px;    left: -1px;  border-right: 0; border-bottom: 0; }
.boot__brackets span:nth-child(2) { top: -1px;    right: -1px; border-left: 0;  border-bottom: 0; }
.boot__brackets span:nth-child(3) { bottom: -1px; left: -1px;  border-right: 0; border-top: 0; }
.boot__brackets span:nth-child(4) { bottom: -1px; right: -1px; border-left: 0;  border-top: 0; }

.boot__label {
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--amber);
  margin-bottom: 18px;
}
.boot__title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
  color: #fffaf0;
}
.boot__sub {
  font-size: 13px;
  color: var(--ink-dim);
  margin: 0 0 28px;
  max-width: 42ch;
}
.boot__sub em { color: var(--cyan); font-style: normal; }

.boot__bar {
  position: relative;
  height: 2px;
  background: var(--line);
  overflow: hidden;
  margin-bottom: 10px;
}
.boot__fill {
  position: absolute;
  inset: 0 100% 0 0;
  background: linear-gradient(90deg, var(--cyan), var(--amber));
  box-shadow: 0 0 12px var(--cyan-glow);
  transition: right 0.3s ease;
}

.boot__status {
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink-dim);
  margin-bottom: 32px;
}

.boot__meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.18em;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

/* ── Camera controls panel ───────────────────────────────── */
#camera-controls {
  padding: 14px 18px;
  min-width: 180px;
  height: 175px;
}
#camera-controls .cam-title {
  font-size: 9px;
  color: var(--amber);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
#camera-controls .cam-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
#camera-controls .cam-list li {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  font-size: 11px;
  color: var(--ink-dim);
}
#camera-controls .cam-list li span {
  margin-left: 6px;
  color: var(--ink);
  letter-spacing: 0.04em;
}
.btn-reset-cam {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 7px 10px;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-reset-cam:hover {
  background: rgba(0, 255, 204, 0.08);
  border-color: var(--cyan);
  color: var(--ink);
}
.btn-reset-cam:active { transform: scale(0.97); }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  letter-spacing: 0.04em;
  display: inline-block;
  margin-right: 6px;
  transition: background 0.06s ease, color 0.06s ease,
              border-color 0.06s ease, transform 0.06s ease,
              box-shadow 0.06s ease;
}
kbd.is-pressed {
  background: var(--amber);
  color: #1a0f00;
  border-color: var(--amber);
  border-bottom-width: 1px;
  transform: translateY(1px);
  box-shadow: 0 0 8px var(--amber-glow);
}

/* ============================================================
   TOOLTIP
   ============================================================ */
#tooltip {
  position: fixed;
  background: var(--bg-panel-solid);
  border: 1px solid var(--line-strong);
  padding: 8px 12px;
  pointer-events: none;
  z-index: 20;
  font-size: 10px;
  display: none;
  min-width: 160px;
}
#tooltip::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px;
  width: 8px; height: 8px;
  border-top: 1px solid var(--amber);
  border-left: 1px solid var(--amber);
}
#tooltip .ttype {
  font-family: var(--serif);
  font-size: 15px;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
  color: #fffaf0;
}
#tooltip .trow {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--ink-dim);
  padding: 1px 0;
}
#tooltip .trow .v { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ============================================================
   SLIDER
   ============================================================ */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2px;
  background: var(--line);
  outline: none;
  margin: 10px 0 4px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px; height: 10px;
  background: var(--cyan);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px var(--cyan-glow);
}
input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px;
  background: var(--cyan);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
.slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 9px;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}
.slider-row .v { color: var(--ink); }

/* ============================================================
   MOBILE NAV + BOTTOM SHEETS
   ============================================================ */
#mobile-nav    { display: none; }
#mobile-backdrop { display: none; }

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

@media (max-width: 800px) {
  /* ── Hide desktop-only panels ───────────────────────────── */
  #particle-list,
  #axis-indicator,
  #event-info,
  #controls,
  #legend,
  #camera-controls,
  .hud-row--bl { display: none; }

  /* ── Compact brand badge ─────────────────────────────────── */
  .brand {
    top: 12px; left: 12px;
    padding: 10px 14px;
    min-width: 0; gap: 8px;
  }
  .brand__mark img { width: 26px; height: 26px; }
  .brand__name { font-size: 15px; }


  /* ── Bottom nav bar ──────────────────────────────────────── */
  #mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 60;
    height: 58px;
    background: rgba(6, 14, 24, 0.97);
    border-top: 1px solid var(--line-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
  .mnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    border-right: 1px solid var(--line);
    color: var(--ink-dim);
    font-family: var(--mono);
    cursor: pointer;
    padding: 8px 4px;
    transition: color 0.15s, background 0.15s;
  }
  .mnav-btn:last-child { border-right: none; }
  .mnav-btn:active { background: rgba(0,255,204,0.06); }
  .mnav-btn.is-active { color: var(--cyan); background: rgba(0,255,204,0.08); }
  .mnav-icon { font-size: 15px; line-height: 1; }
  .mnav-label { font-size: 8px; letter-spacing: 0.2em; text-transform: uppercase; }

  /* ── Tap-to-close backdrop ───────────────────────────────── */
  #mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 10, 0.55);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  #mobile-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── Panels become bottom sheets when open ───────────────── */
  /* Allow hud-row--bl to pass through when a child is open  */
  .hud-row--bl:has(.is-mobile-open) { display: contents; }

  .is-mobile-open {
    position: fixed !important;
    left: 0 !important; right: 0 !important;
    bottom: 58px !important; top: auto !important;
    width: 100% !important; min-width: 0 !important;
    max-height: 62vh;
    overflow-y: auto;
    z-index: 50;
    display: block !important;
    padding: 20px 20px 16px !important;
    animation: slideUp 0.22s ease;
  }
}
