/* =========================================================
   AFA STEEL — VERTICAL SERPENTINE SCROLL-DRIVEN PRODUCTION EXPERIENCE
   Cinematic Industrial Motion Stylesheet
   ========================================================= */

:root {
  --afa-crimson: #d7182a;
  --afa-crimson-glow: rgba(215, 24, 42, 0.4);
  --afa-dark: #0b0d11;
  --afa-dark-surface: #14171d;
  --afa-steel-grey: #a0a4aa;
  --afa-hud-bg: rgba(11, 13, 17, 0.85);
  --afa-hud-border: rgba(255, 255, 255, 0.12);
}

/* Master Serpentine 700vh Scroll Wrapper */
.serpentine-scroll-container {
  position: relative;
  width: 100%;
  height: 700vh;
  background: var(--afa-dark);
  color: #ffffff;
  z-index: 75; /* Above legacy journey-object (z-index: 60) */
}

/* Suppress legacy journey-object when in serpentine scroll */
body.in-serpentine-journey #journeyObject {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.in-serpentine-journey #siteHeader {
  opacity: 0;
  transform: translateY(-110%);
  pointer-events: none;
}

#siteHeader {
  transition: opacity .4s ease, transform .55s cubic-bezier(.16, 1, .3, 1);
}

/* Sticky Viewport Stage */
.serpentine-sticky-stage {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, #161a22 0%, #0b0d11 100%);
  will-change: transform;
}

.serpentine-sticky-stage.is-pinned {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
}

/* Master Industrial Canvas */
#serpentineCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Top Production Navigation Bar & Timeline */
.serpentine-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem clamp(1.2rem, 3vw, 2.5rem);
  background: linear-gradient(180deg, rgba(11, 13, 17, 0.95) 0%, rgba(11, 13, 17, 0) 100%);
  z-index: 30;
  pointer-events: auto;
}

.serpentine-brand-kicker {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.serpentine-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .75rem;
  border-radius: 8px;
  background: rgba(215, 24, 42, 0.15);
  border: 1px solid rgba(215, 24, 42, 0.35);
  color: var(--afa-crimson);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .08em;
  direction: ltr;
}

.serpentine-brand-kicker strong {
  font-size: .88rem;
  color: #e5e5e5;
  font-weight: 700;
}

/* Step Timeline Nav (Interactive Jump Dots) */
.serpentine-timeline-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--afa-hud-bg);
  padding: .4rem .9rem;
  border-radius: 999px;
  border: 1px solid var(--afa-hud-border);
  backdrop-filter: blur(10px);
}

.timeline-step-btn {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .3rem .65rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #888;
  font-family: inherit;
  font-size: .74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 220ms ease;
}

.timeline-step-btn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #555;
  transition: all 220ms ease;
}

.timeline-step-btn:hover {
  color: #fff;
}

.timeline-step-btn.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.timeline-step-btn.is-active .dot {
  background: var(--afa-crimson);
  box-shadow: 0 0 8px var(--afa-crimson);
  transform: scale(1.3);
}

/* Sound & Catalog Actions */
.serpentine-top-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.btn-audio-toggle {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  height: 38px;
  padding: 0 .9rem;
  border: 1px solid var(--afa-hud-border);
  border-radius: 10px;
  background: var(--afa-hud-bg);
  color: #bbb;
  font-family: inherit;
  font-size: .75rem;
  font-weight: 700;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 200ms ease;
}

.btn-audio-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-audio-toggle.is-playing {
  color: #28a745;
  border-color: rgba(40, 167, 69, 0.4);
}

.btn-goto-catalog {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  height: 38px;
  padding: 0 1.1rem;
  border-radius: 10px;
  background: var(--afa-crimson);
  color: #ffffff;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(215, 24, 42, 0.35);
  transition: all 200ms ease;
}

.btn-goto-catalog:hover {
  background: #bb1323;
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(215, 24, 42, 0.45);
}

/* HUD Overlay — Bottom Right Main Narrative Info */
.serpentine-hud-narrative {
  position: absolute;
  bottom: clamp(1.5rem, 3.5vw, 3rem);
  right: clamp(1.5rem, 3.5vw, 3.5rem);
  max-width: 480px;
  background: var(--afa-hud-bg);
  border: 1px solid var(--afa-hud-border);
  border-right: 3.5px solid var(--afa-crimson);
  border-radius: 16px;
  padding: 1.3rem 1.6rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  z-index: 30;
  pointer-events: none;
  transition: transform 300ms ease, opacity 300ms ease;
}

.hud-step-tag {
  display: inline-block;
  color: var(--afa-crimson);
  font-family: Arial, sans-serif;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .1em;
  margin-bottom: .3rem;
  direction: ltr;
}

