/* ============================================================================
   AERO-TYRE X9 — Futuristlik Rehvitöökoja 3D Simulatsiooni Kasutajaliides
   ============================================================================ */

:root {
  --bg-deep: #060a12;
  --panel-bg: rgba(9, 15, 28, 0.74);
  --panel-border: rgba(56, 189, 248, 0.22);
  --panel-border-strong: rgba(0, 229, 255, 0.52);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #00e5ff;
  --accent-rgb: 0, 229, 255;
  --emerald: #10b981;
  --amber: #f59e0b;
  --purple: #c084fc;
  --radius: 14px;
  --font-ui: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", "Consolas", monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* Full-bleed 3D WebGL Canvas */
#viewport {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
}
#viewport:active {
  cursor: grabbing;
}

/* 3D Projected Station Badges */
#labels-layer {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.station-tag {
  position: absolute;
  transform: translate(-50%, -100%);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(7, 13, 24, 0.76);
  border: 1px solid rgba(56, 189, 248, 0.38);
  backdrop-filter: blur(8px);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #e2e8f0;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, border-color 0.25s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.station-tag .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tag-color, var(--accent));
  box-shadow: 0 0 8px var(--tag-color, var(--accent));
}

.station-tag.active {
  border-color: var(--tag-color, var(--accent));
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.28);
  color: #fff;
}

/* Glass Panel Base */
.hud-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius);
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* HUD Layout Shell */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 266px 1fr 312px;
  gap: 12px;
  padding: 12px 14px;
}

#hud > * {
  pointer-events: auto;
}

/* Zen Mode: hide side panels & keep top + bottom subtle */
body.zen-mode .side-panel,
body.zen-mode #labels-layer {
  opacity: 0;
  pointer-events: none !important;
  transform: scale(0.96);
}

/* ---------------- TOP COMMAND BAR ---------------- */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.22), rgba(59, 130, 246, 0.14));
  border: 1px solid rgba(0, 229, 255, 0.55);
  display: grid;
  place-items: center;
  color: var(--accent);
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.25);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.16);
  border: 1px solid rgba(var(--accent-rgb), 0.45);
  color: var(--accent);
}

.brand-text p {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Camera Presets */
.camera-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
  flex-wrap: wrap;
}

.cam-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cam-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.cam-btn.active {
  color: #04101d;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.45);
}

/* Topbar Right Actions */
.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
}

.icon-btn.active {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent);
}

/* ---------------- LEFT PANEL: 8 STAGES TIMELINE ---------------- */
.left-panel {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: hidden;
  max-height: 100%;
  align-self: stretch;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}

.panel-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
}

.status-pill .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulseDot 1.4s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

.stages-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  padding-right: 2px;
  flex: 1;
}

.stages-list::-webkit-scrollbar { width: 4px; }
.stages-list::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.25); border-radius: 4px; }

.stage-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  text-align: left;
  width: 100%;
  color: var(--text-main);
  font-family: var(--font-ui);
}

.stage-item:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(20, 32, 54, 0.72);
  transform: translateX(2px);
}

.stage-item.active {
  border-color: var(--item-accent, var(--accent));
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.18), rgba(15, 23, 42, 0.75));
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.14);
}

.stage-item.done {
  border-color: rgba(16, 185, 129, 0.30);
}

.stage-code {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.25);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.stage-item.active .stage-code {
  background: var(--item-accent, var(--accent));
  color: #04101d;
  border-color: transparent;
}

.stage-item.done .stage-code {
  background: rgba(16, 185, 129, 0.18);
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.45);
}

.stage-meta {
  min-width: 0;
  flex: 1;
}

.stage-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stage-item.active .stage-name {
  color: #ffffff;
}

.stage-station {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

.stage-item.active .stage-station {
  color: var(--item-accent, var(--accent));
}

.stage-progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.5px;
  background: rgba(255, 255, 255, 0.05);
}

.stage-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--item-accent, var(--accent));
  transition: width 0.08s linear;
}

.controls-hint {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 10.5px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
}

/* ---------------- RIGHT PANEL: DESCRIPTION & LIVE TELEMETRY ---------------- */
.right-panel {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  max-height: 100%;
  pointer-events: none !important;
}

.right-panel > .hud-panel {
  pointer-events: auto;
}

.stage-detail-card {
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.stage-detail-card::-webkit-scrollbar { width: 4px; }
.stage-detail-card::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.25); border-radius: 4px; }

