@import url("https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap");

body {
    background-color: #3e3e3e;
}

.buttons {
    font-family: "Space Mono", monospace;
    color: aliceblue;
    margin-left: 20%;
    margin-top: 250px;
    font-size: 18px;
    padding-left: 0;
    list-style: none;
}

#title {
    font-size: 22px;
    display: inline-block; /* shrink to text width so .socials sits at text edge */
}

#menu {
    opacity: 0;
    transition: opacity 300ms ease;
    pointer-events: none;
}

#menu.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Ensure UI sits above the background canvas */
body > canvas {
    z-index: -1; /* nlights canvas uses inline z-index:0; keep any other canvases behind UI */
}

ol.buttons,
#loading-overlay {
    position: relative;
    z-index: 1;
}

/* 8-bit retro loading overlay */
#loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none; /* allow background interaction */
}

.loading-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.loading-bar {
    width: 200px;
    height: 16px;
    background: transparent;
    border: 4px solid #fff; /* white pixel frame */
    image-rendering: pixelated;
    box-shadow: none;
    position: relative;
}

.loading-bar-fill {
    height: 100%;
    width: 0%;
    background: #fff;
    box-shadow: none;
    transition: none;
}

/* Hide overlay when done */
#loading-overlay.hidden {
    display: none;
}

/* Hover dropdown: show "Reading" to the right of "Log" without shifting layout */
#log {
    position: relative;
    display: inline-block;
    cursor: default;
    user-select: none;

    width: 100px;
}

#log .reading {
    position: absolute;
    top: 0;
    left: 100%;
    width: 900px; /* explicit width to override inline-block constraints */
    white-space: wrap; /* prevent text wrapping if needed */
    margin-left: 0; /* remove gap to avoid hover flicker */
    padding-left: 36px; /* keep visual spacing without creating a gap */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition:
        opacity 200ms ease,
        transform 200ms ease,
        visibility 0s linear 200ms;
    pointer-events: none;
    z-index: 2;
}

#log:hover .reading,
#log .reading:hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s, 0s, 0s; /* make visibility immediate on show */
    pointer-events: auto;
}

/* Also show when JS adds 'open' class (for delayed hide) */
#log.open .reading,
#log .reading.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s, 0s, 0s;
    pointer-events: auto;
}

/* Waterfall children inside the reading dropdown (programmatic via CSS vars) */
#log .reading > * {
    opacity: 0;
    transform: translateY(-6px);
    transition:
        opacity 100ms ease,
        transform 100ms ease;
}

#log:hover .reading > *,
#log .reading:hover > * {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--stagger-index, 0) * var(--stagger-step, 40ms));
}

/* Also show children when JS adds 'open' class */
#log.open .reading > *,
#log .reading.open > * {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--stagger-index, 0) * var(--stagger-step, 40ms));
}

#log .reading a {
    text-decoration: none;
    color: inherit;
}

#log .reading a:hover {
    text-decoration: none;
    color: #ffe100;
}

/* Socials dropdown to the right of title with upward waterfall */
#title,
.title {
    position: relative;
}

#title .socials,
.title .socials {
    position: absolute;
    bottom: 0; /* anchor to bottom so it visually grows upward */
    left: 100%;
    margin-left: 0; /* avoid hover gap */
    padding-left: 13px; /* visual spacing without a gap */
    padding-bottom: 3px;
    width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px); /* start slightly below, animate upward */
    transition:
        opacity 200ms ease,
        transform 200ms ease,
        visibility 0s linear 200ms;
    pointer-events: none;
    z-index: 2;
    font-size: 18px;
}

/* Show on hover and when open */
#title:hover .socials,
#title .socials:hover,
.title:hover .socials,
.title .socials:hover,
#title.open .socials,
.title.open .socials,
#title .socials.open,
.title .socials.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s, 0s, 0s;
    pointer-events: auto;
}

/* Children waterfall upward (reverse stagger) */
#title .socials > *,
.title .socials > * {
    opacity: 0;
    transform: translateY(6px); /* animate upward */
    transition:
        opacity 100ms ease,
        transform 100ms ease;
}

#title:hover .socials > *,
#title .socials:hover > *,
.title:hover .socials > *,
.title .socials:hover > *,
#title.open .socials > *,
.title.open .socials > *,
#title .socials.open > *,
.title .socials.open > * {
    opacity: 1;
    transform: translateY(0);
    transition-delay: calc(var(--stagger-index, 0) * var(--stagger-step, 40ms));
}

/* Link style inside socials */
#title .socials a,
.title .socials a {
    text-decoration: none;
    color: inherit;
}
#title .socials a:hover,
.title .socials a:hover {
    text-decoration: none;
    color: #ffe100;
}

/* Mobile-only helper */
.mobile-only {
    display: none;
}

/* Prefer capability-based detection */
@media (hover: none) and (pointer: coarse) {
    .mobile-only {
        display: block;
    }
}

/* Fallback for small screens */
@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
}
