/* Navbar — logo, native burger trigger, global search, account/cart actions.
 * In normal flow (not fixed); the home page may opt into the fixed/scrolled
 * look via a body-class override when migrated (task #9).
 * Scoped reset so this file works on legacy pages without loading base.css. */
.navbar, .navbar * {
    box-sizing: border-box;
}

.navbar {
    font-family: var(--font-body);
    position: relative;
    z-index: 4;
    padding: 12px 0;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    background: var(--navy);
    transition: background 0.3s ease, padding 0.3s ease;
}

.navbar.scrolled {
    background: rgba(28, 28, 28, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 8px 0;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.navbar .container {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--white);
}

.nav-brand-mark {
    height: 46px;
    width: auto;
    flex: 0 0 auto;
}

/* Wordmark in real text (SEO) reproducing the look of the old logo: two bold
   uppercase lines, white "Votre Expert" + orange "Anti-Nuisibles". The top line's
   letter-spacing widens the shorter line to align it with the longer one. */
.nav-brand-text {
    display: flex;
    flex-direction: column;
    font-family: var(--font-heading);
    font-weight: 800;
    text-transform: uppercase;
    line-height: 0.98;
    white-space: nowrap;
}

.nav-brand-text-top,
.nav-brand-text-bottom {
    font-size: 1.05rem;
}

/* The top line's letter-spacing is tuned so its visible width matches
   ANTI-NUISIBLES below — V & A flush left, T & S flush right. */
.nav-brand-text-top {
    color: var(--white);
    letter-spacing: 1.65px;
    margin-bottom: 2px;
}

.nav-brand-text-bottom {
    color: var(--orange);
    letter-spacing: 0.4px;
}

/* ===== Burger trigger (animates into a × on .active, toggled by header.js) ===== */
.nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 5px;
    z-index: 1001;
}

.nav-toggle span {
    width: 25px;
    height: 2px;
    background: var(--white);
    transition: all 0.3s ease;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Global search ===== */
.nav-search-form {
    /* Centered between the logo (left) and the account/cart icons (right): the
     * auto side-margins absorb the free space equally, like Décathlon — instead
     * of hugging the logo and leaving a void before the right-hand icons. */
    flex: 0 1 680px;
    /* min-width:0 (instead of the default auto) so the bar can shrink below its
       content width and yield room to the buttons (otherwise "S'inscrire" / the cart
       overflow and get clipped on tablet). */
    min-width: 0;
    margin: 0 auto;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    padding: 4px 16px;
    transition: all 0.3s ease;
}

.nav-search-form:focus-within {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--orange);
    box-shadow: 0 0 16px rgba(255, 107, 53, 0.2);
}

.nav-search-form .search-icon {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
    margin-right: 12px;
    flex-shrink: 0;
}

.nav-search-form:focus-within .search-icon {
    color: var(--orange);
}

.nav-search-form .search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--white);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 8px 0;
    min-width: 0;
}

.nav-search-form .search-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.nav-search-form .search-input::-webkit-search-cancel-button,
.nav-search-form .search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.nav-search-form .search-input::-ms-clear {
    display: none;
}

/* Mobile-only search toggle (loupe). Hidden on desktop where the full bar shows. */
.nav-search-toggle {
    display: none;
    flex-shrink: 0;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.05rem;
    cursor: pointer;
    padding: 4px 6px;
    transition: color 0.2s ease;
}

.nav-search-toggle:hover {
    color: var(--orange);
}

@media (max-width: 600px) {
    /* Only collapse the bar to the loupe on real phones — at tablet widths the
     * full bar stays visible and fills the centre (no awkward empty middle). */
    .nav-search-form {
        display: none;
    }
    .nav-search-toggle {
        display: flex;
        align-items: center;
    }
    /* Bar gone → its auto side-margins no longer right-align the icons, so push
     * the action group right here. */
    .nav-right {
        margin-left: auto;
    }
    /* When toggled open, the navbar wraps and the search drops to a full-width row. */
    .navbar.search-open .container {
        flex-wrap: wrap;
    }
    .navbar.search-open .nav-search-form {
        display: flex;
        order: 10;
        flex-basis: 100%;
        max-width: none;
        margin-top: 10px;
    }
}

/* ===== Account / cart actions ===== */
.nav-right {
    display: flex;
    align-items: center;
    gap: 18px;
    /* No margin-left:auto — the search form's auto side-margins already push
     * this group to the right edge while keeping the search centered. */
}

.nav-right a {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.nav-right a:hover {
    color: var(--orange);
}

.nav-right .nav-btn {
    background: var(--orange);
    /* Dark text on orange (navy on #ff6b35 ≈ 5:1) — white was too low contrast
     * (~3.3:1) to read on the primary button. */
    color: var(--navy);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-right .nav-btn:hover {
    /* `!important` to beat the legacy global `a:hover { color: #ec7330 !important }`
     * (scss links partial) — without it the label turned orange-on-orange (illisible)
     * on this filled button. Hover feedback is a zoom + shadow; colour stays dark. */
    color: var(--navy) !important;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.nav-right .nav-btn-outline {
    background: transparent;
    border: 1.5px solid var(--orange);
    color: var(--orange);
}

.nav-right .nav-btn-outline:hover {
    /* White fill + navy text on hover for maximum contrast on the dark navbar.
     * `!important` for the same reason as .nav-btn:hover — beats the legacy
     * global `a:hover { color: #ec7330 !important }`. */
    background: var(--white);
    border-color: var(--white);
    color: var(--navy) !important;
}

.nav-right .nav-cart {
    font-size: 1.1rem;
    position: relative;
    display: flex;
    align-items: center;
}

.nav-cart-icon {
    display: block;
}

/* Account link — icon-only, same plain-icon treatment as the cart. */
.nav-right .nav-account {
    position: relative;
    display: flex;
    align-items: center;
}

.nav-account-icon {
    display: block;
}

.nav-cart-count {
    position: absolute;
    top: -8px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--orange);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-sizing: border-box;
}

/* Unread-ticket count on the account link — filled async by header.js. */
.nav-btn {
    position: relative;
}

.nav-account-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--orange);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .nav-right {
        gap: 12px;
    }
    .nav-right a:not(.nav-cart):not(.nav-account) {
        display: none;
    }
}
