/**
 * header_modern.css - the redesigned header (tpl/header_modern.inc.php). Only loaded when
 * the modern header is in use, so the classic header's rules in main.css are untouched.
 * Selectors start with body.header-modern to outrank main.css's bare `header` rules
 * (position: fixed, fixed heights, the lime background).
 */
body.header-modern {
    --kbnav-bg: #2f4a17;
    --kbnav-bg2: #3c5f1a;
    --kbnav-ink: #f4f8ec;
    --kbnav-ink-dim: rgba(244, 248, 236, 0.72);
    --kbnav-hover: rgba(255, 255, 255, 0.10);
    --kbnav-active: rgb(176, 199, 65);
    --kbnav-panel: #ffffff;
    --kbnav-panel-ink: #1f2a14;
    --kbnav-panel-hover: #f1f6e4;
    --kbnav-height: 56px;
}

body.header-modern header.kbnav {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: auto;
    width: auto;
    margin: -8px -8px 14px;
    padding: 0;
    border-radius: 0;
    background: linear-gradient(90deg, var(--kbnav-bg) 0%, var(--kbnav-bg2) 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    font-family: var(--font-family);
    color: var(--kbnav-ink);
}

body.header-modern .kbnav-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--kbnav-height);
    padding: 0 16px;
    max-width: 1600px;
    margin: 0 auto;
}

/* Reset main.css's touch-device rule that pads and margins every anchor. */
body.header-modern header.kbnav a {
    margin: 0;
    color: inherit;
    text-decoration: none;
}

/* ---- Brand ---- */
body.header-modern .kbnav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    flex: 0 0 auto;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.2px;
    white-space: nowrap;
}
body.header-modern .kbnav-brand img {
    height: 40px;
    width: auto;
    margin-top: 4px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

/* ---- Links ---- */
body.header-modern .kbnav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}
body.header-modern .kbnav-section {
    display: flex;
    align-items: center;
    gap: 2px;
}

body.header-modern .kbnav-link,
body.header-modern .kbnav-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 12px;
    border-radius: 18px;
    font: 500 14px/1 var(--font-family);
    color: var(--kbnav-ink-dim);
    white-space: nowrap;
    transition: background-color 0.15s, color 0.15s;
}
body.header-modern .kbnav-link img {
    display: none;
}
body.header-modern .kbnav-link:hover,
body.header-modern .kbnav-trigger:hover,
body.header-modern .kbnav-group.is-open > .kbnav-trigger {
    background: var(--kbnav-hover);
    color: var(--kbnav-ink);
}
body.header-modern .kbnav-link.is-active,
body.header-modern .kbnav-group.has-active > .kbnav-trigger {
    color: var(--kbnav-ink);
    background: rgba(176, 199, 65, 0.22);
    box-shadow: inset 0 -2px 0 var(--kbnav-active);
}

/* main.css styles every <button>; undo that for the menu triggers. */
body.header-modern button.kbnav-trigger,
body.header-modern button.kbnav-toggle {
    margin: 0;
    border: 0;
    background-color: transparent;
    cursor: pointer;
    transform: none;
    border-radius: 18px !important;
}
body.header-modern button.kbnav-trigger:hover,
body.header-modern button.kbnav-toggle:hover {
    box-shadow: none;
    transform: none;
}
body.header-modern .kbnav-trigger svg {
    width: 10px;
    height: 6px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s;
}
body.header-modern .kbnav-group.is-open > .kbnav-trigger svg {
    transform: rotate(180deg);
}

/* ---- Dropdowns ---- */
body.header-modern .kbnav-group {
    position: relative;
}
body.header-modern .kbnav-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 230px;
    padding: 6px;
    background: var(--kbnav-panel);
    color: var(--kbnav-panel-ink);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
}
body.header-modern .kbnav-menu-right {
    left: auto;
    right: 0;
}
body.header-modern .kbnav-group.is-open > .kbnav-menu {
    display: block;
}
body.header-modern .kbnav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    font: 14px/1.2 var(--font-family);
    color: var(--kbnav-panel-ink);
}
body.header-modern .kbnav-item img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}
body.header-modern .kbnav-item:hover {
    background: var(--kbnav-panel-hover);
}
body.header-modern .kbnav-item.is-active {
    background: var(--kbnav-panel-hover);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--lighter);
}
body.header-modern .kbnav-menu hr {
    border: 0;
    border-top: 1px solid #e3e8da;
    margin: 6px 4px;
}

/* ---- Account ---- */
body.header-modern .kbnav-account {
    margin-left: auto;
}
body.header-modern .kbnav-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--kbnav-active);
    color: var(--kbnav-bg);
    font-weight: 700;
    font-size: 13px;
}
body.header-modern .kbnav-account > .kbnav-trigger {
    padding-left: 5px;
}

