/**
 * Ford Super Duty F-250 7.3L "Godzilla" V8 3D Mechanic's Teardown & Live Running Workstation
 * Stylesheet — High-Contrast Ford OASIS / Rotunda Workshop Aesthetic
 */

:root {
  --bg-deep: #070a10;
  --bg-panel: #0f1522;
  --bg-card: #161f30;
  --bg-card-hover: #1e293b;
  --border-subtle: #26334d;
  --border-focus: #38bdf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --ford-blue: #0284c7;
  --ford-cyan: #38bdf8;
  --highlight-yellow: #fde047;
  --danger-red: #ef4444;
  --success-green: #22c55e;
  --warning-amber: #f59e0b;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 13px;
  overflow: hidden;
  user-select: none;
}

/* Visually Hidden Utility per Modern Web Guidance Accessibility Rule */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus-visible {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 9999;
  background: var(--highlight-yellow);
  color: #000;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 700;
  text-decoration: none;
}

:where(a:any-link, button, input, select):focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

/* Main App Grid */
.workstation-shell {
  display: grid;
  grid-template-rows: 58px 1fr 74px;
  grid-template-columns: 340px 1fr 380px;
  grid-template-areas:
    "header header header"
    "sidebar-left viewport sidebar-right"
    "footer footer footer";
  width: 100vw;
  height: 100vh;
}

/* Top Header */
.top-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(90deg, #0b111e 0%, #111b2e 50%, #0b111e 100%);
  border-bottom: 1px solid var(--border-subtle);
  gap: 12px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ford-oval-badge {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  border: 1px solid #38bdf8;
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.08em;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.28);
}

.brand-titles h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #f8fafc;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* Live Engine Running Telemetry Strip */
.telemetry-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 21, 34, 0.9);
  border: 1px solid var(--border-subtle);
  padding: 5px 12px;
  border-radius: 8px;
}

.telemetry-pill {
  display: flex;
  flex-direction: column;
  padding: 0 8px;
  border-right: 1px solid var(--border-subtle);
}

.telemetry-pill:last-child {
  border-right: none;
}

.telemetry-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.telemetry-val {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ford-cyan);
}

.telemetry-val.firing {
  color: var(--highlight-yellow);
}

/* Header Action Controls */
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-block-size: 32px;
  min-inline-size: 32px;
  padding: 6px 12px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: #475569;
}

.btn[aria-pressed="true"],
.btn.active {
  background: rgba(2, 132, 199, 0.28);
  border-color: var(--ford-cyan);
  color: #fff;
}

.btn-ignition {
  background: rgba(34, 197, 94, 0.18);
  border-color: #22c55e;
  color: #86efac;
}

.btn-ignition[aria-pressed="true"] {
  background: #16a34a;
  border-color: #4ade80;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.35);
}

.btn-warn {
  background: rgba(245, 158, 11, 0.16);
  border-color: #f59e0b;
  color: #fde047;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.16);
  border-color: #ef4444;
  color: #fca5a5;
}

/* Left Sidebar: 8-Stage WSM Component Tree & Mechanic Disassembly Bench */
.sidebar-left {
  grid-area: sidebar-left;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(22, 31, 48, 0.65);
}

.panel-header h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #e2e8f0;
  margin-bottom: 8px;
}

.search-box-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-box-row label {
  font-size: 12px;
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 7px 10px;
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 12px;
}

.quick-stage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.component-tree-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.stage-group {
  margin-bottom: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgba(11, 15, 23, 0.55);
  overflow: hidden;
}

.stage-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
}

.stage-group-title {
  font-size: 12px;
  font-weight: 700;
  color: #f8fafc;
}

.stage-toggle-btn {
  font-size: 12px;
  padding: 3px 8px;
  min-block-size: 24px;
}

.component-list {
  list-style: none;
}

.component-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(38, 51, 77, 0.5);
  gap: 6px;
  transition: background 0.12s;
}

.component-item:last-child {
  border-bottom: none;
}

.component-item:hover {
  background: rgba(56, 189, 248, 0.08);
}

.component-item.selected {
  background: rgba(253, 224, 71, 0.14);
  border-left: 3px solid var(--highlight-yellow);
}

.component-item.removed .comp-select-btn {
  text-decoration: line-through;
  color: var(--text-muted);
}

.comp-select-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  min-block-size: 26px;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  background: #1e293b;
  color: var(--ford-cyan);
  font-size: 12px;
  font-weight: 700;
}

.comp-actions {
  display: flex;
  gap: 4px;
}

.mini-btn {
  min-block-size: 24px;
  min-inline-size: 24px;
  padding: 2px 7px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
}

.mini-btn.unbolted {
  background: rgba(239, 68, 68, 0.22);
  border-color: #ef4444;
  color: #fca5a5;
}

.mini-btn.solo-active {
  background: var(--highlight-yellow);
  border-color: #ca8a04;
  color: #000;
  font-weight: 700;
}

/* Center 3D Viewport */
.viewport-center {
  grid-area: viewport;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #162238 0%, #070a10 78%);
}

#webgl-canvas-container {
  width: 100%;
  height: 100%;
}

/* Viewport Overlay HUDs */
.viewport-top-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  gap: 10px;
}

