/* ==================== CSS Variables ==================== */
:root {
    --color-bg: #000;
    --color-primary: #fff;
    --menu-item-width: 292px;
    --menu-item-padding: 10px 20px;
    --menu-expand-height: 90vh;
    --menu-expand-margin: -44.5vh;
    --bullet-spacing: 42px;
    --bullet-top-padding: 15px;
    --animation-fast: 0.25s;
    --animation-medium: 0.5s;
    --animation-slow: 1s;
    --scrollbar-width: 36px;
    --scrollbar-visual-width: 2px;

    /* Safe area insets for mobile notches/browser UI */
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==================== Base Styles ==================== */
body {
    margin: 0;
    padding: 0;
    height: 100vh;
    background: var(--color-bg);
    overflow: hidden;
    font-family: 'Averia Serif Libre', serif;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== Star Background ==================== */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: var(--color-bg);
    z-index: 1;
}

.star {
    position: absolute;
    background: var(--color-primary);
    border-radius: 50%;
    opacity: 0;
}

.star.size-1 { width: 0.5px; height: 0.5px; }
.star.size-2 { width: 1px; height: 1px; }
.star.size-3 { width: 1.5px; height: 1.5px; }

.star.twinkle-1 { animation: twinkle1 4s infinite; }
.star.twinkle-2 { animation: twinkle2 5s infinite; }
.star.twinkle-3 { animation: twinkle3 6s infinite; }
.star.twinkle-4 { animation: twinkle4 4.5s infinite; }

.star.static {
    opacity: 0.3;
    width: 0.5px;
    height: 0.5px;
}

@keyframes twinkle1 {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    25% { opacity: 1; transform: scale(1.2); }
    50% { opacity: 0.5; transform: scale(1); }
    75% { opacity: 0.8; transform: scale(1.1); }
}

@keyframes twinkle2 {
    0%, 100% { opacity: 0.2; transform: scale(1); }
    30% { opacity: 0.9; transform: scale(1.3); }
    60% { opacity: 0.4; transform: scale(1); }
}

@keyframes twinkle3 {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    20% { opacity: 0.1; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.4); }
    80% { opacity: 0.6; transform: scale(1.1); }
}

@keyframes twinkle4 {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    33% { opacity: 0.2; transform: scale(0.9); }
    66% { opacity: 0.9; transform: scale(1.2); }
}

/* ==================== Floating Social Icons ==================== */
.social-star-container {
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-star-container {
    position: absolute;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.social-star-img-container {
    position: relative;
    transition: filter 0.3s ease, transform 0.3s ease;
    transform: scale(1);
}

.social-star {
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: pointer;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
    color: var(--color-primary);
    font-family: 'Averia Serif Libre', serif;
    font-weight: 700;
    font-size: 12px;
    text-align: center;
    display: block;
}

.social-star-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
    color: var(--color-primary);
    font-family: 'Averia Serif Libre', serif;
    font-weight: 700;
    font-size: 12px;
    text-align: center;
}

.social-star-container:hover .social-star-img-container {
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.43))
            drop-shadow(0 0 4px rgba(255, 255, 255, 0.34));
    transform: scale(1.02);
}

.social-star-container:hover .social-star-hover-overlay {
    opacity: 1;
}

.social-star.social-twinkle-1 {
    animation: socialTwinkle1 8s infinite;
    opacity: 0.85;
}
.social-star.social-twinkle-2 {
    animation: socialTwinkle2 9s infinite;
    opacity: 0.6;
}
.social-star.social-twinkle-3 {
    animation: socialTwinkle3 8.5s infinite;
    opacity: 0.75;
}
.social-star.social-twinkle-4 {
    animation: socialTwinkle4 7.5s infinite;
    opacity: 0.7;
}

@keyframes socialTwinkle1 {
    0%, 100% { opacity: 0.85; }
    25% { opacity: 0.7; }
    50% { opacity: 0.4; }
    75% { opacity: 0.75; }
}

@keyframes socialTwinkle2 {
    0%, 100% { opacity: 0.6; }
    30% { opacity: 0.85; }
    60% { opacity: 0.45; }
    80% { opacity: 0.7; }
}

@keyframes socialTwinkle3 {
    0%, 100% { opacity: 0.75; }
    20% { opacity: 0.5; }
    40% { opacity: 0.85; }
    60% { opacity: 0.4; }
    80% { opacity: 0.65; }
}

