/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE.CSS — Van der Hoef Groen & Techniek
   SHARED cross-page mobile fixes. Wordt geladen ná style.css, a11y.css, perf.css.
   Owner: Mobile Agent M1
   ---------------------------------------------------------------------------
   INHOUD
   01 · Viewport / base tweaks (iOS zoom fix, dvh, overscroll)
   02 · Touch-action & tap-highlight
   03 · Skip-link (mobile-visible)
   04 · Header polish (compacter op mobile)
   05 · Hamburger nav (100dvh, safe-area, backdrop, scroll-lock, touch-height)
   06 · Cookie-banner (edge-to-edge, stacked, safe-area)
   07 · Container / section padding (mobile-rythm)
   08 · Body font-baseline (leesbaarheid)
   09 · Reveal / sticky guards
   10 · Universele hover-guard (hover:none apparaten)
   11 · Reduced-motion aanvullingen mobile
   ═══════════════════════════════════════════════════════════════════════════ */


/* ═══ 01 · VIEWPORT / BASE TWEAKS ══════════════════════════════════════════ */

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  /* overscroll-behavior-y: none; -- weggehaald: kon in combinatie met content-visibility
     scroll blokkeren op sommige mobile browsers. Rubber-band gedrag mag terug. */
}

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

/* iOS zoom fix: inputs onder 16px triggeren auto-zoom bij focus.
   Kritisch voor "keyboard-up-scroll" bug op offerte-formulieren. */
@media (max-width: 640px) {
  input,
  textarea,
  select,
  button {
    font-size: 16px;
  }
  /* Extra safeguard voor specifieke velden */
  .field input,
  .field textarea,
  .field select {
    font-size: 16px !important;
  }
}


/* ═══ 02 · TOUCH ACTION / TAP FEEDBACK ═════════════════════════════════════ */

a,
button,
[role="button"],
.btn,
.nav__toggle,
.nav__link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(20, 40, 20, 0.06);
}

/* Actieve tap-state als vervanging voor hover op touch */
@media (hover: none) {
  .btn:active { transform: translateY(1px); }
}


/* ═══ 03 · SKIP-LINK (mobile-visible & non-overlap) ════════════════════════ */

.skip-link {
  /* Zorg dat 't ALTIJD boven de hamburger uitkomt bij focus, ook op smalle schermen */
  z-index: 300;
  font-size: 15px;
  padding: 0.65rem 1rem;
  max-width: calc(100vw - 2rem);
}
@media (max-width: 400px) {
  .skip-link:focus {
    top: 0.5rem;
    left: 0.5rem;
    right: auto;
    padding: 0.6rem 0.9rem;
    font-size: 14px;
  }
}


/* ═══ 04 · HEADER polish op mobile ═════════════════════════════════════════ */

