/* ============================================================================
   wwwroot/css/marketplace-header.css   (v1)
   ----------------------------------------------------------------------------
   Styles for the Marketplace header widget + its lazy-built dropdown menu,
   plus the in-burger-drawer entry that mirrors it on mobile.

   Layered AFTER site.css in _Layout.cshtml so brand utility classes are
   already defined. Standalone — no shared classes with auth-widget.css,
   so changes here don't leak into the profile button next door.

   Three style zones:
     1. .ikh-mp-widget — the icon glyph itself + scan-beam animation
     2. .ikh-mp-tooltip — single-line confirmation on hover
     3. .ikh-mp-menu — the lazy-built three-peer dropdown
                       (Browse / Sign In / Register)
   ============================================================================ */


/* ════════════════════════════════════════════════════════════════════════
   ZONE 1 — THE GLYPH (no wrapper, just an inline anchor)
   ════════════════════════════════════════════════════════════════════════ */

.ikh-mp-widget {
    /* The widget is a positioning anchor for both tooltip and dropdown.
       Inline-flex so it sits as a peer of the auth widget in
       .header-actions and respects the row's gap. */
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 1;
    /* Lift the widget above the .header-strip ::after gradient line.
       .header-strip has z-index:10 and its ::after (the animated orange→
       blue gradient line at bottom:0) paints on top of normal-flow
       descendants by default. Without an explicit z-index here the
       tooltip below the glyph rendered UNDERNEATH the gradient line.
       Matches the .profile-btn-kqg approach next door (z-index:20 +
       isolation:isolate creates its own stacking context so the tooltip
       wins the paint order against the parent header's pseudo-element). */
    z-index: 20;
    isolation: isolate;
}

.ikh-mp-glyph-anchor {
    /* Strip every default link affordance so the glyph IS the chrome. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #1A1A1F; /* charcoal — currentColor for SVG strokes */
    text-decoration: none;
    outline: none;
    cursor: pointer;
    padding: 4px; /* clickable padding without a visible bg */
    border-radius: 10px;
    transition: color 0.22s ease, transform 0.22s ease, filter 0.22s ease;
}

    /* HOVER / FOCUS — colour shifts to sky blue, glyph lifts slightly.
       We deliberately DO NOT add a background — per the design brief
       this is "glyph, no wrapper". The subtle filter glow does the
       state-change heavy lifting instead. */
    .ikh-mp-glyph-anchor:hover,
    .ikh-mp-glyph-anchor:focus-visible {
        color: #3FA9D9;
        transform: translateY(-1px);
        filter: drop-shadow(0 4px 12px rgba(86, 196, 248, 0.32));
    }

    .ikh-mp-glyph-anchor:active {
        transform: translateY(0) scale(0.97);
    }

/* Pressed state — when the dropdown is open we keep the glyph
       in its active visual. Set by marketplace-header.js. */
.ikh-mp-widget[data-menu-open="true"] .ikh-mp-glyph-anchor {
    color: #3FA9D9;
    filter: drop-shadow(0 4px 14px rgba(86, 196, 248, 0.45));
}


/* ── The glyph SVG container ───────────────────────────────────────── */

.ikh-mp-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
}

    .ikh-mp-glyph svg {
        display: block;
        overflow: visible; /* let the scan beam glow paint outside the box */
    }


/* ── Scan-beam animation — the "alive" detail ──────────────────────── */
/* Sweeps horizontally across the storefront every 3.2s, with a 1.4s
   offset from the auth widget's scan so they don't blink in sync. */

.ikh-mp-scan {
    animation: ikh-mp-scan-sweep 3.2s ease-in-out infinite;
    animation-delay: 1.4s;
    transform-origin: center;
}

@keyframes ikh-mp-scan-sweep {
    0%, 100% {
        opacity: 0.25;
        transform: translateX(-4px);
    }

    50% {
        opacity: 1;
        transform: translateX(4px);
    }
}


/* ── Verified-tick badge pulse — slow expansion ring ───────────────── */
/* NOT a flash — a slow, almost imperceptible breath. Reads as "live". */

.ikh-mp-tick-ring {
    transform-origin: 58px 22px; /* match the circle's cx/cy */
    animation: ikh-mp-tick-breathe 2.6s ease-in-out infinite;
}

