/* ============================================================
   RESPONSIVE NAVIGATION
   Desktop (>=768px): normal horizontal menu bar
   Mobile  (<768px): hamburger icon + visible language switcher
   Pure CSS "checkbox hack" - no JavaScript required.
   ============================================================ */

/* Row that holds: logo | mobile language switcher | hamburger */
nav[role="navigation"] .nav-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---------- Mobile language switcher ---------- */

/* Hidden on desktop; visible on mobile */
.mobile-language-switcher {
    display: none;
}

.mobile-language-switcher .i18n-switcher {
    display: flex;
    align-items: center;
}

.mobile-language-switcher .i18n-switcher a {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* ---------- Facebook icon (circular, matches the flag icons) ---------- */

.facebook-icon-link {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.facebook-icon-img {
    height: 20px !important;
    width: 20px !important;
    border-radius: 50%;
    vertical-align: middle;
    display: inline-block;
}

/* ---------- Hamburger button ---------- */

/* The checkbox itself is invisible but stays keyboard-focusable */
.nav-toggle-checkbox {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.nav-toggle-label {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 22px;
    cursor: pointer;
    position: relative;
    z-index: 10001;
}

.nav-toggle-label span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: #ffffff;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Animate the three lines into an "X" when the menu is open */
.nav-toggle-checkbox:checked ~ .nav-toggle-label span:nth-child(1) {
    transform: translateY(9.5px) rotate(45deg);
}

.nav-toggle-checkbox:checked ~ .nav-toggle-label span:nth-child(2) {
    opacity: 0;
}

.nav-toggle-checkbox:checked ~ .nav-toggle-label span:nth-child(3) {
    transform: translateY(-9.5px) rotate(-45deg);
}

/* Visible focus ring when tabbing to the hamburger */
.nav-toggle-checkbox:focus-visible ~ .nav-toggle-label {
    outline: 2px solid #ffae00;
    outline-offset: 4px;
}

/* Dimmed backdrop behind the open sidebar */
.nav-overlay {
    display: none;
}

/* ---------- Ministries dropdown ---------- */

/* Reset default <details>/<summary> browser styling */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-summary {
    cursor: pointer;
    list-style: none;
}

/* Hide the default disclosure triangle across browsers */
.nav-dropdown-summary::-webkit-details-marker {
    display: none;
}

.nav-dropdown-summary::marker {
    content: "";
}

/* Small caret to show the item opens a menu */
.nav-dropdown-summary::after {
    content: "▾";
    display: inline-block;
    margin-left: 0.4em;
    font-size: 0.7em;
    vertical-align: middle;
}

.nav-dropdown[open] .nav-dropdown-summary::after {
    content: "▾";
}

.nav-dropdown-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* ---------- DESKTOP: >=768px ---------- */

@media (min-width: 48em) {
    .nav-menu {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        position: static !important;
        height: auto !important;
        width: auto !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        transform: none !important;
    }

    /* Mobile-only language switcher stays hidden */
    .mobile-language-switcher {
        display: none;
    }

    /*
     * Dropdown panel floats below the "Ministries" label. Visibility is
     * driven by :hover / :focus-within instead of the native <details>
     * "open" toggle, so the menu shows the moment the mouse is over it
     * and disappears the instant it isn't - no click tracking needed.
     *
     * display:block overrides the browser's default of hiding <details>
     * content when it isn't [open], so the menu always has a real box to
     * hover over. margin-top is 0 (visual spacing comes from padding-top
     * instead) so there's no gap between the label and the menu that the
     * mouse could pass through and lose the hover state.
     */
    .nav-dropdown-menu {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 0;
        min-width: 200px;
        background-color: rgba(10, 10, 10, 0.97);
        border-radius: 4px;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
        padding: 0.75rem 0 0.5rem;
        z-index: 10000;

        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.15s ease-in-out;
    }

    .nav-dropdown:hover .nav-dropdown-menu,
    .nav-dropdown:focus-within .nav-dropdown-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Keep the caret in sync with the hover-driven visibility above */
    .nav-dropdown:hover .nav-dropdown-summary::after,
    .nav-dropdown:focus-within .nav-dropdown-summary::after {
        content: "▾";
    }

    .nav-dropdown-menu li {
        padding: 0;
    }

    .nav-dropdown-menu li a {
        display: block;
        padding: 0.6rem 1.25rem;
        white-space: nowrap;
    }

    .nav-dropdown-menu li a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

/* ---------- MOBILE: <768px> ---------- */

@media (max-width: 47.99em) {
    /* Show the language switcher beside the hamburger */
    .mobile-language-switcher {
        display: block;
        margin-left: auto;
        margin-right: 1rem;
    }

    /*
     * Hide the language switcher inside the slide-out menu - the visible
     * copy is the one beside the hamburger. The Facebook icon is NOT
     * hidden here; on mobile it moves into the drawer instead (styled
     * below) and appears at the very bottom, under the page links.
     */
    .nav-menu .i18n-switcher {
        display: none;
    }

    .nav-toggle-label {
        display: flex;
    }

    /* Slide-in sidebar */
    .nav-menu {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 78vw;
        max-width: 330px;
        background-color: rgba(10, 10, 10, 0.97);
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 5rem 1.75rem 2rem;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        box-shadow: -6px 0 16px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
        z-index: 9999;
    }

    .nav-toggle-checkbox:checked ~ .nav-menu {
        transform: translateX(0);
    }

    .nav-toggle-checkbox:checked ~ .nav-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }

    /*
     * These target .nav-menu > li directly - the actual top-level menu
     * items in the markup - not ".nav-list", which doesn't exist on
     * anything in site-navigation.html and never matched. The child
     * combinator (>) also keeps this from touching the nested <li>s
     * inside .nav-dropdown-menu, which get their own sizing below.
     */
    .nav-menu > li {
        display: block !important;
        width: 100%;
        padding: 1rem 0 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    .nav-menu > li > a {
        font-size: 1.3rem;
        font-weight: 600;
        display: block;
    }

    /* Facebook icon inside the slide-out menu: sits at the very bottom,
       below the page links, set off with a divider and sized for touch. */
    .nav-menu > .facebook-icon-link {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin-top: 1.5rem;
        padding-top: 1.5rem;
        padding-bottom: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.15);
    }

    .nav-menu > .facebook-icon-link .facebook-icon-img {
        height: 36px !important;
        width: 36px !important;
    }

    /* Social icons inside the mobile menu */
    .nav-menu > div {
        margin-top: 1.5rem;
    }

    /* Dropdown expands inline within the slide-out menu */
    .nav-has-dropdown {
        padding: 0 !important;
    }

    .nav-dropdown-summary {
        padding: 1rem 0;
        font-size: 1.3rem;
        font-weight: 600;
    }

    /* Bigger, easier-to-tap caret, and rotate it open like the
       browser's native disclosure triangle would. */
    .nav-dropdown-summary::after {
        font-size: 0.85em;
        transition: transform 0.2s ease;
    }

    .nav-dropdown[open] > .nav-dropdown-summary::after {
        transform: rotate(180deg);
    }

    .nav-dropdown-menu {
        padding-left: 1.1rem;
        padding-bottom: 0.5rem;
        margin-top: 0.25rem;
        border-left: 2px solid rgba(255, 255, 255, 0.2);
    }

    .nav-dropdown-menu li a {
        padding: 0.75rem 0;
        font-size: 1.15rem;
        font-weight: 400;
        display: block;
        color: rgba(255, 255, 255, 0.75);
    }
}