@media (max-width: 900px) {
  .header__inner {
    padding-block: 0.75rem;
    gap: 0.75rem;
  }
  .brand__mark-img {
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 380px) {
  /* Ruimte maken voor hamburger — verberg subtitel */
  .brand__sub { display: none; }
  .brand { gap: 0.5rem; }
  .brand__mark-img { width: 34px; height: 34px; }
}


/* ═══ 05 · HAMBURGER NAV (mobile) ══════════════════════════════════════════ */

@media (max-width: 900px) {
  /* Body scroll-lock wanneer menu open — CSS-side (JS regelt ook) */
  body.nav-open {
    overflow: hidden;
    /* Voorkomt iOS-rubber-band scroll van background */
    position: fixed;
    inset: 0;
    width: 100%;
  }

  /* Nav panel: vaste breedte off-canvas van RECHTS — GEEN full-width stretch
     want translateX(100%) op een 100vw-breed element bleek onbetrouwbaar op
     tablets/foldables (bleef half-zichtbaar rechts). Nu een panel met
     vaste breedte + drie hide-mechanismen (transform, visibility, pointer-events). */
  .nav__list {
    position: fixed;
    top: 64px;
    left: auto;                          /* undo style.css inset left:0 */
    right: 0;
    bottom: 0;
    width: min(85vw, 380px);
    max-width: 100vw;
    height: calc(100dvh - 64px);
    padding-top: var(--space-md);
    padding-bottom: max(var(--space-lg), env(safe-area-inset-bottom));
    padding-left: max(clamp(1.25rem, 3vw, 2.5rem), env(safe-area-inset-left));
    padding-right: max(clamp(1.25rem, 3vw, 2.5rem), env(safe-area-inset-right));
    background: var(--color-cream);
    box-shadow: -20px 0 60px -20px rgba(20, 40, 20, 0.25);
    transform: translateX(110%);          /* 110% extra safety margin */
    visibility: hidden;
    pointer-events: none;
    transition: transform var(--dur) var(--ease), visibility 0s linear var(--dur);
    z-index: 45;
  }
  body.nav-open .nav__list {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform var(--dur) var(--ease), visibility 0s linear;
  }

  /* Backdrop-blur pseudo achter nav — subtiel gedimd */
  .nav__list::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(20, 24, 15, 0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
    z-index: -1;
  }
  body.nav-open .nav__list::before {
    opacity: 1;
  }

  /* Touch-height minimaal 48px voor duimen */
  .nav__link {
    min-height: 48px;
    padding: 0.9rem 0;
    display: flex;
    align-items: center;
  }

  /* CTA prominent op mobile */
  .nav__cta {
    width: 100%;
    justify-content: center;
    padding: 0.9em 1.4em !important;
    font-size: var(--step-0) !important;
    min-height: 52px;
    margin-top: 0.5rem;
  }

  /* Hamburger toggle prominenter + safe-area rekening */
  .nav__toggle {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 900px) and (max-width: 380px) {
  .nav__link {
    font-size: var(--step-1);
    padding: 0.8rem 0;
  }
}


/* ═══ 06 · COOKIE-BANNER ═══════════════════════════════════════════════════ */
/* Passief — mag genegeerd worden, blokkeert niks. Compact op mobile zodat het
   niet aanvoelt als een modaal menu. */

@media (max-width: 640px) {
  .cookie-banner {
    left: 0.5rem;
    right: 0.5rem;
    bottom: max(0.5rem, env(safe-area-inset-bottom));
    padding: 0.85rem 0.9rem 0.95rem;
    border-radius: 10px;
    max-width: none;
    box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.45);
  }
  .cookie-banner__text {
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 0.65rem;
  }
  .cookie-banner__actions {
    flex-direction: row;
    gap: 0.5rem;
  }
  .cookie-banner__actions .btn {
    flex: 1;
    justify-content: center;
    min-height: 40px;
    padding: 0.5em 0.75em;
    font-size: 13px;
  }
  /* "Alleen noodzakelijk" is secundair — subtieler op mobile */
  .cookie-banner__decline {
    border: 1px solid var(--color-mist);
    color: var(--color-cream);
    background: transparent;
  }
}


/* ═══ 07 · CONTAINER / SECTION PADDING op mobile ═══════════════════════════ */

@media (max-width: 640px) {
  .container,
  .container-narrow {
    padding-inline: 1.1rem;
  }
  .section    { padding-block: 3.5rem; }
  .section-lg { padding-block: 4.5rem; }
  .section-sm { padding-block: 2.5rem; }
}

@media (max-width: 400px) {
  .container,
  .container-narrow {
    padding-inline: 1rem;
  }
}


/* ═══ 08 · BODY FONT-BASELINE (leesbaarheid) ═══════════════════════════════ */

@media (max-width: 640px) {
  body {
    font-size: max(15px, var(--step-0));
    line-height: 1.55;
  }
}


/* ═══ 09 · REVEAL & STICKY GUARDS op mobile ════════════════════════════════ */

/* Snelle scrollers krijgen niet-blokkerende reveal — kortere duration */
@media (max-width: 900px) {
  .reveal {
    transition-duration: 380ms;
  }
  /* Voorkom dat sticky elementen op mobile de layout ondermijnen (case-by-case) */
  .hp-index__stage,
  .sticky-side,
  [data-sticky] {
    position: relative !important;
    top: auto !important;
  }
}


/* ═══ 10 · UNIVERSELE HOVER-GUARD (hover: none) ════════════════════════════ */

@media (hover: none) {
  /* Zet transform-based hover-effects uit — die veroorzaken sticky-hover-glitches
     op touch. Kleur- en background-hovers laten we staan (schaden niet). */
  .btn:hover,
  .machine-card:hover,
  .service-card:hover,
  .hp-fleet__card:hover,
  .hp-index__link:hover,
  .hp-refs__item:hover {
    transform: none;
  }
  .btn:hover .btn__arrow { transform: none; }
  .hp-fleet__card:hover .hp-fleet__media img { transform: none; }

  /* Onderline-in animatie op nav-link mag aan blijven (kleur only) */
  .nav__link::after { transition: none; }
}


/* ═══ 11 · REDUCED-MOTION aanvullingen op mobile ═══════════════════════════ */

@media (max-width: 900px) and (prefers-reduced-motion: reduce) {
  * {
    animation-play-state: paused !important;
  }
}


/* ═══ 12 · FORM tweaks (algemene mobile) ═══════════════════════════════════ */

@media (max-width: 640px) {
  .form { gap: 1rem; }
  .field input,
  .field textarea,
  .field select {
    padding: 0.9em 0.9em;
    min-height: 48px;
    border-radius: 6px;
  }
  .field textarea { min-height: 120px; }

  /* Voorkom viewport-jump wanneer keyboard opent op iOS — smooth focus */
  .field input:focus,
  .field textarea:focus,
  .field select:focus {
    scroll-margin-top: 80px;
    scroll-margin-bottom: 80px;
  }
}


/* ═══ 13 · FOOTER compact op mobile ════════════════════════════════════════ */

@media (max-width: 640px) {
  .footer {
    padding-block: 3rem 1.25rem;
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  }
  .footer__grid { gap: 2rem; margin-bottom: 2rem; }
  .footer__bottom { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}


/* ═══ 14 · CTA-STRIP mobile ════════════════════════════════════════════════ */

@media (max-width: 640px) {
  .cta-strip { padding-block: 3.5rem; }
  .cta-strip__actions { align-items: stretch; }
  .cta-strip__actions .btn { width: 100%; justify-content: center; }
  .cta-strip__phone { font-size: var(--step-3); word-break: break-all; }
}


/* ═══ 15 · UTILITIES ═══════════════════════════════════════════════════════ */

/* iOS momentum-scroll fix voor horizontal scrollers */
@media (max-width: 900px) {
  [class*="__scroller"],
  .horizontal-scroll {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
}

/* Prevent overflow-x horrors from decoratieve elementen */
@media (max-width: 640px) {
  html, body { overflow-x: hidden; }
}


/* ═══════════════════════════════════════════════════════════════════════════
   16 · MOBILE DRAWER (herbouwd VANAF NUL — nieuwe classnames)
   ---------------------------------------------------------------------------
   Vervangt de oude .nav__list-drawer op mobiel. Op <=900px wordt de oude
   .nav__list volledig verborgen (display:none !important) zodat oude CSS
   NIET meer kan interfereren met een half-zichtbaar paneel-bug.
   Gebruikt native <dialog> element → native focus-trap, backdrop, ESC-sluiten.
   Op desktop (>900px) is de drawer volledig display:none en werkt de originele
   horizontale nav zoals altijd.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Default: op desktop volledig weg (dialog is 'display: none' native als niet [open], maar we forceren extra) */
.mobile-drawer {
  display: none;
}

@media (max-width: 900px) {
  /* ─── Oude nav__list HELEMAAL uit op mobile ─── */
  /* Voorkomt dat oude off-canvas CSS ooit nog per ongeluk half-zichtbaar wordt. */
  .nav__list {
    display: none !important;
  }
  .nav__list::before {
    display: none !important;
    content: none !important;
  }
  /* body.nav-open scroll-lock is niet meer nodig — dialog regelt zelf modaal-gedrag.
     Laat de oude regel bestaan als fallback wanneer <dialog> niet ondersteund wordt. */

  /* ─── Nieuwe drawer ─── */
  .mobile-drawer {
    display: block;
    /* Reset native dialog styling */
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    max-width: 100vw;
    max-height: 100vh;
    inset: 0;
    color: inherit;
  }
  /* Gesloten dialog moet écht weg zijn (browser default is display:none, maar make explicit) */
  .mobile-drawer:not([open]) {
    display: none !important;
  }
  .mobile-drawer[open] {
    display: block;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 999;
    animation: mobileDrawerFadeIn 220ms ease-out;
  }
  .mobile-drawer::backdrop {
    background: rgba(20, 24, 15, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }

  .mobile-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 400px);
    background: var(--color-cream, #f5f1e6);
    padding: 1.25rem clamp(1.25rem, 4vw, 2rem) max(1.5rem, env(safe-area-inset-bottom));
    padding-right: max(clamp(1.25rem, 4vw, 2rem), env(safe-area-inset-right));
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    box-shadow: -20px 0 60px -20px rgba(20, 40, 20, 0.35);
    animation: mobileDrawerSlideIn 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
    -webkit-overflow-scrolling: touch;
  }

  .mobile-drawer__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-line, rgba(20, 40, 20, 0.12));
  }
  .mobile-drawer__title {
    font-family: var(--font-display, serif);
    font-size: var(--step-2, 1.5rem);
    color: var(--color-ink, #14281e);
    font-weight: 600;
    letter-spacing: 0.02em;
  }
  .mobile-drawer__close {
    width: 44px;
    height: 44px;
    background: transparent;
    border: 0;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-ink, #14281e);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 160ms ease;
  }
  .mobile-drawer__close:hover,
  .mobile-drawer__close:focus-visible {
    background: rgba(20, 40, 20, 0.08);
    outline: none;
  }

  .mobile-drawer__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
  }
  .mobile-drawer__item {
    margin: 0;
  }
  .mobile-drawer__link {
    display: flex;
    align-items: center;
    min-height: 52px;
    padding: 0.9rem 0;
    font-family: var(--font-display, serif);
    font-size: var(--step-2, 1.375rem);
    color: var(--color-ink, #14281e);
    text-decoration: none;
    border-bottom: 1px solid var(--color-line, rgba(20, 40, 20, 0.10));
    transition: color 160ms ease, padding-left 160ms ease;
  }
  .mobile-drawer__link:hover,
  .mobile-drawer__link:focus-visible {
    color: var(--color-forest, #1f5233);
    padding-left: 0.35rem;
    outline: none;
  }
  .mobile-drawer__link.is-active {
    color: var(--color-forest, #1f5233);
    font-weight: 600;
  }

  .mobile-drawer__cta {
    width: 100%;
    justify-content: center;
    margin-top: 0.75rem;
    padding: 0.95em 1.4em !important;
    font-size: var(--step-0, 1rem) !important;
    min-height: 52px;
  }

  .mobile-drawer__footer {
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid var(--color-line, rgba(20, 40, 20, 0.12));
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }
  .mobile-drawer__phone {
    font-family: var(--font-display, serif);
    font-size: var(--step-2, 1.375rem);
    color: var(--color-forest, #1f5233);
    text-decoration: none;
    font-weight: 600;
  }
  .mobile-drawer__phone:hover,
  .mobile-drawer__phone:focus-visible {
    text-decoration: underline;
    outline: none;
  }
  .mobile-drawer__email {
    color: var(--color-slate, #4a5a4f);
    text-decoration: none;
    font-size: var(--step--1, 0.9rem);
    word-break: break-all;
  }
  .mobile-drawer__email:hover,
  .mobile-drawer__email:focus-visible {
    color: var(--color-forest, #1f5233);
    text-decoration: underline;
    outline: none;
  }

  /* Body scroll-lock als extra safety-net (dialog.showModal doet dit al native) */
  body.mobile-drawer-open {
    overflow: hidden;
  }
}

/* Extra klein scherm — iets kleinere fonts */
@media (max-width: 380px) {
  .mobile-drawer__panel {
    width: min(92vw, 360px);
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }
  .mobile-drawer__link {
    font-size: var(--step-1, 1.15rem);
    min-height: 48px;
  }
}

/* Reduced motion — geen slide-in animatie */
@media (prefers-reduced-motion: reduce) {
  .mobile-drawer[open],
  .mobile-drawer__panel {
    animation: none !important;
  }
}

@keyframes mobileDrawerFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes mobileDrawerSlideIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

