/*
 * Makhluot Header Polish v1.0
 *
 * Premium overlay enhancements for the legacy theme header.
 * All targets existing classes — no markup changes required.
 *
 * Goldilocks pack:
 *   1. Glassmorphism (blur + saturation)
 *   2. Scroll-aware compact mode
 *   3. Active indicator (gradient line under current category)
 *   4. Logo hover with sparkle glow
 *   5. Theme toggle smooth morph (sun↔moon)
 *   6. Notification badge on user button
 *
 * All animations respect prefers-reduced-motion.
 */

/* =========================================================
   1. GLASSMORPHISM HEADER
   ========================================================= */
#masthead.site-header {
    /* Make sure the header stays on top while scrolling */
    position: sticky;
    top: 0;
    z-index: 9000;

    /* Base translucent surface that the blur sits on */
    background: rgba(15, 23, 42, .72) !important;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .04);

    /* Smooth height/shadow transitions for compact mode */
    transition: background .25s ease,
                box-shadow .25s ease,
                padding .25s ease,
                min-height .25s ease;

    will-change: padding, min-height, background;
}

/* Light theme adapts the surface tint */
[data-theme="light"] #masthead.site-header,
body.light #masthead.site-header {
    background: rgba(255, 255, 255, .78) !important;
    border-bottom: 1px solid rgba(15, 23, 42, .08);
}

/* Admin bar offset to avoid overlap */
body.admin-bar #masthead.site-header { top: 32px; }
@media (max-width: 782px) {
    body.admin-bar #masthead.site-header { top: 46px; }
}

/* =========================================================
   2. SCROLL-AWARE COMPACT MODE
   ========================================================= */
#masthead.site-header.mhp-scrolled {
    box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
    background: rgba(15, 23, 42, .92) !important;
}
[data-theme="light"] #masthead.site-header.mhp-scrolled,
body.light #masthead.site-header.mhp-scrolled {
    background: rgba(255, 255, 255, .94) !important;
    box-shadow: 0 4px 24px rgba(15, 23, 42, .08);
}
#masthead.site-header.mhp-scrolled .header-inner {
    min-height: 54px !important;
    padding-top: 4px;
    padding-bottom: 4px;
}
.header-inner {
    transition: min-height .25s ease, padding .25s ease;
}

/* =========================================================
   3. ACTIVE INDICATOR (gradient underline under current page)
   ========================================================= */
.primary-menu {
    position: relative;
}
.primary-menu .menu-item > a {
    position: relative;
    transition: color .2s ease, background .2s ease;
}
.primary-menu .menu-item > a::after {
    content: '';
    position: absolute;
    inset-inline: 12%;
    bottom: -6px;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, #a855f7, #ec4899);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform .35s cubic-bezier(.4, 0, .2, 1), opacity .25s ease;
    opacity: 0;
    pointer-events: none;
}
/* Active state */
.primary-menu .menu-item.current-menu-item > a::after,
.primary-menu .menu-item.current-menu-ancestor > a::after,
.primary-menu .menu-item.current-menu-parent > a::after {
    transform: scaleX(1);
    opacity: 1;
}
/* Hover preview (only when not active to avoid double effect) */
.primary-menu .menu-item:not(.current-menu-item):not(.current-menu-ancestor) > a:hover::after {
    transform: scaleX(.6);
    opacity: .7;
}

/* Tint the active item icon + text gently */
.primary-menu .menu-item.current-menu-item > a {
    color: #fff;
}
.primary-menu .menu-item.current-menu-item > a svg.cm-menu-icon {
    color: #a855f7;
}

/* =========================================================
   4. LOGO HOVER WITH SPARKLE
   ========================================================= */
.site-branding .custom-logo-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}
.site-branding .custom-logo-link:hover {
    transform: translateY(-1px);
}

.site-branding .custom-logo-link .logo-icon {
    display: inline-grid;
    place-items: center;
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
    will-change: transform;
}
.site-branding .custom-logo-link:hover .logo-icon {
    transform: rotate(-8deg) scale(1.08);
}

/* Sparkle dot (added by JS as ::after via class to avoid markup change) */
.site-branding .custom-logo-link::after {
    content: '✨';
    position: absolute;
    top: -4px;
    inset-inline-start: -6px;
    font-size: 11px;
    opacity: 0;
    transform: scale(.4) rotate(0deg);
    transition: opacity .3s ease, transform .45s cubic-bezier(.34, 1.56, .64, 1);
    pointer-events: none;
    text-shadow: 0 0 8px #fde047;
}
.site-branding .custom-logo-link:hover::after {
    opacity: 1;
    transform: scale(1) rotate(180deg);
}

/* Add gentle gradient sweep on first page-load */
.site-branding .logo-text.gradient-text {
    background-size: 200% 100% !important;
    animation: mhp-grad-sweep 3.5s ease-in-out 1;
}
@keyframes mhp-grad-sweep {
    0%   { background-position: 200% 0; }
    100% { background-position: 0 0; }
}

/* =========================================================
   5. THEME TOGGLE MORPH (sun ↔ moon smooth)
   ========================================================= */
