/* ==========================================================================
   Layout: header, navigation, mobile menu, footer
   ========================================================================== */

/* ---------- Header ---------- */
.site-header {
    position: fixed;
    inset: 0 0 auto;
    z-index: 100;
    height: var(--header-h);
    transition: height 0.5s var(--ease-out);
}

/* Solid background lives on a pseudo-element so backdrop-filter never
   becomes the containing block of the fixed mobile menu. */
.site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--color-bg) 90%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(1.2);
    backdrop-filter: blur(14px) saturate(1.2);
    box-shadow: 0 1px 0 color-mix(in srgb, var(--color-secondary) 35%, transparent),
                0 12px 30px -20px rgb(31 77 54 / 0.35);
    opacity: 0;
    transition: opacity 0.5s var(--ease-out);
    pointer-events: none;
}

.site-header.is-scrolled::before,
.has-banner-photo .site-header::before {
    opacity: 1; /* pages with a photo banner: solid header from the start so the logo and links stay readable */
}

.site-header__inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-md);
    height: 100%;
}

/* ---------- Logo ---------- */
.site-logo {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    margin-right: auto;
    text-decoration: none;
    color: var(--color-primary);
}

/* Logo width comes from admin → Branding (--logo-w-*, set in head.php); height
   stays auto so it never distorts. On phones the width is also capped so the
   logo, two icon buttons and the menu button always fit on one row. */
.site-logo__img {
    width: min(var(--logo-w-mobile, 190px), calc(100vw - var(--gutter) * 2 - 136px));
    height: auto;
    max-width: none;
    transition: width 0.5s var(--ease-out);
}

.site-logo__text {
    font-family: var(--font-heading);
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: 0.01em;
}

/* Phones with the Call + WhatsApp header buttons switched off (admin → Branding):
   only the logo and the menu button share the row, so the logo gets the space
   (the Call button lives in the mobile menu, WhatsApp stays as the floating button). */
@media (max-width: 767.98px) {
    .hdr-actions-off .header-actions {
        display: none;
    }

    .hdr-actions-off .site-logo__img {
        width: min(var(--logo-w-mobile, 220px), calc(100vw - var(--gutter) * 2 - 52px));
    }
}

@media (min-width: 1024px) {
    .site-logo__img {
        width: min(var(--logo-w-desktop, 240px), max(240px, 20vw));
    }

    .site-header.is-scrolled .site-logo__img {
        width: calc(min(var(--logo-w-desktop, 240px), max(240px, 20vw)) * 0.8);
    }
}

/* ---------- Navigation: shared ---------- */
.site-nav__link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--color-text);
    text-decoration: none;
    font-weight: 500;
}

.site-nav__link:hover,
.site-nav__link.is-active {
    color: var(--color-primary);
}

/* ---------- Header Call + WhatsApp buttons ---------- */
.header-actions {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

/* Phones: round icon-only buttons (the aria-label gives the name) */
.header-actions__btn {
    width: 44px;
    padding: 0;
}

/* Small phones: the bigger logo needs more room, so tighten the header's
   own gaps and shrink the two icon buttons slightly (still ≥40px tall —
   only the width is reduced where the row would otherwise be too tight). */
@media (max-width: 480px) {
    .site-header__inner {
        gap: var(--space-2xs);
    }

    .header-actions {
        gap: var(--space-2xs);
    }

    .header-actions__btn {
        width: 40px;
    }
}

.header-actions__label {
    display: none;
}

@media (min-width: 768px) {
    .header-actions__btn {
        width: auto;
        padding: 0.6em 1.2em;
    }

    .header-actions__label {
        display: inline;
    }
}

@media (min-width: 1024px) {
    .header-actions {
        margin-left: var(--space-md);
    }
}

/* 1024-1279px: six nav links + the bigger logo leave no room for the button
   labels, so the Call / WhatsApp buttons stay round icon buttons (aria-labels
   give their names) and the full labels return from 1280px. */
@media (min-width: 1024px) and (max-width: 1279.98px) {
    .header-actions__btn {
        width: 44px;
        padding: 0;
    }

    .header-actions__label {
        display: none;
    }
}

/* ---------- Hamburger toggle ---------- */
.nav-toggle {
    position: relative;
    z-index: 2;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 48px;
    height: 48px;
    margin-right: calc(var(--space-xs) * -1);
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    color: var(--color-primary);
}

.nav-toggle__bar {
    display: block;
    width: 24px;
    height: 1.5px;
    background: currentColor;
    border-radius: 2px;
    transition: transform 0.5s var(--ease-out), opacity 0.3s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
    opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

/* ---------- Navigation: mobile / tablet (< 1024px) ---------- */
@media (max-width: 1023.98px) {
    .js .nav-toggle {
        display: inline-flex;
    }

    .js .site-nav {
        position: fixed;
        inset: 0;
        z-index: 1;
        display: flex;
        flex-direction: column;
        gap: var(--space-2xl);
        padding: calc(var(--header-h) + var(--space-xl)) var(--gutter) var(--space-2xl);
        overflow-y: auto;
        overscroll-behavior: contain;
        background:
            radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, var(--color-secondary) 16%, transparent), transparent 70%),
            var(--color-bg);
        visibility: hidden;
        opacity: 0;
        transform: translateY(-12px);
        transition: opacity 0.5s var(--ease-out), transform 0.6s var(--ease-out), visibility 0s linear 0.6s;
    }

    .js .site-nav.is-open {
        visibility: visible;
        opacity: 1;
        transform: none;
        transition-delay: 0s;
    }

    .js .site-nav__list {
        display: flex;
        flex-direction: column;
    }

    .js .site-nav__list li {
        border-bottom: 1px solid color-mix(in srgb, var(--color-secondary) 35%, transparent);
    }

    .js .site-nav__link {
        width: 100%;
        min-height: 60px;
        font-family: var(--font-heading);
        font-size: clamp(1.75rem, 1.5rem + 1.2vw, 2.25rem);
        font-weight: 500;
        color: var(--color-primary);
    }

    .js .site-nav__link.is-active {
        font-style: italic;
    }

    /* Without JS: a simple wrapped row of links under the logo */
    .no-js .site-header {
        position: relative;
        height: auto;
        padding-block: var(--space-sm);
    }

    .no-js .site-header__inner {
        flex-wrap: wrap;
    }

    .no-js .site-nav {
        order: 3;
        width: 100%;
    }

    .no-js .site-nav__list {
        display: flex;
        flex-wrap: wrap;
        gap: 0 var(--space-lg);
    }
}

