/**
 * CFRO Layout — Header & Navigation (Figma v3)
 * @package CFRO
 * @since   4.1.0
 */

/* ── Skip Link ───────────────────────────────── */
.cfro-skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    background: var(--cfro-forest);
    color: var(--cfro-white);
    padding: 0.75rem 1.5rem;
    z-index: 10000;
    font-weight: 600;
    border-radius: var(--cfro-radius);
    text-decoration: none;
}
.cfro-skip-link:focus { top: 1rem; }

/* ── Header wrapper ──────────────────────────── */
.cfro-header {
    position: sticky;
    top: 0;
    z-index: 100;
}

/* ── Utility bar (Accessibility + Search) ────── */
.cfro-utility-bar {
    background: var(--cfro-cream-dark);
    padding: 0.5rem 0;
    font-size: 0.75rem;
    border-bottom: 1px solid rgba(27, 122, 90, 0.08);
}
.cfro-utility-bar .cfro-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

/* Left group: label + a11y toggles */
.cfro-utility-bar__left {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}
.cfro-utility-bar__label {
    display: none;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--cfro-charcoal-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

/* A11y buttons (shared style) */
.cfro-a11y-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    height: 2.75rem;          /* 44px — WCAG touch target */
    min-width: 2.75rem;
    padding: 0 0.5rem;
    background: transparent;
    border: none;
    border-radius: var(--cfro-radius);
    color: var(--cfro-charcoal);
    font-family: var(--cfro-font-sans);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--cfro-transition), color var(--cfro-transition);
    white-space: nowrap;
}
.cfro-a11y-btn:hover,
.cfro-a11y-btn:focus-visible {
    background: rgba(27, 122, 90, 0.1);
    color: var(--cfro-forest);
}
.cfro-a11y-btn[aria-pressed="true"] {
    background: var(--cfro-forest);
    color: var(--cfro-white);
}
.cfro-a11y-btn__text {
    display: none;
}
.cfro-a11y-font-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Shared icon sizing */
.cfro-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* Right group: inline search (desktop) + mobile toggle */
.cfro-utility-bar__right {
    display: flex;
    align-items: center;
}

/* Inline search form — hidden on mobile, visible md+ */
.cfro-search-inline {
    display: none;
    align-items: center;
    gap: 0;
    width: 16rem;
}
.cfro-search-inline__input {
    flex: 1;
    height: 2.25rem;
    padding: 0 0.75rem;
    border: 1px solid rgba(27, 122, 90, 0.15);
    border-radius: var(--cfro-radius);
    background: var(--cfro-white);
    font-family: var(--cfro-font-sans);
    font-size: 0.75rem;
    color: var(--cfro-charcoal);
    outline: none;
    transition: border-color var(--cfro-transition), box-shadow var(--cfro-transition);
}
.cfro-search-inline__input::placeholder {
    color: var(--cfro-charcoal-light);
    opacity: 0.6;
}
.cfro-search-inline__input:focus {
    border-color: var(--cfro-forest);
    box-shadow: 0 0 0 3px rgba(27, 122, 90, 0.15);
}
.cfro-search-inline__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.25rem;
    width: 2.25rem;
    min-width: 2.75rem;
    background: none;
    border: none;
    border-radius: var(--cfro-radius);
    color: var(--cfro-forest);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--cfro-transition);
}
.cfro-search-inline__btn:hover {
    background: rgba(27, 122, 90, 0.1);
}

/* Mobile search toggle — visible on mobile only */
.cfro-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.75rem;
    width: 2.75rem;
    min-width: 2.75rem;
    background: transparent;
    border: none;
    border-radius: var(--cfro-radius);
    color: var(--cfro-charcoal);
    cursor: pointer;
    transition: background var(--cfro-transition);
}
.cfro-search-toggle:hover,
.cfro-search-toggle:focus-visible {
    background: rgba(27, 122, 90, 0.1);
    color: var(--cfro-forest);
}

/* Search bar (hidden by default) */
.cfro-search-bar {
    background: var(--cfro-white);
    border-bottom: 1px solid var(--cfro-border-gray);
    padding: 0.5rem 0;
}
.cfro-search-bar[hidden] { display: none; }
.cfro-search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.cfro-search-form input[type="search"] {
    flex: 1;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--cfro-border-gray);
    border-radius: var(--cfro-radius);
    font-family: var(--cfro-font-sans);
    font-size: 0.9rem;
    background: var(--cfro-cream);
    color: var(--cfro-charcoal);
    outline: none;
    transition: border-color var(--cfro-transition);
}
.cfro-search-form input[type="search"]:focus {
    border-color: var(--cfro-forest);
}
.cfro-search-form input[type="search"]::placeholder {
    color: var(--cfro-charcoal-light);
    opacity: 0.6;
}
.cfro-search-submit,
.cfro-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--cfro-charcoal-light);
    padding: 0.35rem;
    border-radius: var(--cfro-radius);
    transition: var(--cfro-transition);
}
.cfro-search-submit:hover,
.cfro-search-close:hover {
    color: var(--cfro-forest);
    background: var(--cfro-sage-pale);
}