@keyframes ikh-mp-tick-breathe {
    0%, 100% {
        transform: scale(1);
        filter: none;
    }

    50% {
        transform: scale(1.08);
        filter: drop-shadow(0 0 4px rgba(86, 196, 248, 0.6));
    }
}


/* ── Awning gradient ribs — subtle shimmer on hover only ───────────── */

.ikh-mp-glyph-anchor:hover .ikh-mp-awning-ribs {
    animation: ikh-mp-rib-shimmer 1.4s ease-in-out infinite;
}

@keyframes ikh-mp-rib-shimmer {
    0%, 100% {
        opacity: 0.65;
    }

    50% {
        opacity: 1.0;
    }
}


/* ── Door reveal on hover — stroke-dashoffset thread ──────────────── */

.ikh-mp-door {
    stroke-dasharray: 64;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.45s ease;
}

.ikh-mp-glyph-anchor:hover .ikh-mp-door {
    stroke-dashoffset: 4; /* tiny redraw, just a flicker of motion */
}


/* ════════════════════════════════════════════════════════════════════════
   ZONE 2 — TOOLTIP (single-line product confirmation)
   ════════════════════════════════════════════════════════════════════════ */

.ikh-mp-tooltip {
    /* Positioned BELOW the glyph (auth widget uses the right side; we
       use below so they don't fight on narrow viewports). */
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: #1A1A1F;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.22s ease;
    z-index: 12;
}

    /* Small triangle pointing up to the glyph */
    .ikh-mp-tooltip::before {
        content: "";
        position: absolute;
        top: -4px;
        left: 50%;
        transform: translateX(-50%) rotate(45deg);
        width: 8px;
        height: 8px;
        background: #1A1A1F;
    }

/* Show on hover/focus, BUT hide when the dropdown menu is open — the
   menu is now the dominant affordance and a tooltip on top would clash. */
.ikh-mp-widget:hover .ikh-mp-tooltip,
.ikh-mp-glyph-anchor:focus-visible .ikh-mp-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.ikh-mp-widget[data-menu-open="true"] .ikh-mp-tooltip {
    opacity: 0 !important;
}


/* ════════════════════════════════════════════════════════════════════════
   ZONE 3 — DROPDOWN MENU (Browse / Sign In / Register)
   ════════════════════════════════════════════════════════════════════════
   Built lazily by marketplace-header.js on first interaction. We style
   it here regardless of mount state — if the JS hasn't appended the
   menu yet, none of these rules match anything.
   ════════════════════════════════════════════════════════════════════════ */

.ikh-mp-menu {
    /* Positioned below the glyph, right-aligned to it. Width is fluid
       within a sensible range — wide enough for "Register Your Business"
       in the longest expected SA language (siSwati is occasionally longer
       than English; we leave headroom). */
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 264px;
    max-width: 320px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.98);
    border-radius: 16px;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 1);
    padding: 10px;
    transform-origin: top right;
    transform: translateY(-6px) scale(0.97);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 14;
}

    .ikh-mp-menu[data-open="true"] {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }


/* ── Header eyebrow inside the menu ──────────────────────────────── */

.ikh-mp-menu-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    margin-bottom: 8px;
}

.ikh-mp-menu-head-icon {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #56C4F8;
}

.ikh-mp-menu-head-title {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #6B7280;
}


/* ── Menu items (the three peer rows) ────────────────────────────── */

.ikh-mp-menu-item {
    /* Anchor + button reset */
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: none;
    text-decoration: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    color: #1A1A1F;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.25;
    min-height: 50px;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

    .ikh-mp-menu-item + .ikh-mp-menu-item {
        margin-top: 2px;
    }

    .ikh-mp-menu-item:hover,
    .ikh-mp-menu-item:focus-visible {
        background: rgba(86, 196, 248, 0.10);
        color: #3FA9D9;
        outline: none;
    }

    .ikh-mp-menu-item:active {
        transform: scale(0.985);
    }


/* The icon slot in each row — small SVG square, accent-coloured */

.ikh-mp-menu-item-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #56C4F8;
    background: rgba(86, 196, 248, 0.10);
    border-radius: 10px;
    transition: background 0.18s ease, color 0.18s ease;
}

.ikh-mp-menu-item:hover .ikh-mp-menu-item-icon {
    background: rgba(63, 169, 217, 0.18);
    color: #3FA9D9;
}


/* The text column — two lines: label + helper */

