/* =========================================================================
   RCW SITE HEADER  —  assets/css/site-header.css
   Self-contained header system. Load this AFTER assets/css/style.css.

   It deliberately uses its own class names (.site-header, .sh-*) so none of
   the old .header / .nav-menu / .hamburger rules inside style.css can apply
   to it. Nothing here needs !important except --header-height, which style.css
   redefines with !important in several old media queries.

   Breakpoints (only three, on purpose):
     < 768px    phone      : compact bar + full-width slide-in drawer
     768-1099px tablet     : taller bar + 380px slide-in drawer
     >= 1100px  desktop    : single-row bar with hover/click dropdowns
   ========================================================================= */

:root {
    --sh-h: 60px;                 /* header height, phone */
    --sh-max: 1600px;             /* matches --max-width in style.css */
    --sh-pad: 14px;               /* horizontal padding, phone */
    --sh-bg: #ffffff;
    --sh-fg: #22313f;
    --sh-muted: #6c757d;
    --sh-primary: #1a5276;
    --sh-primary-light: #2980b9;
    --sh-accent: #f39c12;
    --sh-border: #e6eaee;
    --sh-chip: #f1f5f8;
    --sh-shadow: 0 1px 0 rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.05);
    --sh-shadow-strong: 0 10px 30px rgba(0,0,0,.14);
    --sh-radius: 10px;
    --sh-font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --sh-z: 1200;
}

@media (min-width: 768px)  { :root { --sh-h: 68px; --sh-pad: 20px; } }
@media (min-width: 1100px) { :root { --sh-h: 76px; --sh-pad: 24px; } }

/* Old page CSS offsets content with margin-top: var(--header-height) and
   re-declares it with !important in five different media queries. Chain it to
   --sh-h once, here, so the gap under the fixed header is always correct. */
:root { --header-height: var(--sh-h) !important; }

/* ===================== 1. BAR ===================== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--sh-z);
    height: var(--sh-h);
    background: var(--sh-bg);
    box-shadow: var(--sh-shadow);
    font-family: var(--sh-font);
    /* No backdrop-filter / transform here on purpose: either one would make
       this element the containing block for the position:fixed drawer. */
    transition: box-shadow .25s ease;
}

.site-header.is-scrolled { box-shadow: 0 2px 18px rgba(0,0,0,.14); }

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

.sh-inner {
    height: 100%;
    max-width: var(--sh-max);
    margin: 0 auto;
    padding: 0 var(--sh-pad);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ===================== 2. BRAND ===================== */

.sh-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;            /* lets the text truncate instead of pushing */
    flex: 0 1 auto;
    color: var(--sh-primary);
    text-decoration: none;
}

.sh-brand-badge {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--sh-primary), var(--sh-primary-light));
    color: var(--sh-accent);
    font-size: .95rem;
}

/* --- brand logo image (assets/images/logo.png|svg|webp|jpg) --- */
.sh-brand-badge { position: relative; overflow: hidden; }

.sh-brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* A logo file was found: drop the gradient disc, let the artwork speak. */
.sh-brand-badge.has-logo {
    background: none;
    border-radius: 0;
    overflow: visible;
}

.sh-brand-badge.has-logo .sh-brand-fallback { display: none; }

/* Round crest / square mark: keep the circular badge footprint. */
.sh-brand-badge.has-logo.is-square {
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
}

/* Wide horizontal lockup: let the badge grow instead of squashing the art. */
.sh-brand-badge.has-logo.is-wide {
    width: auto;
    max-width: 150px;
    height: 34px;
}

@media (min-width: 768px) {
    .sh-brand-badge.has-logo.is-wide { max-width: 190px; height: 42px; }
}

@media (max-width: 400px) {
    .sh-brand-badge.has-logo.is-wide { max-width: 118px; height: 30px; }
}

.sh-brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    line-height: 1.15;
}

