/* Zyra site footer (Phase 2.3 footer redesign) — theme-following colours
   and foldable link sections (user instructions 2026-12-01). Loaded from
   templates/footer.php so header.php stays untouched.
   The footer FOLLOWS the site theme: light surface with dark ink text in
   light mode, dark ink with white text in dark mode. Colours are
   footer-local custom properties (--zf-*) defined explicitly for both
   modes in this file — the background must never reference var(--zyra-ink):
   that DS token is the TEXT colour and flips to #f9fafb under
   [data-bs-theme="dark"], which once turned this background near-white
   under white text (white-on-white, user screenshot 2026-12-01).
   Bottom clearance for the floating pill is the existing body padding
   (DS §11: body:has(.zyra-mobile-nav) 84px).
   All footer content is centre-aligned (user instruction 2026-12-01):
   logo, headings, blurb, contact lines (icon + text together), column
   links and the bottom legal bar. Compact side-by-side layout (user
   instruction 2026-12-01): below desktop the link columns sit side by
   side instead of stacking in one long column — About Zyra full width on
   top, Quick Links (left) and Categories (right) in one two-column row,
   then Account full width with its links side by side in a tidy grid.
   Foldable sections (user instruction 2026-12-01): below desktop the
   three link columns start collapsed behind their headings (tap to
   unfold); desktop keeps them expanded. Collapsing only applies when JS
   is present (.zyra-footer--js, added by zyra-footer.js) so without JS
   every link stays visible. Compact spacing from the contrast fix is
   preserved. */

.zyra-footer {
    /* Light mode (default): DS surface background so the footer reads as
       a distinct section against the white page, dark ink text. Contrast
       on #f5f5f4: heading 16.3:1, links 9.5:1, blurb 6.9:1, legal
       5.3:1, contact icons 5.3:1 (brand-dark teal; the mid brand teal
       only reaches 3.7:1 on this background). */
    --zf-bg: #f5f5f4;
    --zf-text: #374151;
    --zf-heading: #111827;
    --zf-blurb: #4b5563;
    --zf-link: #374151;
    --zf-link-hover: #111827;
    --zf-contact: #374151;
    --zf-legal: #5b6675;
    --zf-legal-link: #4b5563;
    --zf-border: #e5e7eb;
    --zf-icon: #346d7a;
    --zf-logo: #111827;
    --zf-input-bg: #ffffff;
    --zf-input-text: #111827;
    --zf-input-border: #d1d5db;
    background-color: var(--zf-bg);
    color: var(--zf-text);
    border-top: 1px solid var(--zf-border);
}

[data-bs-theme="dark"] .zyra-footer {
    /* Dark mode: the established dark ink footer. Contrast on #111827:
       heading 17.7:1, text 11.1:1, links 9.5:1, legal 6.1:1, icons
       4.4:1. */
    --zf-bg: #111827;
    --zf-text: rgba(255, 255, 255, .78);
    --zf-heading: #fff;
    --zf-blurb: rgba(255, 255, 255, .72);
    --zf-link: rgba(255, 255, 255, .72);
    --zf-link-hover: #fff;
    --zf-contact: rgba(255, 255, 255, .85);
    --zf-legal: rgba(255, 255, 255, .55);
    --zf-legal-link: rgba(255, 255, 255, .72);
    --zf-border: rgba(255, 255, 255, .12);
    --zf-icon: #4d8693;
    --zf-logo: #fff;
    --zf-input-bg: #1f2937;
    --zf-input-text: #f9fafb;
    --zf-input-border: rgba(255, 255, 255, .28);
}

.zyra-footer .container {
    padding-top: 48px;
    padding-bottom: 8px;
}

.zyra-footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 32px 24px;
    padding-bottom: 40px;
    /* Centre all column content (headings, blurb, links). Block-level
       children that need their own centring are handled below. */
    text-align: center;
}

.zyra-footer-logo {
    display: inline-flex;
    /* logo artwork is currentColor, so it follows the theme via --zf-logo */
    color: var(--zf-logo);
    margin-bottom: 20px;
}

.zyra-footer-logo-svg {
    height: 34px;
    width: auto;
    display: block;
}

.zyra-footer-head {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--zf-heading);
    margin: 0 0 14px;
}

/* Foldable section toggles: the heading button is a plain heading on
   desktop (chevron hidden, panel always expanded); below desktop it
   becomes a full-width 44px tap target with a rotating chevron. */
