:root {
  --mobile-gutter: 16px;
  --mobile-panel-maxw: 240px;
  --mobile-cta-maxw: 320px;
}

img,
video {
  max-width: 100%;
  height: auto;
}

/* ============================================
   SECTION CONTAINMENT
   Prevent absolute overlays from bleeding into adjacent sections
   ============================================ */
section {
  position: relative;
  isolation: isolate;
}

section>.absolute {
  z-index: 1;
}

.min-h-screen-safe {
  min-height: 100vh;
}

@supports (height: 100svh) {
  .min-h-screen-safe {
    min-height: 100svh;
  }
}

@supports (height: 100dvh) {
  .min-h-screen-safe {
    min-height: 100dvh;
  }
}

@media (max-width: 768px) {

  /* Prevent horizontal overflow on mobile */
  html,
  body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  body {
    font-size: 16px;
    line-height: 1.6;
  }

  /* Constrain containers properly */
  .max-w-7xl,
  .max-w-6xl,
  .max-w-5xl {
    max-width: 100%;
    padding-left: var(--mobile-gutter);
    padding-right: var(--mobile-gutter);
  }

  /* Responsive text scaling - prevent overwhelming large text */
  .text-7xl,
  .text-6xl {
    font-size: clamp(1.75rem, 8vw, 3rem) !important;
    line-height: 1.1;
  }

  .text-5xl {
    font-size: clamp(1.5rem, 6vw, 2.25rem) !important;
    line-height: 1.15;
  }

  .text-4xl {
    font-size: clamp(1.25rem, 5vw, 1.75rem) !important;
    line-height: 1.2;
  }

  .text-3xl {
    font-size: clamp(1.125rem, 4.5vw, 1.5rem) !important;
    line-height: 1.25;
  }

  /* Body text - reduce sizes for mobile readability */
  .text-lg {
    font-size: 0.9375rem !important;
    /* 15px instead of 18px */
    line-height: 1.6;
  }

  .text-base {
    font-size: 0.875rem !important;
    /* 14px */
    line-height: 1.6;
  }

  /* Paragraph text in content sections */
  p.leading-relaxed,
  .leading-relaxed {
    font-size: 0.9375rem;
    line-height: 1.65;
  }

  /* Intro/description text */
  .text-gray-500.text-lg,
  .text-gray-600.leading-relaxed {
    font-size: 0.875rem !important;
    line-height: 1.6;
  }

  /* Smaller text stays small */
  .text-sm {
    font-size: 0.8125rem !important;
    /* 13px */
  }

  .text-xs {
    font-size: 0.6875rem !important;
    /* 11px */
  }

  /* Reduce padding on dense content sections */
  .p-12 {
    padding: 1.5rem !important;
  }

  .p-20 {
    padding: 2rem !important;
  }

  .md\:p-20 {
    padding: 1.5rem;
  }

  :root {
    --mobile-gutter: clamp(12px, 4vw, 20px);
    --mobile-panel-maxw: clamp(200px, calc(100vw - (var(--mobile-gutter) * 2) - 80px), 240px);
    --mobile-cta-maxw: clamp(260px, calc(100vw - (var(--mobile-gutter) * 2)), 320px);
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  button,
  a[href],
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
  }

  h1,
  h2,
  h3,
  h4 {
    word-break: break-word;
    hyphens: auto;
  }

  .cookie-content,
  .privacy-content,
  .disclaimer-content {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #mobile-menu {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  #mobile-menu a {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
  }

  .bg-fixed {
    background-attachment: scroll !important;
  }

  .section-compact {
    padding-top: clamp(48px, 10vw, 72px);
    padding-bottom: clamp(48px, 10vw, 72px);
  }

  /* ============================================
     MOBILE COMPACTNESS OPTIMIZATION
     Target: iPhone XR (414x896) / iPhone 12 Pro (390x844)
     ============================================ */

  /* Section vertical padding - drastically reduced */
  .py-20 {
    padding-top: 2.5rem !important;
    /* 40px instead of 80px */
    padding-bottom: 2.5rem !important;
  }

  .py-24 {
    padding-top: 2.5rem !important;
    /* 40px instead of 96px */
    padding-bottom: 2.5rem !important;
  }

  .py-32 {
    padding-top: 3rem !important;
    /* 48px instead of 128px */
    padding-bottom: 3rem !important;
  }

  .py-16 {
    padding-top: 2rem !important;
    /* 32px instead of 64px */
    padding-bottom: 2rem !important;
  }

  /* Padding-top/bottom individual */
  .pt-20,
  .pt-24,
  .pt-32 {
    padding-top: 2.5rem !important;
  }

  .pb-20,
  .pb-24,
  .pb-32 {
    padding-bottom: 2.5rem !important;
  }

  /* Bottom margins - tightened */
  .mb-16 {
    margin-bottom: 2rem !important;
    /* 32px instead of 64px */
  }

  .mb-12 {
    margin-bottom: 1.5rem !important;
    /* 24px instead of 48px */
  }

  .mb-8 {
    margin-bottom: 1rem !important;
    /* 16px instead of 32px */
  }

  .mb-6 {
    margin-bottom: 0.75rem !important;
    /* 12px instead of 24px */
  }

  /* Top margins - tightened */
  .mt-16,
  .mt-20 {
    margin-top: 2rem !important;
  }

  .mt-12 {
    margin-top: 1.5rem !important;
  }

  /* Gap utilities - compact spacing */
  .gap-16 {
    gap: 2rem !important;
    /* 32px instead of 64px */
  }

  .gap-12 {
    gap: 1.5rem !important;
    /* 24px instead of 48px */
  }

  .gap-8 {
    gap: 1rem !important;
    /* 16px instead of 32px */
  }

  .gap-6 {
    gap: 0.75rem !important;
    /* 12px instead of 24px */
  }

  /* Space-y utilities - tighter vertical rhythm */
  .space-y-16>*+* {
    margin-top: 2rem !important;
  }

  .space-y-12>*+* {
    margin-top: 1.5rem !important;
  }

  .space-y-8>*+* {
    margin-top: 1rem !important;
  }

  .space-y-6>*+* {
    margin-top: 0.75rem !important;
  }

  /* Min-height reductions */
  .min-h-\[600px\] {
    min-height: 350px !important;
  }

  .min-h-\[500px\] {
    min-height: 300px !important;
  }

  .min-h-\[400px\] {
    min-height: 250px !important;
  }

  /* Height reductions for containers */
  .h-\[600px\] {
    height: auto !important;
    min-height: 300px;
  }

  .h-\[500px\] {
    height: auto !important;
    min-height: 280px;
  }

  .h-\[400px\] {
    height: 280px !important;
  }

  /* Grid gaps - compact */
  .grid.gap-16 {
    gap: 1.5rem !important;
  }

  .grid.gap-12 {
    gap: 1rem !important;
  }

  /* Border/divider spacing adjustments */
  .border-l-4 {
    padding-left: 0.75rem !important;
  }

  /* Compact content blocks */
  .md\:pl-8 {
    padding-left: 0 !important;
    padding-top: 1rem;
  }

  /* Section intro text - max width for readability */
  section p.max-w-3xl,
  section p.max-w-2xl {
    max-width: 100%;
  }

  .stats-rail,
  .feature-rail {
    display: flex;
    overflow-x: auto;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .stats-rail::-webkit-scrollbar,
  .feature-rail::-webkit-scrollbar {
    display: none;
  }

  .stats-rail>* {
    flex: 0 0 auto;
    min-width: 150px;
    scroll-snap-align: start;
  }

  .feature-rail>* {
    flex: 0 0 auto;
    min-width: 220px;
    scroll-snap-align: start;
  }

  .feature-rail>*+* {
    margin-top: 0 !important;
  }

  .feature-rail--dark>* {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 0.75rem 1rem;
  }

  .feature-rail--light>* {
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 14px;
    padding: 0.75rem 1rem;
  }

  .rail-fade {
    position: relative;
    --rail-fade: #ffffff;
  }

  .rail-fade::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 100%;
    background: linear-gradient(to left, var(--rail-fade), rgba(255, 255, 255, 0));
    pointer-events: none;
  }

  .rail-fade--dark {
    --rail-fade: #0a0a0a;
  }
}

/* ============================================
   SKIP LINK - Accessibility
   ============================================ */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 9999;
  padding: 12px 24px;
  background: #D4B483;
  color: #000;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  border-radius: 4px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 16px;
  outline: 2px solid #000;
  outline-offset: 2px;
}