/* =============================================================================
   navbar.css  -  Main navbar (mobile first)
   -----------------------------------------------------------------------------
   Component: .hh-nav   Markup: front/layout/partials/navbar.blade.php

   One flex row (.hh-nav__bar), three sections in this DOM order:
     1. Brand    hamburger + logo                    .hh-nav__toggler / __brand
     2. Links    category links, collapsible          .hh-nav__links / __list
     3. Actions  search, cart, wishlist, profile      .hh-nav__actions

   Mobile (default): [hamburger][logo] ........ [search][cart][wishlist][avatar]
   The links collapse into a full-width panel on a second row.

   Desktop (>= 992px): [logo]  [ links, centred ]  [search bar][cart][wishlist][profile]
   The search icon turns into a slim bar at the left edge of the actions section.
   The profile shows avatar + name from 1200px.

   The announcement strip lives in header.css, the live-search widget in
   search.css. Only the search wrapper is sized and skinned here.

   Sections
     1. Tokens
     2. Bar
     3. Section 1: brand
     4. Section 3: actions (icons, badge, profile, menu)
     5. Section 2: links (mobile panel)
     6. Desktop (>= 992px)
     7. Wide desktop (>= 1200px)
     8. Reduced motion

   Specificity note: style1.css and Bootstrap both style .navbar / .nav-link.
   Bootstrap's own variables are set on .navbar.hh-nav below so its rules
   resolve to our values instead of being fought with !important.
============================================================================= */


/* --- 1. Tokens ------------------------------------------------------------- */

