/*
 * Shared refinements for the existing BSAviation site.
 * Loaded after page-specific stylesheets so targeted overrides stay consistent.
 */
html.gallery-viewer-open,
html.gallery-viewer-open body {
    perspective: none;
}

/* Short About pages fill the viewport without fixing the footer over content. */
body.about-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

body.about-page > .about {
    flex: 1 0 auto;
}

body.about-page > .footer {
    flex-shrink: 0;
}

body.site-unified .about.about--editorial .about-grid {
    display: block;
    max-width: 760px;
    padding: 0;
}

body.site-unified .about.about--editorial .about-text :is(h2, h3) {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--ui-ink);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

body.site-unified .about.about--editorial .about-text p {
    margin-bottom: 0;
    line-height: 1.7;
}

body.site-unified .about.about--editorial .about-detail-block {
    margin-top: clamp(26px, 4vw, 40px);
    padding-top: clamp(18px, 3vw, 26px);
    border-top: 1px solid var(--ui-line);
}

body.site-unified .meeting-calendar-section {
    margin: clamp(28px, 4vw, 48px) auto;
}

body.site-unified .meeting-calendar-intro {
    max-width: 760px;
    margin: 0 auto 20px;
    text-align: center;
}

body.site-unified .meeting-calendar-intro h2 {
    margin: 0 0 10px;
    color: var(--ui-ink);
    font-size: clamp(1.6rem, 3vw, 2rem);
    line-height: 1.2;
}

body.site-unified .meeting-calendar-intro p,
body.site-unified .meeting-calendar-fallback {
    color: var(--ui-muted);
    line-height: 1.65;
}

body.site-unified .meeting-calendar-frame {
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--ui-line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(16, 48, 65, .08);
}

body.site-unified .meeting-calendar-frame iframe {
    display: block;
    width: 100%;
    height: 640px;
    border: 0;
    background: #fff;
}

body.site-unified .meeting-calendar-fallback {
    margin: 12px 0 0;
    font-size: .9rem;
    text-align: right;
}

body.site-unified .meeting-calendar-fallback a {
    color: var(--ui-ink);
    font-weight: 700;
    text-underline-offset: 3px;
}

body.pathways-page .pathways-hero-inner {
    display: block;
    max-width: 860px;
}

body.pathways-page.site-unified .pathways-section {
    padding: clamp(32px, 4.5vw, 56px) 0;
}

body.pathways-page.site-unified .pathway-resources-heading {
    margin-bottom: 18px;
}

body.pathways-page.site-unified .pathway-resources {
    margin-top: 0;
}

body.pathways-page.site-unified .pathway-resources-heading h2 {
    max-width: none;
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    line-height: 1.2;
}

@media (max-width: 360px) {
    body.pathways-page.site-unified .pathway-resource-nav a span {
        display: none;
    }
}

body.legacy-home .stats-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

body.legacy-home .stats-grid--three .stat-item {
    border-bottom: 0;
}

body.legacy-home .stats-grid--three .stat-item:not(:last-child) {
    border-right: 1px solid #cfdae0;
}

