/* ============================================================
   ARW500N — Interactive Exploded View
   Assembly-bay instrument · Team Arrow
   ============================================================ */

:root {
  --ink: #0B0E11;
  --panel: #12171C;
  --solder: #2E7D57;
  --solder-dim: rgba(46, 125, 83, 0.35);
  --silk: #E9E6DC;
  --amber: #F5A623;
  --brand: #FF6200;
  --line: rgba(233, 230, 223, 0.14);
  --line-strong: rgba(233, 230, 223, 0.32);
  --f-sans: 'Barlow', system-ui, sans-serif;
  --f-disp: 'Rajdhani', 'Barlow', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --rail-h: 56px;
  --dock-h: 118px;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--ink);
  color: var(--silk);
  font-family: var(--mon-sans, var(--f-sans));
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--f-mono);
  color: var(--silk);
  background: transparent;
  border: 1px solid var(--line-strong);
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.mono {
  font-family: var(--f-mono);
}

/* ---------- Viewer container ---------- */
.viewer {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--ink);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* PCB hatch over the floor band of the stage */
.hatch {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34vh;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(45deg, rgba(245, 166, 35, 0.045) 0, rgba(245, 166, 35, 0.045) 1px, transparent 1px, transparent 14px),
    repeating-linear-gradient(-45deg, rgba(245, 166, 35, 0.045) 0, rgba(245, 166, 35, 0.045) 1px, transparent 1px, transparent 14px),
    linear-gradient(180deg, transparent 0%, rgba(11, 14, 17, 0.55) 100%);
  z-index: 2;
}

/* ---------- Loading / Error ---------- */
.load-overlay,
.error-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  transition: opacity 0.5s ease;
}

.load-overlay[hidden],
.error-overlay[hidden] {
  display: none;
}

.load-overlay.done {
  opacity: 0;
  pointer-events: none;
}

.load-stamp {
  border-left: 1px solid var(--amber);
  padding: 4px 0 4px 18px;
  min-width: 240px;
}

.load-name {
  font-family: var(--f-disp);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.3em;
  color: var(--silk);
}

.load-pct {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--amber);
}

.load-track {
  margin-top: 10px;
  height: 3px;
  background: rgba(233, 230, 223, 0.12);
}

.load-bar {
  height: 100%;
  width: 0%;
  background: var(--solder);
  transition: width 0.2s ease;
}

.error-overlay {
  color: var(--silk);
}

.error-card {
  border: 1px dashed var(--amber);
  padding: 26px 30px;
  max-width: 420px;
}

.error-code {
  color: var(--amber);
  font-size: 13px;
  letter-spacing: 0.2em;
}

.error-title {
  font-family: var(--f-disp);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.04em;
  margin: 12px 0 6px;
}

.error-body {
  font-size: 15px;
  color: rgba(233, 230, 223, 0.72);
}

.error-body .mono {
  color: var(--silk);
}

.error-msg {
  margin-top: 10px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(245, 166, 35, 0.8);
  word-break: break-all;
}

/* ---------- Top rail ---------- */
.rail {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--rail-h);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(11, 14, 17, 0.92), rgba(11, 14, 17, 0.55));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.rail-back {
  display: none;
}

.rail-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  white-space: nowrap;
}

.rail-name {
  font-family: var(--f-disp);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: 0.18em;
  line-height: 1;
  color: var(--silk);
  text-transform: uppercase;
}

.rail-name::after {
  content: '/26';
  color: var(--amber);
  font-size: 16px;
  letter-spacing: 0;
  margin-left: 2px;
}

.rail-sub {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: rgba(233, 230, 223, 0.6);
  text-transform: uppercase;
}

.rail-readouts {
  display: flex;
  gap: 22px;
  margin-left: auto;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: rgba(233, 230, 223, 0.72);
  white-space: nowrap;
}

.rail-readouts span::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-right: 8px;
  background: var(--solder);
  vertical-align: middle;
}

.rail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rail-btn {
  padding: 6px 10px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: rgba(233, 230, 223, 0.85);
}

.rail-btn:hover,
.rail-btn[aria-pressed="true"] {
  color: var(--amber);
  border-color: var(--amber);
}