.ikh-mp-menu-item-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ikh-mp-menu-item-label {
    font-size: 0.94rem;
    font-weight: 700;
    color: inherit;
    line-height: 1.2;
}

.ikh-mp-menu-item-helper {
    font-size: 0.72rem;
    font-weight: 500;
    color: #6B7280;
    line-height: 1.3;
    /* Don't recolour on hover — helper stays muted. */
}


/* ── Primary CTA variant — "Register Your Business" gets the orange
       brand gradient so it visually outranks the other two rows. ── */

.ikh-mp-menu-item.is-primary {
    background: linear-gradient(135deg, #F58220 0%, #F89622 100%);
    color: #fff;
    margin-top: 6px;
}

    .ikh-mp-menu-item.is-primary .ikh-mp-menu-item-icon {
        background: rgba(255, 255, 255, 0.20);
        color: #fff;
    }

    .ikh-mp-menu-item.is-primary .ikh-mp-menu-item-helper {
        color: rgba(255, 255, 255, 0.92);
    }

    .ikh-mp-menu-item.is-primary:hover,
    .ikh-mp-menu-item.is-primary:focus-visible {
        background: linear-gradient(135deg, #F89622 0%, #F58220 100%);
        color: #fff;
        transform: translateY(-1px);
        box-shadow: 0 10px 24px rgba(245, 130, 32, 0.32);
    }

        .ikh-mp-menu-item.is-primary:hover .ikh-mp-menu-item-icon {
            background: rgba(255, 255, 255, 0.30);
            color: #fff;
        }


/* ════════════════════════════════════════════════════════════════════════
   ZONE 4 — MOBILE / BURGER DRAWER ENTRY
   ════════════════════════════════════════════════════════════════════════
   On viewports ≤991px the header glyph still renders (it's still useful)
   but we ALSO surface a Marketplace section inside the burger drawer so
   the dropdown isn't the only path. Styling here mirrors the existing
   .ikh-burger-section + .ikh-burger-nav-link patterns from site.css.
   ════════════════════════════════════════════════════════════════════════ */

.ikh-burger-mp-section {
    /* Same vertical rhythm as the other drawer sections — site.css
       already adds the margin-top/border-top via the
       `.ikh-burger-section + .ikh-burger-section` adjacent selector. */
}

.ikh-burger-mp-icon {
    /* Sky-blue glyph slot, mirroring the menu-item icon styling */
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #56C4F8;
    background: rgba(86, 196, 248, 0.12);
    border-radius: 10px;
    flex-shrink: 0;
}

    .ikh-burger-mp-icon svg {
        width: 20px;
        height: 20px;
    }

/* Hover/focus on the marketplace rows tinges sky-blue (orange would
   clash with the Marketplace's brand accent). Overrides the default
   .ikh-burger-nav-link:hover orange tint. */
.ikh-burger-nav-link.ikh-burger-mp-link:hover,
.ikh-burger-nav-link.ikh-burger-mp-link:focus-visible {
    background: rgba(86, 196, 248, 0.10);
    color: #3FA9D9;
}


/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE — narrow the menu on very small viewports
   ════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .ikh-mp-menu {
        min-width: 240px;
        max-width: 280px;
    }

    .ikh-mp-menu-item {
        padding: 10px;
        min-height: 46px;
    }

    .ikh-mp-menu-item-label {
        font-size: 0.88rem;
    }

    .ikh-mp-menu-item-helper {
        font-size: 0.68rem;
    }
}


/* ════════════════════════════════════════════════════════════════════════
   REDUCED MOTION — kill the scan + breathe + shimmer animations
   ════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .ikh-mp-scan,
    .ikh-mp-tick-ring,
    .ikh-mp-awning-ribs,
    .ikh-mp-door {
        animation: none !important;
        transition: none !important;
    }

    .ikh-mp-menu {
        transition: opacity 0.12s linear !important;
        transform: none !important;
    }
}


/* ════════════════════════════════════════════════════════════════════════
   HIGH-CONTRAST — collapse the duotone to a single legible hue
   ════════════════════════════════════════════════════════════════════════ */

@media (prefers-contrast: more) {
    .ikh-mp-awning-ribs,
    .ikh-mp-tick-ring,
    .ikh-mp-door-handle,
    .ikh-mp-scan {
        stroke: currentColor !important;
        fill: currentColor !important;
    }
}
