/* =========================================================
   VENTUREEX — Responsive layer (loads last)
   Covers: large screens · laptops · tablets (portrait + landscape)
   · large phones · phones · small phones · landscape phones
   · touch devices · notched screens.

   Breakpoint ladder used throughout:
     ≥1700   large desktop        ≤1100  small laptop / tablet landscape
     ≤980    tablet portrait      ≤720   large phone
     ≤560    phone                ≤520   header CTA moves into menu
     ≤480    small phone          ≤380   very small phone
     landscape + max-height 540   phones held sideways
   ========================================================= */

/* ---------------------------------------------------------
   0. Foundations
   --------------------------------------------------------- */
html{
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;                 /* no sideways scroll, without breaking scrolling */
}
.parsec{
  overflow-x: clip;                 /* falls back to the existing "hidden" in old browsers */
  -webkit-tap-highlight-color: rgba(0,255,56,.15);
}
.parsec img, .parsec video, .parsec iframe, .parsec canvas{ max-width: 100%; }
.parsec h1, .parsec h2, .parsec h3, .parsec h4,
.parsec p, .parsec li, .parsec a{ overflow-wrap: break-word; }

/* Respect phone notches / rounded corners (needs viewport-fit=cover, set in header.php) */
.parsec .container{
  padding-left:  max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-left));
  padding-right: max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-right));
}
.p-cta{
  margin-left:  max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-left));
  margin-right: max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-right));
}
.p-footer{ padding-bottom: calc(2.5rem + env(safe-area-inset-bottom)); }

/* Hero: 100svh with a 100vh fallback for older browsers */
.p-hero{ min-height: 100vh; min-height: 100svh; overflow-x: clip; }
/* Fill the container so the hero copy always lines up with the logo on the left
   (without this it shrinks to its content and floats centred when the heading is smaller). */
.p-hero-inner{ width: 100%; }

/* ---------------------------------------------------------
   Smooth scrolling (Lenis) — the rules the library requires.
   --------------------------------------------------------- */
html.lenis, html.lenis body{ height: auto; }
.lenis.lenis-smooth{ scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent]{ overscroll-behavior: contain; }
.lenis.lenis-stopped{ overflow: hidden; }
.lenis.lenis-scrolling iframe{ pointer-events: none; }   /* embeds never swallow scroll */

/* Reserve room under the hero content for the "scroll" indicator so they never touch */
@media (min-width: 561px){
  .p-hero{ padding-bottom: 6.5rem; }
}

/* Mobile-menu CTA (added in header.php) — hidden unless a rule below shows it */
.p-nav-links a.p-nav-mobile-cta{ display: none; }

/* ---------------------------------------------------------
   1. Large screens
   --------------------------------------------------------- */
@media (min-width: 1700px){
  :root{ --container: 1400px; }
}
@media (min-width: 2200px){
  :root{ --container: 1640px; }
  html{ font-size: 112.5%; }        /* 18px base so 4K / ultrawide doesn't look tiny */
}

/* ---------------------------------------------------------
   2. Small laptops / tablet landscape  (≤1100)
   --------------------------------------------------------- */
@media (min-width: 981px) and (max-width: 1100px){
  /* desktop nav row only — below 981px the links become a stacked menu with no gap */
  .p-nav-links{ gap: 1.4rem; }
  .p-nav-cta{ gap: 1rem; }
}
@media (max-width: 1100px){
  .p-marquee-track{ gap: 3.5rem; }
}

/* ---------------------------------------------------------
   3. Tablet portrait  (≤980)
   --------------------------------------------------------- */
@media (max-width: 980px){
  .p-hero-inner{ max-width: 100%; }

  /* 4-up process steps → 2×2 instead of a long single column */
  .p-process-list{ grid-template-columns: repeat(2, 1fr); gap: 2.2rem 1.6rem; }

  /* 3 work cards → 2 columns, the odd one out spans the full row */
  .p-work-grid{ grid-template-columns: repeat(2, 1fr); }
  .p-work-grid .p-work-card:last-child:nth-child(odd){ grid-column: 1 / -1; aspect-ratio: 16 / 8; }

  .p-footer-top{ gap: 2.5rem; }
  .p-pagehead{ padding-top: 6.8rem; }
}

/* Footer stacks once the brand block and the three link columns can't share a row */
/* Mobile menu panel: blur whatever scrolls behind it so the hero text doesn't ghost through */
@media (max-width: 980px){
  .p-nav-links{
    background: rgba(0,0,0,.985);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    padding-left:  max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-left));
    padding-right: max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-right));
  }
}

@media (max-width: 860px){
  .p-footer-top{ flex-direction: column; }
  .p-footer-cols{ width: 100%; justify-content: flex-start; }
  .p-footer-brand p{ max-width: 46ch; }
}

/* ---------------------------------------------------------
   4. Large phones / small tablets  (≤720)
   --------------------------------------------------------- */
