/* layout.css — header, nav, footer, page scaffolding */
.site-main { position: relative; z-index: 1; }

.site-header {
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: blur(14px) saturate(1.4);
    background: rgba(13, 17, 23, 0.72);
    border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 0.55rem; font-weight: 800; font-size: 1.15rem; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 5px; display: block; flex: none;
}
/* CBA wordmark logo (header + footer). Width auto keeps the ~2:1 aspect ratio. */
.brand-logo { height: 34px; width: auto; display: block; flex: none; }
/* align-self avoids the column flex parent stretching the logo to full width. */
.footer-brand .brand-logo { height: 30px; align-self: flex-start; }
.brand:hover { color: var(--text); }

/* Right cluster: nav links + language switcher + hamburger. Keeps them grouped
   on the right; on mobile the nav collapses out of flow, leaving the language
   switcher and the toggle inline. */
.header-right { display: flex; align-items: center; gap: 1.6rem; }
.site-nav { display: flex; align-items: center; gap: 1.6rem; font-weight: 600; font-size: 0.95rem; }
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--text); }

.nav-toggle { display: none; background: none; border: 0; flex-direction: column; gap: 5px; }
.nav-toggle span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; }

.site-footer { position: relative; z-index: 1; margin-top: 6rem; border-top: 1px solid var(--border); background: rgba(10, 14, 21, 0.7); backdrop-filter: blur(8px); }
.footer-inner { display: grid; grid-template-columns: 1.3fr 1fr 1.4fr; gap: 2rem; padding: 3rem 0 1.5rem; }
.footer-brand p { color: var(--muted); margin-top: 0.5rem; }
.footer-brand { display: flex; flex-direction: column; gap: 0.3rem; }
/* Links sit in the third grid column — where the removed footer note used to be.
   align-items:flex-end right-aligns them to the container edge (direction-aware:
   becomes left-aligned under RTL). */
.footer-links { display: flex; flex-direction: column; gap: 0.5rem; color: var(--muted); grid-column: 3; align-items: flex-end; }
.footer-note { color: var(--muted); font-size: 0.86rem; }
/* Anti-ripper honeypot link: kept in the DOM for site-mirroring bots to follow,
   but invisible to humans and screen readers (the markup also sets aria-hidden +
   tabindex=-1). Off-screen rather than display:none, which some scrapers skip. */
.hp-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.footer-bottom {
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    padding: 1.2rem 0 2rem; color: var(--muted); font-size: 0.82rem;
    border-top: 1px solid var(--border);
}

/* "Ask AI about CBA" band — full-width strip at the top of the footer. Centered,
   so it is direction-agnostic (no RTL override needed). */
.footer-ai {
    text-align: center;
    padding: 1.6rem 1rem 1.4rem;
    border-bottom: 1px solid var(--border);
}
.footer-ai-title {
    margin: 0 0 0.9rem;
    font-size: 0.95rem; font-weight: 600; letter-spacing: 0.02em;
    color: var(--text);
}
.footer-ai-icons {
    list-style: none; margin: 0; padding: 0;
    display: flex; justify-content: center; align-items: center;
    gap: 1.4rem; flex-wrap: wrap;
}
.footer-ai-link {
    display: inline-flex; border-radius: 8px; opacity: 0.82;
    transition: transform 0.18s ease, opacity 0.18s ease;
}
.footer-ai-link:hover, .footer-ai-link:focus-visible { opacity: 1; transform: scale(1.12); }
/* Explicit keyboard focus ring (WCAG 2.4.7) — scale/opacity alone is too subtle. */
.footer-ai-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.footer-ai-link img { width: 36px; height: 36px; display: block; border-radius: 8px; }
@media (max-width: 820px) {
    .footer-ai { padding: 1.3rem 1rem; }
    .footer-ai-icons { gap: 1.1rem; }
}

/* Match the homepage hero's top spacing so inner-page titles sit at the same height. */
.page-head { padding: 4rem 0 1rem; text-align: center; }
.page-head h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
@media (max-width: 540px) {
    .page-head { padding: 2.2rem 0 1rem; }
}

