/* ================================================================
   whalu demo — ocean dark theme
   Typefaces: Inter (body) · Space Mono (data/labels)
   ================================================================ */

:root {
  --bg:           #03080f;
  --bg-2:         #070f1c;
  --bg-3:         #0c1a2e;
  --bg-4:         #112237;

  --border:       rgba(0, 180, 255, 0.10);
  --border-2:     rgba(0, 180, 255, 0.20);

  --text:         #cce4f6;
  --text-2:       #6ea8ce;
  --text-3:       #3a617e;

  --accent:       #00c8f8;
  --accent-dim:   rgba(0, 200, 248, 0.08);
  --accent-glow:  rgba(0, 200, 248, 0.25);

  --radius:       12px;
  --radius-sm:    7px;
  --font:         'Inter', system-ui, sans-serif;
  --font-mono:    'Space Mono', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* noise overlay */
.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ================================================================
   HEADER
   ================================================================ */

header {
  padding: 20px 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(3, 8, 15, 0.92);
  backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.header-icon {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}

.header-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
}

.tagline {
  font-size: 12px;
  color: var(--text-3);
  letter-spacing: 0.02em;
}

.gh-link {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 99px;
  transition: border-color 0.2s, color 0.2s;
}
.gh-link:hover { border-color: var(--border-2); color: var(--text); }

/* ================================================================
   MAIN
   ================================================================ */

main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 56px 40px 100px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* ================================================================
   LOADING STATE
   ================================================================ */

.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 80px 0;
}

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-2);
  font-size: 14px;
}

.loading-pulse {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.audio-hint {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  background: var(--accent-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ================================================================
   META BAR
   ================================================================ */

.meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
}

.meta-item {
  flex: 1 1 160px;
  padding: 14px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.meta-item:last-child { border-right: none; }

.meta-key {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

.meta-val {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}

.meta-mode {
  color: var(--accent);
}

/* ================================================================
   PLAYER
   ================================================================ */

.player-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.play-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}
.play-btn:hover { background: rgba(0, 200, 248, 0.15); box-shadow: 0 0 16px var(--accent-glow); }
.play-btn.playing { background: rgba(0, 200, 248, 0.15); }

.time-cur, .time-tot {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  min-width: 48px;
}

.time-cur { color: var(--text); }

.scrubber-wrap {
  flex: 1;
  position: relative;
}

.scrubber-bg {
  height: 40px;
  background: var(--bg-3);
  border-radius: 6px;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border: 1px solid var(--border);
}

.mini-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scrubber-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(0, 200, 248, 0.06);
  pointer-events: none;
  transition: width 0.1s linear;
}

.scrubber-cursor {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  pointer-events: none;
  transform: translateX(-50%);
  transition: left 0.1s linear;
}


/* ================================================================
   TIMELINE
   ================================================================ */

.timeline-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tl-hint {
  font-size: 11px;
  color: var(--text-3);
}

.tl-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: crosshair;
}

#tl-canvas {
  display: block;
  width: 100%;
  height: 96px;
}

.tl-cursor {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(0, 200, 248, 0.8), 0 0 2px #fff;
  pointer-events: none;
  transform: translateX(-50%);
  transition: left 0.1s linear;
  left: 0%;
}

.tl-tooltip {
  position: absolute;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.tl-tooltip.visible { opacity: 1; }

.tl-tooltip-sp {
  font-weight: 600;
  color: var(--text);
}
.tl-tooltip-detail {
  color: var(--text-2);
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ================================================================
   ACTIVE DETECTIONS
   ================================================================ */

.active-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.active-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.active-win {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 99px;
}

.active-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  min-height: 100px;
  position: relative;
}

.empty-msg {
  grid-column: 1 / -1;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
  padding: 28px 0;
  font-style: italic;
}

.det-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: card-in 0.25s ease;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.det-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
}

.det-card.active {
  box-shadow: 0 0 0 1px var(--sp-color, var(--border-2)), 0 0 20px rgba(0,0,0,0.3);
  border-color: var(--sp-color, var(--border-2));
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-emoji {
  font-size: 24px;
  line-height: 1;
}

.card-names {
  flex: 1;
  min-width: 0;
}

.card-common {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sci {
  font-size: 11px;
  color: var(--text-3);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-code {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  flex-shrink: 0;
}

.conf-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conf-track {
  flex: 1;
  height: 5px;
  background: var(--bg-4);
  border-radius: 99px;
  overflow: hidden;
}

.conf-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.conf-pct {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  min-width: 36px;
  text-align: right;
}

.card-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

/* pulse ring on new detection */
@keyframes pulse-ring {
  0%   { transform: scale(0.8); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}

.pulse-ring {
  position: absolute;
  top: 12px; right: 12px;
  width: 10px; height: 10px;
  border-radius: 50%;
  animation: pulse-ring 0.6s ease-out forwards;
}

/* ================================================================
   STATS
   ================================================================ */

.stats-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-row {
  display: grid;
  grid-template-columns: 160px 1fr 80px 80px;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s;
}
.stat-row:hover { border-color: var(--border-2); }

.stat-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
}

.stat-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stat-bar-track {
  height: 6px;
  background: var(--bg-4);
  border-radius: 99px;
  overflow: hidden;
}

.stat-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}

.stat-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  text-align: right;
}

.stat-min {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-3);
  text-align: right;
}

/* ================================================================
   SECTION LABEL
   ================================================================ */

.sec-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

/* ================================================================
   FOOTER
   ================================================================ */

footer {
  border-top: 1px solid var(--border);
  padding: 20px 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
}

footer a { color: var(--text-3); text-decoration: none; }
footer a:hover { color: var(--text-2); }

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 700px) {
  header { padding: 16px 20px; }
  main { padding: 32px 16px 80px; }
  footer { padding: 16px 20px; flex-direction: column; gap: 6px; }
  .meta-bar { flex-direction: column; }
  .meta-item { border-right: none; border-bottom: 1px solid var(--border); }
  .meta-item:last-child { border-bottom: none; }
  .stat-row { grid-template-columns: 140px 1fr 60px; }
  .stat-min { display: none; }
  .player-row { gap: 10px; }
  .time-tot { display: none; }
}
