/**
 * Header & Navigation Styles
 *
 * P0 redesign: simplified 5-item nav (Start Here | Learn ▼ | Divination | Books | Bonus)
 * with Login/User in the top-right corner.
 * Desktop: single-row layout — Logo left, nav center, login right.
 * Mobile: hamburger menu with collapsible nav.
 *
 * @package Yi
 */

/* ====== Header base ====== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    border-bottom: 1px solid rgba(46, 78, 126, 0.1);
    box-shadow: 0 2px 10px rgba(46, 78, 126, 0.08);
    z-index: 99999; /* Must exceed WooCommerce store notice (99998) */
    transition: all var(--transition-normal);
}

.site-header.scrolled {
    background-color: rgba(255, 255, 255, 0.97);
    box-shadow: 0 2px 20px rgba(46, 78, 126, 0.12);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--container-padding);
    max-width: var(--container-max-width);
    margin: 0 auto;
    height: 64px;
    position: relative;
}

/* ====== Logo ====== */
.site-logo {
    flex-shrink: 0;
    z-index: 1001;
}

.site-logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-secondary);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: #2e4e7e;
    text-decoration: none;
    letter-spacing: 0.5px;
    transition: color var(--transition-fast);
    white-space: nowrap;
}

.logo-image {
    height: 36px;
    width: auto;
    max-width: 36px;
    transition: transform var(--transition-fast);
}

.logo-icon {
    font-size: 1.8rem;
    color: #2e4e7e;
    transition: transform var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.logo-text {
    font-family: var(--font-secondary);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: #2e4e7e;
    transition: color var(--transition-fast);
    white-space: nowrap;
    line-height: 1;
}

.site-logo a:hover .logo-text,
.site-logo a:focus .logo-text {
    color: var(--color-gold);
}

.site-logo a:hover .logo-image,
.site-logo a:focus .logo-image {
    transform: scale(1.05);
}

.site-logo a:hover .logo-icon,
.site-logo a:focus .logo-icon {
    transform: scale(1.05) rotate(10deg);
    color: var(--color-gold);
}

.site-logo a:hover,
.site-logo a:focus {
    text-decoration: none;
}

/* ====== Hamburger toggle (mobile only) ====== */
.nav-toggle {
    display: none; /* hidden on desktop */
    background: transparent;
    border: none;
    color: #2e4e7e;
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--spacing-xs);
    z-index: 1001;
    transition: color var(--transition-fast);
    line-height: 1;
}

.nav-toggle:hover,
.nav-toggle:focus {
    color: var(--color-gold);
    outline: none;
}

/* ====== Primary navigation ====== */
.site-nav {
    flex: 1;
    display: flex;
    justify-content: center;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-list li {
    margin: 0;
    position: relative;
}

.nav-list a {
    display: block;
    padding: 8px 14px;
    color: #2e4e7e;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: color var(--transition-fast);
    white-space: nowrap;
    border-radius: 6px;
}

.nav-list a:hover,
.nav-list a:focus {
    color: var(--color-gold);
    text-decoration: none;
}

/* Active page indicator */
.nav-list .current-menu-item > a,
.nav-list .current-page-ancestor > a {
    color: var(--color-gold);
    position: relative;
}

.nav-list .current-menu-item > a::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background-color: var(--color-gold);
    border-radius: 1px;
}

/* Bonus link in nav — subtle highlight */
.nav-bonus-link {
    background: linear-gradient(135deg, rgba(32, 178, 170, 0.08), rgba(72, 202, 228, 0.08));
    color: #1a8a82 !important;
    font-weight: 600 !important;
    border-radius: 16px !important;
    padding: 6px 16px !important;
    transition: all var(--transition-fast) !important;
}

.nav-bonus-link:hover {
    background: linear-gradient(135deg, rgba(32, 178, 170, 0.15), rgba(72, 202, 228, 0.15)) !important;
    color: #148a82 !important;
}

/* Books link subtle emphasis */
.nav-list a[href*="/books"] {
    font-style: italic;
}

/* ====== Dropdown menus ====== */
.nav-dropdown {
    position: relative;
}

.nav-dropdown .dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    user-select: none;
}

