/* ==========================================================================
   Midvaal Service Centre — Exploded 3D Workbench Stylesheet
   Tokens & alternating Midnight Fleet Navy (#0A1426) / Daylight Cladding (#F4F7FC)
   ========================================================================== */

:root {
  --sc-canvas: #0a1426;
  --sc-surface: #11203b;
  --sc-ink: #f4f7fc;
  --sc-ink-soft: #cbd5e1;
  --sc-accent: #facc15;
  --sc-accent-ink: #0a1426;

  --msc-cobalt: #1d4ed8;
  --msc-cobalt-light: #93c5fd;
  --msc-steel: #f4f7fc;
  --msc-steel-card: #ffffff;
  --msc-navy: #0a1426;
  --msc-navy-card: #11203b;
  --msc-burnt: #c2410c;
  --msc-tangerine: #f97316;

  --sc-font-display: "Archivo", system-ui, sans-serif;
  --sc-font-text: "Plus Jakarta Sans", system-ui, sans-serif;
  --sc-font-mono: "Plus Jakarta Sans", ui-monospace, monospace;
}

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

html {
  scroll-behavior: auto;
  background-color: var(--msc-navy);
  color: var(--sc-ink);
  font-family: var(--sc-font-text);
  overflow-x: clip;
}

body {
  margin: 0;
  background-color: var(--msc-navy);
  color: var(--sc-ink);
  font-family: var(--sc-font-text);
  overflow-x: clip;
  line-height: 1.6;
}

h1, h2, h3, .msc-display {
  font-family: var(--sc-font-display);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

section[id^="bay-"],
#msc-dispatch-console {
  scroll-margin-top: 4.5rem;
}

/* Focus visibility */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--sc-accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Alternating Ground Subtree Re-Inking
   ========================================================================== */
.msc-ground-navy {
  --sc-canvas: #0a1426;
  --sc-surface: #11203b;
  --sc-ink: #f4f7fc;
  --sc-ink-soft: #cbd5e1;
  background-color: #0a1426;
  color: #f4f7fc;
}

.msc-ground-steel {
  --sc-canvas: #f4f7fc;
  --sc-surface: #ffffff;
  --sc-ink: #0a1426;
  --sc-ink-soft: #334155;
  background-color: #f4f7fc;
  color: #0a1426;
}

/* ==========================================================================
   Persistent 3D Stage & Callout Layer (Hard-Gated to Stages 1-3)
   ========================================================================== */
.msc-3d-stage {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  background:
    radial-gradient(ellipse 68% 58% at 68% 48%, rgba(29, 78, 216, 0.22) 0%, rgba(17, 32, 59, 0.45) 48%, rgba(10, 20, 38, 0.96) 100%);
  transition: opacity 220ms cubic-bezier(0.23, 1, 0.32, 1), visibility 220ms linear;
}

.msc-3d-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(147, 197, 253, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(147, 197, 253, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 65% 48%, black 15%, transparent 72%);
  pointer-events: none;
}

.msc-3d-stage.is-gated-out {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#msc-webgl-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

/* Stage 3 HUD hidden until Stage 3 is actually active (prevents Stage 2 bottom bleed) */
.msc-3d-hud-bar {
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(0.23, 1, 0.32, 1);
}

#bay-exploded.is-hud-active .msc-3d-hud-bar {
  opacity: 1;
  pointer-events: auto;
}

/* Fallback schematic inside #bay-exploded when WebGL or Reduced Motion is active */
.msc-3d-fallback {
  display: none;
  width: 100%;
  margin-bottom: 1.5rem;
}

.msc-3d-fallback.is-visible {
  display: block;
}

.msc-3d-stage.is-fallback #msc-webgl-canvas {
  display: none;
}

/* Projected 2D Callouts over 3D parts */
.msc-callout-layer {
  position: fixed;
  inset: 0;
  z-index: 26;
  pointer-events: none;
  transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1);
}

.msc-callout-pin {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate3d(-9999px, -9999px, 0);
  opacity: 0;
  transition: opacity 180ms cubic-bezier(0.23, 1, 0.32, 1);
  will-change: transform, opacity;
  max-width: 240px;
}

.msc-callout-pin.is-visible {
  opacity: 1;
}

.msc-callout-pin.is-flipped > div {
  flex-direction: row-reverse;
}

.msc-callout-card {
  background: rgba(10, 20, 38, 0.94);
  border: 1px solid rgba(250, 204, 21, 0.48);
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 12px 28px rgba(4, 9, 20, 0.55);
  color: #f4f7fc;
}

.msc-callout-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #facc15;
  border: 2px solid #0a1426;
  box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.65);
}

/* ==========================================================================
   Scroll Sections & Layer Order (Stages 4-6 sit solidly over z-35)
   ========================================================================== */
.msc-layer-stage {
  position: relative;
  z-index: 22;
}

.msc-layer-solid {
  position: relative;
  z-index: 35;
}

/* Top Navigation */
.msc-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(10, 20, 38, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(244, 247, 252, 0.12);
}

/* Desktop Right-Edge 6-Bay Waypoint Spine (30px hit targets + crisp hover tooltip) */
.msc-bay-spine {
  position: fixed;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 45;
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  background: rgba(10, 20, 38, 0.88);
  border: 1px solid rgba(244, 247, 252, 0.14);
  border-radius: 999px;
  padding: 0.4rem 0.25rem;
  backdrop-filter: blur(8px);
}

