/* ═══════════════════════════════════════════════════════════════════════════
   Navbar
   ═══════════════════════════════════════════════════════════════════════════

   States (managed by Alpine.js)
   ─────────────────────────────
   (no class)          fully transparent — hero pages before scroll
   .navbar--opaque     solid bg          non-hero pages · OR scrolled hero
   .navbar--scrolled   frosted glass     hero page · scrolled (overrides --opaque)

   Critical rendering notes
   ────────────────────────
   • NO border-bottom — replaced by box-shadow: inset 0 -1px 0 0.
     border-bottom + backdrop-filter = WebKit 1-px compositing seam.

   • backdrop-filter is NOT in the transition list — not animatable per spec.
     It is always-on at the base level (blur(12px)); --scrolled deepens it.
     On --opaque the solid background makes it visually inert (no cost).

   • background-color transitions from --nb-glass (warm-cream / charcoal
     low-alpha) to --bg-primary (solid), staying within the brand colour space.
*/

/* ═══════════════════════════════════════════════════════════════════════════
   Theme tokens
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Light (default) ────────────────────────────────────────────────────── */
:root {
    /* Alpha-0 of --bg-primary — fully transparent over hero before scroll.
       Keeps background-color transition inside the warm-cream colour space. */
    --nb-glass:         rgba(248, 246, 242, 0);

    /* ── Transparent-over-hero state ── */
    --nh-link-on:       rgba(22, 20, 17, 0.92);
    --nh-action:        rgba(22, 20, 17, 0.60);
    --nh-icon:          rgba(22, 20, 17, 0.68);
    --nh-icon-bg-h:     rgba(22, 20, 17, 0.08);

    /* CTA ghost — over semi-transparent hero glass */
    --nh-cta:           rgba(22, 20, 17, 0.72);
    --nh-cta-border:    rgba(22, 20, 17, 0.28);
    --nh-cta-bg-h:      rgba(22, 20, 17, 0.07);

    /* ── Scrolled / deeper glass (hero scrolled) ── */
    --ns-bg:            rgba(248, 246, 240, 0.88);
    --ns-shadow:        rgba(22, 20, 17, 0.09);
    --ns-blur:          blur(20px) saturate(140%);

    /* ── Nav panel drawer ── */
    --np-bg:            rgba(255, 255, 255, 0.92);
    --np-blur:          blur(20px) saturate(120%);
}

/* ─── Dark (explicit toggle) ─────────────────────────────────────────────── */
[data-theme="dark"] {
    --nb-glass:         rgba(26, 25, 23, 0);

    --nh-link-on:       rgba(255, 255, 255, 0.95);
    --nh-action:        rgba(255, 255, 255, 0.60);
    --nh-icon:          rgba(255, 255, 255, 0.55);
    --nh-icon-bg-h:     rgba(255, 255, 255, 0.08);

    --nh-cta:           rgba(255, 255, 255, 0.75);
    --nh-cta-border:    rgba(255, 255, 255, 0.28);
    --nh-cta-bg-h:      rgba(255, 255, 255, 0.07);

    --ns-bg:            rgba(20, 18, 16, 0.85);
    --ns-shadow:        rgba(255, 255, 255, 0.07);
    --ns-blur:          blur(20px) saturate(160%);

    --np-bg:            rgba(10, 10, 9, 0.88);
    --np-blur:          blur(20px) saturate(140%);
}

/* ─── Dark (system preference) ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --nb-glass:         rgba(26, 25, 23, 0);

        --nh-link-on:       rgba(255, 255, 255, 0.95);
        --nh-action:        rgba(255, 255, 255, 0.60);
        --nh-icon:          rgba(255, 255, 255, 0.55);
        --nh-icon-bg-h:     rgba(255, 255, 255, 0.08);

        --nh-cta:           rgba(255, 255, 255, 0.75);
        --nh-cta-border:    rgba(255, 255, 255, 0.28);
        --nh-cta-bg-h:      rgba(255, 255, 255, 0.07);

        --ns-bg:            rgba(20, 18, 16, 0.85);
        --ns-shadow:        rgba(255, 255, 255, 0.07);
        --ns-blur:          blur(20px) saturate(160%);

        --np-bg:            rgba(10, 10, 9, 0.88);
        --np-blur:          blur(20px) saturate(140%);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Shell
   ═══════════════════════════════════════════════════════════════════════════ */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);

    /* Fully transparent over hero — alpha-0 of brand colour keeps
       background-color transition within the warm-cream/charcoal space. */
    background-color: var(--nb-glass);

    box-shadow: inset 0 -1px 0 0 transparent;

    transition:
        background-color 380ms ease,
        box-shadow       280ms ease;
}