.nav-dropdown .dropdown-arrow {
    font-size: 0.75em;
    transition: transform var(--transition-fast);
    line-height: 1;
}

.nav-dropdown:hover .dropdown-arrow,
.nav-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    min-width: 190px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1000;
    list-style: none;
    margin: 0;
    padding: 6px 0;
    border: 1px solid rgba(46, 78, 126, 0.1);
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.dropdown-menu li {
    margin: 0;
}

.dropdown-menu a {
    display: block;
    padding: 10px 18px;
    color: #2e4e7e;
    text-decoration: none;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.15s ease;
    border-radius: 0;
    white-space: nowrap;
}

.dropdown-menu a:hover {
    background-color: rgba(200, 134, 62, 0.08);
    color: var(--color-gold);
}

/* ====== Right side: Login / User ====== */
.header-right-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    z-index: 1002;
}

/* Login button (not logged in) */
.header-login-btn {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #2e4e7e, #4a6fa5);
    color: #ffffff !important;
    padding: 7px 18px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(46, 78, 126, 0.3);
    transition: all var(--transition-fast);
    border: none;
    white-space: nowrap;
}

.header-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(46, 78, 126, 0.4);
    background: linear-gradient(135deg, #3a5e92, #5a7fb5);
    text-decoration: none;
    color: #ffffff !important;
}

/* Login/Signup text cycling animation */
.login-text {
    display: inline-block;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.login-text.fade-out {
    opacity: 0;
    transform: scale(0.85);
}

.login-text.fade-in {
    opacity: 1;
    transform: scale(1);
}

/* User dropdown (logged in) */
.user-dropdown-container {
    position: relative;
}

.user-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: 1px solid rgba(200, 134, 62, 0.3);
    background-color: rgba(200, 134, 62, 0.08);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    color: #2e4e7e;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.user-dropdown-trigger:hover,
.user-dropdown-trigger:focus {
    background-color: rgba(200, 134, 62, 0.15);
    border-color: var(--color-gold);
    color: var(--color-gold);
    outline: none;
}

.user-dropdown-trigger .dropdown-arrow {
    font-size: 0.7em;
    transition: transform var(--transition-fast);
    line-height: 1;
}

.user-dropdown-container.active .user-dropdown-trigger .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background-color: #ffffff;
    border: 1px solid rgba(46, 78, 126, 0.12);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 1003;
}

.user-dropdown-container.active .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-menu ul {
    list-style: none;
    padding: 6px 0;
    margin: 0;
}

.user-dropdown-menu li {
    border-bottom: 1px solid rgba(46, 78, 126, 0.06);
}

.user-dropdown-menu li:last-child {
    border-bottom: none;
}

.user-dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: #2e4e7e;
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition-fast);
}

.user-dropdown-menu a:hover,
.user-dropdown-menu a:focus {
    background-color: rgba(200, 134, 62, 0.08);
    color: var(--color-gold);
}

/* Visual separator between primary actions (profile / books / tools) and
   destructive secondary actions (reset password, logout) — prevents the
   misclick-into-reset-password problem reported by readers. */
.user-dropdown-menu .user-menu-divider {
    border-bottom: none;
    height: 6px;
    margin-top: 4px;
    background:
        linear-gradient(transparent calc(50% - 1px), rgba(46, 78, 126, 0.18) calc(50% - 1px), rgba(46, 78, 126, 0.18) calc(50% + 1px), transparent calc(50% + 1px));
    pointer-events: none;
}

.user-dropdown-menu .user-menu-secondary a {
    color: #6c7a8a;
    font-size: 13px;
    font-weight: 400;
}

.user-dropdown-menu .user-menu-secondary a:hover,
.user-dropdown-menu .user-menu-secondary a:focus {
    color: #c0392b; /* warn color on destructive items */
    background-color: rgba(192, 57, 43, 0.06);
}

/* Calendar Tools sub-dropdown */
.tools-dropdown-item {
    position: relative;
}

.tools-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: #2e4e7e;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    transition: all var(--transition-fast);
}

