/* ==========================================================================
   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: smooth;
  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;
}

/* 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 (taste.md mandatory color restatement)
   ========================================================================== */
.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;
}

/* 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;
}

.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);
}

/* 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-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-30)
   ========================================================================== */
.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.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(244, 247, 252, 0.12);
}

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

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

.msc-bay-dot {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(203, 213, 225, 0.5);
  background: transparent;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

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

/* 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: 102svh;
    align-items: flex-start;
    padding-top: 5rem;
    padding-bottom: 44vh;
  }

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

.msc-hero-panel {
  background: rgba(10, 20, 38, 0.88);
  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);
  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-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;
  }
}

/* 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;
  }
}

/* Reduced Motion Overrides */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

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

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

  .msc-callout-layer {
    display: none !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;
  }
}