@keyframes socialTwinkle4 {
    0%, 100% { opacity: 0.7; }
    25% { opacity: 0.45; }
    50% { opacity: 0.8; }
    75% { opacity: 0.4; }
    90% { opacity: 0.85; }
}

/* ==================== Menu Styles ==================== */
.menu-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    gap: 40px;
    z-index: 10;
    align-items: center;
    height: 0;
}

.menu-item {
    background: var(--color-bg);
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    padding: var(--menu-item-padding);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.5s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: var(--menu-item-width);
    height: 1em;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.menu-item span {
    transition: opacity 0.25s ease;
    white-space: nowrap;
    position: relative;
    z-index: 1;
    font-family: 'Averia Serif Libre', serif;
    font-weight: 700;
}

/* Desktop-only hover behavior */
@media (min-width: 769px) {
    .menu-item:hover {
        height: var(--menu-expand-height);
        margin-top: var(--menu-expand-margin);
        margin-bottom: var(--menu-expand-margin);
    }

    .menu-item:hover span {
        opacity: 0;
    }
}

/* ==================== Content Scrolling ==================== */
.scroll-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    transition: opacity var(--animation-medium) ease var(--animation-medium);
    pointer-events: none;
}

.menu-item:hover .scroll-wrapper {
    opacity: 1;
    pointer-events: auto;
    transition-delay: var(--animation-medium);
}

.menu-item:not(:hover) .scroll-wrapper {
    opacity: 0;
    transition: opacity 0.17s ease;
    transition-delay: 0s;
}

.scroll-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 23px;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.scroll-container::-webkit-scrollbar {
    display: none;
}

/* ==================== Custom Scrollbar ==================== */
.custom-scrollbar {
    position: absolute;
    right: -13px;
    top: 10px;
    bottom: 20px;
    width: var(--scrollbar-width);
    opacity: 0;
    transition: opacity 0.4s ease; /* Slower fade-in */
    pointer-events: none;
}

.custom-scrollbar-track {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    background: transparent;
    cursor: pointer;
}

.custom-scrollbar-thumb {
    position: absolute;
    left: 17px;
    width: 0;
    height: 10px;
    border-left: var(--scrollbar-visual-width) solid var(--color-primary);
    background: transparent;
    cursor: pointer;
    transition: none;
}

.custom-scrollbar-thumb::before {
    content: '';
    position: absolute;
    left: -17px;
    width: var(--scrollbar-width);
    top: 0;
    bottom: 0;
    background: transparent;
    cursor: pointer;
}

.custom-scrollbar-thumb:hover,
.custom-scrollbar-thumb:active,
.custom-scrollbar-thumb.dragging {
    border-left: var(--scrollbar-visual-width) solid var(--color-primary);
    background: transparent;
    width: 0;
    left: 17px;
}

/* ==================== Content Flow ==================== */
.content-flow-wrapper {
    padding: 20px;
    color: var(--color-primary);
    font-size: 14px;
    font-family: 'Averia Serif Libre', serif;
    font-weight: 700;
}

.content-line {
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
    margin-bottom: 8px;
}

.content-header {
    margin-top: 12px;
    margin-bottom: 8px;
}

.content-spacer {
    height: 8px;
    margin: 0;
}

.content-paragraph {
    line-height: 1.5;
}

.content-bullet {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: 0;
}

.content-bullet .bullet-dot {
    width: 7px;
    height: 7px;
    background: var(--color-primary);
    border-radius: 50%;
    flex-shrink: 0;
}

.content-bullet .bullet-text {
    color: var(--color-primary);
    font-size: 14px;
    font-family: 'Averia Serif Libre', serif;
    font-weight: 700;
    flex: 1;
}

.content-line a,
.content-bullet .bullet-text a {
    color: #9370DB;
    text-decoration: none;
    border-bottom: 1px solid rgba(147, 112, 219, 0.5);
    transition: border-bottom-color 0.3s ease, color 0.3s ease;
}

.content-line a:hover,
.content-bullet .bullet-text a:hover {
    color: #BA55D3;
    border-bottom-color: rgba(186, 85, 211, 1);
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* ==================== Notifications ==================== */
.notification {
    position: fixed;
    top: 20px;
    background: var(--color-bg);
    border: 2px solid var(--color-primary);
    padding: 10px 32px 10px 12px;
    font-size: 14px;
    font-family: 'Averia Serif Libre', serif;
    font-weight: 700;
    color: var(--color-primary);
    z-index: 8;
}

#notification2 {
    left: calc(50% - 177px);
}

.notification.dismissing {
    animation: notificationBounceOut 0.6s ease-in-out forwards;
}