/* Solid surface — non-hero pages and scrolled-past-hero */
.navbar--opaque {
    background-color: var(--bg-primary);
    box-shadow: inset 0 -1px 0 0 var(--border-light);
}

/* Deep glass — hero page after scroll. Applied alongside --opaque; wins by cascade. */
.navbar--scrolled {
    background-color: var(--ns-bg);
    box-shadow: inset 0 -1px 0 0 var(--ns-shadow);
    backdrop-filter: var(--ns-blur);
    -webkit-backdrop-filter: var(--ns-blur);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Inner row
   ═══════════════════════════════════════════════════════════════════════════ */

.navbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    max-width: var(--width-full);
    margin-inline: auto;
    padding: 22px var(--space-8);
    height: var(--navbar-height);
    box-sizing: border-box;
    transition: height 350ms ease, padding 350ms ease;
}

.navbar--opaque  .navbar__inner,
.navbar--scrolled .navbar__inner {
    height: var(--navbar-height-scrolled);
    padding-top: 14px;
    padding-bottom: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Brand (image logo)
   ═══════════════════════════════════════════════════════════════════════════

   Two SVG files stacked in a CSS-grid cell; opacity cross-fades on theme
   change. No JS, no layout duplication, no CLS.

   Shared by the navbar bar (--lg, 40px) and the slide-over panel header
   (--sm, 27px) via components/nav-logo.html.
   ═══════════════════════════════════════════════════════════════════════════ */

.navbar__brand {
    display: flex;
    align-items: center;
    margin-right: auto;
    flex-shrink: 0;
    text-decoration: none;
    transition: opacity 200ms ease;
}

.navbar__brand:hover { opacity: 0.70; }

.navbar-logo {
    display: grid;
    align-items: center;
}

.navbar-logo__img {
    grid-area: 1 / 1;
    display: block;
    height: 40px;
    width: auto;
    transition: opacity 350ms ease;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.navbar-logo--sm .navbar-logo__img { height: 27px; }

@media (max-width: 479px) {
    .navbar-logo--lg .navbar-logo__img { height: 28px; }
}

/* Light: black logo visible; dark logo hidden */
.navbar-logo__img--light { opacity: 1; }
.navbar-logo__img--dark  { opacity: 0; }

[data-theme="dark"] .navbar-logo__img--light { opacity: 0; }
[data-theme="dark"] .navbar-logo__img--dark  { opacity: 1; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .navbar-logo__img--light { opacity: 0; }
    :root:not([data-theme="light"]) .navbar-logo__img--dark  { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Actions — right-side cluster (user · CTA · hamburger)
   ═══════════════════════════════════════════════════════════════════════════ */

.navbar__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* ─── User block (authenticated) ──────────────────────────────────────────── */

.navbar__user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    transition: opacity 200ms ease;
}

.navbar__user:hover { opacity: 0.78; }

/* Circular avatar — initials or profile image.
   Shared by the navbar bar (base, 34px) and the panel's user card
   (--lg, 44px) via components/nav-avatar.html. */
.navbar-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    background-color: var(--accent-gold);
    color: var(--bg-primary);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    overflow: hidden;
    user-select: none;
}

.navbar-avatar--lg {
    width: 44px;
    height: 44px;
    font-size: var(--text-sm);
}

.navbar-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* User's name — hidden on mobile, visible at 768 px+ */
.navbar__username {
    display: none;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color 200ms ease;
}

/* Over transparent hero */
.navbar:not(.navbar--opaque) .navbar__user     { opacity: 1; }
.navbar:not(.navbar--opaque) .navbar__username { color: var(--nh-action); }

/* ─── Sign In link (unauthenticated) ──────────────────────────────────────── */

.navbar__action-link {
    display: none;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: color 200ms ease;
}

.navbar__action-link:hover { color: var(--text-primary); }

.navbar:not(.navbar--opaque) .navbar__action-link       { color: var(--nh-action); }
.navbar:not(.navbar--opaque) .navbar__action-link:hover { color: var(--nh-link-on); }

/* ─── Book a Consultation CTA — ghost/outlined ────────────────────────────── */

.navbar__cta {
    display: none;
    align-items: center;
    padding: 7px var(--space-4);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition:
        color            200ms ease,
        border-color     200ms ease,
        background-color 200ms ease;
}

.navbar__cta:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background-color: var(--surface-hover);
}

/* Over transparent hero — ghost against the image */
.navbar:not(.navbar--opaque) .navbar__cta {
    color: var(--nh-cta);
    border-color: var(--nh-cta-border);
    background-color: transparent;
}

.navbar:not(.navbar--opaque) .navbar__cta:hover {
    color: var(--nh-link-on);
    border-color: var(--nh-cta);
    background-color: var(--nh-cta-bg-h);
}

/* ─── Theme toggle ────────────────────────────────────────────────────────── */

.navbar__theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color 200ms ease, background-color 200ms ease;
}

