/* ===================================================================
   TOURS / CIRCUITS — MOBILE & TABLET POLISH
   ===================================================================
   Scope: Morocco tours landing (morocco-circuits.html) + every
          individual tour page (/tours/*.html) + future tour pages.

   Load order (IMPORTANT):
   Include this file AFTER the page's inline <style> block, i.e.
   place this <link> as the LAST stylesheet inside <head>:

       <link rel="stylesheet" href="/styles/tours-mobile.css">

   That way the cascade lets these rules win without heavy !important.

   Design system: untouched. No new colors, fonts, radii. Only
   responsive behavior, spacing, tap targets, sticky/sticky-safe
   geometry, and touch-only fixes.
   =================================================================== */


/* ─────────────────────────────────────────────
   0 · HEADER HEIGHT VARIABLE
   header-loader.js can override this at runtime:
     document.documentElement.style.setProperty('--header-h', h+'px')
   The static default below already fixes the
   sidebar-under-header issue on desktop tour pages.
   ───────────────────────────────────────────── */
:root {
  --header-h: 96px;
}


/* ─────────────────────────────────────────────
   1 · STICKY SIDEBAR RESPECTS THE FIXED HEADER
   Affects individual tour pages only. No effect on landing.
   ───────────────────────────────────────────── */
@media (min-width: 769px) {
  .sidebar {
    top: calc(var(--header-h) + 20px) !important;
  }
}


/* ─────────────────────────────────────────────
   2 · iOS SAFE-AREA FOR STICKY BOTTOM ELEMENTS
   Keeps the mobile booking bar and WhatsApp float
   above the iPhone home indicator.
   ───────────────────────────────────────────── */
.mobile-bar {
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }
  .wa-float {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
}


/* ─────────────────────────────────────────────
   3 · HERO: USE SMALL-VIEWPORT-HEIGHT
   Prevents the URL-bar-toggle layout jump on mobile.
   ───────────────────────────────────────────── */
.hero {
  min-height: 100svh;
}


/* ─────────────────────────────────────────────
   4 · RE-SHOW HERO STATS ON MOBILE (LANDING)
   Original CSS hides them with display:none at ≤768.
   This brings them back as an inline pill row below
   the CTAs — keeps social proof above the fold.
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero-stats {
    display: flex !important;
    position: static;
    left: auto;
    bottom: auto;
    transform: none;
    margin: 28px auto 0;
    gap: 18px;
    padding: .55rem 1.1rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
  }
  .hero-stat strong { font-size: 1rem; }
  .hero-stat span   { font-size: .66rem; }
}

@media (max-width: 380px) {
  .hero-stats { gap: 12px; padding: .5rem .8rem; }
  .hero-stat:nth-child(4) { display: none; } /* drop the 4th on the smallest phones */
}


/* ─────────────────────────────────────────────
   5 · TIGHTER HERO ON SMALL PHONES
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .hero {
    padding: 80px 16px 48px;
  }
  .hero h1 {
    font-size: clamp(1.95rem, 8vw, 2.6rem);
    margin-bottom: 18px;
  }
  .hero-desc {
    font-size: .95rem;
    line-height: 1.65;
    margin-bottom: 28px;
  }
  .hero-eyebrow {
    letter-spacing: .14em;
    padding: .35rem .8rem;
    font-size: .68rem;
    margin-bottom: 18px;
  }
}


/* ─────────────────────────────────────────────
   6 · HERO CTAs FULL-WIDTH WHEN STACKED
   Aligns the two buttons in the column instead of
   varying with label length.
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    max-width: 320px;
    margin: 0 auto;
  }
  .hero-actions .btn-primary,
  .hero-actions .btn-outline {
    width: 100%;
    justify-content: center;
    padding: .95rem 1.5rem;
  }
}


/* ─────────────────────────────────────────────
   7 · TIGHTER SECTION PADDING ON PHONES
   Recovers ~120px scroll per section.
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .section { padding: 56px 16px; }
  .cta-section { padding: 64px 16px; }
}


/* ─────────────────────────────────────────────
   8 · GALLERY: ALWAYS-VISIBLE LABELS ON TOUCH
   Original reveals captions only on :hover, which
   never fires on touch devices.
   ───────────────────────────────────────────── */
