/* ==========================================================================
   responsive.css
   Additive responsive layer for the existing layout.

   LOAD ORDER MATTERS: link this file LAST, after base.css, index.css and
   animations.css:

     <link th:href="@{/css/base.css}"        rel="stylesheet">
     <link th:href="@{/css/index.css}"       rel="stylesheet">
     <link th:href="@{/css/animations.css}"  rel="stylesheet">
     <link th:href="@{/css/responsive.css}"  rel="stylesheet">   <-- add this

   The mobile NAV also needs nav.js (tiny) + a hamburger button in the markup.
   See the notes where the chat message describes the two HTML lines to add.

   Two breakpoints:
     • <= 1024px  tablets / small laptops  (lighten margins, thin out grids)
     • <=  768px  phones                   (collapse to one column + hamburger)
   ========================================================================== */


/* ==========================================================================
   HAMBURGER BUTTON  (drawn here, but only shown on phones once JS enhances it)
   ========================================================================== */
.nav-toggle {
    display: none;                 /* hidden on desktop */
    align-items: center;
    justify-content: center;
    width: 44px;                   /* comfortable tap target */
    height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

/* three bars = one middle span + its ::before / ::after */
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
    content: "";
    display: block;
    width: 24px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .3s var(--ease), opacity .2s var(--ease), background .2s var(--ease);
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before { position: absolute; left: 0; top: -7px; }
.nav-toggle-bars::after  { position: absolute; left: 0; top:  7px; }

/* morph into an X when the menu is open */
.nav-open .nav-toggle-bars            { background: transparent; }
.nav-open .nav-toggle-bars::before    { top: 0; transform: rotate(45deg); }
.nav-open .nav-toggle-bars::after     { top: 0; transform: rotate(-45deg); }


/* ==========================================================================
   BRAND LOGO SAFEGUARD
   The brand <svg> has no viewBox, so some browsers give it the 300px default
   replaced-element width. That pushes the nav contents past the screen edge on
   phones (the fixed nav escapes body's overflow-x:hidden). Capping the width
   stops it ballooning. The real fix is adding viewBox="0 0 34 34" to the <svg>,
   which also lets the logo scale to fill — but this keeps things safe either way.
   ========================================================================== */
.brand svg {
    height: 100%;
    width: auto;
    max-width: var(--nav-height);   /* never wider than the bar is tall (~60px) */
    aspect-ratio: 1;
    flex: 0 0 auto;
}


/* ==========================================================================
   TABLETS & SMALL LAPTOPS  (<= 1024px)
   ========================================================================== */
@media (max-width: 1024px) {

    /* Pull the page margins in a little. */
    body {
        margin-left: 32px;
        margin-right: 32px;
    }

    /* Tighten the big vertical rhythm (keeps the auto left margin intact). */
    section {
        margin-top: 64px;
        margin-bottom: 64px;
    }

    /* Footer: 4 columns -> 2. */
    .grid-container {
        grid-template-columns: 1fr 1fr;
        grid-row-gap: 36px;
    }

    /* Accreditation logos: let them wrap and centre instead of squashing. */
    .accreditations-wrapper {
        width: auto;
        max-width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }
}


/* ==========================================================================
   PHONES  (<= 768px)
   ========================================================================== */
@media (max-width: 768px) {

    /* Margins: keep enough top space to clear the fixed nav (~80px tall). */
    body {
        margin: 90px 16px 0 16px;
    }

    section {
        margin-top: 48px;
        margin-bottom: 48px;
    }

    /* Collapse EVERY two-column split (hero, intro, CTA) to one column. */
    .split {
        grid-template-columns: 1fr;
        row-gap: 32px;
    }

    /* Once stacked, the right-hand column shouldn't stick. */
    .sticky {
        position: static;
    }

    /* Hero photo: drop the forced viewport height so it sizes by its 4:5 ratio.
       (Needs !important because the original rule uses one.) */
    .hero-photo {
        height: auto !important;
    }

    /* Service cards: stack and centre. */
    .card-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    /* Accreditation logos: two per row, full-width wrapper. */
    .accreditations-wrapper {
        width: 100%;
    }
    .accreditation-logo {
        width: 45%;
    }

    /* Footer: single column. */
    .grid-container {
        grid-template-columns: 1fr;
        grid-row-gap: 32px;
    }

    /* CTA panel: full width with lighter padding. */
    .cta-wrapper {
        width: auto;
        padding: 24px;
    }

    /* Paired ghost-button + link: stack them instead of a 50px-gap row. */
    .inline-btns {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    /* ===================== MOBILE NAV (hamburger) =====================
       The bar keeps just the brand + hamburger. The links drop down as a
       full-width panel. All gated on `.nav-js` (added by nav.js) so that if
       JS is unavailable the normal links simply stay visible. */

    .nav.nav-js .nav-toggle {
        display: inline-flex;
    }

    /* Book button isn't needed in the bar on mobile (hero has booking CTAs). */
    .inner-nav .btn {
        display: none;
    }

    /* The <nav> (id="primary-nav") becomes a fixed dropdown below the bar. */
    .nav.nav-js #primary-nav {
        position: fixed;
        top: calc(var(--nav-height) + 2 * var(--nav-padding));
        left: 0;
        right: 0;
        z-index: 90;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow-md);
        overflow: hidden;
        max-height: 0;                       /* collapsed */
        transition: max-height .32s var(--ease);
    }
    .nav.nav-js.nav-open #primary-nav {
        max-height: 70vh;                    /* opened */
        overflow-y: auto;
    }

    /* Stack the links vertically inside the panel. */
    .nav.nav-js #primary-nav .nav-links {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 6px 20px 14px;
    }
    .nav.nav-js #primary-nav .nav-links a {
        display: block;
        padding: 14px 2px;
        font-size: 1.05rem;
    }
    /* drop the sliding underline in the dropdown — looks odd full-width */
    .nav.nav-js #primary-nav .nav-links a::after {
        display: none;
    }
}