.zyra-footer-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit;
    cursor: default;
}

.zyra-footer-chevron {
    display: none;
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .25s ease;
}

.zyra-footer-col.is-open .zyra-footer-chevron {
    transform: rotate(225deg);
}

/* Link panel: grid-rows 0fr/1fr gives a smooth fold. The list needs
   min-height: 0 + overflow: hidden to collapse fully; its 3px padding
   keeps link focus outlines from being clipped while expanded. */
.zyra-footer-panel {
    display: grid;
    grid-template-rows: 1fr;
}

.zyra-footer-panel > ul {
    min-height: 0;
    overflow: hidden;
    padding: 3px;
}

.zyra-footer-blurb {
    font-size: 14px;
    line-height: 1.6;
    color: var(--zf-blurb);
    max-width: 44ch;
    /* auto side margins centre the blurb block itself in its column */
    margin: 0 auto 12px;
}

.zyra-footer-more {
    font-size: 14px;
    font-weight: 600;
    color: var(--zf-heading);
    text-decoration: none;
}

.zyra-footer-more:hover {
    color: var(--zf-heading);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.zyra-footer-contact {
    list-style: none;
    margin: 20px 0 0;
    padding: 0;
    display: grid;
    gap: 10px;
    /* each contact row (icon + text as one flex unit) centres in the column */
    justify-items: center;
}

.zyra-footer-contact li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.zyra-footer-contact li > * {
    min-width: 0;
}

.zyra-footer-contact i {
    color: var(--zf-icon);
    font-size: 17px;
    line-height: 1;
    flex-shrink: 0;
}

.zyra-footer-contact a {
    color: var(--zf-contact);
    text-decoration: none;
    word-break: break-all;
}

.zyra-footer-contact a:hover {
    color: var(--zf-heading);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.zyra-footer-col ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.zyra-footer-col li a {
    display: block;
    padding: 9px 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--zf-link);
    text-decoration: none;
}

.zyra-footer-col li a:hover {
    color: var(--zf-link-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.zyra-footer-bottom {
    border-top: 1px solid var(--zf-border);
    padding: 20px 0 24px;
    display: flex;
    /* legal line centred, Privacy/Terms links centred below it */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px 24px;
}

.zyra-footer-legal p {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--zf-legal);
}

.zyra-footer-legal a {
    color: var(--zf-legal-link);
}

.zyra-footer-legal-links {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.zyra-footer-legal-links a {
    font-size: 13px;
    color: var(--zf-legal-link);
    text-decoration: none;
    padding: 6px 0;
}

.zyra-footer-legal-links a:hover {
    color: var(--zf-link-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.zyra-footer a:focus-visible,
.zyra-footer button:focus-visible {
    outline: 2px solid var(--zyra-brand, #4d8693);
    outline-offset: 2px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .zyra-footer-panel,
    .zyra-footer-chevron {
        transition: none;
    }
}

@media (max-width: 991.98px) {
    /* Side-by-side below desktop (user instruction 2026-12-01): About
       Zyra full width on top, then Quick Links (left) and Categories
       (right) in one two-column row, then Account full width below —
       instead of stacking every column in one long column. */
    .zyra-footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    .zyra-footer-about {
        grid-column: 1 / -1;
    }

    /* columns may shrink below their longest word instead of forcing
       the grid wider than the screen on narrow phones */
    .zyra-footer-col {
        min-width: 0;
    }

    .zyra-footer-col li a {
        overflow-wrap: break-word;
    }

    /* Account spans the full row with its links side by side in a tidy
       grid (3 columns on tablet widths; phones narrow it to 2 below),
       instead of sitting in a half-width cell next to an empty one
       (the empty cell made the phone footer look stretched/broken). */
    .zyra-footer-col--account {
        grid-column: 1 / -1;
    }

    .zyra-footer-col--account ul {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        column-gap: 24px;
    }

    /* Foldable sections (user instruction 2026-12-01): headings become
       44px tap targets with a chevron; with JS present the panels start
       collapsed and unfold smoothly. Without JS (.zyra-footer--js
       absent) every panel stays expanded and reachable. */
    .zyra-footer-col .zyra-footer-head {
        margin-bottom: 0;
    }

    .zyra-footer-toggle {
        min-height: 44px;
        padding: 10px 8px;
        cursor: pointer;
    }

    .zyra-footer-chevron {
        display: block;
    }

    .zyra-footer-panel {
        transition: grid-template-rows .3s ease, opacity .25s ease, visibility 0s linear .3s;
    }

    .zyra-footer-panel > ul {
        padding-top: 6px;
    }

    .zyra-footer--js .zyra-footer-col:not(.is-open) .zyra-footer-panel {
        grid-template-rows: 0fr;
        opacity: 0;
        visibility: hidden;
    }

    .zyra-footer--js .zyra-footer-col.is-open .zyra-footer-panel {
        transition: grid-template-rows .3s ease, opacity .25s ease, visibility 0s;
    }
}

@media (max-width: 575.98px) {
    .zyra-footer .container {
        padding-top: 32px;
    }

    /* Phones: keep Quick Links and Categories side by side in two
       columns (text-align: center is inherited from the base grid rule),
       compact gaps preserved. About stays full width above them and
       Account stays full width below them. */
    .zyra-footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 24px 16px;
        padding-bottom: 24px;
    }

    /* Account links: two side-by-side columns on phones (three would
       squeeze labels like "Terms & Conditions" too narrow) */
    .zyra-footer-col--account ul {
        grid-template-columns: 1fr 1fr;
        column-gap: 16px;
    }

    .zyra-footer-logo {
        margin-bottom: 14px;
    }

    .zyra-footer-contact {
        margin-top: 16px;
        gap: 8px;
    }

    .zyra-footer-col li a {
        padding: 7px 0;
    }

    .zyra-footer-bottom {
        padding: 16px 0 20px;
    }

    .zyra-footer-legal p {
        line-height: 1.6;
    }
}

/* Home Screen app (standalone): keep the legal bar clear of the
   home-indicator zone. Browser tabs are untouched. */
@media (display-mode: standalone) {
    .zyra-footer-bottom {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }
}

/* Safari tab (DS §33): same home-indicator clearance in a browser
   tab, preserving each breakpoint's base padding (24px desktop /
   20px phone) so layouts are unchanged wherever the inset is 0.
   Scoped to display-mode: browser — standalone keeps the rule
   above as its sole source. */
@media (display-mode: browser) {
    .zyra-footer-bottom {
        padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    }
}
@media (display-mode: browser) and (max-width: 991.98px) {
    .zyra-footer-bottom {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }
}

/* Newsletter signup (Phase 2 Workstream C): centred like the rest
   of the footer; input and button stack full-width on phones and
   sit side by side from small tablets up. */
.zyra-footer-newsletter {
    text-align: center;
    max-width: 560px;
    margin: 0 auto 36px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--zf-border);
}

.zyra-footer-newsletter-copy {
    font-size: 14px;
    line-height: 1.6;
    color: var(--zf-blurb);
    margin: 0 auto 16px;
    max-width: 46ch;
}

.zyra-footer-newsletter-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zyra-footer-newsletter-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--zf-heading);
    text-align: left;
}

.zyra-footer-newsletter-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.zyra-footer-newsletter-input {
    width: 100%;
    min-height: 52px;
    padding: 12px 16px;
    border-radius: var(--zyra-radius-pill, 999px);
    border: 1px solid var(--zf-input-border);
    background: var(--zf-input-bg);
    color: var(--zf-input-text);
    font-size: 16px;
    box-sizing: border-box;
}

.zyra-footer-newsletter-input::placeholder {
    color: var(--zf-blurb);
}

.zyra-footer-newsletter-input:focus-visible {
    outline: 3px solid var(--zyra-brand, #4d8693);
    outline-offset: 1px;
}

.zyra-footer-newsletter-btn {
    width: 100%;
    min-height: 52px;
}

.zyra-footer-newsletter-btn:disabled {
    opacity: .6;
}

.zyra-footer-newsletter-msg {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.55;
    margin: 4px 0 0;
    text-align: left;
}

.zyra-footer-newsletter-msg[hidden] {
    display: none;
}

.zyra-footer-newsletter-msg.is-error {
    color: var(--zyra-danger, #f03d3d);
}

.zyra-footer-newsletter-msg.is-success {
    color: var(--zf-heading);
}

.zyra-footer-newsletter-note {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--zf-legal);
    margin: 4px 0 0;
    text-align: left;
}

@media (min-width: 576px) {
    .zyra-footer-newsletter-row {
        flex-direction: row;
    }

    .zyra-footer-newsletter-input {
        flex: 1 1 auto;
        min-width: 0;
    }

    .zyra-footer-newsletter-btn {
        width: auto;
        flex: 0 0 auto;
    }
}