@media (hover: none), (pointer: coarse) {
  .gallery-item-overlay {
    opacity: 1 !important;
    background: linear-gradient(180deg, transparent 55%, rgba(15,13,10,.88) 100%);
  }
}


/* ─────────────────────────────────────────────
   9 · GALLERY: HORIZONTAL SCROLL-SNAP ON PHONES
   Replaces the 6× / 5× vertical stack with a
   swipeable row — preserves landscape feel.
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .gallery-grid {
    display: flex !important;
    grid-template-columns: none;
    grid-template-rows: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 10px;
    padding: 4px 16px 10px;
    margin: 0 -16px;
  }
  .gallery-grid::-webkit-scrollbar { display: none; }

  .gallery-grid .gallery-item,
  .gallery-grid .g-item {
    flex: 0 0 78%;
    height: 240px !important;
    scroll-snap-align: center;
    grid-column: auto !important;
    grid-row: auto !important;
  }
  .gallery-grid .gallery-item:first-child,
  .gallery-grid .g-item:first-child {
    grid-column: auto !important;
    grid-row: auto !important;
  }
}


/* ─────────────────────────────────────────────
   10 · TOUR CARDS — READABLE ON PHONES
   Smaller image, larger body copy, tighter chips.
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .tour-card-img,
  .circuit-card-img { height: 180px; }

  .tour-card-body,
  .circuit-card-body { padding: 18px 16px; }

  .tour-card-title,
  .circuit-card-title { font-size: 1.15rem; }

  .tour-card-desc,
  .circuit-card-desc {
    font-size: .9rem;   /* lifted off the .83rem floor */
    line-height: 1.6;
  }

  .tour-duration-badge,
  .tour-popular-badge,
  .circuit-duration-badge {
    font-size: .66rem;
    padding: .25rem .55rem;
  }

  /* Limit route chips to roughly one row so cards stay scannable */
  .tour-route-chips {
    max-height: 26px;
    overflow: hidden;
    position: relative;
  }
  .tour-route-chips::after {
    content: "";
    position: absolute;
    inset: 0 0 0 auto;
    width: 32px;
    background: linear-gradient(90deg, transparent, var(--bg-card, #1c1a16));
    pointer-events: none;
  }
}


/* ─────────────────────────────────────────────
   11 · TRUST GRID (LANDING) — NO ORPHAN ON MOBILE
   5 cards normally land as 2+2+1 on phones.
   Switch to a swipeable horizontal row instead.

   IMPORTANT: scoped to .trust-grid only, so the
   TripAdvisor / Google trust badges on tour pages
   (.trust-cards .trust-card) are NOT affected.
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .trust-grid {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding: 4px 16px 10px;
    margin: 0 -16px;
    scrollbar-width: none;
  }
  .trust-grid::-webkit-scrollbar { display: none; }

  .trust-grid .trust-card {
    flex: 0 0 62%;
    min-width: 200px;
    scroll-snap-align: center;
    padding: 26px 18px;
  }
  .trust-grid .trust-number { font-size: 2.3rem; }
}


/* ─────────────────────────────────────────────
   12 · CHOICE CARDS — TIGHTER PADDING
   Original 40px padding eats ~63% of card width
   on 360-wide phones.
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .choice-card {
    padding: 28px 22px;
    min-height: 380px;
  }
  .choice-card h2 { font-size: clamp(1.6rem, 6vw, 2rem); }
  .choice-card p  { font-size: .9rem; margin-bottom: 20px; }
  .choice-card-features { gap: 8px; margin-bottom: 22px; }
}
@media (max-width: 480px) {
  .choice-card {
    padding: 22px 18px;
    min-height: 340px;
  }
}


/* ─────────────────────────────────────────────
   13 · FILTER PILLS — HORIZONTAL SCROLL ROW
   Original wraps 14 pills to ~4 rows — visually heavy.
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .tours-filter {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    justify-content: flex-start;
    padding: 4px 16px;
    margin: 28px -16px 16px;
    gap: 8px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tours-filter::-webkit-scrollbar { display: none; }
  .tours-filter-btn {
    flex: 0 0 auto;
    scroll-snap-align: start;
    font-size: .8rem;
    padding: .55rem 1rem;
    white-space: nowrap;
  }
}


/* ─────────────────────────────────────────────
   14 · FILTER DROPDOWN PANEL — TIGHTER ON PHONES
   Pure CSS only; for full collapse, wrap the panel
   in <details><summary> at the HTML layer.
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .tours-filter-panel {
    padding: 14px 14px;
    gap: 10px;
    margin: 0 12px 24px;
  }
  .tours-filter-group { min-width: 0; }
  .tours-filter-label { font-size: .58rem; }
  .tours-filter-select { font-size: .85rem; padding: 10px 30px 10px 12px; }
}


/* ─────────────────────────────────────────────
   15 · TAP-TARGET FLOOR FOR TOUCH DEVICES
   WCAG 2.5.5 / Apple HIG: ≥44×44 pt.
   ───────────────────────────────────────────── */
@media (pointer: coarse) {
  .tours-filter-btn,
  .tour-card-btn,
  .tours-filter-reset,
  .tours-empty-btn,
  .faq-question,
  .faq-q,
  .day-header {
    min-height: 44px;
  }
  .tour-card-btn { padding: .65rem 1rem; }

  .pax-btn {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .lb-prev, .lb-next {
    width: 48px;
    height: 48px;
  }
  .lb-close { padding: 12px; font-size: 1.6rem; }
}


/* ─────────────────────────────────────────────
   16 · FAQ — UNCLAMP THE MAX-HEIGHT
   Long answers were clipping at 400px on phones.
   ───────────────────────────────────────────── */
.faq-item.open .faq-answer { max-height: 1200px; }


/* ─────────────────────────────────────────────
   17 · TOURS RESULT COUNT — VISIBLE WHEN FILTERED
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .tours-result-count {
    font-size: .88rem;
    padding: 10px 14px;
    background: rgba(200,151,43,.04);
    border: 1px solid rgba(200,151,43,.14);
    border-radius: 8px;
    margin: 0 16px 20px;
  }
}


/* ─────────────────────────────────────────────
   18 · TABLET — SLIMMER SIDEBAR (TOUR PAGES)
   Keeps the sticky booking sidebar visible down
   to ~700px instead of dropping at 768.
   ───────────────────────────────────────────── */
@media (min-width: 700px) and (max-width: 900px) {
  :root { --sidebar-w: 280px; --gap: 24px; }
  .sidebar-body { padding: 16px 16px; }
  .sidebar-price { font-size: 1.7rem; }
  .sb-opts { gap: 6px; }
}


/* ─────────────────────────────────────────────
   19 · REDUCED-MOTION — SUPPRESS HOVER TRANSFORMS
   ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .tour-card:hover,
  .circuit-card:hover,
  .trust-card:hover,
  .choice-card:hover,
  .intro-highlight-item:hover,
  .gallery-item:hover img,
  .g-item:hover img,
  .choice-card:hover .choice-card-bg {
    transform: none !important;
    transition: none !important;
  }
}


/* ─────────────────────────────────────────────
   20 · LIGHTBOX — PREVENT BACKGROUND SCROLL
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  body:has(.lb.on) { overflow: hidden; }
}


/* ─────────────────────────────────────────────
   21 · LANDING-PAGE STICKY MOBILE CTA (OPT-IN)
   Mirrors the per-tour mobile-bar pattern so the
   landing page also has a 1-tap path to booking.

   To activate, add this snippet just before </body>
   in morocco-circuits.html (no JS required):

     <div class="landing-mobile-cta" aria-label="Book a Morocco tour">
       <a href="/private-morocco-tours" class="landing-mobile-cta-btn">
         <i class="fas fa-route"></i> Plan Trip
       </a>
       <a href="https://wa.me/212628028090?text=Hi%20Qimal Tours%2C%20I%27d%20like%20to%20plan%20a%20Morocco%20tour"
          class="landing-mobile-cta-wa"
          target="_blank" rel="noopener noreferrer">
         <i class="fab fa-whatsapp"></i> WhatsApp
       </a>
     </div>
   ───────────────────────────────────────────── */
.landing-mobile-cta { display: none; }

@media (max-width: 768px) {
  .landing-mobile-cta {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 800;
    gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(15,13,10,.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(200,151,43,.22);
  }
  .landing-mobile-cta-btn,
  .landing-mobile-cta-wa {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .85rem 1rem;
    font-family: 'Jost', sans-serif;
    font-weight: 700;
    font-size: .9rem;
    text-decoration: none;
    border-radius: 10px;
    min-height: 44px;
  }
  .landing-mobile-cta-btn {
    background: #c8972b;
    color: #0f0d0a;
  }
  .landing-mobile-cta-wa {
    background: #25D366;
    color: #fff;
  }

  /* When the landing CTA bar is present, reserve space at page bottom */
  body:has(.landing-mobile-cta) {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}


/* ─────────────────────────────────────────────
   22 · TOUR-PAGE HERO — SMALL-SCREEN TYPOGRAPHY
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .hero-meta { gap: 10px; font-size: .8rem; }
  .meta-tag  { padding: 3px 9px; font-size: .72rem; }
  .hero-lead { font-size: .92rem; line-height: 1.75; margin-bottom: 18px; }
  .hero-tag  { font-size: .7rem; padding: 3px 9px; }
}


/* ─────────────────────────────────────────────
   23 · INTRO GRID — CARDS FIRST ON MOBILE
   On a phone the user benefits from the highlight
   cards (icons + short claims) before the long
   SEO copy. Flip the visual order at ≤768.
   ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .intro-grid { gap: 32px; }
}
@media (max-width: 768px) {
  .intro-highlights { order: -1; }
  .intro-text p { line-height: 1.7; }
}


/* ─────────────────────────────────────────────
   24 · FOOTER — TIGHTER ON PHONES
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .footer { padding: 40px 16px 0; }
  .footer-container { gap: 28px; padding-bottom: 32px; }
  .footer-section h3 { font-size: 1.05rem; margin-bottom: 12px; }
}

/* ─────────────────────────────────────────────
   25 · IN-HERO CTA ROW (Book / WhatsApp / Call)
   Pattern used by tour pages that replaced the
   sidebar booking widget with a 3-button CTA row
   in the hero (e.g. 3-days-atlas-berber-villages).
   ───────────────────────────────────────────── */
@media (max-width: 520px) {
  .cta-row {
    flex-direction: column;
    gap: 10px;
    margin-top: 18px;
  }
  .cta-btn {
    width: 100%;
    justify-content: center;
    padding: .9rem 1rem;
    font-size: .92rem;
    min-height: 48px;
  }
  .cta-btn span { white-space: normal; }
}

/* The "+212 628 028 090" call button is wide — keep it
   on one line, shrink its font slightly on small phones. */
@media (max-width: 380px) {
  .cta-call { font-size: .85rem; letter-spacing: 0; }
}


/* ─────────────────────────────────────────────
   26 · IN-HERO TRUST BADGES (.trust-cards plural)
   TripAdvisor + Google review cards that sit inline
   between CTAs and gallery on mobile/narrow tablet.
   ───────────────────────────────────────────── */
@media (max-width: 1023px) {
  .trust-cards { margin: 18px 0 4px; }
}
@media (max-width: 480px) {
  .trust-cards {
    flex-direction: row;
    gap: 8px;
  }
  .trust-cards .trust-card {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 12px 8px;
    gap: 6px;
    border-radius: 12px;
  }
  .trust-cards .tc-icon img { width: 26px; height: 26px; }
  .trust-cards .tc-score    { font-size: 1.25rem; }
  .trust-cards .tc-score small { font-size: .72rem; }
  .trust-cards .tc-stars    { font-size: .62rem; }
  .trust-cards .tc-label    { font-size: .64rem; line-height: 1.25; }
  .trust-cards .tc-count    { font-size: .56rem; }
  .trust-cards .tc-btn      { padding: 5px 8px; font-size: .6rem; }
}


/* ─────────────────────────────────────────────
   27 · HERO META / HERO TAGS — TIGHTER ON PHONES
   Many tour pages list 4+ meta chips and 6–8 hero
   tags, which wraps to 4–5 dense rows on a phone.
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .hero-meta {
    gap: 8px 12px;
    font-size: .8rem;
    margin-bottom: 14px;
  }
  .hero-meta > span { line-height: 1.4; }
  .meta-tag {
    padding: 3px 9px;
    font-size: .72rem;
  }
  .hero-lead {
    font-size: .92rem;
    line-height: 1.7;
    margin-bottom: 16px;
  }
  .hero-tags { gap: 6px; }
  .hero-tag  {
    font-size: .68rem;
    padding: 3px 8px;
  }
}


/* ─────────────────────────────────────────────
   28 · HIGHLIGHT GRIDS (hl-grid / diff-grid)
   Page-specific custom grids on tour pages.
   Original collapses 3-col → 2 → 1 — six cards
   stacked on phone is too tall. Keep 2-col on
   smallest phones so the section stays scannable.
   ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .hl-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }
  .hl-card {
    padding: 14px 12px;
  }
  .hl-icon { font-size: 1.4rem; margin-bottom: 8px; }
  .hl-title { font-size: .98rem; margin-bottom: 4px; }
  .hl-desc  { font-size: .76rem; line-height: 1.55; }
}
@media (max-width: 380px) {
  .hl-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 540px) {
  .diff-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  .diff-card { padding: 13px 14px; }
  .diff-card h4 { font-size: .95rem; }
  .diff-card p  { font-size: .8rem; line-height: 1.55; }
}


/* ─────────────────────────────────────────────
   29 · BERBER / NARRATIVE BOX (berber-box)
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .berber-box {
    padding: 20px 16px;
    border-radius: 10px;
  }
  .berber-box h3 { font-size: 1.25rem; }
  .berber-box p  { font-size: .85rem; line-height: 1.75; }
  .berber-list   { grid-template-columns: 1fr !important; gap: 6px; }
  .berber-list li { font-size: .8rem; }
}


/* ─────────────────────────────────────────────
   30 · LEG CARDS — STACK META ON PHONES
   .leg-top is flex row by default; on a 360-wide
   phone the route + 3 stats compete for space.
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .leg-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .leg-route { font-size: 1rem; flex-wrap: wrap; }
  .leg-stats { gap: 10px; flex-wrap: wrap; }
  .leg-stat  { font-size: .74rem; }
  .leg       { padding: 14px 14px; }
}


/* ─────────────────────────────────────────────
   31 · BOOKING POPUP (.bk-overlay) — MOBILE FIT
   Some tour pages open the booking widget inside
   an overlay popup. Make sure it fills the phone
   nicely and respects safe-area insets.
   ───────────────────────────────────────────── */
@media (max-width: 520px) {
  .bk-overlay-card {
    margin: 12px;
    max-width: none;
    padding: 50px 14px calc(16px + env(safe-area-inset-bottom));
    border-radius: 12px;
  }
  .bk-overlay-title {
    font-size: 1.1rem;
    margin: 0 28px 12px;
  }
  .bk-overlay-close {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
  }
}


/* ─────────────────────────────────────────────
   32 · INNER LINK ROW + BACK ROW — TIGHTER
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .inner-link-row { gap: 6px; margin-top: 12px; }
  .inner-link-row a { font-size: .72rem; padding: 5px 9px; }
  .back-row { gap: 12px; padding: 16px 0 22px; font-size: .8rem; }
}


/* ─────────────────────────────────────────────
   33 · SECTION SPACING ON TOUR PAGES
   Tour pages use .section with padding:24px 0 0
   plus a sec-eyebrow + sec-title + sec-sub stack.
   Tighten on phones.
   ───────────────────────────────────────────── */
@media (max-width: 540px) {
  .sec-title { font-size: 1.45rem; line-height: 1.2; }
  .sec-sub   { font-size: .82rem; margin-bottom: 18px; }
}


/* ─────────────────────────────────────────────
   34 · OUTER WRAPPER PADDING
   Tour pages wrap content in .outer { padding: 0 28px }.
   Already drops to 0 16px at ≤480 in the page CSS;
   ensure breadcrumb stays readable.
   ───────────────────────────────────────────── */
@media (max-width: 480px) {
  .breadcrumb {
    font-size: .72rem;
    padding: 14px 0 10px;
    line-height: 1.5;
  }
}


/* ─────────────────────────────────────────────
   35 · HEADER PLACEHOLDER — RESPONSIVE HEIGHT
   #site-header-placeholder is hardcoded 96px. On
   phones the injected header is usually shorter,
   wasting 30+ px above the breadcrumb. Use the
   --header-h variable so header-loader can set it.
   ───────────────────────────────────────────── */
#site-header-placeholder {
  height: var(--header-h, 96px) !important;
}

@media (max-width: 768px) {
  /* If header-loader hasn't measured yet, assume ~72px on phones. */
  :root { --header-h: 72px; }
}


/* ─── END tours-mobile.css ─── */