/* ============================================================================
 * HAUSEN — DESIGN SYSTEM & CUSTOM STYLES
 * ============================================================================
 * Color Palette Tokens:
 * - Deep Background: #101812
 * - Charcoal Surface: #191917
 * - Forest Green:    #23382B / #24352D
 * - Warm Ivory:      #F3F0E8
 * - Muted Sage:      #AEB9AB
 * - Muted Gold:      #B99A70
 * ============================================================================ */

:root {
  --bg-deep: #101812;
  --bg-charcoal: #191917;
  --bg-forest: #23382B;
  --bg-forest-deep: #24352D;
  --text-ivory: #F3F0E8;
  --text-sage: #AEB9AB;
  --accent-gold: #B99A70;

  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Cinematic easing curve */
  --ease-cinematic: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
  background-color: var(--bg-deep);
  color: var(--text-ivory);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-ivory);
  overflow-x: hidden;
  line-height: 1.6;
}

/* Typography Helpers */
.font-editorial {
  font-family: var(--font-serif);
}

.font-body {
  font-family: var(--font-sans);
}

/* ============================================================================
 * HERO VIDEO CONTAINER & RESPONSIVE SCALING (Desktop & Mobile)
 * ============================================================================ */
.hero-video-wrapper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  background-color: var(--bg-deep);
}

.hero-video-element {
  position: absolute;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%) scale(1.02);
  object-fit: cover;
  transition: opacity 1.2s var(--ease-cinematic);
}

/* Cinematic Dark Gradient Scrim over Hero Video */
.hero-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(16, 24, 18, 0.85) 0%,
    rgba(16, 24, 18, 0.58) 45%,
    rgba(16, 24, 18, 0.90) 85%,
    var(--bg-deep) 100%
  );
  pointer-events: none;
}

/* ============================================================================
 * ADAPTED AURORA AMBIENT BACKGROUND (Desktop Smooth, Mobile Minimal / Static)
 * ============================================================================ */
@keyframes hausenAurora {
  0%, 100% {
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1);
  }
  33% {
    transform: translate3d(6%, 5%, 0) rotate(8deg) scale(1.06);
  }
  66% {
    transform: translate3d(-5%, 8%, 0) rotate(-6deg) scale(0.96);
  }
}

.aurora-light {
  position: absolute;
  width: 72%;
  height: 72%;
  border-radius: 9999px;
  pointer-events: none;
  will-change: transform;
  animation-name: hausenAurora;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

/* ============================================================================
 * SELECTIVE MODERN GLASSMORPHISM RECIPES
 * ============================================================================ */
.glass-navbar {
  height: 60px;
  background: rgba(16, 24, 18, 0.76);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(243, 240, 232, 0.11);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  transition: background-color 0.35s var(--ease-cinematic),
              border-color 0.35s var(--ease-cinematic),
              box-shadow 0.35s var(--ease-cinematic);
}

#nav-logo {
  display: block;
  max-height: 32px;
  width: auto;
  object-fit: contain;
}

/* Scroll-Adaptive Header Transition */
#site-header {
  pointer-events: none;
  transition: padding 0.35s var(--ease-cinematic);
}

#site-header .glass-navbar {
  pointer-events: auto;
}

#site-header.is-scrolled {
  padding-top: 0.625rem;
  padding-bottom: 0.25rem;
}

#site-header.is-scrolled .glass-navbar {
  background: rgba(16, 24, 18, 0.94);
  border-color: rgba(243, 240, 232, 0.16);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
}

/* ============================================================================
 * MOBILE HAMBURGER BUTTON & EXPANDABLE NAVIGATION
 * ============================================================================ */
#mobile-menu-toggle {
  transition: background-color 0.3s ease, transform 0.2s ease, border-color 0.3s ease;
}

#mobile-menu-toggle:active {
  transform: scale(0.92);
}

.hamburger-line {
  transition: transform 0.32s var(--ease-cinematic),
              opacity 0.2s ease,
              background-color 0.25s ease;
  transform-origin: center;
}

#mobile-menu-toggle:hover .hamburger-line {
  background-color: var(--accent-gold);
}

#mobile-menu-toggle[aria-expanded="true"] {
  background-color: rgba(35, 56, 43, 0.45);
}

#mobile-menu-toggle[aria-expanded="true"] .hamburger-line {
  background-color: var(--accent-gold);
}

#mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

#mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

#mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

#mobile-nav-menu {
  opacity: 0;
  visibility: hidden;
  max-height: 0;
  overflow: hidden;
  margin-top: 0 !important;
  transform: translateY(-8px) scale(0.985);
  transform-origin: top center;
  pointer-events: none;
  transition: opacity 0.32s var(--ease-cinematic),
              transform 0.32s var(--ease-cinematic),
              max-height 0.35s var(--ease-cinematic),
              margin-top 0.35s var(--ease-cinematic),
              visibility 0.32s var(--ease-cinematic);
}