.navbar__theme-toggle:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

.navbar:not(.navbar--opaque) .navbar__theme-toggle       { color: var(--nh-icon); }
.navbar:not(.navbar--opaque) .navbar__theme-toggle:hover {
    color: var(--nh-link-on);
    background-color: var(--nh-icon-bg-h);
}

/* Moon / sun glyph — swaps on theme change */
.navbar__theme-icon::before { content: '☾'; font-size: var(--text-sm); line-height: 1; }

[data-theme="dark"] .navbar__theme-icon::before { content: '☀'; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .navbar__theme-icon::before { content: '☀'; }
}

/* ─── Saved fabrics — heart icon with cart-style count badge ──────────────── */

.navbar__saved {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color 200ms ease, background-color 200ms ease;
}

.navbar__saved:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

.navbar:not(.navbar--opaque) .navbar__saved       { color: var(--nh-icon); }
.navbar:not(.navbar--opaque) .navbar__saved:hover {
    color: var(--nh-link-on);
    background-color: var(--nh-icon-bg-h);
}

.navbar__saved svg { width: 18px; height: 18px; }

.navbar__saved-count {
    position: absolute;
    top: 1px;
    right: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: var(--radius-full);
    background-color: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    pointer-events: none;
}

/* ─── Search toggle — mobile only, opens the search modal ─────────────────── */

.navbar__search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color 200ms ease, background-color 200ms ease;
}

.navbar__search-toggle:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

.navbar:not(.navbar--opaque) .navbar__search-toggle       { color: var(--nh-icon); }
.navbar:not(.navbar--opaque) .navbar__search-toggle:hover {
    color: var(--nh-link-on);
    background-color: var(--nh-icon-bg-h);
}

.navbar__search-toggle svg { width: 18px; height: 18px; }

