/* P32 — header + layout in plain CSS (no missing Tailwind utilities) */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    width: 100%;
    max-width: 100%;
    margin: 0;
    overflow-x: clip;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

main, #main-content, footer, section {
    width: 100%;
    max-width: 100%;
}

.max-w-7xl, .max-w-6xl {
    width: 100%;
    max-width: min(80rem, 100%);
    margin-left: auto;
    margin-right: auto;
    padding-left: max(1rem, env(safe-area-inset-left, 0));
    padding-right: max(1rem, env(safe-area-inset-right, 0));
}

/* ── Marketing header ── */
.mathla-site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(214, 211, 209, 0.8);
    padding-top: env(safe-area-inset-top, 0);
}

.mathla-header-inner {
    width: 100%;
    max-width: min(80rem, 100%);
    margin: 0 auto;
    padding: 0.625rem max(1rem, env(safe-area-inset-left, 0)) 0.625rem max(1rem, env(safe-area-inset-right, 0));
}

/* Mobile: one compact row — logo + locale + sign up + menu */
.mathla-header-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 48px;
}

.mathla-header-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: #334155;
    cursor: pointer;
    flex-shrink: 0;
}
.mathla-header-menu-btn:hover { background: #f5f5f4; }

.mathla-header-brand {
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.mathla-header-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.375rem;
    flex-shrink: 0;
}

/* Nav links: desktop inline only */
.mathla-header-links--desktop {
    display: none;
}

.mathla-header-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--mathla-text-body, #334155);
    text-decoration: none;
    white-space: nowrap;
}
.mathla-header-link:hover {
    color: var(--mathla-primary-dark, #A67C00);
    background: #f5f5f4;
}

@media (min-width: 1024px) {
    .mathla-header-menu-btn { display: none; }
    .mathla-header-inner {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.5rem 1rem;
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
    }
    .mathla-header-top {
        display: contents;
    }
    .mathla-header-brand { flex: 0 0 auto; }
    .mathla-header-actions {
        flex: 0 0 auto;
        margin-inline-start: auto;
    }
    .mathla-header-links--desktop {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 0.25rem 0.5rem;
        flex: 1 1 auto;
        min-width: 0;
    }
    #mathla-mobile-nav { display: none !important; }
}

@media (max-width: 1023px) {
    .mathla-header-actions .mathla-locale-switcher,
    .mathla-header-locale--desktop {
        display: none !important;
    }
}

@media (min-width: 1024px) {
    .mathla-mobile-nav__locale-wrap {
        display: none !important;
    }
}

/* Locale switcher (plain CSS — no Tailwind dependency) */
.mathla-locale-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.mathla-locale-switcher .mathla-locale-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--mathla-muted, #64748B);
}
.mathla-locale-switcher .mathla-locale-btn:hover {
    background: #f5f5f4;
    color: var(--mathla-text-body, #334155);
}
.mathla-locale-switcher .mathla-locale-btn.bg-amber-100,
.mathla-locale-switcher a.mathla-locale-btn[href*="/locale/en"]:where([hreflang="en"]) {
    /* active state set via inline classes in blade */
}
.mathla-mobile-nav__locale-wrap {
    padding: 0 1rem 1rem;
    border-bottom: 1px solid #e7e5e4;
    margin-bottom: 0.75rem;
}
.mathla-mobile-nav__locale-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mathla-muted, #64748B);
    margin-bottom: 0.5rem;
}
.mathla-mobile-nav__locale {
    display: flex;
    justify-content: center;
    width: 100%;
    gap: 0.5rem;
}
.mathla-mobile-nav__locale .mathla-locale-btn {
    flex: 1 1 0;
    text-align: center;
}

@media (max-width: 479px) {
    .mathla-header-actions .mathla-header-signin-link { display: none; }
    .mathla-header-actions .mathla-btn-primary {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
}

/* Mobile nav drawer */
.mathla-mobile-nav {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 60;
}
body.mathla-nav-marketing-open #mathla-mobile-nav,
body.mathla-nav-app-open #mathla-app-mobile-nav {
    display: block;
}
body.mathla-scroll-lock { overflow: hidden !important; touch-action: none; }