@keyframes notificationBounceOut {
    0% {
        top: 20px;
    }
    30% {
        top: 40px;
    }
    100% {
        top: -200px;
    }
}

.notification a {
    color: #9370DB;
    text-decoration: none;
    border-bottom: 1px solid rgba(147, 112, 219, 0.5);
    transition: border-bottom-color 0.3s ease, color 0.3s ease;
}

.notification a:hover {
    color: #BA55D3;
    border-bottom-color: rgba(186, 85, 211, 1);
}

.close-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    line-height: 20px;
    font-family: 'Averia Serif Libre', serif;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #999;
}

/* ==================== Utility Classes ==================== */
.keyboard-nav .menu-item:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

/* ==================== Mobile Styles ==================== */
@media (max-width: 768px) {
    /* Mobile-specific menu layout - vertical stacking */
    .menu-container {
        flex-direction: column;
        gap: 20px;
        height: auto;
        top: 50%;
        transform: translate(-50%, -50%);
    }

    /* Mobile menu items - clean slate approach */
    .menu-item {
        width: 280px;
        height: 1em;
        max-height: 1em;
        flex-shrink: 0;
        transition: height 0.5s ease, max-height 0.5s ease, opacity 0.5s ease;
    }

    /* No hover effects on mobile - keep items at base size */
    .menu-item:hover {
        height: 1em;
        max-height: 1em;
        margin-top: 0;
        margin-bottom: 0;
    }

    .menu-item:hover span {
        opacity: 1;
    }

    /* Mobile expansion - this MUST win over any other rules */
    .menu-item.mobile-expanded {
        /* Use smaller height and account for browser chrome */
        height: min(60vh, calc(100vh - var(--safe-area-top) - var(--safe-area-bottom) - 120px)) !important;
        max-height: 500px !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        transition: height 0.5s ease, max-height 0.5s ease, opacity 0.5s ease !important;
    }

    /* Show content when expanded on mobile */
    .menu-item.mobile-expanded .scroll-wrapper {
        opacity: 1 !important;
        pointer-events: auto;
        transition-delay: var(--animation-medium);
    }

    /* Hide span when expanded on mobile */
    .menu-item.mobile-expanded span {
        opacity: 0 !important;
    }

    /* Fix scrollbar positioning for mobile - match desktop */
    .menu-item.mobile-expanded .custom-scrollbar {
        right: -13px;
        top: 10px;
        bottom: 20px;
    }

    /* Allow scrolling within expanded mobile menus */
    .menu-item.mobile-expanded .scroll-container {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
        right: 23px;
    }

    /* Ensure bullet items work properly with smooth fade transitions */
    .menu-item.mobile-expanded .bullet-item {
        pointer-events: auto;
        touch-action: pan-y;
        transition: opacity 0.3s ease;
    }

    /* Fast fade-out for mobile bullet items when closing */
    .menu-item .bullet-item {
        transition: opacity 0.17s ease;
    }

    /* Faster fade specifically when mobile-expanded class is removed */
    .menu-item:not(.mobile-expanded) .bullet-item {
        opacity: 0;
        transition: opacity 0.17s ease;
    }

    /* Fast fade-out for scroll-wrapper when closing on mobile */
    .menu-item:not(.mobile-expanded) .scroll-wrapper {
        opacity: 0;
        transition: opacity 0.17s ease;
        transition-delay: 0s;
    }

    /* Adjust social star sizes for mobile */
    .social-star {
        font-size: 10px;
    }

    /* Add padding to account for browser UI on mobile */
    body {
        padding-top: var(--safe-area-top);
        padding-bottom: var(--safe-area-bottom);
    }

    /* Mobile-specific variables */
    :root {
        --menu-item-width: 280px;
        --menu-expand-height: min(60vh, calc(100vh - 120px));
    }

    /* Mobile notification adjustments */
    .notification {
        font-size: 12px;
        padding: 8px 32px 8px 12px;
        max-width: calc(100vw - 40px);
        top: calc(20px + var(--safe-area-top));
        transition: top 0.5s ease;
    }

    #notification2 {
        left: 50%;
        transform: translateX(-50%);
    }

    /* On mobile, dismissing animation should start from current position */
    .notification.dismissing {
        animation: none;
        transform: translateX(-50%);
        transition: top 0.6s ease-in-out;
        top: calc(-200px + var(--safe-area-top));
    }

    .close-btn {
        right: 6px;
        font-size: 18px;
    }
}