/* ---------- Navigation: desktop (>= 1024px) ---------- */
@media (min-width: 1024px) {
    .site-nav__list {
        display: flex;
        align-items: center;
        gap: clamp(0.9rem, -0.5rem + 2vw, 2.25rem);
    }

    .site-nav__link {
        font-size: 0.9375rem;
        letter-spacing: 0.05em;
        white-space: nowrap;
    }

    .site-nav__link::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: 8px;
        height: 1px;
        background: var(--color-secondary);
        transform: scaleX(0);
        transform-origin: left;
        transition: transform 0.5s var(--ease-out);
    }

    .site-nav__link:hover::after,
    .site-nav__link.is-active::after {
        transform: scaleX(1);
    }
}

/* "Book a free 20-minute call" button: shown inside the mobile menu only */
.site-nav__cta {
    display: none;
}

@media (max-width: 1023.98px) {
    .js .site-nav__list li.site-nav__cta {
        display: block;
        margin-top: var(--space-lg);
        border-bottom: 0;
    }

    .js .site-nav__cta .btn {
        width: 100%;
        white-space: normal;
    }

    .js .site-nav__list li.site-nav__call {
        margin-top: var(--space-sm);
    }
}

/* Lock page scroll while the mobile menu is open */
html.menu-open,
html.menu-open body {
    overflow: hidden;
}

/* ---------- Footer ---------- */
.site-footer {
    padding-block: clamp(3.5rem, 3rem + 3vw, 5.5rem) var(--space-xl);
    background: var(--color-primary-dark);
    color: var(--color-bg);
    font-size: var(--text-sm);
}

.site-footer a {
    color: var(--color-bg);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--color-secondary);
}

.site-footer :focus-visible {
    outline-color: var(--color-secondary);
}

.site-footer__grid {
    display: grid;
    gap: var(--space-2xl) var(--space-xl);
    grid-template-columns: 1fr;
}

@media (min-width: 600px) {
    .site-footer__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .site-footer__grid {
        grid-template-columns: 1.4fr 1fr 1.2fr 1.3fr;
    }
}

.site-footer__col--about {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
}

.site-footer__logo {
    display: inline-flex;
    padding: 1rem 1.25rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-size: 1.35rem;
}

.site-footer__logo:hover {
    color: var(--color-primary);
}

/* Bigger, more visible logo per client request (was 84px ≈ 176px wide) */
.site-footer__logo img {
    width: var(--logo-w-footer, 240px);
    max-width: 100%;
    height: auto;
}

.site-footer__about-text {
    margin: 0;
    max-width: 30ch;
    color: color-mix(in srgb, var(--color-bg) 85%, transparent);
}

.site-footer__heading {
    margin: 0 0 var(--space-md);
    font-family: var(--font-body);
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    color: var(--color-secondary);
}

.site-footer__links li + li {
    margin-top: 0.1rem;
}

.site-footer__links a,
.site-footer__plain {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 44px;
    min-height: 44px;
}

