/* =============================================================================
   4) HEADER & NAVIGATION
   Scope: CCH header, navbar, dropdowns, utilities and desktop search
   ============================================================================= */

/* --------------------------------------------------------------------------
   Base Bootstrap navbar overrides
   -------------------------------------------------------------------------- */

.cch .navbar {
    min-height: 96px;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

    .cch .navbar > .container {
        min-height: 72px;
    }

.cch .navbar-nav {
    align-items: center;
}

.cch .nav-link,
.cch .dropdown-item {
    min-height: 44px;
    font-size: 1rem;
}

.cch .nav-link {
    display: inline-flex;
    align-items: center;
    padding-block: 0.625rem;
    color: #222;
}

.cch .dropdown-item {
    padding-block: 0.625rem;
    color: #222;
    font-weight: 600;
    text-decoration: underline;
}

    .cch .dropdown-item:hover,
    .cch .dropdown-item:focus {
        color: var(--cch-white) !important;
        background-color: var(--cch-blue) !important;
        text-decoration: none;
    }

/* --------------------------------------------------------------------------
   Header shell
   -------------------------------------------------------------------------- */

.cch .cch-site-header {
    position: relative;
    z-index: 50;
}

.cch .header-utility-bar {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

/* --------------------------------------------------------------------------
   Utility bar links
   -------------------------------------------------------------------------- */

.cch .cch-utility-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    color: var(--cch-white);
    background-color: rgba(255, 255, 255, 0.08);
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

    .cch .cch-utility-link i,
    .cch .cch-utility-link__chevron {
        font-size: 1rem;
        line-height: 1;
    }

    .cch .cch-utility-link:hover,
    .cch .cch-utility-link:focus-visible {
        color: var(--cch-white) !important;
        background-color: rgba(255, 255, 255, 0.18);
        border-color: rgba(255, 255, 255, 0.75);
        text-decoration: none;
    }

    .cch .cch-utility-link:focus-visible {
        outline: 3px solid var(--cch-orange);
        outline-offset: 3px;
    }

@media (max-width: 767.98px) {
    .cch .cch-utility-link {
        width: 100%;
        justify-content: center;
    }
}

/* --------------------------------------------------------------------------
   Main dark navbar
   -------------------------------------------------------------------------- */

.cch .cch-main-navbar {
    min-height: 5.5rem;
    background-color: var(--cch-dark-blue);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

    .cch .cch-main-navbar > .container {
        min-height: 5.5rem;
    }

/* Logo sits inside the navbar, not over the hero */
.cch .cch-navbar-brand {
    flex: 0 0 auto;
    margin-right: 0;
    padding: 0;
}

.cch .cch-navbar-brand__logo-wrap {
    position: static;
    width: 12rem;
    height: 5.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cch .cch-navbar-brand__logo {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: contain;
}

/* Desktop layout: logo left, navigation and search right */
@media (min-width: 768px) {
    .cch .cch-main-navbar > .container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1.5rem;
    }

    .cch .cch-navbar-brand {
        flex: 0 0 auto;
        margin-right: 2rem;
    }

    .cch .cch-main-navbar #mainNavDesktop {
        flex: 1 1 auto;
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        min-width: 0;
    }

        .cch .cch-main-navbar #mainNavDesktop > .navbar-nav {
            display: flex;
            align-items: center;
            justify-content: flex-end;
            gap: 0.25rem;
            margin-left: auto !important;
            margin-right: 0 !important;
        }

    .cch .cch-main-navbar #mainNavDesktop > .dropdown {
        flex: 0 0 auto;
    }
}

/* --------------------------------------------------------------------------
   Main navbar links
   -------------------------------------------------------------------------- */

.cch .cch-main-navbar .nav-link {
    min-width: 44px;
    min-height: 56px;
    color: var(--cch-white) !important;
    font-size: 1rem;
    font-weight: 700;
}

.cch .navbar .nav-link-underlined:hover,
.cch .navbar .nav-link-underlined:focus-visible,
.cch .navbar .nav-link-underlined.active {
    text-decoration: none;
}

.cch .navbar .nav-link-underlined {
    font-weight: 700;
    text-decoration: none;
    text-transform: uppercase;
}

    .cch .navbar .nav-link-underlined:hover,
    .cch .navbar .nav-link-underlined:focus-visible {
        text-decoration-thickness: 3px;
    }

.cch .cch-main-navbar .nav-link-underlined.active,
.cch .cch-main-navbar .nav-link-underlined:hover,
.cch .cch-main-navbar .nav-link-underlined:focus-visible {
    text-decoration-color: var(--cch-orange);
}

/* Thick hover bar for text navigation links only. */
@media (hover: hover) and (pointer: fine) {
    .cch .cch-main-navbar #mainNavDesktop .cch-nav-text-link {
        position: relative;
    }

    .cch .cch-main-navbar #mainNavDesktop .cch-nav-text-link::after {
        content: "";
        position: absolute;
        right: 0.75rem;
        bottom: 0;
        left: 0.75rem;
        height: 4px;
        background-color: transparent;
    }

    .cch .cch-main-navbar #mainNavDesktop .cch-nav-text-link:hover::after {
        background-color: var(--cch-white, #fff);
    }
}

