/* ==========================================================================
   navigation.css - top bar, menu and footer
   --------------------------------------------------------------------------
   Purpose:     Parts that surround every page, and the offline message.
   Used by:     Every page.
   ========================================================================== */

/* ---------- Top bar ---------- */
/* Stays at the top; allows for the notch on phones */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 300;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding-top: env(safe-area-inset-top, 0px);
}

.site-nav-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 20px;
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
    position: relative;
}

.site-nav-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    min-width: 0;
    gap: 0;
}

.site-nav-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.site-nav-links {
    display: none;
    gap: clamp(1rem, 2.2vw, 2.25rem);
}

.site-nav-link {
    font-family: var(--font-body);
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
    font-size: 1.1rem;
    font-weight: 500;
    white-space: nowrap;
}

.site-nav-link:hover,
.site-nav-link:focus-visible {
    color: var(--accent);
}

.site-nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* Home page only: Donate button instead of the logo */
.site-nav-donate {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 44px;
    margin: 12px 0;
    padding: 0.55rem 1.3rem;
    background: var(--row-highlight-bg, #EAF0DF); /* Light Grey Green */
    color: #264F27; /* Myrtle */
    border: 1px solid rgba(38, 79, 39, 0.35);
    border-radius: 999px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s;
}

.site-nav-donate svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.site-nav-donate:hover {
    background: #DCE6CC;
    border-color: #264F27;
}

.site-nav-donate:focus-visible {
    background: #DCE6CC;
    border-color: #264F27;
    outline: 2px solid #264F27;
    outline-offset: 2px;
}

/* 68px tall = 151px wide, just above the 150px brand minimum */
img.site-nav-logo-img {
    height: 68px;
    width: auto;
    display: block;
    object-fit: contain;
}

@media (min-width: 768px) {
    .site-nav-inner {
        max-width: 700px;
    }

    .site-nav-title {
        font-size: 1.05rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .site-nav {
        position: relative;
    }
}

@media (min-width: 1024px) {
    .site-nav-inner {
        max-width: 1180px;
    }
}

@media (min-width: 1100px) {
    /* Room for the full menu. Keep 1100px in step with assets/js/nav.js */
    .site-nav-links {
        display: flex;
        align-items: center;
    }
}

@media (min-width: 1440px) {
    .site-nav-inner {
        max-width: 1320px;
    }
}

@media (max-width: 520px) {
    .site-nav-donate {
        font-size: 1rem;
        padding: 0.5rem 1.1rem;
    }
}

@media (max-width: 400px) {
    .site-nav-inner {
        gap: 6px;
    }

    .site-nav-donate {
        padding: 0.5rem 0.9rem;
        font-size: 1rem;
    }
}

/* ---------- Menu button and slide-in menu ---------- */
/* 44px minimum tap size (Apple / Google guidance) */
.nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    min-width: 44px;
    min-height: 44px;
}

.nav-toggle:hover {
    background: var(--row-highlight-bg);
}

.nav-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) 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(-7px) rotate(-45deg);
}

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 40, 20, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 350;
}

.nav-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(82%, 320px);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    z-index: 400;
    padding: 20px 18px 30px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.nav-drawer.open {
    transform: translateX(0);
}

.nav-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.nav-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--row-highlight-bg);
    color: var(--text-primary);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

.nav-drawer-link {
    padding: 14px 10px;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: background 0.2s ease, color 0.2s ease;
    font-size: 1.2rem;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.nav-drawer-link:hover,
.nav-drawer-link:focus-visible {
    background: var(--row-highlight-bg);
}

.nav-drawer-link.active {
    color: var(--accent);
    font-weight: 700;
}

body.nav-open {
    overflow: hidden;
}

@media (min-width: 1100px) {
    .nav-toggle,
    .nav-drawer,
    .nav-overlay {
        display: none;
    }
}

/* ---------- Footer ---------- */
.site-footer-banner {
    background: #1d3a1e;
    color: #e8efe6;
    font-size: 0.74rem;
    line-height: 1.5;
    text-align: center;
    padding: 0.7rem 1rem;
    margin-top: 1.5rem;
    padding-bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
}

.site-footer-banner a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.site-footer-banner p {
    margin: 0;
}

.footer-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    column-gap: 0.45rem;
    row-gap: 0.1rem;
}

.footer-line > span {
    white-space: nowrap;
}

.footer-line > span:not(.footer-sep):has(> span) {
    white-space: normal;
}

.has-ticker .site-footer-banner {
    padding-bottom: calc(0.9rem + 64px + env(safe-area-inset-bottom, 0px));
}

@media (max-height: 500px) and (orientation: landscape) {
    .has-ticker .site-footer-banner {
        padding-bottom: calc(0.9rem + 44px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 767px) {
    /* Clears the taller message bar */
    .has-ticker .site-footer-banner {
        padding-bottom: calc(0.9rem + 76px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 700px) {
    .footer-sep {
        display: none;
    }

    .footer-line {
        column-gap: 0.9rem;
    }
}

/* ---------- Offline message ---------- */
/* Added by assets/js/pwa.js when the connection drops */
.offline-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 8px 16px;
    background: #7a3b12;
    color: #fff;
    font-size: 0.95rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