@media (max-width: 720px){
  /* Hero orb: sit behind the text and stay out of the way of legibility */
  .orb-host canvas{ opacity: .6; }
  .orb-host::after{
    background: radial-gradient(75% 55% at 50% 32%, transparent 0%, rgba(0,0,0,.45) 65%, var(--void) 100%);
  }

  .p-map{ aspect-ratio: 4 / 3; }
  .p-card{ padding: 1.5rem 1.3rem 1.7rem; }
  .p-stat-card{ padding: 1.3rem; }
  .p-price-card{ padding: 1.7rem 1.4rem; }
  .p-section-head{ margin-bottom: 1.6rem; }
}

/* 3-up service cards are only ~165px wide between 560–700px (large phones, foldables,
   small landscape phones) — use 2 columns there, last odd card spans the row. */
@media (min-width: 561px) and (max-width: 700px){
  .p-services-grid.is-3col{ grid-template-columns: repeat(2, 1fr); }
  .p-services-grid.is-3col > .p-card:last-child:nth-child(odd){ grid-column: 1 / -1; }
}

/* Heavy glass blur is expensive on phones — the cards are already dark enough without it */
@media (max-width: 720px), (hover: none) and (pointer: coarse){
  .p-card, .p-work-card, .p-team-card, .p-price-card, .p-quote-panel,
  .p-spotlight, .p-contact-item, .p-form, .p-stat-card, .p-logo-chip,
  .p-project-card .p-card, .p-float-badge{
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ---------------------------------------------------------
   5. Phones  (≤560)
   --------------------------------------------------------- */
@media (max-width: 560px){
  /* The page templates set 2 columns inline on some service grids; inline styles
     beat normal media queries, so !important is required here. */
  .p-services-grid,
  .p-services-grid.is-3col{ grid-template-columns: 1fr !important; }

  .p-process-list{ grid-template-columns: 1fr; gap: 2.2rem; }
  /* Stat cards that carry a paragraph (About page) need the room of a full row.
     Cards with only a number + label keep the compact 2×2 layout. */
  .p-stats-grid:has(.p-stat-card p){ grid-template-columns: 1fr; }
  .p-work-grid{ grid-template-columns: 1fr; }
  .p-work-grid .p-work-card:last-child:nth-child(odd){ aspect-ratio: 4 / 5; }
  .p-logo-grid{ grid-template-columns: repeat(2, 1fr); }

  /* Hero */
  .p-eyebrow{ border-radius: 18px; line-height: 1.4; max-width: 100%; margin-bottom: 1.2rem; }
  .p-hero-sub{ margin-bottom: 1.8rem; }
  .p-hero-ctas{ margin-bottom: 2.2rem; gap: .8rem; }
  .p-hero-ctas .p-btn{ flex: 1 1 100%; }
  .p-hero-stats{ display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.4rem 1rem; }
  .p-scroll-cue{ display: none; }                 /* collides with the stats on short phones */

  /* Marquee */
  .p-marquee-wrap{ padding: 1.3rem 0; }
  .p-marquee-label{ font-size: .62rem; padding-right: 1rem; }
  .p-marquee-track{ padding-left: 7.5rem; gap: 2.6rem; }
  .p-marquee-track span{ font-size: 1.05rem; }

  /* Cards & panels */
  .p-btn{ --btnpad-x: 1.3rem; }
  .p-stat-card span{ font-size: .68rem; }
  .p-contact-item{ padding: 1rem; }
  .p-contact-item > div, .p-contact-item p, .p-contact-item a{ min-width: 0; overflow-wrap: anywhere; }
  .p-cta{ border-radius: 24px; }
  .p-spotlight{ min-height: 300px; }

  /* Footer */
  .p-footer-cols{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem 1.5rem; }
  .p-footer-col:last-child{ grid-column: 1 / -1; }
  .p-footer-col a{ overflow-wrap: anywhere; }
  .p-newsletter{ max-width: 100%; }
  .p-footer-bottom{ flex-direction: column; gap: .6rem; }
}

/* ---------------------------------------------------------
   6. Header on narrow screens  (≤520)
   The wordmark is ~170px wide, so the header button + logo + menu
   toggle cannot share a row. The CTA moves into the menu instead.
   --------------------------------------------------------- */
@media (max-width: 520px){
  .p-nav-cta > .p-btn{ display: none; }
  .p-nav-links a.p-nav-mobile-cta{
    display: inline-flex;
    margin-top: 1rem;
    padding: .9rem 1.6rem;
    border-bottom: 0;
    color: #04050a;
    justify-content: center;
  }
  .p-nav-links a.p-nav-mobile-cta:hover{ color: #04050a; }
}

/* ---------------------------------------------------------
   7. Small phones  (≤480)
   --------------------------------------------------------- */
@media (max-width: 480px){
  :root{
    --fs-h1:   clamp(2.1rem, 9.2vw, 2.9rem);
    --fs-h2:   clamp(1.65rem, 6.8vw, 2.2rem);
    --fs-stat: clamp(1.9rem, 8vw, 2.5rem);
  }
  .p-pagehead h1{ font-size: clamp(2rem, 8.6vw, 2.6rem); }
  .p-logo-img{ height: 22px; }
  .p-newsletter{ flex-direction: column; }
  .p-newsletter .p-btn{ width: 100%; }
  .p-filters{ gap: .5rem; }
  .p-filter-btn{ padding: .5rem .95rem; }
}

/* ---------------------------------------------------------
   8. Very small phones  (≤380)
   --------------------------------------------------------- */
@media (max-width: 380px){
  .p-btn{ white-space: normal; text-align: center; line-height: 1.3; }
  .p-hero-stats{ gap: 1.1rem .8rem; }
  .p-stats-grid{ gap: .8rem; }
  .p-stat-card{ padding: 1.1rem .9rem; }
}

/* ---------------------------------------------------------
   9. Touch devices (phones + tablets of any size)
   --------------------------------------------------------- */
@media (hover: none), (pointer: coarse){
  /* Stop "sticky" hover lifts after a tap */
  .p-card:hover, .p-work-card:hover, .p-team-card:hover, .p-price-card:hover,
  .p-quote-panel:hover, .p-spotlight:hover, .p-contact-item:hover,
  .p-stat-card:hover, .p-logo-chip:hover, .p-btn-primary:hover, .p-btn-ghost:hover{
    transform: none;
  }

  /* iOS zooms the page when a focused field is under 16px */
  .p-field input, .p-field textarea, .p-field select, .p-newsletter input{ font-size: 16px; }

  /* Comfortable tap targets (≈44px) */
  .p-nav-toggle{ width: 44px; height: 44px; }
  .p-filter-btn{ min-height: 42px; }
  .p-footer-col a{ padding: .55rem 0; }
  .p-nav-links a{ min-height: 44px; display: flex; align-items: center; }
  .p-testi-dots{ gap: .75rem; }
  .p-testi-dots button{ position: relative; }
  .p-testi-dots button::after{ content: ""; position: absolute; inset: -12px -6px; }
}

/* ---------------------------------------------------------
   10. Phones in landscape (short viewports)
   Height is the scarce resource here, so tighten vertical spacing,
   stop forcing the hero to full height, and use wider layouts.
   --------------------------------------------------------- */
@media (orientation: landscape) and (max-height: 540px){
  :root{
    --fs-h1: clamp(1.9rem, 1.2rem + 5vh, 3.2rem);
    --fs-h2: clamp(1.6rem, 1.1rem + 3.6vh, 2.4rem);
    --space-section: clamp(2rem, 1.5rem + 3vh, 3rem);
  }

  /* Header */
  .p-nav{ padding: .5rem 0; }
  .p-nav.is-scrolled{ padding: .4rem 0; }
  .p-logo-img{ height: 20px; }
  .p-nav-links{
    /* a long menu must scroll instead of running off the bottom of the screen */
    max-height: calc(100vh - 56px);
    max-height: calc(100dvh - 56px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-left:  max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-left));
    padding-right: max(clamp(1.25rem, 4vw, 2.5rem), env(safe-area-inset-right));
  }
  .p-nav-links a{ min-height: 40px; padding-block: .55rem; }

  /* Hero: content decides the height */
  .p-hero{ min-height: 0; padding-top: 4.6rem; padding-bottom: 2.4rem; }
  .p-scroll-cue{ display: none; }
  .p-eyebrow{ margin-bottom: .9rem; padding: .35rem .8rem; }
  .p-hero h1{ margin-bottom: .8rem; }
  .p-hero-sub{ margin-bottom: 1.2rem; max-width: 60ch; }
  .p-hero-ctas{ margin-bottom: 1.5rem; }
  .p-hero-ctas .p-btn{ flex: 0 1 auto; }
  .p-hero-stats{ display: flex; flex-wrap: wrap; gap: 1rem 1.8rem; }

  /* Inner-page headers + general rhythm */
  .p-pagehead{ padding-top: 4.8rem; padding-bottom: 1.8rem; }
  .p-breadcrumb{ margin-bottom: .8rem; }
  .p-section-head{ margin-bottom: 1.3rem; }
  .p-cta{ padding-block: 2.2rem; }
  .p-footer{ margin-top: 2rem; }
  .p-map{ aspect-ratio: 16 / 7; }
}

/* Wider-than-tall layouts for landscape phones that are wide enough to use them */
@media (orientation: landscape) and (max-height: 540px) and (min-width: 760px){
  .p-contact-grid{ grid-template-columns: .8fr 1.2fr; }
  .p-split{ grid-template-columns: 1fr 1fr; }
  .p-spotlight-grid{ grid-template-columns: repeat(2, 1fr); }
  .p-stats-grid{ grid-template-columns: repeat(4, 1fr); }
  .p-process-list{ grid-template-columns: repeat(4, 1fr); gap: 1.4rem; }
  .p-team-grid{ grid-template-columns: repeat(3, 1fr); }
  .p-footer-top{ flex-direction: row; }
}
@media (orientation: landscape) and (max-height: 540px) and (min-width: 820px){
  .p-pricing-grid{ grid-template-columns: repeat(3, 1fr); max-width: none; }
}

/* Short laptop windows & tablets in landscape (not phones): keep hero from being cramped */
@media (orientation: landscape) and (min-height: 541px) and (max-height: 700px){
  .p-hero{ padding-top: 5rem; padding-bottom: 2.5rem; }
  .p-scroll-cue{ display: none; }
}