@media (min-width: 1024px) {
  .msc-bay-spine {
    display: flex;
  }
}

.msc-bay-dot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
}

.msc-bay-dot::after {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 999px;
  border: 2px solid rgba(203, 213, 225, 0.55);
  background: transparent;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.msc-bay-dot[aria-current="true"]::after {
  background: #facc15;
  border-color: #facc15;
  transform: scale(1.22);
}

.msc-bay-dot::before {
  content: attr(data-label);
  position: absolute;
  right: 38px;
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(10, 20, 38, 0.95);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: #f4f7fc;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.msc-bay-dot:hover::before,
.msc-bay-dot:focus-visible::before {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* Hero composition */
.msc-hero {
  min-height: 100svh;
  padding-top: 5.25rem;
  padding-bottom: 2.5rem;
  display: flex;
  align-items: center;
}

@media (max-width: 1023px) {
  .msc-hero {
    min-height: 100svh;
    align-items: flex-start;
    padding-top: 4.5rem;
    padding-bottom: 42vh;
  }

  .msc-3d-stage {
    background:
      radial-gradient(ellipse 90% 52% at 50% 76%, rgba(29, 78, 216, 0.25) 0%, rgba(17, 32, 59, 0.45) 55%, rgba(10, 20, 38, 0.96) 100%);
  }

  .msc-callout-pin {
    max-width: 175px;
  }

  .msc-callout-card {
    padding: 5px 8px;
  }
}

.msc-hero-panel {
  background: rgba(10, 20, 38, 0.90);
  border: 1px solid rgba(244, 247, 252, 0.14);
  border-radius: 16px;
  backdrop-filter: blur(10px);
}

/* Stage 3 Pinned Cue Cards */
#bay-exploded [data-sc-stage] {
  min-height: 100svh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4.8rem 1.25rem 1.5rem;
}

@media (min-width: 1024px) {
  #bay-exploded [data-sc-stage] {
    padding: 5.25rem 4rem 2.25rem;
  }
}

@media (max-width: 767px) {
  #bay-exploded [data-sc-stage] {
    padding: 4.5rem 0.9rem 5rem;
  }
}

.msc-cue-stack {
  position: relative;
  min-height: 195px;
  width: 100%;
  max-width: 440px;
}

@media (max-width: 1023px) {
  .msc-cue-stack {
    min-height: 160px;
    max-width: 100%;
    margin-top: auto;
  }
}

.msc-cue-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 20, 38, 0.93);
  color: #f4f7fc;
  border: 1px solid rgba(244, 247, 252, 0.16);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  box-shadow: 0 20px 44px rgba(3, 8, 18, 0.65);
  backdrop-filter: blur(12px);
}

/* Panoramic workshop gallery mobile swipe strip */
.msc-panorama-frame {
  position: relative;
}

.msc-panorama-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
}

.msc-panorama-img {
  width: 100%;
  min-width: 780px;
  aspect-ratio: 1024 / 304;
  height: auto;
  object-fit: cover;
  display: block;
}

@media (min-width: 768px) {
  .msc-panorama-img {
    min-width: 0;
  }
}

@media (max-width: 767px) {
  .msc-panorama-frame::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 44px;
    border-radius: 0 14px 14px 0;
    background: linear-gradient(to left, rgba(10, 20, 38, 0.55), transparent);
    pointer-events: none;
  }
}

/* Sticky Mobile Roadside Bar (< 768px) */
.msc-mobile-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: rgba(10, 20, 38, 0.96);
  border-top: 1px solid rgba(250, 204, 21, 0.35);
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  backdrop-filter: blur(12px);
}

@media (min-width: 768px) {
  .msc-mobile-dock {
    display: none;
  }
}

/* Ensure footer content isn't hidden under mobile dock */
@media (max-width: 767px) {
  footer.msc-footer {
    padding-bottom: 5.5rem;
  }
}

/* Static Fallback Layout (Shared by Reduced Motion AND Non-WebGL Fallback) */
html.msc-webgl-fallback .msc-3d-stage,
html.msc-webgl-fallback .msc-3d-hud-bar,
html.msc-webgl-fallback .msc-callout-layer {
  display: none !important;
}

html.msc-webgl-fallback .msc-3d-fallback {
  display: block !important;
}

html.msc-webgl-fallback #bay-exploded,
html.msc-webgl-fallback #bay-exploded [data-sc-stage] {
  height: auto !important;
  min-height: auto !important;
  position: relative !important;
}

html.msc-webgl-fallback .msc-cue-stack {
  min-height: auto;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

html.msc-webgl-fallback .msc-cue-card {
  position: relative !important;
  opacity: 1 !important;
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .msc-3d-stage,
  .msc-3d-hud-bar,
  .msc-callout-layer {
    display: none !important;
  }

  .msc-3d-fallback {
    display: block !important;
  }

  #bay-exploded,
  #bay-exploded [data-sc-stage] {
    height: auto !important;
    min-height: auto !important;
    position: relative !important;
  }

  .msc-cue-stack {
    min-height: auto;
    max-width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
  }

  .msc-cue-card {
    position: relative !important;
    opacity: 1 !important;
    transform: none !important;
  }

  [data-sc-in] > * {
    opacity: 1 !important;
    transform: none !important;
  }

  [data-sc-reveal] {
    clip-path: none !important;
  }
}