/* ── Main header bar (Logo + toggle) ──────────── */
.cfro-header__main {
    background: var(--cfro-white);
    padding: 1.25rem 0;
}
.cfro-header__main .cfro-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo */
.cfro-logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--cfro-charcoal);
    flex-shrink: 0;
}
.cfro-logo:hover { text-decoration: none; color: var(--cfro-charcoal); }
.cfro-logo__img {
    height: 3.5rem;           /* 56px mobile */
    width: auto;
}
.cfro-logo__text {
    display: none;            /* hidden on mobile; shown sm+ */
    flex-direction: column;
}
.cfro-logo__title {
    font-weight: 700;
    font-size: 1.25rem;       /* text-xl */
    line-height: 1.25;
    letter-spacing: -0.025em; /* tracking-tight */
    color: var(--cfro-charcoal);
}
.cfro-logo__subtitle {
    font-size: 0.75rem;       /* text-xs */
    font-weight: 400;
    color: var(--cfro-charcoal-light);
    letter-spacing: 0.05em;   /* tracking-wide */
    margin-top: 0.15rem;
}

/* Larger icon helper */
.cfro-icon--lg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
}

/* Mobile menu toggle (md:hidden) */
.cfro-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    height: 2.75rem;          /* 44px WCAG touch target */
    width: 2.75rem;
    min-width: 2.75rem;
    background: var(--cfro-white);
    border: 1px solid rgba(27, 122, 90, 0.2);
    color: var(--cfro-forest);
    cursor: pointer;
    border-radius: var(--cfro-radius);
    transition: background var(--cfro-transition);
}
.cfro-menu-toggle:hover,
.cfro-menu-toggle:focus-visible {
    background: rgba(27, 122, 90, 0.1);
}

/* ── Primary Navigation Bar (forest-dark) ────── */
.cfro-navbar {
    background: var(--cfro-forest-dark);
}
.cfro-navbar .cfro-container {
    display: flex;
    align-items: center;
}

/* Nav wrapper (<nav>) */
.cfro-nav {
    width: 100%;
}

/* Nav list (<ul>) — flat flex row, donate pushed right */
.cfro-nav__list {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
}

/* Regular nav items */
.cfro-nav__list > li > a {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    padding: 0.75rem 1.15rem;
    font-weight: 500;
    font-size: 0.875rem;
    letter-spacing: 0.025em;
    transition: var(--cfro-transition);
    text-decoration: none;
    white-space: nowrap;
}
.cfro-nav__list > li > a:hover,
.cfro-nav__list > li > a:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    color: var(--cfro-white);
    text-decoration: none;
}

/* Current page highlight */
.cfro-nav__list > li.current-menu-item > a,
.cfro-nav__list > li.current-menu-ancestor > a {
    background: rgba(255, 255, 255, 0.15);
    color: var(--cfro-sage-light);
    border-bottom: 2px solid var(--cfro-sage);
}

/* Donate item — pushed right, coral button */
.cfro-nav__list > li.cfro-nav-donate {
    margin-left: auto;
}
.cfro-nav__list > li.cfro-nav-donate > a {
    background: var(--cfro-coral);
    color: var(--cfro-white);
    border-radius: var(--cfro-radius);
    padding: 0.55rem 1.35rem;
    font-weight: 600;
}
.cfro-nav__list > li.cfro-nav-donate > a:hover {
    background: var(--cfro-accent-dark);
}

/* ── Responsive: sm+ (≥640px) ────────────────── */
@media (min-width: 640px) {
    .cfro-utility-bar__label { display: inline; }
    .cfro-a11y-btn__text   { display: inline; }
    .cfro-a11y-btn         { padding: 0 0.75rem; }

    /* Logo: show text, scale up image */
    .cfro-logo__text     { display: flex; }
    .cfro-logo__img      { height: 4rem; }        /* 64px = h-16 */
    .cfro-logo__title    { font-size: 1.5rem; }   /* text-2xl */
    .cfro-logo__subtitle { font-size: 0.875rem; } /* text-sm */
}

/* ── Responsive: md+ (≥768px) ────────────────── */
@media (min-width: 768px) {
    .cfro-search-inline { display: flex; }
    .cfro-search-toggle { display: none; }
    .cfro-menu-toggle   { display: none !important; }
}

/* ── Mobile (≤768px) ─────────────────────────── */
@media (max-width: 768px) {
    .cfro-menu-toggle { display: inline-flex; }

    /* Hide the full nav bar on mobile; toggle reveals it */
    .cfro-navbar {
        display: none;
    }
    .cfro-navbar.is-open {
        display: block;
    }

    .cfro-nav__list {
        flex-direction: column;
        align-items: stretch;
    }
    .cfro-nav__list > li > a {
        padding: 0.85rem 1.25rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }
    .cfro-nav__list > li.cfro-nav-donate {
        margin: 0.75rem 1rem;
    }
    .cfro-nav__list > li.cfro-nav-donate > a {
        display: block;
        text-align: center;
    }
}