.site-footer__contact .icon {
    width: 1.1em;
    height: 1.1em;
    color: var(--color-secondary);
    flex: none;
}

.site-footer__cta {
    margin-top: var(--space-xs);
}

.site-footer__small {
    margin: 0;
    color: color-mix(in srgb, var(--color-bg) 78%, transparent);
}

.site-footer__bacp {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
}

/* The BACP logo is purple-on-white, so it always sits on a true white card
   (not the cream --color-bg), regardless of what section it's placed in. */
.bacp-logo {
    display: inline-flex;
    max-width: 260px;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
}

.bacp-logo img {
    width: auto;
    max-width: 100%;
    height: 84px;
}

.site-footer__bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-xs) var(--space-xl);
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid color-mix(in srgb, var(--color-bg) 18%, transparent);
    color: color-mix(in srgb, var(--color-bg) 78%, transparent);
}

.site-footer__bottom p {
    margin: 0;
}

/* ---------- Floating buttons ---------- */
.fab {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    z-index: 90;
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 12px 28px -10px rgb(22 58 40 / 0.45);
    transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out), visibility 0s linear 0s;
}

.fab .icon {
    width: 26px;
    height: 26px;
}

.fab--whatsapp {
    right: max(1.25rem, env(safe-area-inset-right));
    bottom: max(1.25rem, env(safe-area-inset-bottom));
    background: var(--color-whatsapp);
    color: var(--color-text);
}

/* Hidden while the hero (with its own Call/WhatsApp buttons) is in view on
   the homepage — shown again once scrolled past it. Always visible on pages
   without a hero, and always visible with JS disabled. */
.js .fab--whatsapp.is-hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: transform 0.4s var(--ease-out), opacity 0.4s var(--ease-out), visibility 0s linear 0.4s;
}

.fab--whatsapp:hover {
    color: var(--color-text);
    transform: translateY(-3px);
}

.fab--top {
    bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 56px + 0.75rem);
    width: 48px;
    height: 48px;
    right: calc(max(1rem, env(safe-area-inset-right)) + 4px);
    background: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid color-mix(in srgb, var(--color-secondary) 55%, transparent);
}

.fab--top .icon {
    width: 20px;
    height: 20px;
}

.fab--top:hover {
    color: var(--color-primary-dark);
    transform: translateY(-3px);
}

/* Back-to-top only appears after scrolling (JS); always shown without JS */
.js .fab--top:not(.is-visible) {
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: transform 0.5s var(--ease-out), opacity 0.5s var(--ease-out), visibility 0s linear 0.5s;
}

/* WhatsApp button is for mobile; desktop has it in the hero, header menu and contact */
@media (min-width: 1024px) {
    .fab--whatsapp {
        display: none;
    }

    .fab--top {
        bottom: max(1.5rem, env(safe-area-inset-bottom));
        right: max(1.5rem, env(safe-area-inset-right));
    }
}

html.menu-open .fab {
    opacity: 0;
    visibility: hidden;
}

/* Keep the last footer line clear of the floating WhatsApp button */
@media (max-width: 1023.98px) {
    .site-footer {
        padding-bottom: calc(56px + 2.5rem);
    }
}

/* ---------- Footer: text-style button ("Cookie settings") ---------- */
.site-footer__linkbtn {
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
}

.site-footer__linkbtn:hover {
    color: var(--color-secondary);
}

/* ---------- Cookie consent banner ---------- */
.cookie-banner {
    position: fixed;
    inset: auto 0 0;
    z-index: 95;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md) max(var(--gutter), env(safe-area-inset-right)) max(var(--space-md), env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
    background: var(--color-surface);
    border-top: 1px solid color-mix(in srgb, var(--color-secondary) 55%, transparent);
    box-shadow: 0 -12px 30px -18px rgb(22 58 40 / 0.35);
}

.cookie-banner[hidden] {
    display: none;
}

.cookie-banner__text {
    max-width: 52rem;
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
}

.cookie-banner__text a {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-color: var(--color-secondary);
    text-underline-offset: 0.2em;
}

.cookie-banner__actions {
    display: flex;
    gap: var(--space-sm);
}

.cookie-banner__actions .btn {
    flex: 1;
    min-width: 0;
}

@media (min-width: 768px) {
    .cookie-banner {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: var(--space-lg);
    }

    .cookie-banner__actions .btn {
        flex: none;
        min-width: 7.5rem;
    }
}

/* Keep the floating buttons clear of the banner */
.has-consent-banner .fab--whatsapp {
    bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + var(--consent-h, 0px) + 0.75rem);
}

.has-consent-banner .fab--top {
    bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 56px + 0.75rem + var(--consent-h, 0px) + 0.75rem);
}