#mobile-nav-menu.is-open {
  opacity: 1 !important;
  visibility: visible !important;
  max-height: calc(100vh - 80px) !important;
  overflow-y: auto !important;
  margin-top: 0.5rem !important;
  transform: translateY(0) scale(1) !important;
  pointer-events: auto !important;
}

#mobile-nav-backdrop {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s var(--ease-cinematic), visibility 0.32s var(--ease-cinematic);
}

#mobile-nav-backdrop.is-open {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Staggered mobile navigation links entrance */
.mobile-nav-link {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.28s var(--ease-cinematic),
              transform 0.28s var(--ease-cinematic),
              background-color 0.2s ease,
              color 0.2s ease;
}

#mobile-nav-menu.is-open .mobile-nav-link {
  opacity: 1;
  transform: translateY(0);
}

#mobile-nav-menu.is-open .mobile-nav-link:nth-of-type(1) { transition-delay: 0.04s; }
#mobile-nav-menu.is-open .mobile-nav-link:nth-of-type(2) { transition-delay: 0.08s; }
#mobile-nav-menu.is-open .mobile-nav-link:nth-of-type(3) { transition-delay: 0.12s; }
#mobile-nav-menu.is-open .mobile-nav-link:nth-of-type(4) { transition-delay: 0.16s; }
#mobile-nav-menu.is-open .mobile-nav-link:nth-of-type(5) { transition-delay: 0.20s; }

.mobile-nav-cta-wrapper {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s var(--ease-cinematic),
              transform 0.3s var(--ease-cinematic);
}

#mobile-nav-menu.is-open .mobile-nav-cta-wrapper {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.24s;
}

/* Instant link exit on menu close */
#mobile-nav-menu:not(.is-open) .mobile-nav-link,
#mobile-nav-menu:not(.is-open) .mobile-nav-cta-wrapper {
  transition-delay: 0s !important;
  transition-duration: 0.15s !important;
}

.mobile-nav-link:active {
  background-color: rgba(35, 56, 43, 0.55) !important;
  color: var(--accent-gold) !important;
  transform: scale(0.985);
}

.mobile-nav-inquire:active {
  transform: scale(0.98);
  filter: brightness(0.95);
}

.glass-card {
  background: linear-gradient(
    145deg,
    rgba(35, 56, 43, 0.34) 0%,
    rgba(25, 25, 23, 0.78) 100%
  );
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(243, 240, 232, 0.09);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  transition: border-color 0.4s var(--ease-cinematic),
              transform 0.4s var(--ease-cinematic),
              box-shadow 0.4s var(--ease-cinematic);
}

@media (hover: hover) and (min-width: 768px) {
  .glass-card:hover {
    border-color: rgba(185, 154, 112, 0.45);
    transform: translateY(-5px);
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.6);
  }
}

.glass-pill {
  background: rgba(35, 56, 43, 0.52);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(185, 154, 112, 0.32);
}

