/* =====================================================================
   paalupiste.es - mobile layer
   Loaded last on every page (after page CSS and inline styles), so the
   rules here override the desktop-first styles on phones and tablets.
   Desktop (>1100px) is not affected.
   ===================================================================== */

/* <picture class="mhero"> only adds a lighter phone version of the first image;
   it must not create a box of its own */
picture.mhero { display: contents; }

/* Elements created by js/mobile.js are hidden on desktop */
.mbar,
.mm-quick,
.mm-lang,
.mfilter-toggle { display: none; }

/* ---------- All sizes: the hit areas of the hero dots overlapped, so a click
   on a dot opened the next slide ---------- */
.hero-dot::before { left: -4px; right: -4px; }

/* ---------- Tablet: product catalogue had 4 columns at every width ---------- */
@media (max-width: 1100px) {
    .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =====================================================================
   PHONES AND SMALL TABLETS
   ===================================================================== */
@media (max-width: 768px) {

    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    body { -webkit-tap-highlight-color: rgba(255, 0, 43, 0.12); }

    /* ---------- Sticky header that actually sticks ----------
       overflow-x: hidden on both html and body made body a scroll container,
       so position: sticky (header, catalogue tabs, page anchors) never engaged.
       clip gives the same clipping without that side effect; browsers that do
       not know clip ignore the line and keep the old behaviour. */
    html, body { overflow-x: clip; }
    html { scroll-padding-top: 64px; }
    .nav { transition: top 0.25s ease; }
    body.nav-up .nav { top: -72px; }
    .anchor-nav, .sp-tab-bar, .tab-nav-section { transition: top 0.25s ease; }
    body.nav-up .anchor-nav,
    body.nav-up .sp-tab-bar,
    body.nav-up .tab-nav-section { top: 0 !important; }

    /* ---------- Header: 72px -> 64px, room for the logo ---------- */
    .nav-inner { height: 64px; padding: 0 10px 0 16px; }
    .nav-logo-img { height: 28px; }
    .mega-menu { top: 64px; }
    .anchor-nav,
    .sp-tab-bar,
    .tab-nav-section { top: 64px !important; }
    body.has-mbar .nav-cta { display: none; }
    .nav-cta { font-size: 14px; }

    /* ---------- Mobile menu ---------- */
    .mega-menu-inner { padding: 4px 20px 40px; gap: 0; }
    .mm-quick { display: block; order: -3; margin-bottom: 4px; }
    .mm-quick a {
        display: flex; align-items: center; justify-content: space-between;
        min-height: 54px; padding: 0 2px;
        font-size: 18px; font-weight: 700; color: var(--black);
        text-decoration: none; border-bottom: 1px solid #f0f0f0;
    }
    .mm-quick a::after {
        content: ''; width: 8px; height: 8px; margin-right: 6px;
        border-right: 2px solid var(--red); border-top: 2px solid var(--red);
        transform: rotate(45deg);
    }
    .mm-quick a:active { color: var(--red); }
    .mega-menu-col { padding-bottom: 0; }
    .mega-menu-col h3 {
        font-size: 13px; letter-spacing: 1px; color: var(--dark-gray);
        min-height: 52px; padding: 0; margin: 0;
    }
    .mega-menu-col h3::after { font-size: 24px; color: var(--red); }
    .mega-menu-col.accordion-open .mega-menu-items { padding-bottom: 12px; }
    .mega-menu-item { margin-bottom: 0; }
    .mega-menu-item a { font-size: 16px; padding: 10px 0 2px; margin: 0; }
    .mega-menu-item p { font-size: 13px; padding-bottom: 8px; }
    /* the fifth column repeated the phone and e-mail of the fourth one */
    .mega-menu-col:has(.mega-menu-map) { display: none; }
    .mega-menu-contact { gap: 8px; padding-top: 16px; }
    .mega-menu-contact h4 { font-size: 16px; }
    .mega-menu-contact-info { align-items: flex-start; gap: 0; }
    .mega-menu-contact-info p { margin-bottom: 4px !important; }
    .mega-menu-phone,
    .mega-menu-email { display: inline-flex; align-items: center; min-height: 44px; }
    .mega-menu-phone { font-size: 22px; }
    .mega-menu-email { font-size: 16px; }
    .mm-lang {
        display: flex; flex-wrap: wrap; gap: 8px; order: 5;
        padding: 18px 0 4px;
    }
    .mm-lang a {
        display: inline-flex; align-items: center; gap: 8px; min-height: 44px;
        padding: 0 16px; border: 1px solid var(--light-gray); border-radius: 22px;
        font-size: 15px; font-weight: 600; color: var(--dark-gray); text-decoration: none;
    }
    .mm-lang .nav-lang-flag { width: 20px; height: 14px; }

    /* ---------- Sticky action bar (call + quote) ---------- */
    .mbar {
        display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
        padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
        background: rgba(255, 255, 255, 0.97);
        border-top: 1px solid #ececec;
        box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08);
        transition: transform 0.25s ease;
    }
    .mbar a {
        display: flex; align-items: center; justify-content: center; gap: 8px;
        min-height: 48px; padding: 0 10px; border-radius: 8px;
        font-size: 15px; font-weight: 700; line-height: 1.15; text-align: center;
        text-decoration: none;
    }
    .mbar svg { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
    .mbar-call { color: var(--black); background: var(--white); border: 2px solid var(--light-gray); }
    .mbar-quote { color: #fff; background: var(--red); }
    .mbar-quote:active { background: var(--red-dark); }
    body.has-mbar .footer { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
    body.menu-open .mbar { transform: translateY(110%); }
    body.has-mbar .back-to-top { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); left: 16px; }
    body.has-mbar .scroll-top-btn { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
    body.has-mbar #pp-fallback-widget { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }
    body.has-mbar .woot-widget-bubble { bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important; }
    body.has-mbar .woot-widget-holder { bottom: calc(150px + env(safe-area-inset-bottom, 0px)) !important; }

    /* ---------- Typography and spacing ---------- */
    .section-eyebrow,
    .page-hero-eyebrow,
    .hero-eyebrow,
    .hero-slide-eyebrow { letter-spacing: 1.6px; line-height: 1.5; }
    .section-header { margin-bottom: 28px; }

    /* ---------- Tap targets ---------- */
    .card-link { min-height: 44px; }
    .contact-strip { padding: 36px 0; }
    .contact-strip-phone,
    .contact-strip-email { display: inline-flex; align-items: center; min-height: 44px; }
    .btn-primary,
    .btn-secondary { min-height: 48px; }
    .footer-social a { width: 44px; height: 44px; }
    .checkbox-label input[type="checkbox"] { width: 22px; height: 22px; flex-shrink: 0; }
    input, select, textarea { font-size: 16px; }

    /* ---------- Inner-page heroes ---------- */
    .page-hero { min-height: 0; }
    .page-hero-content { padding: 44px 24px 32px; }
    .page-hero h1 { font-size: 30px; line-height: 1.15; }
    .page-hero p { font-size: 15px; line-height: 1.6; }
    .stat-banner { grid-template-columns: 1fr 1fr; }
    .stat-banner-item { padding: 18px 12px; border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
    .stat-banner-item:nth-child(odd) { border-right: 1px solid rgba(255, 255, 255, 0.1); }
    .stat-banner-item:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: none; }
    .stat-banner-number { font-size: 26px; }
    .stat-banner-label { font-size: 11px; letter-spacing: 1px; line-height: 1.4; }

    /* ---------- Scrollable tables: fade on the side that has more ---------- */
    .mtable { position: relative; margin: 0 0 16px; }
    .mtable > table { margin-bottom: 0 !important; }
    .mtable::after {
        content: ''; position: absolute; top: 0; right: 0; bottom: 0; width: 36px;
        background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
        pointer-events: none; transition: opacity 0.2s;
    }
    .mtable.at-end::after { opacity: 0; }
    .mtable-hint {
        display: flex; align-items: center; gap: 6px; margin: 0 0 8px;
        font-size: 13px; font-weight: 600; color: var(--mid-gray);
    }
    .mtable-hint svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

    /* ---------- Sticky in-page navigation: one swipeable row (was up to 181px tall) ---------- */
    .anchor-nav {
        flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
        gap: 2px; padding: 0 12px; white-space: nowrap;
    }
    .anchor-nav a { flex: 0 0 auto; padding: 0 10px; min-height: 46px; font-size: 12px; }

    /* ---------- Horizontally scrolling tab bars: hide the scrollbar ---------- */
    .tab-nav, .sp-tab-bar, .anchor-nav { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .tab-nav::-webkit-scrollbar, .sp-tab-bar::-webkit-scrollbar, .anchor-nav::-webkit-scrollbar { display: none; }

    /* ---------- Footer: two columns instead of one long list ---------- */
    .footer { padding-top: 40px; }
    .footer-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 20px; padding-bottom: 24px; }
    .footer-social { flex-wrap: wrap; gap: 8px; }
    .footer-brand { grid-column: 1 / -1; margin-bottom: 4px; }
    .footer-brand p { margin-top: 12px; }
    .footer-col h4 { margin: 20px 0 4px; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
    .footer-col h4[style] { margin-top: 20px !important; }
    .footer-col li { margin-bottom: 0; }
    .footer-col a { min-height: 40px; padding: 6px 0; line-height: 1.35; font-size: 14px; }
    .footer-contact-item { margin-bottom: 0; }
    .footer-contact-item a { display: inline-flex; align-items: center; min-height: 40px; }
    .footer-bottom { flex-direction: column; align-items: flex-start; gap: 16px; padding: 20px 0 28px; }
    .footer-bottom-left { font-size: 13px; line-height: 1.6; color: rgba(255, 255, 255, 0.5); }
    .footer-bottom-right { flex-wrap: wrap; gap: 0 20px; }
    .footer-bottom-right a { font-size: 13px; color: rgba(255, 255, 255, 0.6); }

    /* =================================================================
       HOMEPAGE
       ================================================================= */

    /* Hero: slides share one grid cell, so the hero grows to the tallest
       slide instead of clipping text and buttons at a fixed 520px */
    .hero { height: auto; display: grid; }
    .hero > .hero-full-slide { grid-area: 1 / 1; position: relative; height: auto; }
    .hero-content,
    .hero-slide-centered {
        min-height: 0; height: 100%; overflow: visible;
        padding: 40px 24px 76px; justify-content: center;
    }
    .hero-slide-bg::after {
        background: linear-gradient(180deg, rgba(20, 20, 20, 0.62) 0%, rgba(20, 20, 20, 0.74) 55%, rgba(20, 20, 20, 0.86) 100%);
    }
    .hero-eyebrow,
    .hero-slide-eyebrow { font-size: 12px; margin-bottom: 12px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
    .hero h1 { font-size: 31px; line-height: 1.13; margin-bottom: 18px; }
    .hero-checks { margin-bottom: 24px; }
    .hero-checks li { font-size: 15px; padding: 4px 0 4px 26px; color: rgba(255, 255, 255, 0.9); }
    .hero-buttons { flex-direction: column; gap: 10px; }
    .hero-buttons .btn-primary,
    .hero-buttons .btn-secondary { justify-content: center; width: 100%; max-width: 440px; }
    .hero-trust-inline { gap: 6px 16px; margin-top: 22px; padding-top: 16px; }
    .hero-trust-item { font-size: 13px; color: rgba(255, 255, 255, 0.7); }
    .hero-slide-icon { display: none; }
    .hero-slide-title { font-size: 27px; line-height: 1.18; margin-bottom: 14px; }
    .hero-slide-text { font-size: 15px; line-height: 1.6; color: rgba(255, 255, 255, 0.88); }
    .hero-slide-cta { min-height: 48px; padding: 12px 22px; font-size: 15px; margin-top: 22px; }
    .hero-dots { gap: 14px; padding-bottom: 24px; }
    .hero-dot::before { top: -12px; left: -7px; right: -7px; bottom: -12px; }

    /* Section rhythm: 56px -> 44px top and bottom */
    .why-section, .products-section, .applications-section, .quality-section,
    .cases-section, .solution-section, .comparison-section, .testimonials-section,
    .purchasing-section { padding: 44px 0; }
    .sustainability-section { padding: 48px 0; }

    /* Why-stats: icon beside the number, list underneath */
    .stats-grid { gap: 14px; }
    .stat-card {
        display: grid; grid-template-columns: 48px 1fr; column-gap: 14px;
        align-items: center; text-align: left; padding: 22px 20px;
    }
    .stat-icon { width: 48px; height: 48px; margin: 0; grid-row: 1 / span 2; }
    .stat-number { font-size: 30px; margin: 0; }
    .stat-label { font-size: 16px; margin: 2px 0 0; grid-column: 2; }
    .stat-details { grid-column: 1 / -1; margin-top: 14px; }
    .stat-details li { font-size: 15px; }

    /* Product cards: shorter image area */
    .product-cards { gap: 20px; }
    .product-card-image { height: 210px; }
    .product-card-image .product-brand-logo { top: 14px; left: 14px; height: 26px; }
    .product-card-body { padding: 22px 20px; }
    .product-card-body h3 { font-size: 20px; }
    .product-card-features li { font-size: 15px; }

    /* Applications: tabs scroll sideways, render tiles keep their space */
    .applications-header { margin-bottom: 24px; }
    .app-tabs {
        flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
        margin: 0 -24px 22px; padding: 2px 24px 6px;
        scrollbar-width: none; -webkit-overflow-scrolling: touch;
    }
    .app-tabs::-webkit-scrollbar { display: none; }
    .app-tab { flex: 0 0 auto; white-space: nowrap; display: flex; align-items: center; min-height: 44px; }
    .app-tab-renders { gap: 10px; }
    .render-box { aspect-ratio: 4 / 3; padding: 4px; }
    .render-box img { height: 100%; object-fit: contain; }
    .render-box-label { font-size: 13px; line-height: 1.35; }
    .app-tab-details ul li { font-size: 15px; }

    /* Quality */
    .quality-layout { gap: 28px; }
    .quality-cards { gap: 12px; }
    .quality-card { padding: 20px 18px; }
    .quality-card li { font-size: 15px; }

    /* Complete solution / steps */
    .solution-left h2 { font-size: 28px; }
    .solution-cta .btn-primary,
    .solution-cta .btn-secondary { max-width: none; min-height: 52px; }
    .solution-image { max-width: none; height: 190px; }
    .services-grid { gap: 30px; }
    .service-item ul li,
    .service-advantages ul li { font-size: 14px; }

    /* Comparison */
    .comparison-card { padding: 26px 20px; }
    .comparison-time { font-size: 30px; }
    .comparison-time-sub { margin-bottom: 18px; }
    .comparison-label { font-size: 12px; letter-spacing: 1.6px; margin-bottom: 14px; }

    /* Testimonials: swipe sideways instead of three stacked cards */
    .testimonials-grid {
        display: flex; gap: 12px; overflow-x: auto;
        scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
        margin: 0 -24px; padding: 4px 24px 14px; scrollbar-width: none;
    }
    .testimonials-grid::-webkit-scrollbar { display: none; }
    .testimonial-card { flex: 0 0 86%; scroll-snap-align: center; padding: 26px 20px; }
    .testimonials-grid .reveal { opacity: 1; transform: none; }
    .testimonial-role { font-size: 13px; }

    /* Sustainability: 2 x 2 figures */
    .sustainability-layout { gap: 28px; }
    .sustainability-text h2 { font-size: 30px; }
    .eco-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .eco-stat { padding: 16px 14px; }
    .eco-stat-number { font-size: 26px; }
    .eco-stat p { color: rgba(255, 255, 255, 0.66); }
    .sustainability-badge { color: rgba(255, 255, 255, 0.66); }

    /* Worldwide delivery */
    .purchasing-layout { gap: 28px; }
    .purchasing-text h2 { font-size: 28px; }
    .purchasing-map { height: 230px; }

    /* Case cards */
    .cases-grid { gap: 18px; }
    .case-tag { font-size: 13px; }

    /* =================================================================
       PRODUCT CATALOGUE (products.html)
       ================================================================= */
    .catalog-intro { flex-direction: column; align-items: flex-start; gap: 16px; padding: 24px 24px 0; }
    .catalog-intro-text h2 { font-size: 22px; }
    .catalog-intro-text p { font-size: 15px; }
    .catalog-intro-piles { gap: 20px; }
    .catalog-container { padding: 0 24px; }
    .tab-nav { padding: 0 12px; }
    .tab-btn { padding: 15px 14px; }
    .filter-row { padding: 10px 12px; }
    .filter-pill { min-height: 40px; padding: 0 14px; font-size: 14px; }
    .filter-pills { gap: 8px; }
    .mf-collapsed .filter-row:nth-child(n+3):not(:has(.filter-clear)) { display: none; }
    .mfilter-toggle {
        display: flex; align-items: center; justify-content: center; gap: 8px;
        width: 100%; min-height: 46px; margin: 4px 0 8px;
        font-family: inherit; font-size: 15px; font-weight: 700; color: var(--black);
        background: var(--white); border: 2px solid var(--light-gray); border-radius: 8px; cursor: pointer;
    }
    .mfilter-toggle::after {
        content: ''; width: 7px; height: 7px; margin-top: -4px;
        border-right: 2px solid var(--red); border-bottom: 2px solid var(--red); transform: rotate(45deg);
    }
    .mfilter-toggle[aria-expanded="true"]::after { margin-top: 4px; transform: rotate(-135deg); }
    .ds-cta-banner { align-items: flex-start; }
    .prod-card-header h3 { font-size: 16px; }
    .prod-card-subtitle { font-size: 13px; }
    .spec-row { font-size: 14px; padding: 6px 0; }
    .length-badge { font-size: 13px; padding: 3px 8px; }
    .prod-card-footer a,
    .prod-card-footer button { min-height: 44px; font-size: 14px; display: flex; align-items: center; justify-content: center; }
    .bottom-cta { padding: 48px 24px; }
    .bottom-cta h2 { font-size: 26px; }
}

@media (max-width: 560px) {
    .product-grid { grid-template-columns: 1fr; gap: 12px; }
    /* one card per row: a lower picture strip keeps the list shorter */
    .prod-card-img.has-image,
    .prod-card-img.has-render { aspect-ratio: 5 / 2; }
}

/* ---------- Small phones ---------- */
@media (max-width: 380px) {
    .nav-logo-img { height: 26px; }
    .mbar { grid-template-columns: 1fr 1.25fr; gap: 6px; padding-left: 8px; padding-right: 8px; }
    .mbar a { font-size: 14px; padding: 0 6px; }
    .hero h1 { font-size: 28px; }
    .hero-slide-title { font-size: 25px; }
    .page-hero h1 { font-size: 27px; }
    .footer-top { column-gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .mbar, .nav, .anchor-nav, .sp-tab-bar, .tab-nav-section { transition: none; }
}