.hud-title {
  margin: 0 0 .4rem;
  font-size: clamp(1.15rem, 1.8vw, 1.5rem);
  font-weight: 800;
  color: #ffffff;
  line-height: 1.3;
}

.hud-description {
  margin: 0;
  font-size: .82rem;
  color: #a8aab0;
  line-height: 1.6;
}

/* HUD Cross-Section Real-time Vector Inspector (Top Right) */
.serpentine-hud-cross-section {
  position: absolute;
  top: 5rem;
  left: clamp(1.2rem, 3vw, 2.5rem);
  background: var(--afa-hud-bg);
  border: 1px solid var(--afa-hud-border);
  border-radius: 16px;
  padding: 1rem 1.3rem;
  backdrop-filter: blur(12px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.cs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.cs-title {
  font-size: .74rem;
  font-weight: 800;
  color: #888;
  letter-spacing: .06em;
}

.cs-stage-val {
  color: var(--afa-crimson);
  font-size: .75rem;
  font-weight: 800;
  direction: ltr;
}

.cs-canvas-box {
  width: 180px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#crossSectionCanvas {
  width: 100%;
  height: 100%;
}

.cs-footer-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .7rem;
  color: #666;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: .4rem;
}

.cs-footer-metrics strong {
  color: #bbb;
}

/* Bottom Scroll Scrubber Indicator */
.serpentine-bottom-scrubber {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  z-index: 35;
}

.scrubber-fill-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--afa-crimson), #ff4a5a);
  box-shadow: 0 0 10px var(--afa-crimson);
  transition: width 80ms linear;
}

/* Scroll Hint Indicator */
.serpentine-scroll-hint {
  position: absolute;
  bottom: 1.8rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  color: #888;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  z-index: 30;
  pointer-events: none;
  animation: hint-bounce 2s infinite ease-in-out;
}

.scroll-hint-mouse {
  width: 18px;
  height: 28px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  position: relative;
}

.scroll-hint-mouse::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 5px;
  border-radius: 2px;
  background: var(--afa-crimson);
  animation: mouse-wheel 1.5s infinite;
}

@keyframes mouse-wheel {
  0% { transform: translate(-50%, 0); opacity: 1; }
  80% { transform: translate(-50%, 9px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 0; }
}

@keyframes hint-bounce {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 6px); }
}

/* Final Reveal Screen CTA Modal Inside Canvas Stage */
.serpentine-final-reveal-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: clamp(3rem, 6vw, 5.5rem);
  text-align: center;
  z-index: 32;
  pointer-events: none;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 400ms ease, transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.serpentine-final-reveal-box.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.reveal-inner-card {
  max-width: 680px;
  padding: 2rem 2.5rem;
  background: rgba(11, 13, 17, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  backdrop-filter: blur(16px);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.6);
}

.reveal-kicker {
  display: inline-block;
  color: var(--afa-crimson);
  font-family: Arial, sans-serif;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  margin-bottom: .4rem;
}

.reveal-title {
  margin: 0 0 .5rem;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 800;
  color: #ffffff;
}

.reveal-subtitle {
  margin: 0 0 1.2rem;
  font-size: .94rem;
  color: #c4c6cc;
  line-height: 1.6;
}

.reveal-action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.btn-reveal-catalog {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  height: 48px;
  padding: 0 1.8rem;
  border-radius: 12px;
  background: var(--afa-crimson);
  color: #ffffff;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(215, 24, 42, 0.4);
  transition: all 220ms ease;
}

.btn-reveal-catalog:hover {
  background: #bb1323;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(215, 24, 42, 0.5);
}

.btn-reveal-contact {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  height: 48px;
  padding: 0 1.4rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 200ms ease;
}

.btn-reveal-contact:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.35);
}

/* Responsive Rules for Mobile (9:16) */
@media (max-width: 768px) {
  .serpentine-top-bar {
    padding: .8rem 1rem;
  }
  .serpentine-timeline-nav {
    display: none;
  }
  .serpentine-hud-cross-section {
    top: 4.2rem;
    left: .8rem;
    padding: .6rem .8rem;
  }
  .cs-canvas-box {
    width: 120px;
    height: 50px;
  }
  .serpentine-hud-narrative {
    bottom: 1.2rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
    padding: 1rem 1.2rem;
  }
  .hud-title {
    font-size: 1.05rem;
  }
  .hud-description {
    font-size: .75rem;
    line-height: 1.45;
  }
  .reveal-inner-card {
    padding: 1.4rem;
    margin: 0 1rem;
  }
  .reveal-title {
    font-size: 1.4rem;
  }
  .btn-reveal-catalog,
  .btn-reveal-contact {
    width: 100%;
    justify-content: center;
  }
}