.detail-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.detail-step-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.15);
  border: 1px solid rgba(var(--accent-rgb), 0.42);
  padding: 2px 8px;
  border-radius: 6px;
}

.detail-station-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

#detail-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  color: #ffffff;
}

.subphase-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(var(--accent-rgb), 0.10);
  border-left: 3px solid var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  color: #e0f2fe;
}

#detail-desc {
  font-size: 12px;
  line-height: 1.55;
  color: #cbd5e1;
}

.highlights-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 2px;
}

.highlights-list li {
  font-size: 11.2px;
  line-height: 1.35;
  color: #94a3b8;
  padding-left: 14px;
  position: relative;
}

.highlights-list li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

/* Telemetry Card */
.telemetry-card {
  padding: 12px 14px;
  flex: 0 0 auto;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.metric-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 9px;
  padding: 7px 9px;
}

.metric-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: #f8fafc;
  margin-top: 2px;
}

.metric-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  margin-top: 5px;
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.08s linear;
}

/* Star Pattern 5-Lug Torque Widget */
.torque-star-row {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.star-info {
  flex: 1;
}

.star-info .metric-val {
  font-size: 14px;
  color: var(--emerald);
}

.star-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.star-svg {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
}

.star-line {
  fill: none;
  stroke: rgba(148, 163, 184, 0.25);
  stroke-width: 1.6;
  stroke-dasharray: 3 3;
}

.lug-dot {
  fill: #1e293b;
  stroke: #64748b;
  stroke-width: 1.8;
  transition: all 0.18s ease;
}

.lug-dot.active {
  fill: #00e5ff;
  stroke: #ffffff;
  filter: drop-shadow(0 0 5px #00e5ff);
}

.lug-dot.locked {
  fill: #10b981;
  stroke: #a7f3d0;
  filter: drop-shadow(0 0 5px #10b981);
}

.lug-num {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  fill: #cbd5e1;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}

.xyz-strip {
  margin-top: 7px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* ---------------- BOTTOM TRANSPORT & SCRUBBER ---------------- */
.bottombar {
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 14px;
}

.transport-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: all 0.18s ease;
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 229, 255, 0.12);
}

.ctrl-btn.primary {
  width: 40px;
  background: var(--accent);
  color: #04101d;
  border-color: transparent;
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.45);
  font-weight: 800;
}

.ctrl-btn.primary:hover {
  filter: brightness(1.12);
  color: #04101d;
}

.scrubber-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.scrubber-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
}

.scrubber-track {
  position: relative;
  height: 16px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.scrubber-bg {
  position: relative;
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  overflow: hidden;
}

.scrubber-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00e5ff, #38bdf8, #c084fc, #10b981);
  border-radius: 999px;
}

.scrubber-ticks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}

.scrubber-ticks span {
  border-right: 1.5px solid rgba(6, 10, 18, 0.85);
}
.scrubber-ticks span:last-child { border-right: none; }

.scrubber-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  border: 2.5px solid var(--accent);
  box-shadow: 0 0 12px var(--accent);
  pointer-events: none;
}

.speed-group {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
}

.speed-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.speed-btn.active {
  background: rgba(var(--accent-rgb), 0.22);
  color: var(--accent);
}

.clock-readout {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  min-width: 92px;
  text-align: right;
}

/* ---------------- CONCEPT SPECIFICATION MODAL ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(8px);
  display: none;
  place-items: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: grid;
}

.modal-card {
  width: min(760px, 95vw);
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px 24px;
  background: rgba(10, 17, 32, 0.94);
  border: 1px solid rgba(0, 229, 255, 0.42);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.modal-head h2 {
  font-size: 19px;
  font-weight: 800;
  color: #fff;
}

.modal-head p {
  font-size: 12px;
  color: var(--accent);
  margin-top: 3px;
}

.specs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.spec-tile {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 10px;
  padding: 11px 12px;
}

.spec-tile h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 5px;
}

.spec-tile p {
  font-size: 12px;
  line-height: 1.48;
  color: #cbd5e1;
}

/* Responsive compact screens */
@media (max-width: 1120px) {
  #hud {
    grid-template-columns: 240px 1fr 280px;
  }
  .camera-pills {
    display: none;
  }
}

@media (max-width: 820px) {
  #hud {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .left-panel {
    display: none;
  }
  .right-panel {
    grid-column: 1;
    max-width: 340px;
    justify-self: end;
  }
}