/* Language switcher (flag dropdown in the header nav) */
.lang-switcher { position: relative; }
.lang-current {
    display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer;
    padding: 0.38rem 0.55rem; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 0.9rem;
    transition: background 0.2s ease;
}
.lang-current:hover { background: var(--surface-2); }
.lang-flag { border-radius: 2px; object-fit: cover; display: block; box-shadow: 0 0 0 1px rgba(0,0,0,0.25); }
.lang-caret { transition: transform 0.2s ease; opacity: 0.7; }
.lang-switcher.is-open .lang-caret { transform: rotate(180deg); }
.lang-menu {
    position: absolute; top: calc(100% + 0.45rem); right: 0; z-index: 60;
    min-width: 184px; margin: 0; padding: 0.35rem; list-style: none;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow);
    /* Cap the dropdown at ~10 languages (each ~2.47rem tall) and scroll the rest;
       clamp to the viewport so it never overflows on short screens. */
    max-height: min(25rem, 70vh); overflow-y: auto; overscroll-behavior: contain;
    scrollbar-gutter: stable; scrollbar-width: thin;
    /* Slightly darker shade of the Bitcoin-orange button color (--primary). */
    scrollbar-color: #d98117 transparent;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
}
/* Slim scrollbar for the language dropdown (WebKit/Blink). */
.lang-menu::-webkit-scrollbar { width: 8px; }
.lang-menu::-webkit-scrollbar-thumb {
    background: #d98117; border-radius: 999px;
    border: 2px solid transparent; background-clip: padding-box;
}
.lang-menu::-webkit-scrollbar-track { background: transparent; }
.lang-switcher.is-open .lang-menu { opacity: 1; visibility: visible; transform: none; }
.lang-option {
    display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm); color: var(--text); font-size: 0.92rem;
}
.lang-option:hover { background: var(--surface); color: var(--text); }
.lang-option.is-active { color: var(--primary-2); font-weight: 600; }
@media (max-width: 820px) {
    /* Switcher now sits at the far right of the header bar on mobile too, so the
       dropdown stays right-anchored (left:0 would overflow off-screen). */
    .lang-menu { right: 0; left: auto; }
    /* Tighter spacing between the always-visible switcher and the hamburger. */
    .header-right { gap: 0.9rem; }
}

@media (max-width: 820px) {
    /* Single-column stack on mobile, with everything centered. */
    .footer-inner { grid-template-columns: 1fr; justify-items: center; text-align: center; }
    .footer-brand { align-items: center; }
    .footer-brand .brand-logo { align-self: center; }
    /* Footer menu (4 links): centered 2×2 grid — the bottom two line up under the
       top two. Columns are content-sized and the whole block is centered. */
    .footer-links {
        grid-column: auto;
        display: grid;
        grid-template-columns: repeat(2, auto);
        justify-content: center;
        align-items: start;
        gap: 0.7rem 1.8rem;
        text-align: center;
    }
    /* Center the bottom copyright row too. */
    .footer-bottom { justify-content: center; text-align: center; }
    .site-footer { margin-top: 3rem; }
    .site-nav {
        position: absolute; top: 68px; left: 0; right: 0; flex-direction: column;
        gap: 1rem; padding: 1.4rem; background: var(--bg);
        border-bottom: 1px solid var(--border);
        transform: translateY(-120%); opacity: 0; visibility: hidden;
        transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s;
        align-items: flex-start;
    }
    .site-nav.is-open {
        transform: translateY(0); opacity: 1; visibility: visible;
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    }
    .nav-toggle { display: flex; }
}
/* Tiny phones: shrink the brand so the long name + menu button never collide. */
@media (max-width: 400px) {
    .brand { font-size: 1rem; gap: 0.4rem; }
    .brand-mark { width: 30px; height: 30px; }
    .brand-logo { height: 32px; }
    .header-inner { height: 60px; }
    .site-nav { top: 60px; } /* match the shorter header so no gap shows above the menu */
}

/* Error pages (404/405/...): rendered on any route, so the styling lives in this
   always-loaded global sheet rather than a page-specific one. */
.error-page { padding: 6rem 0; text-align: center; }
.error-card { max-width: 480px; margin-inline: auto; padding: 3rem 2rem; }
.error-card h1 { font-size: 4rem; }
