/* ============================================
   Vertical Integration Elements
   Depth Gauge + Pipe Connectors
   ============================================ */

/* ========================================
   DEPTH GAUGE - Scroll Progress Indicator
   Fixed right side, shows altitude as you scroll
   ======================================== */

.depth-gauge-container {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.depth-gauge-container.visible {
  opacity: 1;
}

.depth-gauge {
  position: relative;
  width: 52px;
  filter: drop-shadow(2px 4px 10px rgba(0,0,0,0.5));
}

/* --- Valve (top, rotates on scroll) --- */

.gauge-valve {
  width: 40px;
  height: 40px;
  margin: 0 auto 4px;
  background:
    url('../assets/images/textures/brass-scratched.png'),
    radial-gradient(circle at 40% 35%,
      #E5C87A 0%,
      var(--color-brass-polished) 25%,
      var(--color-brass-aged) 60%,
      var(--color-bronze-dark) 100%
    );
  border: 2px solid var(--color-bronze-dark);
  border-radius: 50%;
  position: relative;
  box-shadow:
    inset 0 2px 6px rgba(255,255,255,0.35),
    inset 0 -2px 6px rgba(0,0,0,0.5),
    0 3px 6px rgba(0,0,0,0.35);
}

/* Valve cross-spokes */
.gauge-valve::before,
.gauge-valve::after {
  content: '';
  position: absolute;
  background: var(--color-bronze-dark);
  border-radius: 1px;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.2);
}

.gauge-valve::before {
  width: 3px;
  height: 70%;
  left: 50%;
  top: 15%;
  transform: translateX(-50%);
}

.gauge-valve::after {
  width: 70%;
  height: 3px;
  left: 15%;
  top: 50%;
  transform: translateY(-50%);
}

/* Center hub of valve */
.gauge-valve-spoke {
  position: absolute;
  width: 10px;
  height: 10px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--color-brass-polished), var(--color-bronze-dark));
  border-radius: 50%;
  border: 1px solid var(--color-bronze-dark);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}

/* --- Main Gauge Body --- */

.gauge-body {
  width: 52px;
  height: 350px;
  background:
    url('../assets/images/textures/brass-scratched.png'),
    linear-gradient(90deg,
      rgba(0,0,0,0.25) 0%,
      transparent 15%,
      transparent 85%,
      rgba(0,0,0,0.25) 100%
    ),
    linear-gradient(180deg,
      var(--color-brass-aged) 0%,
      #8B6F47 50%,
      var(--color-bronze-dark) 100%
    );
  border: 3px solid var(--color-bronze-dark);
  border-radius: var(--radius-sm);
  position: relative;
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,0.15),
    inset 0 -2px 8px rgba(0,0,0,0.5),
    4px 0 10px rgba(0,0,0,0.25),
    -2px 0 8px rgba(0,0,0,0.15);
}

/* Rivets on gauge body */
.gauge-rivet {
  position: absolute;
  width: 8px;
  height: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle at 35% 35%, #E5C87A, var(--color-bronze-dark));
  border: 1px solid rgba(0,0,0,0.4);
  border-radius: 50%;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.3),
    0 1px 2px rgba(0,0,0,0.4);
  z-index: 3;
}

.gauge-rivet-top { top: 8px; }
.gauge-rivet-bottom { bottom: 8px; }

/* --- Glass Window --- */

.gauge-glass {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 280px;
  background: rgba(10, 20, 30, 0.35);
  border: 2px solid rgba(180, 160, 120, 0.5);
  border-radius: 4px;
  overflow: hidden;
  box-shadow:
    inset 0 0 12px rgba(0,0,0,0.6),
    inset 0 2px 4px rgba(255,255,255,0.1);
}

/* Glass shine highlight */
.gauge-glass-shine {
  position: absolute;
  top: 0;
  left: 0;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.12) 0%,
    rgba(255,255,255,0.03) 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* Liquid fill (height controlled by JS) */
.gauge-liquid {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: linear-gradient(0deg,
    rgba(60, 130, 122, 0.95) 0%,
    rgba(91, 155, 142, 0.85) 40%,
    rgba(60, 130, 122, 0.7) 100%
  );
  box-shadow:
    0 -3px 10px rgba(60, 130, 122, 0.5),
    inset 0 2px 6px rgba(255,255,255,0.2);
  z-index: 1;
}

/* Liquid surface shimmer */
.gauge-liquid::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255,255,255,0.35) 50%,
    transparent 100%
  );
}

/* --- Gauge Markings (right side labels) --- */

.gauge-markings {
  position: absolute;
  left: calc(100% + 8px);
  top: 28px;
  height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.gauge-mark {
  font-family: var(--font-technical);
  font-size: 8px;
  color: var(--color-brass-polished);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  white-space: nowrap;
  position: relative;
  padding-left: 10px;
  line-height: 1;
}

/* Tick marks */
.gauge-mark::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 1px;
  background: var(--color-brass-polished);
  box-shadow: 0 0 2px rgba(212, 168, 88, 0.4);
}

/* --- Bottom Cap --- */