.isro-chip {
  display: flex;
  align-items: center;
  justify-content: center;
height: 38px;
  margin-left: 4px;
  padding: 5px 10px;
  background: var(--silk);
  border-radius: 3px;
}

.isro-logo {
  height: 26px;
  width: auto;
  display: block;
}

/* ---------- Dock ---------- */
.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--dock-h);
  z-index: 9;
  display: flex;
  align-items: stretch;
  background: linear-gradient(0deg, rgba(11, 14, 17, 0.95), rgba(11, 14, 17, 0.6));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.insp {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 14px 22px;
  min-width: 0;
  max-width: 460px;
  border: 1px dashed var(--amber);
  border-top-width: 0;
  border-bottom-width: 0;
  background: rgba(245, 166, 35, 0.04);
}

.insp-close {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 10px;
  letter-spacing: 0.14em;
  padding: 2px 6px;
  color: rgba(233, 230, 223, 0.6);
  border-color: var(--line);
}

.insp-close:hover {
  color: var(--amber);
  border-color: var(--amber);
}

.insp[hidden] {
  display: none;
}

.insp-id {
  display: flex;
  align-items: center;
  gap: 8px;
}

.insp-pid {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--amber);
}

.insp-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--solder);
}

.insp-name {
  font-family: var(--f-disp);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.12em;
  color: var(--silk);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insp-spec {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--silk);
}

.insp-note {
  font-size: 13px;
  color: rgba(233, 230, 223, 0.6);
  line-height: 1.35;
}

.rail-ctl {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  min-width: 0;
}

.rail-ctl-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(233, 230, 223, 0.65);
  text-transform: uppercase;
  white-space: nowrap;
}

.rail-ctl-val {
  color: var(--amber);
  font-size: 12px;
  width: 26px;
  text-align: right;
}

.explode {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 28px;
  background: transparent;
  cursor: pointer;
}

.explode::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--solder) 0%, var(--solder) var(--fill, 0%), rgba(233, 230, 223, 0.25) var(--fill, 0%));
}

.explode::-moz-range-track {
  height: 2px;
  background: linear-gradient(to right, var(--solder) 0%, var(--solder) var(--fill, 0%), rgba(233, 230, 223, 0.25) var(--fill, 0%));
}

.explode::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 0;
  background: var(--amber);
  border: none;
}

.explode::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 0;
  background: var(--amber);
  border: none;
}

/* Hint */
.hint {
  position: absolute;
  bottom: calc(var(--dock-h) + 14px);
  right: 18px;
  z-index: 8;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(233, 230, 223, 0.45);
}

/* ---------- Responsive ---------- */
@media (max-width: 1120px) {
  .rail-readouts span:nth-child(1),
  .rail-readouts span:nth-child(2) {
    display: none;
  }
}

@media (max-width: 900px) {
  .rail-btn {
    display: inline-block;
  }

  .isro-chip {
    display: none;
  }

  .rail-sub {
    display: none;
  }

  .rail-readouts {
    margin-left: auto;
  }

  .rail-readouts span:nth-child(3),
  .rail-readouts span:nth-child(4) {
    display: none;
  }

  .dock {
    flex-direction: column;
    height: auto;
    min-height: var(--dock-h);
    padding-left: 0;
  }

  .hint {
    display: none;
  }

  :root {
    --dock-h: 150px;
  }

  .insp {
    max-width: none;
    border-right-width: 0;
  }
}

@media (max-width: 640px) {
  .rail-name {
    font-size: 20px;
  }

  .rail-back span {
    display: none;
  }

  .rail {
    gap: 10px;
    padding: 0 12px;
  }

  .rail-ctl {
    padding: 0 16px;
  }

  .rail-ctl-label {
    font-size: 9px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .load-overlay,
  .error-overlay,
  .rail,
  .dock {
    transition: none;
  }
}

/* ---------- Scroll mode (embedded scroll-scrub showcase) ---------- */
body.scroll-mode .rail,
body.scroll-mode .dock,
body.scroll-mode .hint {
  display: none;
}

body.scroll-mode .tag {
  display: none !important;
}

body.scroll-mode .viewer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

body.scroll-mode canvas {
  outline: none;
}