.theme-toggle {
    position: relative;
    overflow: hidden;
}
.theme-toggle .mfort-icon {
    transition: transform .35s cubic-bezier(.4, 0, .2, 1),
                opacity .25s ease !important;
    will-change: transform, opacity;
}
.theme-toggle .theme-icon-dark {
    transform: rotate(0deg) scale(1);
}
[data-theme="light"] .theme-toggle .theme-icon-dark,
body.light .theme-toggle .theme-icon-dark {
    transform: rotate(180deg) scale(0);
    opacity: 0;
}
.theme-toggle .theme-icon-light {
    position: absolute;
    inset: 0;
    margin: auto;
    display: grid !important;
    place-items: center;
    transform: rotate(-180deg) scale(0);
    opacity: 0;
}
[data-theme="light"] .theme-toggle .theme-icon-light,
body.light .theme-toggle .theme-icon-light {
    transform: rotate(0deg) scale(1);
    opacity: 1;
}

/* =========================================================
   6. ICON BUTTONS — premium hover ring
   ========================================================= */
.btn-icon,
.cm-login-btn,
.cm-user-btn {
    transition: all .2s cubic-bezier(.4, 0, .2, 1) !important;
    position: relative;
}
.btn-icon:hover,
.cm-user-btn:hover {
    background: rgba(168, 85, 247, .12) !important;
    border-color: rgba(168, 85, 247, .35) !important;
    color: #a855f7 !important;
    transform: translateY(-1px);
}
[data-theme="light"] .btn-icon:hover,
body.light .btn-icon:hover {
    background: rgba(168, 85, 247, .08) !important;
}

/* =========================================================
   7. LOGIN BUTTON — gradient pill bremium
   ========================================================= */
.cm-login-btn,
.cm-login-trigger {
    background: linear-gradient(135deg, #a855f7, #ec4899) !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 999px !important;
    padding: 0 18px !important;
    height: 38px !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    letter-spacing: .01em;
    box-shadow: 0 4px 14px rgba(168, 85, 247, .35) !important;
    transition: transform .2s ease, box-shadow .25s ease, filter .2s ease !important;
    position: relative;
    overflow: hidden;
}
.cm-login-btn::before,
.cm-login-trigger::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #ec4899, #a855f7);
    opacity: 0;
    transition: opacity .25s ease;
    z-index: 0;
}
.cm-login-btn:hover,
.cm-login-trigger:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(236, 72, 153, .45) !important;
}
.cm-login-btn:hover::before,
.cm-login-trigger:hover::before { opacity: 1; }
.cm-login-btn > *,
.cm-login-trigger > * { position: relative; z-index: 1; }

/* =========================================================
   8. NOTIFICATION BADGE
   ========================================================= */
.cm-user-btn,
.cm-login-btn,
.cm-login-trigger {
    position: relative;
}
.mhp-notif-badge {
    position: absolute;
    top: -4px;
    inset-inline-end: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
    font-size: 10.5px;
    font-weight: 900;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(239, 68, 68, .45),
                0 0 0 2px rgba(15, 23, 42, .9);
    pointer-events: none;
    animation: mhp-pulse-ring 2.2s ease-in-out infinite;
}
[data-theme="light"] .mhp-notif-badge,
body.light .mhp-notif-badge {
    box-shadow: 0 2px 6px rgba(239, 68, 68, .45),
                0 0 0 2px rgba(255, 255, 255, .95);
}
@keyframes mhp-pulse-ring {
    0%, 100% { box-shadow: 0 2px 6px rgba(239, 68, 68, .45), 0 0 0 2px rgba(15,23,42,.9), 0 0 0 0 rgba(239,68,68,.6); }
    50%      { box-shadow: 0 2px 6px rgba(239, 68, 68, .45), 0 0 0 2px rgba(15,23,42,.9), 0 0 0 6px rgba(239,68,68,0); }
}

/* =========================================================
   9. MOBILE TOGGLE (hamburger) — slight polish
   ========================================================= */
.mobile-toggle {
    transition: all .2s ease !important;
}
.mobile-toggle:hover {
    border-color: rgba(168, 85, 247, .35) !important;
}
.mobile-toggle span {
    transition: transform .25s ease, opacity .2s ease, width .25s ease;
}
.mobile-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
    width: 18px;
}
.mobile-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.mobile-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
    width: 18px;
}

/* =========================================================
   10. REDUCED MOTION
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    #masthead.site-header,
    .primary-menu .menu-item > a::after,
    .site-branding .custom-logo-link,
    .site-branding .custom-logo-link .logo-icon,
    .site-branding .custom-logo-link::after,
    .theme-toggle .mfort-icon,
    .btn-icon, .cm-login-btn, .cm-login-trigger,
    .cm-login-btn::before, .cm-login-trigger::before,
    .mhp-notif-badge,
    .mobile-toggle span {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
}

/* =========================================================
   11. RESPONSIVE TWEAKS
   ========================================================= */
@media (max-width: 768px) {
    #masthead.site-header {
        backdrop-filter: blur(16px) saturate(160%);
        -webkit-backdrop-filter: blur(16px) saturate(160%);
    }
    .cm-login-btn,
    .cm-login-trigger {
        height: 34px !important;
        padding: 0 14px !important;
        font-size: 12.5px !important;
    }
}