.gauge-cap {
  width: 36px;
  height: 20px;
  margin: 4px auto 0;
  background:
    url('../assets/images/textures/brass-scratched.png'),
    linear-gradient(180deg,
      var(--color-brass-aged) 0%,
      var(--color-bronze-dark) 100%
    );
  border: 2px solid var(--color-bronze-dark);
  border-radius: 0 0 6px 6px;
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,0.15),
    0 3px 6px rgba(0,0,0,0.35);
}

/* --- Steam Puffs (emitted at section crossings) --- */

.gauge-steam-puffs {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 80px;
  pointer-events: none;
  z-index: 10;
  overflow: visible;
}

.steam-puff {
  position: absolute;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, rgba(245, 241, 232, 0.7), transparent 70%);
  border-radius: 50%;
  opacity: 0;
}


/* ========================================
   PIPE NETWORK - Background Plumbing System
   Absolute-positioned tilemap between section backgrounds and content
   ======================================== */

/* Main needs relative positioning for the pipe network */
#main-content {
  position: relative;
}

/* Network container: sits between section backgrounds and section content.
   Sections must NOT have z-index (to avoid creating stacking contexts).
   Pipe network z-index: 1 places it above section backgrounds.
   Section content (.container) gets z-index: 2 to sit above pipes. */
.pipe-network {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* Sections: position relative for layout, but NO z-index
   so they don't create stacking contexts that trap content above/below pipes */
#main-content > section,
#main-content > .section-divider {
  position: relative;
  /* z-index deliberately omitted */
}

/* Section content sits above the pipe network */
#main-content > section > .container,
#main-content > section > h2,
#main-content > section > .section-header {
  position: relative;
  z-index: 2;
}

/* --- Pipe Tiles (base class for all pipe images) --- */

.pipe-tile {
  position: absolute;
  pointer-events: none;
  image-rendering: auto;
}

/* Vertical straight pipe: native 200x400, rendered at 100x200 */
.pipe-tile-v {
  width: 100px;
  height: 200px;
}

/* Horizontal straight pipe: rotated vertical.
   After rotation the visual footprint becomes 200w x 100h,
   but the CSS box remains 100w x 200h. JS compensates with offset positioning. */
.pipe-tile-h {
  width: 100px;
  height: 200px;
  transform: rotate(90deg);
  transform-origin: center center;
}

/* Elbow rotations (applied via inline style by JS) */
.pipe-tile-elbow-bl {
  /* bottom-left: opens bottom and left */
  transform: rotate(90deg);
}
.pipe-tile-elbow-br {
  /* bottom-right: opens bottom and right */
  transform: rotate(180deg);
}

/* Elbow and junction tiles: native 200x200, rendered at 100x100 */
.pipe-tile-elbow,
.pipe-tile-junction {
  width: 100px;
  height: 100px;
}

/* --- Pipe Overlay Decorations (gauges, valves — sit ON TOP of pipes) --- */

.pipe-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

/* Pressure gauge: rendered at 80x80 */
.pipe-overlay-gauge {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

/* Valve: rendered at 65x65, rotated by anime.js */
.pipe-overlay-valve {
  width: 65px;
  height: 65px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5));
}

/* Subtle drop shadow on all pipe tiles */
.pipe-tile {
  filter: drop-shadow(2px 3px 6px rgba(0,0,0,0.35));
}

/* Steam particle (reused for pipe network ambient effect) */
.pipe-steam-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: radial-gradient(circle,
    rgba(200, 200, 190, 0.5) 0%,
    rgba(200, 200, 190, 0.1) 60%,
    transparent 100%
  );
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}


/* ========================================
   RESPONSIVE
   ======================================== */

/* On tablet and up the depth gauge replaces the scrollbar as a scroll indicator.
   Hide the native scrollbar visually; scrolling still works via wheel/keyboard/touch. */
@media (min-width: 769px) {
  html {
    scrollbar-width: none; /* Firefox */
  }
  html::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Edge */
  }
}

@media (max-width: 1024px) {
  .depth-gauge-container {
    right: 8px;
  }

  .gauge-markings {
    display: none;
  }

  .depth-gauge {
    transform: scale(0.85);
    transform-origin: right center;
  }

  /* Scale pipe tiles down */
  .pipe-tile-v {
    width: 70px;
    height: 140px;
  }

  .pipe-tile-h {
    width: 70px;
    height: 140px;
  }

  .pipe-tile-elbow,
  .pipe-tile-junction {
    width: 70px;
    height: 70px;
  }

  .pipe-overlay-gauge {
    width: 56px;
    height: 56px;
  }

  .pipe-overlay-valve {
    width: 46px;
    height: 46px;
  }
}

@media (max-width: 768px) {
  .depth-gauge-container {
    display: none;
  }

  .pipe-network {
    display: none;
  }
}


/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .steam-puff,
  .pipe-steam-particle {
    display: none !important;
  }

  .gauge-liquid::after {
    animation: none !important;
  }

  .depth-gauge-container {
    opacity: 1;
    transition: none;
  }

  .pipe-overlay-valve {
    animation: none !important;
  }
}