@media (max-width: 767px) {
    html,
    body {
        perspective: none;
    }

    html {
        scroll-padding-top: 84px;
    }

    body {
        overflow-x: clip;
        -webkit-text-size-adjust: 100%;
    }

    body :is(main, section, article, aside, header, footer, .container, .news-layout, .news-main-content) {
        min-width: 0;
    }

    body :is(p, li, h1, h2, h3, h4, a, button, label, span) {
        overflow-wrap: anywhere;
    }

    body :is(img, svg) {
        max-width: 100%;
    }

    body :is(a, button, input, select, textarea) {
        -webkit-tap-highlight-color: rgba(75, 120, 148, .16);
    }

    body :is(a, button):focus-visible,
    body :is(input, select, textarea):focus-visible {
        outline: 3px solid #a9c66a;
        outline-offset: 3px;
    }

    /* A full-width, safely inset menu remains scrollable on short landscape screens. */
    body:is(.site-unified, .partners-page) .navbar .nav-menu:not(.active),
    body:is(.site-unified, .partners-page) .navbar .nav-menu.active {
        transform: none;
        transition: opacity .16s ease, visibility .16s ease;
    }

    body:is(.site-unified, .partners-page) .navbar .nav-menu.active {
        position: fixed;
        top: 70px;
        right: max(12px, env(safe-area-inset-right));
        left: max(12px, env(safe-area-inset-left));
        width: auto;
        max-width: 420px;
        max-height: calc(100vh - 82px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 82px - env(safe-area-inset-bottom));
        margin-inline: auto;
        padding: 8px;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
        transform: none;
    }

    body:is(.site-unified, .partners-page) .navbar.scrolled .nav-menu.active {
        top: 60px;
        max-height: calc(100vh - 72px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 72px - env(safe-area-inset-bottom));
    }

    body:is(.site-unified, .partners-page) .navbar .nav-menu.active .nav-link {
        min-height: 48px;
        padding: .7rem .85rem;
        line-height: 1.3;
        overflow-wrap: normal;
    }

    .navbar .hamburger {
        flex: 0 0 48px;
        min-width: 48px;
        min-height: 48px;
    }

    /* Keep every slide control visible and genuinely tappable at 320px. */
    body.legacy-home .hero-slide-controls {
        right: 12px;
        left: 12px;
        top: auto;
        bottom: 12px;
        grid-template-columns: repeat(6, minmax(0, 1fr));
        grid-template-rows: 44px 44px;
        gap: 2px 0;
    }

    body.legacy-home .hero-slide-arrow {
        width: 44px;
        height: 44px;
    }

    body.legacy-home .hero-slide-dots {
        display: contents;
    }

    body.legacy-home .hero-slide-prev {
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }

    body.legacy-home .hero-slide-next {
        grid-column: 6;
        grid-row: 1;
        justify-self: end;
    }

    body.legacy-home .hero-slide-dot {
        grid-row: 2;
        justify-self: center;
        width: 44px;
        min-width: 44px;
        height: 44px;
    }

    body.legacy-home .hero-slide-pause {
        grid-column: 3 / span 2;
        grid-row: 1;
        justify-self: center;
        width: 44px;
        height: 44px;
    }

    body.legacy-home .stats-grid--three {
        gap: 0;
    }

    body.legacy-home .stats-grid--three .stat-item {
        padding: 1.15rem .35rem;
    }

    body.legacy-home .stats-grid--three .stat-item:nth-child(odd) {
        border-right: 0;
        border-bottom: 0;
    }

    body.legacy-home .stats-grid--three .stat-item:not(:last-child) {
        border-right: 1px solid #cfdae0;
    }

    body.site-unified.legacy-home .legacy-feature-section {
        padding: 48px 0;
    }

    body.legacy-home .hero {
        padding-top: 112px;
        padding-bottom: 96px;
    }

    body.legacy-home .hero .hero-tagline {
        max-width: none;
        margin-bottom: 10px;
        font-size: .9rem !important;
        line-height: 1.35;
    }

    body.legacy-home .hero .hero-intro {
        max-width: 34ch;
        font-size: .86rem;
        line-height: 1.35;
    }

    body.legacy-home .hero-buttons {
        width: min(100%, 420px);
        margin-top: 16px;
        align-items: stretch;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
    }

    body.legacy-home .hero-buttons .btn {
        width: auto;
        max-width: none;
        min-width: 0;
        min-height: 44px;
        flex: 1 1 0;
        padding-inline: 10px;
    }

    /* Comfortable reading measure and vertical rhythm across the existing pages. */
    body.site-unified:not(.legacy-home) :is(.about, .team, .services, .gallery, .contact) {
        padding-top: 104px !important;
        padding-bottom: 56px !important;
    }

    body.site-unified:not(.legacy-home) .section-title {
        margin-bottom: 24px;
        font-size: clamp(2rem, 8.8vw, 2.8rem);
        line-height: 1.08;
    }

    body.site-unified:not(.legacy-home) :is(.about-text, .team-text, .meeting-card, .contact-info, .article-body-v2, .sidebar-widget-v2) p {
        line-height: 1.7;
    }

    body.site-unified:not(.legacy-home) .about-text :is(h3, h4),
    body.site-unified:not(.legacy-home) .team-text :is(h3, h4) {
        line-height: 1.2;
        text-wrap: balance;
    }

    body.site-unified:not(.legacy-home) :is(.about-stats, .meeting-info, .gallery-grid, .news-layout, .contact-grid, .team-content, .about-grid, .pathways-hero-inner, .pathway-list, .partner-showcase, .partner-origin-story) {
        min-width: 0;
    }

    body.site-unified:not(.legacy-home) :is(.stat-card, .meeting-card, .gallery-item, .contact-form, .pathway-resource-card, .pathway-partner, .partner-impact-card, .partner-logo-card) {
        min-width: 0;
    }

    body.site-unified:not(.legacy-home) :is(.btn, .btn-news-v2, .news-link-v2, .pathway-link, .partner-origin-link) {
        max-width: 100%;
        min-height: 44px;
        line-height: 1.35;
        white-space: normal;
    }

    body.site-unified:not(.legacy-home) :is(.group-actions, .hero-buttons, .pathways-actions, .partners-connection-actions, .legacy-feature-actions) {
        flex-wrap: wrap;
        align-items: stretch;
        gap: 10px 14px;
    }

    body.site-unified:not(.legacy-home) .pathway-link {
        display: inline-flex;
        align-items: center;
        flex-wrap: wrap;
        gap: .3em;
    }

    /* The local callout used to let its non-shrinking link escape the viewport. */
    body.pathways-page .pathway-local-callout {
        min-width: 0;
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 20px 16px;
    }

    body.pathways-page .pathway-local-callout > * {
        min-width: 0;
        max-width: 100%;
    }

    body.pathways-page .pathway-local-callout .pathway-link {
        flex: 0 1 auto;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    body.site-unified:not(.legacy-home) .gallery-item {
        min-height: 190px;
    }

    body.site-unified:not(.legacy-home) .gallery-lightbox {
        padding: 12px;
    }

    body.site-unified:not(.legacy-home) .gallery-lightbox-dialog {
        width: calc(100vw - 24px);
        max-width: none;
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        grid-template-rows: minmax(0, 1fr) 44px;
        gap: 8px;
        animation: none;
        transform: none;
    }

    body.site-unified:not(.legacy-home) .gallery-lightbox-figure {
        grid-column: 1 / -1;
        grid-row: 1;
        max-height: calc(100vh - 84px);
        max-height: calc(100dvh - 84px);
        overflow-y: auto;
        gap: 8px;
    }

    body.site-unified:not(.legacy-home) .gallery-lightbox-image {
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
    }

    body.site-unified:not(.legacy-home) :is(.gallery-lightbox-nav, .gallery-lightbox-close) {
        grid-row: 2;
        width: 44px;
        height: 44px;
        transform: none;
    }

    body.site-unified:not(.legacy-home) .gallery-lightbox-prev {
        grid-column: 1;
    }

    body.site-unified:not(.legacy-home) .gallery-lightbox-next {
        grid-column: 3;
    }

    body.site-unified:not(.legacy-home) .gallery-lightbox-close {
        position: static;
        grid-column: 2;
        justify-self: center;
    }

    /* Form controls stay readable at native zoom and easy to reach by thumb. */
    body.site-unified:not(.legacy-home) .contact-form {
        padding: 20px 16px;
    }

    body.site-unified:not(.legacy-home) :is(.contact-form input, .contact-form select, .contact-form textarea) {
        width: 100%;
        min-width: 0;
        min-height: 46px;
        padding: 11px 12px;
        font-size: 16px;
    }

    body.site-unified:not(.legacy-home) .contact-form textarea {
        min-height: 128px;
    }

    body.site-unified:not(.legacy-home) .contact-form button[type="submit"] {
        width: 100%;
        min-height: 48px;
    }

    body.pathways-page.site-unified .pathway-resource-search input {
        font-size: 16px;
    }

    /* News copy, metadata and sidebar links wrap naturally on narrow screens. */
    body.site-unified:not(.legacy-home) .news-layout {
        gap: 22px;
    }

    body.site-unified:not(.legacy-home) .article-meta-v2 {
        flex-wrap: wrap;
        gap: 7px 12px;
    }

    body.site-unified:not(.legacy-home) .news-article-card,
    body.site-unified:not(.legacy-home) .news-article-card-v2,
    body.site-unified:not(.legacy-home) .sidebar-widget-v2 {
        min-width: 0;
    }

    /* Stack footer groups on phones; keep the link list in two readable columns. */
    body:is(.site-unified, .partners-page) .footer-content {
        grid-template-columns: minmax(0, 1fr);
        gap: 22px;
        padding-bottom: 24px;
    }

    body:is(.site-unified, .partners-page) .footer-content > .footer-section:first-child {
        grid-column: auto;
        text-align: center;
    }

    body:is(.site-unified, .partners-page) .footer-content > .footer-section:not(:first-child) {
        padding-top: 18px;
        border-top: 1px solid rgba(222, 235, 236, 0.18);
        text-align: left;
    }

    body:is(.site-unified, .partners-page) .footer-content > .footer-section:not(:first-child) h4 {
        margin: 0 0 10px;
        text-align: left;
    }

    body:is(.site-unified, .partners-page) .footer-section ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px 14px;
    }

    body:is(.site-unified, .partners-page) .footer-section li,
    body:is(.site-unified, .partners-page) .footer-section a {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    body:is(.site-unified, .partners-page) .footer-section li a {
        display: flex;
        width: 100%;
        min-height: 44px;
        align-items: center;
        font-size: 0.86rem;
    }

    body:is(.site-unified, .partners-page) .footer .social-links {
        justify-content: flex-start;
        gap: 10px;
    }

    body:is(.site-unified, .partners-page) .social-links a,
    body.site-unified .social-grid-v2 a {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
    }

    body:is(.site-unified, .partners-page) .footer-bottom {
        line-height: 1.6;
        text-wrap: pretty;
    }

    /* Partners uses a deliberately separate page theme but shares the same phone needs. */
    body.partners-page :is(.partners-hero, .partners-section, .partner-details, .partners-connection) {
        min-width: 0;
    }

    body.partners-page .partners-hero {
        padding: 104px 0 40px;
    }

    body.partners-page :is(.partner-showcase, .partner-origin-story, .partner-impact-grid, .partners-connection-card) {
        min-width: 0;
    }

    body.partners-page :is(.partner-copy, .partner-origin-copy, .partner-details-heading) p {
        line-height: 1.7;
    }

    body.partners-page .partner-impact-card {
        min-width: 0;
    }

    body.partners-page .partners-connection-actions {
        display: flex;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px 14px;
    }

    body.partners-page :is(.btn, .pathway-link, .partner-origin-link) {
        min-height: 44px;
        max-width: 100%;
        white-space: normal;
    }
}

@media (max-width: 360px) {
    body:is(.site-unified, .partners-page) .footer-content {
        grid-template-columns: minmax(0, 1fr);
    }

    body:is(.site-unified, .partners-page) .footer-content > .footer-section:first-child {
        grid-column: auto;
    }

    body:is(.site-unified, .partners-page) .footer-section ul {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    body.site-unified .meeting-calendar-frame iframe {
        height: 580px;
    }

    body.site-unified .meeting-calendar-fallback {
        text-align: left;
    }
}

@media (max-width: 767px) and (orientation: landscape) {
    body.legacy-home .hero {
        min-height: 100svh;
        padding: 76px 0 108px;
    }

    body.legacy-home .hero h1 {
        max-width: none;
        margin-bottom: 6px;
        font-size: clamp(1.9rem, 5vw, 2.35rem);
        line-height: 1.05;
    }

    body.legacy-home .hero .hero-tagline {
        max-width: none;
        margin-bottom: 8px;
        font-size: .95rem !important;
        line-height: 1.3;
    }

    body.legacy-home .hero .hero-intro {
        font-size: .86rem;
        line-height: 1.35;
    }

    body.legacy-home .hero-buttons {
        margin-top: 12px;
    }

    body.legacy-home .hero-slide-controls {
        top: auto;
        bottom: 30px;
        grid-template-columns: repeat(9, minmax(44px, 1fr));
        grid-template-rows: 44px;
        gap: 0;
    }

    body.legacy-home .hero-slide-prev {
        grid-column: 1;
        grid-row: 1;
    }

    body.legacy-home .hero-slide-next {
        grid-column: 9;
        grid-row: 1;
    }

    body.legacy-home .hero-slide-dot {
        grid-row: 1;
    }

    body.legacy-home .hero-slide-pause {
        grid-column: auto;
        grid-row: 1;
    }

    body:is(.site-unified, .partners-page) .navbar .nav-menu.active {
        max-height: calc(100vh - 76px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 76px - env(safe-area-inset-bottom));
    }

    body:is(.site-unified, .partners-page) .navbar .nav-menu.active .nav-link {
        min-height: 44px;
        padding-block: .45rem;
    }
}