/* Icons inside desktop nav links */
@media (min-width: 768px) {
    .cch .cch-main-navbar .nav-link {
        min-height: 64px;
        padding-inline: 0.75rem;
    }

    .cch .cch-main-navbar .nav-link-underlined {
        text-underline-offset: 0.25em;
    }

    .cch .cch-nav-link-inner {
        display: inline-flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 0.45rem;
        line-height: 1.1;
        text-align: center;
    }

    .cch .cch-nav-link-icon {
        flex: 0 0 auto;
        color: currentColor;
        font-size: 1.125rem;
        line-height: 1;
    }
}

/* --------------------------------------------------------------------------
   Accessibility + Cymraeg links in the main navbar
   -------------------------------------------------------------------------- */

.cch .cch-nav-utility-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
}


    .cch .cch-nav-utility-link i {
        font-size: 1rem;
        line-height: 1;
    }

/* Main navbar version: standard navigation links, not pill controls. */
.cch .cch-main-navbar .cch-nav-utility-link {
    border: 0;
    border-radius: 0;
    color: var(--cch-white) !important;
    background-color: transparent !important;
    box-shadow: none !important;
}

    .cch .cch-main-navbar .cch-nav-utility-link:hover,
    .cch .cch-main-navbar .cch-nav-utility-link:focus-visible {
        color: var(--cch-white) !important;
        background-color: transparent !important;
        text-decoration: none;
    }

.cch .cch-nav-utility-link:focus-visible {
    outline: 3px solid var(--cch-orange);
    outline-offset: 3px;
}

@media (max-width: 767.98px) {
    .cch .cch-nav-utility-link {
        width: 100%;
        justify-content: center;
    }

    .cch .cch-mobile-utility-bar {
        min-height: 52px;
        color: var(--cch-white);
        background-color: #002957;
        border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    }

    .cch .cch-mobile-utility-link {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        min-width: 44px;
        min-height: 44px;
        padding: 0.25rem;
        color: var(--cch-white) !important;
        font-weight: 700;
        text-decoration: none;
    }

    .cch .cch-mobile-utility-link:hover {
        color: var(--cch-white) !important;
        text-decoration: underline;
        text-decoration-color: var(--cch-orange);
        text-underline-offset: 0.25em;
    }

    .cch .cch-mobile-utility-link:focus-visible {
        color: var(--cch-white) !important;
        outline: 3px solid var(--cch-orange);
        outline-offset: 2px;
    }

    .cch .cch-mobile-utility-link--icon {
        justify-content: center;
        font-size: 1.5rem;
    }

    .cch .cch-main-navbar {
        min-height: 72px;
        padding-block: 0.5rem !important;
        background-color: #003D7C;
    }

    .cch .cch-main-navbar > .container {
        min-height: 56px;
    }

    .cch .cch-navbar-brand__logo-wrap {
        width: 96px;
        height: 56px;
    }

    .cch .cch-navbar-toggler {
        border-color: rgba(255, 255, 255, 0.65);
    }

    .cch .cch-main-navbar .navbar-toggler-icon {
        filter: invert(1);
    }

    .cch .cch-navbar-toggler:focus-visible {
        outline-color: var(--cch-orange);
    }

    /* Match the footer and retain the desktop navigation's contrast and focus pattern. */
    .cch .cch-main-navbar .offcanvas {
        color: var(--cch-white);
        background-color: #003D7C;
    }

    .cch .cch-main-navbar .offcanvas-header {
        border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    }

    .cch .cch-main-navbar .offcanvas-title {
        color: var(--cch-white, #fff);
    }

    .cch .cch-main-navbar .offcanvas .btn-close {
        filter: invert(1) grayscale(100%) brightness(200%);
        opacity: 1;
    }

    .cch .cch-main-navbar .offcanvas-body {
        display: flex;
        flex-direction: column;
    }

    .cch .cch-main-navbar .offcanvas .navbar-nav {
        align-items: stretch;
        margin-top: 1rem;
    }

    .cch .cch-main-navbar .offcanvas .nav-link,
    .cch .cch-main-navbar .offcanvas .cch-nav-utility-link {
        width: 100%;
        color: var(--cch-white) !important;
    }

    .cch .cch-main-navbar .offcanvas .nav-link-underlined:hover,
    .cch .cch-main-navbar .offcanvas .nav-link-underlined:focus-visible,
    .cch .cch-main-navbar .offcanvas .nav-link-underlined.active {
        color: var(--cch-white) !important;
        text-decoration: underline;
        text-decoration-color: var(--cch-orange);
        text-underline-offset: 0.25em;
    }

    .cch .cch-main-navbar .offcanvas .nav-link:focus-visible,
    .cch .cch-main-navbar .offcanvas .cch-nav-utility-link:focus-visible,
    .cch .cch-main-navbar .offcanvas .btn-close:focus-visible,
    .cch .cch-main-navbar .offcanvas .cch-mobile-search .form-control:focus-visible,
    .cch .cch-main-navbar .offcanvas .cch-mobile-search .btn:focus-visible {
        outline: 3px solid var(--cch-orange);
        outline-offset: 3px;
        box-shadow: none;
    }

    .cch .cch-main-navbar .offcanvas .cch-mobile-search {
        margin-top: 1.5rem !important;
        padding-bottom: 0.25rem;
        border-top: 1px solid rgba(255, 255, 255, 0.25);
    }

    .cch .cch-main-navbar .offcanvas .cch-mobile-search .form-control,
    .cch .cch-main-navbar .offcanvas .cch-mobile-search .btn {
        min-height: 44px;
    }
}

/* --------------------------------------------------------------------------
   Desktop search dropdown
   -------------------------------------------------------------------------- */

.cch .cch-main-navbar #desktopSearchDropdown {
    width: 44px;
    height: 44px;
    border-radius: 999px;
}

