/**
 * device-compat.css
 * Cross-device compatibility fixes for iOS Safari, Android Chrome,
 * older browsers, and all screen sizes.
 * Included globally via footer.php.
 */

/* ── 1. iOS Safari: prevent input zoom (font-size must be >= 16px) ─────────── */
@media screen and (-webkit-min-device-pixel-ratio: 0) {

    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    input[type="url"],
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* ── 2. iOS Safari: remove inner shadow on inputs ───────────────────────────── */
input,
textarea,
select {
    -webkit-appearance: none;
    appearance: none;
}

input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: auto;
    appearance: auto;
}

/* ── 3. Touch targets: minimum 44×44px (WCAG 2.5.5) ────────────────────────── */
button,
.btn,
[role="button"],
a.btn,
input[type="submit"],
input[type="button"],
input[type="reset"] {
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ── 4. iOS safe area insets (notch / home bar) ─────────────────────────────── */
body {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

.footer,
footer {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
}

#cookie-banner {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
}

/* ── 5. Prevent horizontal overflow on mobile ───────────────────────────────── */
html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

img,
video,
iframe,
embed,
object {
    max-width: 100%;
    height: auto;
}

/* ── 6. Bootstrap modal: bottom-sheet on mobile ─────────────────────────────── */
@media (max-width: 576px) {
    .modal-dialog:not(.modal-fullscreen):not(.modal-dialog-scrollable) {
        margin: 0;
        max-width: 100%;
        align-items: flex-end;
    }

    .modal-content {
        border-radius: 20px 20px 0 0 !important;
        max-height: 92dvh;
        /* dvh = dynamic viewport height, avoids iOS toolbar */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* Keep centered modals (alerts, confirms) centered */
    .modal-dialog-centered {
        align-items: center !important;
    }

    .modal-dialog-centered .modal-content {
        border-radius: 18px !important;
        max-height: 90dvh;
    }
}

/* ── 7. Comparison table: horizontal scroll on small screens ────────────────── */
.comparison-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.comparison-table {
    min-width: 560px;
}

/* ── 8. Pricing cards: stack on mobile ──────────────────────────────────────── */
@media (max-width: 640px) {
    .pricing-cards-wrapper {
        flex-direction: column !important;
    }

    .pricing-card-modern {
        flex: 1 1 100% !important;
        min-width: unset !important;
    }
}

/* ── 9. Blog grid: single column on small mobile ────────────────────────────── */
@media (max-width: 480px) {
    .blg-posts-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ── 10. Scroll-top button: above iOS home bar ──────────────────────────────── */
.scroll-top {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 20px) !important;
}

/* ── 11. Focus-visible: keyboard navigation ring ────────────────────────────── */
:focus-visible {
    outline: 3px solid rgba(229, 84, 0, 0.6);
    outline-offset: 2px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ── 12. Reduced motion: respect user preference ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ── 13. High contrast mode support ─────────────────────────────────────────── */
@media (forced-colors: active) {

    .btn,
    button {
        border: 2px solid ButtonText;
    }

    a {
        color: LinkText;
    }
}

/* ── 14. Print: hide non-essential elements ─────────────────────────────────── */
@media print {

    header,
    footer,
    .scroll-top,
    #cookie-banner,
    .blg-progress-bar,
    nav,
    .modal {
        display: none !important;
    }

    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 10pt;
    }
}

/* ── 15. Very small screens (320px) ─────────────────────────────────────────── */
@media (max-width: 360px) {
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    h1 {
        font-size: clamp(1.4rem, 7vw, 2rem) !important;
    }

    h2 {
        font-size: clamp(1.2rem, 6vw, 1.6rem) !important;
    }
}