.sh-brand-name {
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: .01em;
    color: var(--sh-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sh-brand-sub {
    font-weight: 600;
    font-size: .62rem;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--sh-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (min-width: 768px) {
    .sh-brand-badge { width: 42px; height: 42px; font-size: 1.1rem; }
    .sh-brand-name  { font-size: 1.08rem; }
    .sh-brand-sub   { font-size: .68rem; }
}

@media (min-width: 1100px) {
    .sh-brand { flex: 0 0 auto; margin-right: 8px; }
    .sh-brand-name { font-size: 1.12rem; }
}

/* Very narrow phones: drop the tagline so the bar never overflows. */
@media (max-width: 400px) {
    :root { --sh-pad: 10px; }
    .sh-brand-sub { display: none; }
    .sh-brand-badge { width: 32px; height: 32px; }
    .sh-brand-name { font-size: .88rem; }
}

/* ===================== 3. ACTIONS (right side) ===================== */

.sh-actions {
    margin-left: auto;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- language switcher (keeps .lang-option so main.js still binds it) --- */
.site-header .sh-lang {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border: 1px solid var(--sh-border);
    border-radius: 999px;
    background: #fff;
}

.site-header .sh-lang .lang-option {
    border: 0;
    background: transparent;
    color: var(--sh-muted);
    border-radius: 999px;
    padding: 5px 10px;
    font: 700 .72rem/1 var(--sh-font);
    cursor: pointer;
    transition: background .2s ease, color .2s ease;
}

.site-header .sh-lang .lang-option.active,
.site-header .sh-lang .lang-option:hover {
    background: var(--sh-primary);
    color: #fff;
}

/* --- social icons (bar copy: desktop only) --- */
.sh-social { display: none; align-items: center; gap: 6px; }

.sh-social a {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sh-chip);
    color: var(--sh-primary);
    font-size: .82rem;
    transition: background .2s ease, color .2s ease, transform .2s ease;
}

.sh-social a:hover {
    background: var(--sh-primary);
    color: #fff;
    transform: translateY(-1px);
}

@media (min-width: 1100px) { .sh-social { display: flex; } }

/* --- hamburger --- */
.sh-burger {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    border: 1px solid var(--sh-border);
    border-radius: var(--sh-radius);
    background: #fff;
    cursor: pointer;
}

.sh-burger span {
    display: block;
    width: 20px;
    height: 2px;
    border-radius: 2px;
    background: var(--sh-primary);
    transition: transform .25s ease, opacity .2s ease;
}

.sh-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sh-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.sh-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (min-width: 1100px) { .sh-burger { display: none; } }

/* ===================== 4. NAV — MOBILE / TABLET DRAWER ===================== */

.sh-nav {
    position: fixed;
    top: var(--sh-h);
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px;
    /* .site-header is a stacking context (it has z-index), so this only ranks
       the drawer inside the header. The scrim is kept BELOW the header instead
       -- see .sh-scrim -- which is what actually puts the drawer on top. */
    z-index: 2;
    background: #fff;
    border-left: 1px solid var(--sh-border);
    box-shadow: var(--sh-shadow-strong);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 10px 16px 32px;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .28s ease, visibility 0s linear .28s;
}

.sh-nav.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform .28s ease, visibility 0s;
}

@media (min-width: 768px) { .sh-nav { max-width: 380px; } }

.sh-scrim {
    position: fixed;
    top: var(--sh-h);
    left: 0;
    right: 0;
    bottom: 0;
    /* Must stay under .site-header (var(--sh-z)) or it covers the drawer. */
    z-index: calc(var(--sh-z) - 1);
    background: rgba(12, 24, 36, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility 0s linear .28s;
}

.sh-scrim.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity .28s ease, visibility 0s;
}

body.sh-nav-open { overflow: hidden; }

.sh-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Top-level rows in the drawer */
.sh-list > li > a,
.sh-sub-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 50px;
    padding: 12px 6px;
    border: 0;
    border-bottom: 1px solid var(--sh-border);
    background: transparent;
    color: var(--sh-fg);
    font: 600 1rem/1.3 var(--sh-font);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.sh-list > li > a:hover,
.sh-sub-toggle:hover { color: var(--sh-primary-light); }

.sh-list > li > a.is-active,
.sh-has-sub.has-active > .sh-sub-toggle {
    color: var(--sh-primary);
    box-shadow: inset 3px 0 0 var(--sh-accent);
    padding-left: 12px;
}

.sh-sub-toggle i {
    flex: 0 0 auto;
    font-size: .7rem;
    color: var(--sh-muted);
    transition: transform .25s ease;
}

.sh-has-sub.is-open > .sh-sub-toggle i { transform: rotate(180deg); }

/* Second-level list, drawer = accordion */
.sh-sub {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    background: #f7fafc;
    border-bottom: 1px solid var(--sh-border);
}

.sh-has-sub.is-open > .sh-sub { display: block; }

.sh-sub a {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 10px 6px 10px 22px;
    color: var(--sh-fg);
    font: 500 .94rem/1.3 var(--sh-font);
    text-decoration: none;
}

.sh-sub a:hover { color: var(--sh-primary-light); }
.sh-sub a.is-active { color: var(--sh-primary); font-weight: 700; }

/* Social row at the bottom of the drawer */
.sh-drawer-social {
    display: flex;
    gap: 10px;
    padding: 20px 6px 0;
}

.sh-drawer-social a {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sh-chip);
    color: var(--sh-primary);
    font-size: .95rem;
}

.sh-drawer-social a:hover { background: var(--sh-primary); color: #fff; }

/* ===================== 5. NAV — DESKTOP BAR ===================== */

@media (min-width: 1100px) {
    .sh-nav {
        position: static;
        width: auto;
        max-width: none;
        margin: 0 0 0 auto;
        padding: 0;
        height: 100%;
        border: 0;
        box-shadow: none;
        background: transparent;
        overflow: visible;
        transform: none;
        visibility: visible;
        transition: none;
    }

    .sh-scrim { display: none; }

    .sh-list {
        display: flex;
        align-items: center;
        height: 100%;
        gap: clamp(2px, .7vw, 12px);
    }

    .sh-list > li { position: relative; height: 100%; display: flex; align-items: center; }

    .sh-list > li > a,
    .sh-sub-toggle {
        width: auto;
        min-height: 0;
        padding: 8px 10px;
        border: 0;
        border-radius: 8px;
        gap: 6px;
        white-space: nowrap;
        font-size: clamp(.82rem, .82vw, .95rem);
        font-weight: 600;
        color: var(--sh-fg);
    }

    .sh-list > li > a:hover,
    .sh-sub-toggle:hover,
    .sh-has-sub:hover > .sh-sub-toggle { background: var(--sh-chip); color: var(--sh-primary); }

    .sh-list > li > a.is-active,
    .sh-has-sub.has-active > .sh-sub-toggle {
        color: var(--sh-primary);
        box-shadow: inset 0 -3px 0 var(--sh-accent);
        padding-left: 10px;
        border-radius: 8px 8px 0 0;
    }

    /* dropdown panel */
    .sh-sub {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 230px;
        margin: 0;
        padding: 6px;
        border: 1px solid var(--sh-border);
        border-radius: var(--sh-radius);
        background: #fff;
        box-shadow: var(--sh-shadow-strong);
        opacity: 0;
        visibility: hidden;
        transform: translateY(6px);
        transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
    }

    .sh-has-sub:hover > .sh-sub,
    .sh-has-sub.is-open > .sh-sub,
    .sh-has-sub:focus-within > .sh-sub {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
        transition: opacity .18s ease, transform .18s ease, visibility 0s;
    }

    /* keep the last dropdowns inside the viewport */
    .sh-list > li:nth-last-child(-n+3) .sh-sub { left: auto; right: 0; }

    .sh-sub a {
        min-height: 40px;
        padding: 9px 12px;
        border-radius: 7px;
        font-size: .9rem;
    }

    .sh-sub a:hover { background: var(--sh-chip); }

    .sh-drawer-social { display: none; }

    .sh-actions { gap: 10px; margin-left: 14px; }
}

/* A little more breathing room on wide screens */
@media (min-width: 1400px) {
    .sh-list { gap: 6px; }
    .sh-list > li > a,
    .sh-sub-toggle { padding: 8px 13px; font-size: .95rem; }
}

/* ===================== 6. A11Y / MISC ===================== */

.site-header a:focus-visible,
.site-header button:focus-visible {
    outline: 3px solid rgba(41,128,185,.45);
    outline-offset: 2px;
    border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
    .sh-nav, .sh-scrim, .sh-sub, .sh-burger span { transition: none !important; }
}

/* Landscape phones: the drawer must still be scrollable under a short bar. */
@media (max-height: 460px) and (max-width: 1099px) {
    .sh-nav { padding-bottom: 48px; }
    .sh-list > li > a,
    .sh-sub-toggle { min-height: 42px; padding: 8px 6px; }
    .sh-sub a { min-height: 40px; }
}