.navbar.hh-nav {
    --nav-h:        56px;
    --nav-bg:       var(--bg, #F8F7EF);
    --nav-ink:      var(--text-heading, #18352B);
    --nav-ink-soft: var(--text-body, #26312C);
    --nav-accent:   var(--primary, #07543F);
    --nav-tint:     var(--sage-soft, #EEF4EF);
    --nav-line:     var(--border, #DCE3DD);
    --nav-line-strong: var(--border-md, #BFCBC2);
    --nav-accent-deep: var(--primary-dark, #043D2F);

    --nav-font-display: var(--font-display, 'Playfair Display', Georgia, serif);

    /* Fluid scale for the desktop row */
    --nav-fs:      clamp(.8rem, .66rem + .3vw, .93rem);
    --nav-link-fs: clamp(.82rem, .68rem + .3vw, .96rem);   /* Playfair runs wider than Inter */
    --nav-pad-x:   clamp(.7rem, .25rem + 1.15vw, 1.35rem);
    --nav-gap:     clamp(.75rem, .2rem + 1.4vw, 1.75rem);

    /* Point Bootstrap's navbar variables at our tokens */
    --bs-navbar-color:        var(--nav-ink);
    --bs-navbar-hover-color:  var(--nav-accent);
    --bs-navbar-active-color: var(--nav-accent);
}


/* --- 2. Bar ----------------------------------------------------------------- */

.navbar.hh-nav {
    padding: 0;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-line);
}

.hh-nav__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    max-width: 1440px;
    min-height: var(--nav-h);
    margin-inline: auto;
    padding-inline: clamp(.5rem, 2.4vw, 2.5rem);
}

.hh-nav a:focus-visible,
.hh-nav button:focus-visible {
    outline: 2px solid var(--nav-accent);
    outline-offset: 2px;
    border-radius: 6px;
}


/* --- 3. Section 1: brand ---------------------------------------------------- */

.hh-nav__toggler {
    padding: .45rem;
    border: 0;
}

.hh-nav__toggler:focus {
    box-shadow: none;
}

.hh-nav__toggler .navbar-toggler-icon {
    width: 22px;
    height: 15px;
}

.hh-nav__brand {
    display: flex;
    align-items: center;
    flex: none;
    margin: 0 0 0 .25rem;
    padding: .25rem 0;
}

.hh-nav__brand img {
    display: block;
    height: 55px;
    width: auto;
}


/* --- 4. Section 3: actions -------------------------------------------------- */

.hh-nav__actions {
    display: flex;
    align-items: center;
    order: 2;                    /* above the collapsed links on mobile */
    gap: 0;
    margin-left: auto;
}

/* One look for every icon control: search, cart, wishlist, profile */
.hh-nav__action {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 .5rem;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--nav-ink);
    font-size: 1.1rem;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .18s ease, color .18s ease;
}

.hh-nav__action:hover,
.hh-nav__action:focus-visible {
    background: var(--nav-tint);
    color: var(--nav-accent);
}

/* Cart / wishlist count. JS toggles .d-none and writes the number. */
.hh-nav__badge {
    position: absolute;
    top: 4px;
    right: 1px;
    min-width: 1.2em;
    padding: .3em .45em;
    box-shadow: 0 0 0 2px var(--nav-bg);   /* ring separates it from the icon */
    font-size: .62rem;
    font-weight: 600;
    line-height: 1;
}

/* Profile: avatar only on small screens; name, caret and a pill outline from 1200px */
.hh-nav__profile-wrap {
    position: relative;
}

.hh-nav__profile {
    gap: .5rem;
}

.hh-nav__profile.dropdown-toggle::after {
    display: none;
}

.hh-nav__user-name {
    display: none;
    max-width: 12ch;
    overflow: hidden;
    font-size: var(--nav-fs);
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Account menu. style1.css opens every .dropdown on :hover, which sticks after a
   tap on touch screens, so below 992px the menu follows the .show class only.
   The .hh-nav prefix outranks Bootstrap's .dropdown-menu[data-bs-popper]. */
.hh-nav .hh-nav__menu {
    top: 100%;
    right: 0;
    left: auto;
    min-width: 200px;
    margin-top: .4rem;
    padding: .4rem;
    border: 1px solid var(--nav-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(24, 53, 43, .12);
}

.hh-nav .hh-nav__menu:not(.show) {
    display: none;
}

.hh-nav__menu .dropdown-item {
    padding: .55rem .75rem;
    border-radius: 7px;
    color: var(--nav-ink-soft);
    font-size: .9rem;
}

.hh-nav__menu .dropdown-item:hover,
.hh-nav__menu .dropdown-item:focus {
    background: var(--nav-tint);
    color: var(--nav-accent);
}

/* Name row shown in the menu on screens where the button has no name */
.hh-nav__menu-head {
    display: block;
    padding: .4rem .75rem .5rem;
    margin-bottom: .25rem;
    border-bottom: 1px solid var(--nav-line);
    color: var(--nav-ink);
    font-family: var(--nav-font-display);
    font-size: .95rem;
    font-weight: 500;
}


/* --- 5. Section 2: links (mobile: full-width collapsible panel) ------------- */

.hh-nav__links {
    flex-basis: 100%;
    order: 3;                    /* second row on mobile */
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    border-top: 1px solid var(--nav-line);
}

.hh-nav__list {
    padding: .25rem 0 .75rem;
}

.hh-nav .category-item {
    padding: .15rem 0;
    border-bottom: 1px solid var(--nav-line);
}

.hh-nav .category-item:last-child {
    border-bottom: 0;
}

.hh-nav .parent-link {
    display: block;
    margin: 0;                   /* style1.css gives .navbar .nav-link a 5px side margin */
    padding: .7rem 0 .35rem;
    color: var(--nav-ink);
    font-family: var(--nav-font-display);
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: -.01em;
    transition: color .18s ease;
}

.hh-nav .parent-link:hover,
.hh-nav .parent-link:focus-visible,
.hh-nav .category-item.is-active > .parent-link {
    color: var(--nav-accent);
}

.hh-nav .category-item.is-active > .parent-link {
    font-weight: 700;
}

/* Sub-list stays open on mobile: no JS, and one tap reaches a page */
.hh-nav .nav-sub-list {
    margin: 0 0 .4rem .15rem;
    padding: 0 0 0 .85rem;
    list-style: none;
    border-left: 2px solid var(--nav-tint);
}

.hh-nav .nav-sub-list .sub-link {
    display: block;
    padding: .45rem 0;
    color: var(--nav-ink-soft);
    font-size: .88rem;
    text-decoration: none;
}

.hh-nav .nav-sub-list .sub-link:hover {
    color: var(--nav-accent);
}


/* --- 6. Desktop (>= 992px): one row, three sections ------------------------- */

@media (min-width: 992px) {

    .navbar.hh-nav {
        --nav-h: 66px;
        --bs-navbar-nav-link-padding-x: var(--nav-pad-x);
    }

    .hh-nav__bar {
        flex-wrap: nowrap;
        gap: var(--nav-gap);
    }

    .hh-nav__brand {
        margin-left: 0;
    }

    .hh-nav__brand img {
        height: 55px;
    }

    .hh-nav__actions,
    .hh-nav__links {
        order: 0;
    }

    /* Section 2: links take the free space and sit in the middle, so the
       leftover room is split evenly instead of piling up on one side. */
    .hh-nav__links {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 0;
        max-height: none;
        overflow: visible;
        border-top: 0;
    }

    .hh-nav__list {
        flex-wrap: nowrap;
        align-items: center;
        min-width: 0;
        padding: 0;
    }

    .hh-nav .category-item {
        position: relative;
        flex: 0 1 auto;
        min-width: 0;
        padding: 0;
        border-bottom: 0;
    }

    /* Category link: Playfair Display. A fixed line-height centres the text in
       the bar and gives the hover area the full bar height. A long title
       truncates only when the row runs out of room. */
    .hh-nav .parent-link {
        position: relative;
        max-width: 32ch;            /* border-box: counts the padding, so keep it generous */
        padding: 0 var(--nav-pad-x);
        overflow: hidden;
        font-size: var(--nav-link-fs);
        letter-spacing: -.012em;
        line-height: var(--nav-h);
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .hh-nav .category-item.is-active > .parent-link {
        font-weight: 500;
    }

    /* Underline: draws in from the centre on hover, stays on the active item */
    .hh-nav .parent-link::before {
        content: "";
        position: absolute;
        right: var(--nav-pad-x);
        bottom: 14px;
        left: var(--nav-pad-x);
        height: 2px;
        border-radius: 2px;
        background: var(--nav-accent);
        transform: scaleX(0);
        transition: transform .22s ease;
    }

    .hh-nav .category-item:hover > .parent-link::before,
    .hh-nav .category-item:focus-within > .parent-link::before,
    .hh-nav .category-item.is-active > .parent-link::before {
        transform: scaleX(1);
    }

    /* Chevron: pure CSS, only on items that have a dropdown */
    .hh-nav .has-sub > .parent-link {
        padding-right: calc(var(--nav-pad-x) + .85rem);
    }

    .hh-nav .has-sub > .parent-link::after {
        content: "";
        position: absolute;
        top: 50%;
        right: var(--nav-pad-x);
        width: .38rem;
        height: .38rem;
        border-right: 1.5px solid currentColor;
        border-bottom: 1.5px solid currentColor;
        transform: translateY(-70%) rotate(45deg);
        transition: transform .2s ease;
    }

    .hh-nav .has-sub:hover > .parent-link::after,
    .hh-nav .has-sub:focus-within > .parent-link::after {
        transform: translateY(-30%) rotate(225deg);
    }

    /* Dropdown panel, centred under its link. Always display:block so the fade
       runs (style1.css hides it with display:none); opacity and visibility do
       the hiding. Opens on hover and keyboard focus. The ::before bridge
       closes the gap between link and panel so the menu stays open while the
       cursor travels. */
    .hh-nav .nav-sub-list {
        position: absolute;
        top: 100%;
        left: 50%;
        z-index: 1050;
        display: block;
        min-width: 210px;
        margin: .3rem 0 0;
        padding: .4rem;
        background: #fff;
        border: 1px solid var(--nav-line);
        border-radius: 12px;
        box-shadow: 0 12px 28px rgba(24, 53, 43, .12);
        opacity: 0;
        visibility: hidden;
        transform: translate(-50%, 6px);
        transition: opacity .18s ease, transform .18s ease, visibility .18s;
    }

    .hh-nav .nav-sub-list::before {
        content: "";
        position: absolute;
        top: -.6rem;
        right: 0;
        left: 0;
        height: .6rem;
    }

    .hh-nav .category-item:hover > .nav-sub-list,
    .hh-nav .category-item:focus-within > .nav-sub-list {
        opacity: 1;
        visibility: visible;
        transform: translate(-50%, 0);
    }

    .hh-nav .nav-sub-list .sub-link {
        padding: .5rem .75rem;
        border-radius: 7px;
        font-size: .875rem;
        white-space: nowrap;
    }

    .hh-nav .nav-sub-list .sub-link:hover,
    .hh-nav .nav-sub-list .sub-link:focus-visible {
        background: var(--nav-tint);
        color: var(--nav-accent);
    }

    /* Section 3: slim search bar at the left edge, then the icons.
       The form itself is the pill: white, with a clear border. Input and
       submit button are plain flex items inside it. The button is never
       absolutely positioned, so it cannot drift over the placeholder, and
       the input has min-width: 0 so a long placeholder is clipped with an
       ellipsis instead of pushing past the pill. */
    .hh-nav__actions {
        gap: .25rem;
    }

    .hh-nav__search {
        width: clamp(190px, 17vw, 290px);
        margin-right: .5rem;
    }

    .hh-nav__search .hh-search {
        max-width: none;
    }

    .hh-nav__search .hh-search__form {
        display: flex;
        align-items: center;
        gap: .25rem;
        height: 40px;
        padding: 3px;
        border: 1.5px solid var(--nav-line-strong);
        border-radius: 999px;
        background: #fff;
        transition: border-color .18s ease, box-shadow .18s ease;
    }

    .hh-nav__search .hh-search__form:hover {
        border-color: var(--nav-accent);
    }

    .hh-nav__search .hh-search__form:focus-within {
        border-color: var(--nav-accent);
        box-shadow: 0 0 0 3px rgba(7, 84, 63, .16);
    }

    .hh-nav__search .hh-search__input {
        flex: 1 1 auto;
        min-width: 0;
        height: 100%;
        padding: 0 .25rem 0 .9rem;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        color: var(--nav-ink);
        font-size: .875rem;
        text-overflow: ellipsis;
    }

    .hh-nav__search .hh-search__input:hover,
    .hh-nav__search .hh-search__input:focus {
        border: 0;
        box-shadow: none;
    }

    .hh-nav__search .hh-search__input::placeholder {
        color: var(--nav-ink-soft);
        opacity: .62;
    }

    .hh-nav__search .hh-search__input::-webkit-search-cancel-button {
        -webkit-appearance: none;
    }

    /* Submit: solid brand-green disc with a light icon. This is the focal point of the bar. */
    .hh-nav__search .hh-search__btn,
    .hh-nav__search .hh-search__btn:hover,
    .hh-nav__search .hh-search__btn:active {
        position: static;
        flex: 0 0 32px;
        width: 32px;
        height: 32px;
        border: 0;
        border-radius: 50%;
        background: var(--nav-accent);
        color: #fff;
        font-size: .85rem;
    }

    .hh-nav__search .hh-search__btn:hover,
    .hh-nav__search .hh-search__btn:active {
        background: var(--nav-accent-deep);
    }

    /* Loading spinner (shown by search.js while fetching) sits just left of the button */
    .hh-nav__search .hh-search__input-icon {
        right: 48px;
    }

    /* Suggestions are wider than the slim bar. Anchor the panel to the bar's
       right edge so it opens leftwards, over the links, never off-screen. */
    .hh-nav__search .hh-search__dropdown {
        right: 0;
        left: auto;
        width: 400px;
        max-width: calc(100vw - 2rem);
    }

    .hh-nav__action {
        min-width: 38px;
        height: 38px;
    }

    /* Profile menu also opens on hover (mouse devices only, see below) */
    .hh-nav .hh-nav__menu {
        margin-top: 0;
    }

    .hh-nav__menu::before {
        content: "";
        position: absolute;
        top: -.5rem;
        right: 0;
        left: 0;
        height: .5rem;
    }
}

@media (min-width: 992px) and (hover: hover) {

    .hh-nav .hh-nav__profile-wrap:hover > .hh-nav__menu {
        display: block;
    }
}


/* --- 7. Wide desktop (>= 1200px): profile shows name and caret -------------- */

@media (min-width: 1200px) {

    .hh-nav__brand img {
        height: 65px;
    }

    .hh-nav__user-name {
        display: inline;
    }

    .hh-nav__profile {
        height: 40px;
        padding: 0 .75rem 0 .35rem;
        border: 1px solid var(--nav-line);
    }

    .hh-nav__profile.dropdown-toggle::after {
        display: inline-block;
        margin-left: 0;
    }
}


/* --- 8. Reduced motion ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

    .hh-nav .parent-link::before,
    .hh-nav .has-sub > .parent-link::after,
    .hh-nav .nav-sub-list,
    .hh-nav__action {
        transition: none;
    }
}