/* WebGL cinematic treatment */
.serpentine-sticky-stage::before,
.serpentine-sticky-stage::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
}

.serpentine-sticky-stage::before {
  background:
    radial-gradient(circle at 50% 46%, transparent 38%, rgba(0, 0, 0, .26) 76%, rgba(0, 0, 0, .72) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, .34), transparent 22%, transparent 72%, rgba(0, 0, 0, .42));
}

.serpentine-sticky-stage::after {
  opacity: .14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

#serpentineCanvas {
  z-index: 1;
  background: #080a0d;
  filter: saturate(.92) contrast(1.04);
}

.serpentine-top-bar,
.serpentine-hud-cross-section,
.serpentine-hud-narrative,
.serpentine-scroll-hint,
.serpentine-bottom-scrubber,
.serpentine-final-reveal-box {
  z-index: 30;
}

.serpentine-top-bar {
  padding-top: max(1.15rem, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(5, 7, 10, .9), rgba(5, 7, 10, .42) 50%, transparent);
}

.serpentine-brand-badge,
.serpentine-timeline-nav,
.btn-audio-toggle,
.serpentine-hud-cross-section,
.serpentine-hud-narrative,
.reveal-inner-card {
  background: linear-gradient(135deg, rgba(13, 16, 21, .9), rgba(20, 25, 31, .62));
  border-color: rgba(199, 214, 225, .17);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
}

.serpentine-hud-narrative {
  max-width: min(510px, calc(100vw - 3rem));
  border-right-color: #e11d31;
  box-shadow: 0 26px 72px rgba(0, 0, 0, .52), inset 0 1px rgba(255, 255, 255, .035);
}

.hud-step-tag,
.cs-title,
.cs-stage-val,
.reveal-kicker {
  letter-spacing: .13em;
}

.hud-title {
  letter-spacing: -.025em;
  text-wrap: balance;
}

.hud-description {
  color: #bdc4cc;
  line-height: 1.75;
}

.serpentine-hud-cross-section {
  box-shadow: 0 20px 56px rgba(0, 0, 0, .42), inset 0 1px rgba(255, 255, 255, .035);
}

.timeline-step-btn {
  min-height: 36px;
}

.timeline-step-btn.is-active {
  background: linear-gradient(135deg, rgba(215, 24, 42, .2), rgba(255, 255, 255, .07));
}

.serpentine-loading {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: .65rem;
  color: white;
  background: radial-gradient(circle at 50% 45%, #181d24, #07090c 72%);
  transition: opacity .65s ease, visibility .65s ease;
}

.serpentine-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.serpentine-loading span {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-top-color: #d7182a;
  border-radius: 50%;
  animation: afa-loader 1s linear infinite;
}

.serpentine-loading strong {
  margin-top: .6rem;
  font-size: .92rem;
}

.serpentine-loading small {
  color: #6f7780;
  font: 600 .62rem/1.2 Arial, sans-serif;
  letter-spacing: .18em;
}

@keyframes afa-loader {
  to { transform: rotate(360deg); }
}

.serpentine-no-webgl #serpentineCanvas {
  background:
    linear-gradient(90deg, rgba(7, 9, 12, .82), rgba(7, 9, 12, .34)),
    url('assets/bg.jpg') center / cover no-repeat;
}

@media (max-width: 1100px) {
  .serpentine-brand-kicker > strong {
    display: none;
  }

  .timeline-step-btn span:last-child {
    display: none;
  }

  .timeline-step-btn {
    width: 34px;
    justify-content: center;
    padding: .3rem;
  }
}

@media (max-width: 768px) {
  .serpentine-scroll-container {
    height: 560vh;
  }

  .serpentine-hud-cross-section {
    top: 4.4rem;
    border-radius: 12px;
    transform: scale(.9);
    transform-origin: top left;
  }

  .serpentine-hud-narrative {
    bottom: max(1rem, env(safe-area-inset-bottom));
    border-radius: 15px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .56);
  }

  .serpentine-scroll-hint {
    display: none;
  }

  .btn-audio-toggle {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .btn-audio-toggle span,
  .btn-goto-catalog span {
    display: none;
  }

  .btn-goto-catalog {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  .reveal-inner-card {
    max-height: calc(100dvh - 7rem);
    overflow: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .serpentine-loading span,
  .serpentine-scroll-hint,
  .scroll-hint-mouse::before {
    animation: none !important;
  }

  .serpentine-final-reveal-box,
  .serpentine-loading {
    transition-duration: .01ms !important;
  }
}