.glass-control-btn {
  background: rgba(16, 24, 18, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(243, 240, 232, 0.22);
  transition: all 0.3s var(--ease-cinematic);
}

.glass-control-btn:hover {
  border-color: var(--accent-gold);
  background: rgba(35, 56, 43, 0.9);
  transform: scale(1.08);
}

/* Sound Toggle Button (Mobile 44x44px base with 48x48px hit target) */
.sound-toggle-btn {
  position: relative;
  z-index: 20;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  flex-shrink: 0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

/* Expanded invisible touch hit area (minimum 48x48px on mobile touch screens) */
.sound-toggle-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 9999px;
  pointer-events: auto;
}

.sound-toggle-btn:active {
  transform: scale(0.92);
}

.sound-toggle-btn:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

@media (min-width: 768px) {
  .sound-toggle-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
  }

  .sound-toggle-btn::after {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

/* ============================================================================
 * SUBTLE NOISE / FILM GRAIN OVERLAY (matches services.png editorial texture)
 * ============================================================================ */
.subtle-grain {
  background-image: radial-gradient(rgba(243, 240, 232, 0.04) 1px, transparent 0);
  background-size: 24px 24px;
}

/* ============================================================================
 * VIDEO SHOWCASE CARDS (matches portfolio showcase 1 & 2.png)
 * ============================================================================ */
.video-card-frame {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background-color: #141a15;
  border: 1px solid rgba(243, 240, 232, 0.1);
  transition: border-color 0.4s var(--ease-cinematic),
              transform 0.4s var(--ease-cinematic),
              box-shadow 0.4s var(--ease-cinematic);
}

@media (hover: hover) and (min-width: 768px) {
  .video-card-frame:hover {
    border-color: rgba(185, 154, 112, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
  }
}

.video-overlay-gradient {
  background: linear-gradient(
    to top,
    rgba(16, 24, 18, 0.96) 0%,
    rgba(16, 24, 18, 0.68) 38%,
    rgba(16, 24, 18, 0.12) 72%,
    rgba(16, 24, 18, 0.35) 100%
  );
  transition: opacity 0.65s var(--ease-cinematic);
}

/* ============================================================================
 * IMMERSIVE VIDEO CARD CLEAN-VIEW (YouTube-style auto fade-out during playback)
 * ============================================================================ */
.video-card-frame .video-overlay-gradient,
.video-card-frame .video-card-top-bar,
.video-card-frame .video-card-badge,
.video-card-frame .sound-toggle-btn,
.video-card-frame .play-toggle-btn,
.video-card-frame .video-card-meta {
  transition: opacity 0.35s ease;
  will-change: opacity;
}

/* When 2.5 seconds of inactivity pass during playback, simple fade out */
.video-card-frame.is-immersive .video-overlay-gradient {
  opacity: 0 !important;
}

.video-card-frame.is-immersive .video-card-badge {
  opacity: 0 !important;
  pointer-events: none !important;
}

.video-card-frame.is-immersive .play-toggle-btn {
  opacity: 0 !important;
  pointer-events: none !important;
}

.video-card-frame.is-immersive .video-card-meta {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Sound button fades out visually but remains clickable in the top-right corner */
.video-card-frame.is-immersive .sound-toggle-btn {
  opacity: 0 !important;
  pointer-events: auto !important;
  cursor: pointer;
}

/* Visual feedback animation when the invisible sound button is clicked */
.video-card-frame.is-immersive .sound-toggle-btn.has-feedback {
  opacity: 1 !important;
  transition: opacity 0.2s ease;
}

/* ============================================================================
 * CINEMATIC ENTRANCE & SCROLL REVEAL ANIMATIONS
 * ============================================================================ */
/* Hero Entrance Keyframes */
@keyframes heroFadeUp {
  0% {
    opacity: 0;
    transform: translateY(24px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-animate-eyebrow {
  opacity: 0;
  animation: heroFadeUp 0.9s var(--ease-cinematic) 0.15s forwards;
}

.hero-animate-headline {
  opacity: 0;
  animation: heroFadeUp 1.1s var(--ease-cinematic) 0.35s forwards;
}

.hero-animate-sub {
  opacity: 0;
  animation: heroFadeUp 1s var(--ease-cinematic) 0.55s forwards;
}

.hero-animate-badge {
  opacity: 0;
  animation: heroFadeUp 0.9s var(--ease-cinematic) 0.7s forwards;
}

.hero-animate-cta {
  opacity: 0;
  animation: heroFadeUp 0.9s var(--ease-cinematic) 0.85s forwards;
}

/* Scroll-triggered reveal classes */
.reveal-item {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.85s var(--ease-cinematic), transform 0.85s var(--ease-cinematic);
  will-change: opacity, transform;
}

.reveal-item.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger delay utility classes */
.stagger-1 { transition-delay: 0.08s; }
.stagger-2 { transition-delay: 0.16s; }
.stagger-3 { transition-delay: 0.24s; }
.stagger-4 { transition-delay: 0.32s; }
.stagger-5 { transition-delay: 0.40s; }

/* Interactive button transition */
.btn-cinematic {
  transition: all 0.3s var(--ease-cinematic);
}

.btn-cinematic:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(185, 154, 112, 0.25);
}

.btn-cinematic:active {
  transform: translateY(0);
}

/* ============================================================================
 * MOBILE SERVICES HORIZONTAL CAROUSEL (Direct Card Swiper — No Selector)
 * ============================================================================ */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Carousel Track: Swipes smoothly on touch, snaps gracefully */
.mobile-services-carousel {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 1rem 1rem 1rem;
  margin-left: -1rem;
  margin-right: -1rem;
}

/* Each full service card occupies 82% of screen width so the next card peeks in by 18% */
.mobile-service-card {
  flex: 0 0 82%;
  max-width: 320px;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 1rem;
  padding: 1.5rem;
  background: linear-gradient(
    145deg,
    rgba(35, 56, 43, 0.45) 0%,
    rgba(25, 25, 23, 0.92) 100%
  );
  border: 1px solid rgba(243, 240, 232, 0.11);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
}

/* Service Number: keep '( 001 )' on a single line, never shrink or wrap */
.mobile-service-number {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* Subtle dot pagination indicator */
.carousel-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: rgba(243, 240, 232, 0.2);
  transition: all 0.3s var(--ease-cinematic);
}

.carousel-dot.is-active {
  width: 20px;
  background-color: var(--accent-gold);
}

/* ============================================================================
 * MOBILE-ONLY REFINEMENTS (< 768px)
 * ============================================================================ */
@media (max-width: 767px) {
  html {
    scroll-behavior: auto;
  }

  /* 1. HERO VIDEO ON MOBILE: Enabled, object-fit cover, with balanced mobile contrast scrim */
  .hero-video-element {
    display: block !important;
    opacity: 1 !important;
  }

  .hero-scrim {
    background: linear-gradient(
      to bottom,
      rgba(16, 24, 18, 0.88) 0%,
      rgba(16, 24, 18, 0.65) 45%,
      rgba(16, 24, 18, 0.92) 85%,
      var(--bg-deep) 100%
    );
  }

  /* 2. PORTFOLIO COMPACT REFINEMENTS (Mobile Viewport) */
  /* Vertical 9:16 videos: width approx 58-62% of viewport, centered, max-w 240px */
  .mobile-vertical-wrapper {
    width: 60vw !important;
    max-width: 240px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Landscape 16:9 videos: max-height constraint to avoid excessive vertical scrolling */
  .mobile-horizontal-frame {
    max-height: 220px !important;
  }

  /* Keep horizontal video preview overlay minimal on mobile */
  .horizontal-tags-container {
    display: none !important;
  }

  /* Prevent service number parentheses from wrapping on mobile */
  .mobile-service-number {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  /* 3. LIGHTWEIGHT MOBILE PERFORMANCE & REFINED ANIMATIONS */
  .aurora-light {
    animation: none !important;
    transform: none !important;
    opacity: 0.18 !important;
  }

  .glass-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: linear-gradient(
      145deg,
      rgba(35, 56, 43, 0.5) 0%,
      rgba(25, 25, 23, 0.96) 100%
    );
  }

  .glass-navbar {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(16, 24, 18, 0.94);
  }

  /* Refined Hero Entrance Animations on Mobile (subtle 16px upward float) */
  @keyframes mobileHeroFadeUp {
    0% {
      opacity: 0;
      transform: translateY(16px);
    }
    100% {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .hero-animate-eyebrow {
    opacity: 0;
    animation: mobileHeroFadeUp 0.65s var(--ease-cinematic) 0.10s forwards;
  }

  .hero-animate-headline {
    opacity: 0;
    animation: mobileHeroFadeUp 0.80s var(--ease-cinematic) 0.22s forwards;
  }

  .hero-animate-sub {
    opacity: 0;
    animation: mobileHeroFadeUp 0.75s var(--ease-cinematic) 0.36s forwards;
  }

  .hero-animate-badge {
    opacity: 0;
    animation: mobileHeroFadeUp 0.65s var(--ease-cinematic) 0.48s forwards;
  }

  .hero-animate-cta {
    opacity: 0;
    animation: mobileHeroFadeUp 0.70s var(--ease-cinematic) 0.60s forwards;
  }

  /* Subtle, Editorial Scroll-Triggered Reveals on Mobile (16px translation, 0.65s duration) */
  .reveal-item {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.65s var(--ease-cinematic), transform 0.65s var(--ease-cinematic);
    will-change: opacity, transform;
  }

  .reveal-item.is-revealed {
    opacity: 1 !important;
    transform: translateY(0) !important;
  }

  /* Mobile Stagger Delays (snappy 50-70ms sequence) */
  .stagger-1 { transition-delay: 0.05s; }
  .stagger-2 { transition-delay: 0.11s; }
  .stagger-3 { transition-delay: 0.17s; }
  .stagger-4 { transition-delay: 0.23s; }
  .stagger-5 { transition-delay: 0.29s; }

  /* Mobile Services Carousel Card Content Enhancement */
  .mobile-service-card {
    transition: transform 0.35s var(--ease-cinematic),
                box-shadow 0.35s var(--ease-cinematic),
                border-color 0.35s ease;
  }

  .mobile-service-card:active {
    border-color: rgba(185, 154, 112, 0.3);
  }

  /* Editorial Footer / Contact Sub-staggers on Mobile */
  #contact-info > div {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.55s var(--ease-cinematic), transform 0.55s var(--ease-cinematic);
  }

  #contact-info.is-revealed > div:nth-child(1) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.05s;
  }

  #contact-info.is-revealed > div:nth-child(2) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.12s;
  }

  #contact-info.is-revealed > div:nth-child(3) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.19s;
  }

  #contact-info.is-revealed > div:nth-child(4) {
    opacity: 1;
    transform: translateY(0);
    transition-delay: 0.26s;
  }
}

/* Accessibility: respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .aurora-light {
    animation: none !important;
  }

  .reveal-item,
  .mobile-nav-link,
  .mobile-nav-cta-wrapper,
  #contact-info > div,
  .mobile-service-card,
  .hero-animate-eyebrow,
  .hero-animate-headline,
  .hero-animate-sub,
  .hero-animate-badge,
  .hero-animate-cta {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
  }
}