.cch .cch-main-navbar #desktopSearchDropdown:focus-visible {
    outline: 3px solid var(--cch-white, #fff) !important;
    outline-offset: 4px !important;
}

/* Keep the input and button visually joined */
#desktopSearchDropdown + .dropdown-menu .input-group.input-group-sm > .form-control,
#desktopSearchDropdown + .dropdown-menu .cch-nav-search > .form-control {
    min-height: 0;
    margin-bottom: 0;
    border-right: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

#desktopSearchDropdown + .dropdown-menu .input-group.input-group-sm > .btn.btn-blue,
#desktopSearchDropdown + .dropdown-menu .cch-nav-search > .btn.btn-blue {
    min-width: 2.5rem;
    height: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.75rem;
    border-left: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    box-shadow: none;
    line-height: 1;
    transform: none;
}

#desktopSearchDropdown + .dropdown-menu .cch-nav-search {
    align-items: stretch;
    margin-bottom: 0;
}

    #desktopSearchDropdown + .dropdown-menu .cch-nav-search > .btn.btn-blue:hover,
    #desktopSearchDropdown + .dropdown-menu .cch-nav-search > .btn.btn-blue:focus,
    #desktopSearchDropdown + .dropdown-menu .cch-nav-search > .btn.btn-blue:active {
        box-shadow: none;
        transform: none;
    }

    #desktopSearchDropdown + .dropdown-menu .cch-nav-search > .btn.btn-blue i {
        line-height: 1;
    }

/* --------------------------------------------------------------------------
   Mobile toggler
   -------------------------------------------------------------------------- */

.cch .cch-mobile-header-actions {
    gap: 0.5rem;
}

.cch .cch-mobile-header-actions .dropdown {
    position: static;
}

.cch .cch-mobile-search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: var(--bs-navbar-toggler-border-radius, 0.375rem);
    color: var(--cch-white, #fff) !important;
    background-color: transparent;
    font-size: 1.5rem;
    line-height: 1;
}

.cch .cch-mobile-search-toggle:hover,
.cch .cch-mobile-search-toggle[aria-expanded="true"] {
    border-color: var(--cch-pink);
    color: var(--cch-white, #fff) !important;
    background-color: var(--cch-pink);
}

.cch .cch-mobile-search-toggle:focus-visible {
    outline: 3px solid var(--cch-orange);
    outline-offset: 3px;
    box-shadow: none;
}

.cch .cch-mobile-search-menu {
    right: auto !important;
    left: 50% !important;
    width: 100vw;
    max-width: none;
    margin-top: 0.5rem !important;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    transform: translateX(-50%) !important;
}

.cch .cch-mobile-search-menu .form-control,
.cch .cch-mobile-search-menu .btn {
    min-height: 44px;
}

.cch .cch-mobile-search-menu .form-control:focus-visible,
.cch .cch-mobile-search-menu .btn:focus-visible {
    outline: 3px solid var(--cch-orange);
    outline-offset: 2px;
    box-shadow: none;
}

.cch .cch-navbar-toggler {
    width: 56px;
    height: 56px;
    padding: 0;
    text-align: center;
    border-color: rgba(255, 255, 255, 0.5);
}

.cch .cch-site-header .btn-close,
.cch .cch-main-navbar .dropdown-toggle-split {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

    .cch .cch-navbar-toggler:focus-visible {
        outline: 3px solid var(--cch-orange);
        outline-offset: 3px;
    }

.cch .cch-main-navbar .navbar-toggler-icon {
    filter: brightness(0) invert(1);
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Header-to-hero spacing
   -------------------------------------------------------------------------- */

.cch .cch-site-header + .cch-hero,
.cch .cch-site-header + .cch-banner-hero,
.cch .cch-site-header + main .cch-hero,
.cch .cch-site-header + main .cch-banner-hero {
    margin-top: 0;
}