.mathla-mobile-nav__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.mathla-mobile-nav__panel {
    position: absolute;
    top: 0;
    bottom: 0;
    width: min(100%, 20rem);
    max-width: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
html[dir="ltr"] .mathla-mobile-nav__panel { left: 0; }
html[dir="rtl"] .mathla-mobile-nav__panel { right: 0; }
.mathla-mobile-nav__panel--light { background: #fff; }

.mathla-mobile-nav__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e7e5e4;
}
.mathla-mobile-nav__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    cursor: pointer;
}
.mathla-mobile-nav__close:hover { background: #f5f5f4; }

.mathla-mobile-nav__scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0;
}
.mathla-mobile-nav__link {
    display: block;
    padding: 0.875rem 1rem;
    min-height: 48px;
    font-size: 1rem;
    font-weight: 500;
    color: #1c1917;
    text-decoration: none;
    border-bottom: 1px solid #f5f5f4;
}
.mathla-mobile-nav__link:hover { background: #fafaf9; color: var(--mathla-primary-dark, #A67C00); }
.mathla-mobile-nav__foot {
    padding: 1rem;
    border-top: 1px solid #e7e5e4;
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 0));
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.mathla-mobile-nav__link--signin {
    border-bottom: 0;
    text-align: center;
    padding: 0.75rem 1rem;
}
.mathla-mobile-nav__btn { width: 100%; text-align: center; }

/* Page wrap */
.mathla-page-wrap {
    width: 100%;
    max-width: min(80rem, 100%);
    margin: 0 auto;
    padding: 3rem 1rem;
    box-sizing: border-box;
}

/* Hero */
.mathla-hero-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    width: 100%;
}
@media (min-width: 1024px) {
    .mathla-hero-grid {
        flex-direction: row;
        align-items: center;
        gap: 3rem;
    }
    .mathla-hero-copy { flex: 1 1 50%; min-width: 0; }
    .mathla-hero-map { flex: 1 1 50%; min-width: 0; }
}
.mathla-hero-title {
    font-family: 'Cinzel', Georgia, serif;
    font-size: clamp(1.75rem, 6vw, 3.25rem);
    line-height: 1.2;
    color: var(--mathla-text, #0F172A);
    margin: 0;
}
.mathla-hero-accent { color: var(--mathla-primary-dark, #A67C00); }
.mathla-hero-lead {
    margin: 1.5rem 0 0;
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--mathla-muted, #64748B);
    max-width: 36rem;
}
.mathla-hero-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;
    width: 100%;
}
@media (min-width: 640px) {
    .mathla-hero-actions { flex-direction: row; flex-wrap: wrap; }
}
.mathla-hero-map {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 1rem;
    overflow: hidden;
    background: #0f172a;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

/* App shell */
@media (max-width: 1023px) {
    .mathla-app-mobile-header__extras { display: none !important; }
    .mathla-app-mobile-header__wordmark { display: none !important; }
    .mathla-app-main { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0)); }
}

/* App drawer reuses .mathla-mobile-nav; dark panel variant */
.mathla-mobile-nav__panel:not(.mathla-mobile-nav__panel--light) {
    background: var(--mathla-sidebar, #3D3428);
}

@media (min-width: 1024px) {
    html[dir="ltr"] .mathla-app-with-sidebar { margin-left: 16rem; }
    html[dir="rtl"] .mathla-app-with-sidebar { margin-right: 16rem; }
}

.skip-link {
    position: fixed; top: 0; inset-inline-start: 0;
    width: 1px; height: 1px; clip: rect(0,0,0,0);
    overflow: hidden; border: 0; z-index: 200;
}

.leaflet-container, #mathla-contributor-map { max-width: 100% !important; overflow: hidden; }
img, video, svg, .mathla-card { max-width: 100%; height: auto; }
input, select, textarea, button { font-size: 16px; touch-action: manipulation; }