/* Hidden from tablet up — desktop/tablet keep the inline search bar */
@media (min-width: 769px) {
    .navbar__search-toggle { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Hamburger — mobile/tablet only (<768px); hidden on desktop, see Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

.navbar__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: color 200ms ease, background-color 200ms ease;
}

.navbar__toggle:hover { background-color: var(--surface-hover); }

.navbar:not(.navbar--opaque) .navbar__toggle        { color: var(--nh-icon); }
.navbar:not(.navbar--opaque) .navbar__toggle:hover  { background-color: var(--nh-icon-bg-h); }

.navbar__toggle-icon { width: 22px; height: 22px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tablet+: reveal CTA button */
@media (min-width: 640px) {
    .navbar__cta { display: inline-flex; }
}

/* Desktop+: reveal username and sign-in link; hide the mobile/tablet hamburger */
@media (min-width: 768px) {
    .navbar__username    { display: block; }
    .navbar__action-link { display: block; }
    .navbar__toggle       { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Nav panel (slide-over)
   ═══════════════════════════════════════════════════════════════════════════

   State machine (CSS class driven, bound by Alpine :class)
   ──────────────────────────────────────────────────────
   (no class)         closed — drawer off-screen right; backdrop invisible
   .nav-panel--open   open   — drawer slides in; backdrop fades in

   Transition: 600ms cubic-bezier(0.25, 0.1, 0.25, 1) — spec-exact.
   Teleported to <body> (x-teleport) so z-index: --z-modal (300) is clean.
   pointer-events: none on wrapper when closed — never intercepts clicks.
   backdrop-filter NOT in transition — not animatable per spec.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Wrapper ─────────────────────────────────────────────────────────────── */

.nav-panel {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    pointer-events: none;
}

.nav-panel--open {
    pointer-events: auto;
}

/* ─── Backdrop ────────────────────────────────────────────────────────────── */

.nav-panel__backdrop {
    position: absolute;
    inset: 0;
    background-color: var(--overlay-panel);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.nav-panel--open .nav-panel__backdrop {
    opacity: 1;
}

/* ─── Drawer ──────────────────────────────────────────────────────────────── */

.nav-panel__drawer {
    position: absolute;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(600px, 95vw);

    /* Premium frosted glass surface */
    background-color: var(--np-bg);
    backdrop-filter: var(--np-blur);
    -webkit-backdrop-filter: var(--np-blur);
    border-left: 1px solid var(--border-light);

    /* Only the nav section scrolls — drawer itself clips */
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Closed: off-screen to the right */
    transform: translateX(100%);
    transition: transform 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.nav-panel--open .nav-panel__drawer {
    transform: translateX(0);
}

@media (max-width: 640px) {
    .nav-panel__drawer {
        width: 100vw;
        border-left: none;
    }
}

/* Prevent horizontal scrollbar on page when panel is off-screen */
body { overflow-x: hidden; }

/* ─── Header: logo + close button ────────────────────────────────────────── */

.nav-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    height: var(--navbar-height-scrolled);
    flex-shrink: 0;
    box-shadow: inset 0 -1px 0 0 var(--border-light);
}

/* ─── Logo (panel header) — uses the shared .navbar-logo (--sm) block above ── */

.nav-panel__brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 200ms ease;
}

.nav-panel__brand:hover { opacity: 0.70; }

/* ─── Close button ────────────────────────────────────────────────────────── */

.nav-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color 200ms ease, background-color 200ms ease;
}

.nav-panel__close:hover {
    color: var(--text-primary);
    background-color: var(--surface-hover);
}

.nav-panel__close svg { width: 20px; height: 20px; }

/* ─── Navigation list ─────────────────────────────────────────────────────── */

.nav-panel__nav {
    flex: 1;                              /* fills vertical space, pushes footer sections down */
    overflow-y: auto;                     /* only this section scrolls if links overflow */
    padding: var(--space-8) var(--space-6) var(--space-6);
}

.nav-panel__list {
    display: flex;
    flex-direction: column;
}

.nav-panel__link {
    display: block;
    padding: var(--space-4) 0;
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-weight: 400;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    transition: color 250ms ease, padding-left 250ms ease;
}

.nav-panel__list li:first-child .nav-panel__link {
    border-top: 1px solid var(--border-light);
}

.nav-panel__link:hover {
    color: var(--text-primary);
    padding-left: var(--space-3);
}

.nav-panel__link--active {
    color: var(--accent-gold);
    font-weight: 500;
    padding-left: var(--space-3);
}

/* ─── Book a Consultation CTA ─────────────────────────────────────────────── */

.nav-panel__booking {
    padding: var(--space-4) var(--space-8);
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 0 var(--border-light);
}

.nav-panel__booking-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: var(--space-3) var(--space-6);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    transition:
        color            200ms ease,
        border-color     200ms ease,
        background-color 200ms ease;
}

.nav-panel__booking-link:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
    background-color: var(--surface-hover);
}

/* ─── User profile ────────────────────────────────────────────────────────── */

.nav-panel__user {
    padding: var(--space-5) var(--space-8);
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 0 var(--border-light);
}

.nav-panel__user-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

/* Avatar uses the shared .navbar-avatar (--lg) block above. */

.nav-panel__user-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.nav-panel__user-name {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "Profile" pill link below the name */
.nav-panel__user-pill {
    display: inline-flex;
    align-self: flex-start;
    padding: 2px var(--space-3);
    font-size: var(--text-xs);
    font-weight: 400;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: color 200ms ease, border-color 200ms ease;
}

.nav-panel__user-pill:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
}

/* Sign-in prompt when unauthenticated */
.nav-panel__sign-in {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    transition: color 200ms ease;
}

.nav-panel__sign-in:hover { color: var(--accent-gold); }

/* ─── Theme segmented control — pinned to bottom ──────────────────────────── */

.nav-panel__theme {
    padding: var(--space-4) var(--space-6) var(--space-8);
    flex-shrink: 0;
    box-shadow: inset 0 1px 0 0 var(--border-light);
}

.theme-seg {
    display: flex;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.theme-seg__btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    background-color: transparent;
    cursor: pointer;
    transition:
        color             300ms cubic-bezier(0.25, 0.1, 0.25, 1),
        background-color  300ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.theme-seg__btn + .theme-seg__btn {
    border-left: 1px solid var(--border-light);
}

.theme-seg__btn:hover:not(.theme-seg__btn--active) {
    color: var(--text-secondary);
    background-color: var(--surface-hover);
}

/* Active: filled with accent-dark — inverts naturally across both themes */
.theme-seg__btn--active {
    background-color: var(--accent-dark);
    color: var(--bg-primary);
}

.theme-seg__icon {
    font-size: var(--text-sm);
    line-height: 1;
}