.camera-preset-bar,
.firing-order-hud {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(11, 15, 23, 0.86);
  border: 1px solid var(--border-subtle);
  padding: 6px 8px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
}

.firing-cyl-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: #161f30;
  border: 1px solid #26334d;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  transition: transform 0.08s, background 0.08s;
}

.firing-cyl-box.firing-now {
  background: #f97316;
  border-color: var(--highlight-yellow);
  color: #fff;
  transform: scale(1.14);
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.7);
}

.viewport-bottom-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 15, 23, 0.85);
  border: 1px solid var(--border-subtle);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
}

/* Hover 3D Tooltip */
.hover-tooltip {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  background: rgba(11, 15, 23, 0.94);
  border: 1px solid var(--highlight-yellow);
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
  max-width: 270px;
}

.hover-tooltip[hidden] {
  display: none;
}

/* Right Sidebar: Ford Workshop Manual (Section 303-01C) Inspector */
.sidebar-right {
  grid-area: sidebar-right;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 14px;
  gap: 12px;
}

.wsm-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
}

.wsm-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.wsm-section-tag {
  background: rgba(2, 132, 199, 0.25);
  border: 1px solid var(--ford-cyan);
  color: var(--ford-cyan);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

.wsm-part-tag {
  font-family: monospace;
  font-size: 12px;
  color: var(--highlight-yellow);
}

.wsm-comp-title {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.wsm-desc {
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
}

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

.spec-box {
  background: rgba(9, 13, 22, 0.65);
  border: 1px solid rgba(38, 51, 77, 0.8);
  border-radius: 6px;
  padding: 8px 10px;
}

.spec-box-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 3px;
}

.spec-box-value {
  font-size: 12px;
  font-weight: 600;
  color: #f8fafc;
  line-height: 1.4;
}

.spec-box-value.torque-highlight {
  color: var(--highlight-yellow);
}

.procedure-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.procedure-list li {
  font-size: 12px;
  line-height: 1.45;
  color: #e2e8f0;
}

/* Bottom Footer: Mechanic Teardown Stepper & Running RPM Controls */
.bottom-footer {
  grid-area: footer;
  background: #0b111e;
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
  padding: 8px 16px;
  align-items: center;
}

.control-deck {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 8px 12px;
  border-radius: 8px;
}

.slider-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--ford-cyan);
  cursor: pointer;
}

/* Native <dialog> Modal for Ford WSM Torque Sequence Diagrams */
dialog.wsm-dialog {
  margin: auto;
  max-width: 720px;
  width: 92%;
  background: var(--bg-panel);
  color: var(--text-main);
  border: 1px solid var(--ford-cyan);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}

dialog.wsm-dialog::backdrop {
  background: rgba(5, 8, 15, 0.78);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.torque-blueprint-canvas {
  width: 100%;
  height: 220px;
  background: #080d18;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  position: relative;
  margin: 12px 0;
}

.bolt-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #0284c7;
  border: 2px solid var(--highlight-yellow);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mechanic Teardown & Reinstallation Pop-Up Window in 3D Viewport */
.teardown-popup-window {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, 92%);
  background: rgba(11, 17, 30, 0.96);
  border: 2px solid var(--highlight-yellow);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.85), 0 0 24px rgba(253, 224, 71, 0.25);
  backdrop-filter: blur(10px);
  z-index: 60;
  transition: opacity 0.2s, transform 0.2s;
}

.teardown-popup-window[hidden] {
  display: none;
}

.teardown-popup-window.installing {
  border-color: #22c55e;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.85), 0 0 24px rgba(34, 197, 94, 0.28);
}

.popup-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.popup-action-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.22);
  border: 1px solid var(--highlight-yellow);
  color: var(--highlight-yellow);
}

.teardown-popup-window.installing .popup-action-badge {
  background: rgba(34, 197, 94, 0.22);
  border-color: #4ade80;
  color: #86efac;
}

.popup-part-title {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
}

.popup-meta-line {
  font-size: 12px;
  color: #cbd5e1;
  margin-bottom: 6px;
  line-height: 1.4;
}

.popup-progress-track {
  width: 100%;
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
  border: 1px solid #334155;
}

.popup-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f59e0b, #fde047);
  transition: width 0.06s linear;
}

.teardown-popup-window.installing .popup-progress-fill {
  background: linear-gradient(90deg, #16a34a, #4ade80);
}

.popup-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(51, 65, 85, 0.7);
}



/* Generator Sibling Navigation Masthead */
.generator-sibling-bar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: #040d14;
  border-bottom: 1px solid #163242;
  font-size: 11px;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
}
.generator-sibling-bar .gen-brand {
  color: #38bdf8;
  font-weight: 800;
  text-decoration: none;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.generator-sibling-bar .gen-links {
  display: flex;
  align-items: center;
  gap: 6px;
}
.generator-sibling-bar .gen-links a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(15, 35, 48, 0.75);
  border: 1px solid #1e3a4c;
  font-weight: 600;
  transition: all 0.15s ease;
}
.generator-sibling-bar .gen-links a:hover {
  color: #fde047;
  border-color: #fde047;
  background: rgba(250, 204, 21, 0.12);
}
