/* cargo-packer/styles/app.css */

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ── Top Header Bar ─────────────────────────────────────────────── */
header.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.45);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 0.5rem;
  border-left: 1px solid var(--glass-border);
  padding-left: 0.5rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cam-btn-group {
  display: flex;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 2px;
}

.btn-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.btn-pill.active {
  background: var(--accent-blue);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 0 8px rgba(2, 132, 199, 0.4);
}

.btn-icon {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--glass-border-focus);
}

/* ── Left Control Sidebar ────────────────────────────────────────── */
aside.left-drawer {
  position: absolute;
  top: 68px;
  left: 1rem;
  bottom: 84px;
  width: 310px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  gap: 1.1rem;
}

.section-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-cyan);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chip-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.chip-grid.single-col {
  grid-template-columns: 1fr;
}

.chip-btn {
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chip-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--glass-border-focus);
}

.chip-btn.active {
  background: rgba(2, 132, 199, 0.25);
  border-color: var(--accent-cyan);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.chip-btn strong {
  font-size: 0.82rem;
  color: var(--text-primary);
}

.chip-btn span.chip-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Algorithm Explainer Box */
.algo-explainer {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.76rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.algo-explainer strong {
  color: var(--accent-cyan);
  display: block;
  margin-bottom: 0.25rem;
}

/* ── Right Diagnostics HUD ───────────────────────────────────────── */
aside.right-hud {
  position: absolute;
  top: 68px;
  right: 1rem;
  width: 290px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 1rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.metric-card {
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.metric-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0284c7 0%, #38bdf8 100%);
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Center of Gravity Radar Display */
.cog-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.cog-radar {
  width: 180px;
  height: 90px;
  background: rgba(11, 17, 32, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.cog-crosshair-x {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: rgba(56, 189, 248, 0.25);
}

.cog-crosshair-z {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(56, 189, 248, 0.25);
}

.cog-target-zone {
  position: absolute;
  top: 25%;
  bottom: 25%;
  left: 30%;
  right: 30%;
  border: 1px dashed rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
  border-radius: 3px;
}

.cog-blip {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-emerald);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px var(--accent-emerald);
  transition: left 0.25s ease, top 0.25s ease, background 0.25s ease;
  top: 50%;
  left: 50%;
}

.cog-legend {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.status-optimal {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-acceptable {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.status-hazard {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.status-winner {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.45);
}

/* ── Showdown Comparison Card ─────────────────────────────────────── */
.showdown-card {
  gap: 0.5rem;
  border-color: rgba(249, 115, 22, 0.35);
  background: rgba(15, 23, 42, 0.82);
}

.showdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.showdown-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--glass-border);
  border-radius: 7px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.showdown-row:hover {
  background: rgba(51, 65, 85, 0.65);
  border-color: var(--glass-border-focus);
}

.showdown-row.active {
  border-color: var(--accent-cyan);
  background: rgba(2, 132, 199, 0.22);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.showdown-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
}

.showdown-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.showdown-medal {
  font-size: 0.75rem;
}

.showdown-val {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.showdown-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.showdown-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0284c7 0%, #38bdf8 100%);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.showdown-bar-fill.winner-bar {
  background: linear-gradient(90deg, #ea580c 0%, #f97316 100%);
}

.showdown-insight {
  font-size: 0.7rem;
  line-height: 1.38;
  color: #cbd5e1;
  border-top: 1px solid var(--glass-border);
  padding-top: 0.4rem;
  font-style: italic;
}

.btn-reroll {
  background: linear-gradient(135deg, rgba(234, 88, 12, 0.3) 0%, rgba(249, 115, 22, 0.45) 100%);
  border: 1px solid var(--accent-orange);
  color: #fed7aa;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  margin-top: 0.2rem;
}

.btn-reroll:hover {
  background: var(--accent-orange);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.4);
}

/* ── Bottom Playback Control Dock ────────────────────────────────── */
nav.playback-bar {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 20;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ctrl-btn {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ctrl-btn:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: var(--glass-border-focus);
}

.ctrl-btn.play-btn {
  width: 44px;
  height: 44px;
  background: var(--accent-blue);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 14px rgba(2, 132, 199, 0.5);
}

.ctrl-btn.play-btn:hover {
  background: #0284c7;
  transform: scale(1.05);
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
}

.progress-text {
  font-size: 0.74rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

.progress-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-cyan);
  border-radius: 2px;
  transition: width 0.1s linear;
}

.speed-select {
  display: flex;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 2px;
}

/* Drawer toggle button and mobile close header defaults (desktop) */
.drawer-toggle-btn {
  display: none;
}

.drawer-header-mobile {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 0.25rem;
}

.drawer-header-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.btn-close-drawer {
  width: 28px;
  height: 28px;
}

.cam-label-short {
  display: none;
}

.cam-label-full {
  display: inline;
}

.drawer-backdrop {
  display: none;
}

/* ── Responsive & Mobile Breakpoints ─────────────────────────────── */
@media (max-width: 900px) {
  .drawer-toggle-btn {
    display: flex;
  }

  .drawer-header-mobile {
    display: flex;
  }

  .drawer-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(11, 17, 32, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  aside.left-drawer {
    position: fixed;
    top: 56px;
    bottom: 84px;
    left: 0.75rem;
    width: min(320px, calc(100vw - 1.5rem));
    max-height: calc(100vh - 144px);
    z-index: 30;
    transform: translateX(calc(-100% - 2rem));
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  }

  aside.left-drawer.open {
    transform: translateX(0);
  }

  aside.right-hud {
    position: fixed;
    top: 56px;
    bottom: 84px;
    right: 0.75rem;
    width: min(320px, calc(100vw - 1.5rem));
    max-height: calc(100vh - 144px);
    z-index: 30;
    transform: translateX(calc(100% + 2rem));
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
    overflow-y: auto;
  }

  aside.right-hud.open {
    transform: translateX(0);
  }

  .brand-subtitle {
    display: none;
  }

  .cam-label-full {
    display: none;
  }

  .cam-label-short {
    display: inline;
  }
}

@media (max-width: 640px) {
  header.top-bar {
    height: 48px;
    padding: 0 0.5rem;
  }

  .brand {
    gap: 0.4rem;
  }

  .brand-icon {
    width: 28px;
    height: 28px;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .top-actions {
    gap: 0.3rem;
  }

  .cam-btn-group {
    padding: 1px;
  }

  .btn-pill {
    padding: 3px 6px;
    font-size: 0.72rem;
  }

  .btn-icon {
    width: 30px;
    height: 30px;
  }

  nav.playback-bar {
    bottom: 0.5rem;
    padding: 0.35rem 0.65rem;
    gap: 0.5rem;
    max-width: calc(100vw - 1rem);
    border-radius: 12px;
  }

  .playback-buttons {
    gap: 0.25rem;
  }

  .ctrl-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .ctrl-btn.play-btn {
    width: 38px;
    height: 38px;
  }

  .progress-wrap {
    min-width: 60px;
  }

  .progress-text {
    font-size: 0.68rem;
  }

  /* Hide 0.5x and Instant on very small screens to fit cleanly */
  .speed-select button[data-speed="slow"],
  .speed-select button[data-speed="instant"] {
    display: none;
  }

  aside.left-drawer,
  aside.right-hud {
    top: 50px;
    bottom: 64px;
    left: 0.5rem;
    right: 0.5rem;
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 120px);
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .metric-card {
    padding: 0.6rem;
    gap: 0.25rem;
  }

  .metric-value {
    font-size: 1.15rem;
  }

  .cog-radar {
    width: 140px;
    height: 70px;
  }
}