.tools-dropdown-trigger:hover,
.tools-dropdown-trigger:focus {
    background-color: rgba(200, 134, 62, 0.08);
    color: var(--color-gold);
}

.tools-arrow {
    font-size: 0.7em;
    transition: transform var(--transition-fast);
}

.tools-dropdown-item:hover .tools-arrow {
    transform: translateX(2px);
}

.tools-submenu {
    position: absolute;
    right: 100%;
    left: auto;
    top: 0;
    background-color: #ffffff;
    border: 1px solid rgba(46, 78, 126, 0.12);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    min-width: 170px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(8px);
    transition: all 0.2s ease;
    z-index: 1004;
    margin-right: 4px;
}

.tools-dropdown-item:hover .tools-submenu {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.tools-submenu ul {
    list-style: none;
    padding: 6px 0;
    margin: 0;
}

.tools-submenu li {
    border-bottom: 1px solid rgba(46, 78, 126, 0.06);
}

.tools-submenu li:last-child {
    border-bottom: none;
}

.tools-submenu a {
    display: block;
    padding: 10px 16px;
    color: #2e4e7e;
    text-decoration: none;
    font-size: 13px;
    transition: all var(--transition-fast);
}

.tools-submenu a:hover,
.tools-submenu a:focus {
    background-color: rgba(200, 134, 62, 0.08);
    color: var(--color-gold);
}

/* ====== Body padding for fixed header ====== */
body {
    padding-top: 64px;
}

/* ====== Desktop (768px+) ====== */
@media (min-width: 768px) {
    .site-header-inner {
        height: 68px;
    }

    body {
        padding-top: 68px;
    }

    .logo-image {
        height: 40px;
        max-width: 40px;
    }

    .logo-icon {
        font-size: 2rem;
        width: 40px;
        height: 40px;
    }

    .logo-text {
        font-size: 1.3rem;
    }
}

/* Large desktop (1200px+) */
@media (min-width: 1200px) {
    .nav-list {
        gap: 6px;
    }

    .nav-list a {
        padding: 8px 16px;
        font-size: 15px;
    }
}

/* Medium screens — tighter spacing */
@media (min-width: 768px) and (max-width: 1024px) {
    .nav-list {
        gap: 0;
    }

    .nav-list a {
        padding: 8px 10px;
        font-size: 14px;
    }

    .logo-text {
        font-size: 1.1rem;
    }
}

/* ====== Mobile (< 768px) ====== */
@media (max-width: 767px) {
    .site-header-inner {
        height: 56px;
        flex-wrap: wrap;
    }

    body {
        padding-top: 56px;
    }

    .site-logo {
        order: 1;
        flex: 0 0 auto;
    }

    .logo-image {
        height: 32px;
        max-width: 32px;
    }

    .logo-icon {
        font-size: 1.6rem;
        width: 32px;
        height: 32px;
    }

    .logo-text {
        font-size: 1rem;
    }

    .site-logo a {
        gap: 0.3rem;
    }

    /* Hamburger visible on mobile */
    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        order: 2;
    }

    /* Login/User on right */
    .header-right-tools {
        order: 3;
        flex: 0 0 auto;
    }

    .header-login-btn {
        padding: 5px 14px;
        font-size: 13px;
    }

    /* Nav collapses below header row */
    .site-nav {
        order: 4;
        width: 100%;
        flex: 0 0 100%;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .site-nav.active {
        max-height: 400px;
        border-top: 1px solid rgba(46, 78, 126, 0.08);
        background: #ffffff;
    }

    .nav-list {
        flex-direction: column;
        gap: 0;
        padding: 8px 0;
    }

    .nav-list li {
        width: 100%;
    }

    .nav-list a {
        text-align: center;
        padding: 12px 16px;
        font-size: 15px;
        border-radius: 0;
    }

    .nav-bonus-link {
        border-radius: 0 !important;
        background: transparent !important;
        color: #1a8a82 !important;
    }

    /* Mobile dropdown */
    .dropdown-menu {
        position: static;
        transform: none;
        background: rgba(46, 78, 126, 0.03);
        box-shadow: none;
        border: none;
        border-radius: 0;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, opacity 0.2s ease;
        opacity: 0;
        visibility: hidden;
    }

    .nav-dropdown.active .dropdown-menu {
        max-height: 300px;
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    .nav-dropdown:hover .dropdown-menu {
        /* Disable hover on mobile — use click only */
        opacity: 0;
        visibility: hidden;
    }

    .nav-dropdown.active .dropdown-menu {
        opacity: 1;
        visibility: visible;
    }

    .dropdown-menu a {
        text-align: center;
        padding: 10px 16px;
        font-size: 14px;
        color: #4a6fa5;
    }

    .nav-dropdown .dropdown-trigger {
        justify-content: center;
    }

    /* Active page underline on mobile */
    .nav-list .current-menu-item > a::after {
        width: 40px;
    }

    /* User dropdown positioning on mobile */
    .user-dropdown-menu {
        right: -10px;
        min-width: 160px;
    }

    .user-dropdown-trigger {
        padding: 5px 10px;
        font-size: 13px;
    }

    /* Calendar tools submenu below parent on mobile */
    .tools-submenu {
        position: static;
        margin-left: 0;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
        border-radius: 0;
        border: none;
    }
}

/* ====== Cart styles (preserved from original) ====== */
.header-cart {
    position: relative;
    z-index: 1001;
}

.cart-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #2e4e7e;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    background: rgba(142, 202, 230, 0.1);
    transition: all var(--transition-fast);
    border: 2px solid transparent;
}

.cart-link:hover {
    background: rgba(142, 202, 230, 0.2);
    border-color: rgba(142, 202, 230, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(142, 202, 230, 0.3);
}

.cart-icon {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-count {
    background: #ff6b6b;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1;
    min-width: 20px;
}

.cart-count:empty,
.cart-count[data-count="0"] {
    display: none;
}

.cart-total {
    font-size: 0.9rem;
    color: #2e4e7e;
    font-weight: 700;
}

.cart-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 350px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(142, 202, 230, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
    z-index: 1002;
    max-height: 400px;
    overflow: hidden;
}

.header-cart:hover .cart-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cart-dropdown-content {
    padding: 1rem;
}

.cart-items {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.cart-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid rgba(142, 202, 230, 0.1);
    border-radius: 8px;
    transition: background var(--transition-fast);
}

.cart-item:hover {
    background: rgba(142, 202, 230, 0.05);
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-image img {
    width: 50px;
    height: 70px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(142, 202, 230, 0.2);
}

.cart-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cart-item-details h4 {
    font-size: 0.9rem;
    color: #2e4e7e;
    margin: 0;
    line-height: 1.3;
    font-weight: 600;
}

.cart-item-quantity,
.cart-item-price {
    font-size: 0.8rem;
    color: #666;
}

.cart-item-price {
    font-weight: 700;
    color: #ff6b6b;
}

.cart-dropdown-footer {
    border-top: 2px solid rgba(142, 202, 230, 0.1);
    padding-top: 1rem;
}

.cart-dropdown-total {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: #2e4e7e;
}

.cart-dropdown-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-view-cart,
.btn-checkout {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    border: 2px solid;
}

.btn-view-cart {
    background: white;
    color: #2e4e7e;
    border-color: #2e4e7e;
}

.btn-view-cart:hover {
    background: #2e4e7e;
    color: white;
}

.btn-checkout {
    background: #ff6b6b;
    color: white;
    border-color: #ff6b6b;
}

.btn-checkout:hover {
    background: #ff5252;
    border-color: #ff5252;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.cart-empty {
    text-align: center;
    padding: 2rem 1rem;
}

.cart-empty p {
    color: #666;
    margin-bottom: 1rem;
    font-style: italic;
}

.btn-shop-now {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #2e4e7e 0%, #1e3c72 100%);
    color: white;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.btn-shop-now:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 78, 126, 0.3);
}

@media (max-width: 767px) {
    .header-cart {
        order: 2;
    }

    .cart-link {
        padding: 0.4rem 0.8rem;
        gap: 0.3rem;
    }

    .cart-icon {
        font-size: 1.3rem;
    }

    .cart-total {
        display: none;
    }

    .cart-dropdown {
        width: 280px;
    }
}
