/* =========================================================================
   responsive.css — breakpoints for tablet/mobile
   ========================================================================= */

/* Tablet */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 232px;
    }

    .main-content {
        padding: var(--space-6);
    }

    .grid--2 {
        grid-template-columns: 1fr;
    }

    .grid--detail {
        grid-template-columns: minmax(0, 1fr);
    }

    .submit-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    /* Stacked order: form, then the side cards (balance / current batch /
       today / recent), then the wider "Recent batches" table last. The
       two column wrappers dissolve so the grid can order their children
       directly. */
    .submit-layout__main,
    .submit-layout__side {
        display: contents;
    }

    .submit-layout__form {
        order: 1;
    }

    .submit-layout__side > * {
        order: 2;
    }

    .submit-recent-batches {
        order: 3;
    }
}

/* Mobile — collapse sidebar into a drawer */
@media (max-width: 860px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .site-footer__top {
        /* Brand column moves to its own full-width row (see grid-column
           below) so the link groups get the full row to themselves —
           auto-fit adapts to however many groups actually exist instead
           of a fixed count that would wrap awkwardly if an admin adds
           or removes a footer_link_groups row later. */
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        text-align: left;
    }

    .site-footer__brand-col {
        grid-column: 1 / -1;
    }

    /* Certificate preview drops under the company details, capped so it
       reads as a modest document thumbnail rather than a full-width scan. */
    .company-registration__inner {
        grid-template-columns: 1fr;
    }

    .company-registration__certificate {
        max-width: 360px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform var(--duration-base) var(--ease-standard);
        box-shadow: var(--shadow-elevated);
        /* Solid background + blur — the base .sidebar rule's near-transparent
           background is fine on desktop (sits beside equally-dark content),
           but as a fixed overlay on mobile it let page content show through. */
        background: var(--bg-elevated);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        /* Unlike desktop (where the sidebar has no height cap and just
           extends past the viewport as part of page flow), this drawer is
           pinned to a fixed 100vh box — so with several nav groups expanded
           at once its content can exceed that height with no other way to
           reach the overflow. Scoped to mobile only, scrollbar hidden
           cross-browser so it doesn't look like desktop's separate
           scroll-container pattern the base rule intentionally avoids. */
        overflow-y: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .sidebar::-webkit-scrollbar {
        display: none;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .topbar__menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar {
        padding: 0 var(--space-4);
    }

    .main-content {
        padding: var(--space-4);
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header .btn {
        align-self: flex-start;
    }

    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }

    .card {
        padding: var(--space-5);
        border-radius: 20px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-4);
    }

    .site-footer__top {
        /* Smaller minimum than the 860px tier above so 3 short columns
           (e.g. Product/Company/Support) still fit side by side on a
           narrow phone screen instead of collapsing to a single column —
           brand column still spans the full row via the rule above. */
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    }

    .btn {
        padding: 12px 16px;
    }

    .toast-stack {
        left: var(--space-4);
        right: var(--space-4);
        max-width: none;
    }

    /* Public marketing nav (index.php, pricing.php, contact.php, etc.) —
       the brand mark and button group each get their own full-width row
       instead of squeezing into one line, which previously overflowed
       and clipped items like "Contact" off-screen. */
    .public-nav {
        flex-direction: column;
        align-items: stretch;
    }

    .public-nav > div:last-child {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* Global safety net: nothing on the page should ever be able to force
   horizontal scroll/zoom-out on mobile, regardless of what causes it —
   this was the actual root cause of the public pages appearing
   "zoomed out" (an overflowing element was widening the whole page). */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Touch devices never get pointer-tilt (handled in tilt.js too, this is belt-and-suspenders) */
@media (hover: none) {
    .card--interactive:hover {
        transform: none;
    }
}