/* ---- Right-hand actions ---- */
body.header-modern .kbnav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}
body.header-modern .kbnav-add {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border-radius: 17px;
    background: var(--kbnav-active);
    color: var(--kbnav-bg) !important;
    font: 700 14px/1 var(--font-family);
    white-space: nowrap;
    transition: filter 0.15s;
}
body.header-modern .kbnav-add:hover {
    filter: brightness(1.08);
}
body.header-modern .kbnav-add svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}
body.header-modern .kbnav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--kbnav-ink);
}
body.header-modern .kbnav-toggle svg {
    width: 18px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

body.header-modern .kbnav-guest {
    justify-content: flex-end;
    gap: 6px;
}

/* ---- Page title (was inside the old header) ---- */
body.header-modern h1.kbnav-title {
    margin: 4px 0 12px;
    font-size: 1.7em;
    font-weight: 700;
    color: var(--darkest);
}

/* ---------------------------------------------------------------------------
 * Under 1180px the links move into a drawer that drops below the bar.
 * ------------------------------------------------------------------------- */
/* Between the drawer breakpoint and a roomy desktop, drop the username beside the avatar. */
@media only screen and (max-width: 1340px) {
    body.header-modern .kbnav-username {
        display: none;
    }
}

@media only screen and (max-width: 1180px) {
    body.header-modern .kbnav-bar {
        gap: 8px;
        padding: 0 10px 0 12px;
    }
    body.header-modern .kbnav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    body.header-modern .kbnav-links:not(.kbnav-guest) {
        display: none;
        position: absolute;
        top: var(--kbnav-height);
        left: 0;
        right: 0;
        max-height: calc(100vh - var(--kbnav-height));
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px 12px 14px;
        background: var(--kbnav-panel);
        color: var(--kbnav-panel-ink);
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    }
    body.header-modern header.kbnav.is-open .kbnav-links {
        display: flex;
    }
    body.header-modern .kbnav-actions {
        margin-left: auto;
    }

    /* Everyday pages become a 4-up icon grid at the top of the drawer. */
    body.header-modern .kbnav-section {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding-bottom: 8px;
        border-bottom: 1px solid #e3e8da;
    }
    body.header-modern .kbnav-link {
        flex-direction: column;
        justify-content: center;
        height: 64px;
        padding: 6px 4px;
        border-radius: 10px;
        color: var(--kbnav-panel-ink);
        font-size: 12px;
    }
    body.header-modern .kbnav-link img {
        display: block;
        height: 26px;
        width: auto;
        max-width: 30px;
        object-fit: contain;
    }
    body.header-modern .kbnav-link:hover {
        background: var(--kbnav-panel-hover);
        color: var(--kbnav-panel-ink);
    }
    body.header-modern .kbnav-link.is-active {
        background: var(--kbnav-panel-hover);
        box-shadow: inset 0 -3px 0 var(--lighter);
        color: var(--kbnav-panel-ink);
    }

    /* Groups are always expanded in the drawer: the trigger becomes a section label. */
    body.header-modern .kbnav-group {
        padding-top: 8px;
    }
    body.header-modern .kbnav-account {
        margin-left: 0;
    }
    body.header-modern .kbnav-trigger,
    body.header-modern .kbnav-group.has-active > .kbnav-trigger,
    body.header-modern .kbnav-group.is-open > .kbnav-trigger,
    body.header-modern .kbnav-trigger:hover {
        height: auto;
        padding: 4px 6px;
        background: none;
        box-shadow: none;
        pointer-events: none;
        color: #6b7a5a;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.6px;
    }
    body.header-modern .kbnav-trigger svg,
    body.header-modern .kbnav-account .kbnav-avatar {
        display: none;
    }
    body.header-modern .kbnav-menu,
    body.header-modern .kbnav-group.is-open > .kbnav-menu {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 2px;
        position: static;
        min-width: 0;
        padding: 0;
        box-shadow: none;
        background: none;
    }
    body.header-modern .kbnav-menu hr {
        display: none;
    }
}

@media only screen and (max-width: 520px) {
    body.header-modern .kbnav-brand {
        font-size: 16px;
    }
    body.header-modern .kbnav-add span {
        display: none;
    }
    body.header-modern .kbnav-add {
        width: 36px;
        padding: 0;
        justify-content: center;
    }
    body.header-modern .kbnav-add svg {
        width: 14px;
        height: 14px;
    }
}

/* Logged out there are only four links; drop the two least useful on phones. */
@media only screen and (max-width: 520px) {
    body.header-modern .kbnav-guest .kbnav-link:nth-child(-n+2) {
        display: none;
    }
    body.header-modern .kbnav-guest .kbnav-add {
        width: auto;
        padding: 0 14px;
    }
    body.header-modern .kbnav-guest .kbnav-add span {
        display: inline;
    }
}

@media print {
    body.header-modern header.kbnav {
        display: none;
    }
}
