*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overscroll-behavior: none;
    touch-action: manipulation;
    font-family: "EB Garamond", serif;
}

body {
    background: linear-gradient(135deg, #1c1f26, #2a2d34);
    min-height: 100vh;
    overflow: hidden;
    transition: background 1s ease-in-out, color 1s ease-in-out;
}

/* --- Vanta background layer --- */

#vanta-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    pointer-events: none;
}

/* --- Header (rainy glass) --- */

.site-header {
    position: relative;
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    padding: 18px 24px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.5s ease-in-out, box-shadow 0.5s ease-in-out;
    z-index: 20;
    overflow: hidden;
}

.site-header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle 2px at 12% 30%, rgba(255,255,255,0.25) 0%, transparent 100%),
        radial-gradient(circle 1.5px at 28% 65%, rgba(255,255,255,0.2) 0%, transparent 100%),
        radial-gradient(circle 2.5px at 45% 20%, rgba(255,255,255,0.18) 0%, transparent 100%),
        radial-gradient(circle 1px at 58% 75%, rgba(255,255,255,0.22) 0%, transparent 100%),
        radial-gradient(circle 2px at 72% 40%, rgba(255,255,255,0.2) 0%, transparent 100%),
        radial-gradient(circle 1.5px at 85% 55%, rgba(255,255,255,0.15) 0%, transparent 100%),
        radial-gradient(circle 3px at 35% 50%, rgba(255,255,255,0.12) 0%, transparent 100%),
        radial-gradient(circle 1px at 92% 25%, rgba(255,255,255,0.2) 0%, transparent 100%),
        radial-gradient(circle 2px at 8% 70%, rgba(255,255,255,0.16) 0%, transparent 100%),
        radial-gradient(circle 1.5px at 65% 15%, rgba(255,255,255,0.18) 0%, transparent 100%);
    pointer-events: none;
    z-index: 1;
    animation: dropletShimmer 6s ease-in-out infinite alternate;
}

.site-header::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.06) 40%, transparent 100%) 18% 0 / 1px 100% no-repeat,
        linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.04) 60%, transparent 100%) 42% 0 / 1px 100% no-repeat,
        linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.05) 30%, transparent 100%) 67% 0 / 1px 100% no-repeat,
        linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.03) 50%, transparent 100%) 88% 0 / 1px 100% no-repeat;
    pointer-events: none;
    z-index: 1;
    animation: rainStreaks 4s linear infinite;
}

@keyframes dropletShimmer {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

@keyframes rainStreaks {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

.site-title {
    font-family: "Poiret One", "EB Garamond", serif;
    font-size: 30px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 6px;
    text-transform: uppercase;
    text-decoration: none;
    transition: color 0.3s ease-in-out, letter-spacing 0.4s ease, text-shadow 0.4s ease;
    position: relative;
    z-index: 2;
}

.site-title:hover {
    color: #D49A89;
    letter-spacing: 8px;
    text-shadow: 0 0 12px rgba(212, 154, 137, 0.2);
}

.lit .site-header {
    background: rgba(40, 40, 40, 0.5);
    backdrop-filter: blur(18px) saturate(1.3) brightness(1.1);
    box-shadow: 0 0 25px rgba(255, 230, 180, 0.3),
                0 0 50px rgba(255, 200, 120, 0.15);
}

/* --- Navigation buttons --- */

#main {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    flex-direction: column;
    gap: 40px;
}

#main > a {
    position: relative;
    display: inline-block;
    padding: 18px 58px;
    color: rgba(212, 154, 137, 0.7);
    border: 1px solid rgba(212, 154, 137, 0.15);
    background: transparent;
    font-family: "Poiret One", "EB Garamond", serif;
    font-size: 20px;
    text-decoration: none;
    text-transform: uppercase;
    overflow: visible;
    transition: color 0.3s, border-color 0.3s, box-shadow 0.5s;
    letter-spacing: 10px;
    border-radius: 0;
    z-index: 10;
}

/* Gravitational lens distortion layer */
#main > a .lens-warp {
    position: absolute;
    inset: -10px -16px;
    backdrop-filter: url(#grav-lens);
    -webkit-backdrop-filter: url(#grav-lens);
    z-index: -1;
    pointer-events: none;
    border-radius: 50%;
    mask-image: radial-gradient(ellipse 100% 100% at center, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse 100% 100% at center, black 30%, transparent 70%);
}

#main > a:nth-child(1) { animation: drift 10s ease-in-out infinite; }
#main > a:nth-child(2) { animation: drift 10s ease-in-out 3.3s infinite; }
#main > a:nth-child(3) { animation: drift 10s ease-in-out 6.6s infinite; }

@keyframes drift {
    0%, 100% { transform: translateY(0) translateX(0); }
    25% { transform: translateY(-4px) translateX(2px); }
    75% { transform: translateY(3px) translateX(-2px); }
}

/* Scanline overlay */
#main > a::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.08) 2px,
        rgba(0, 0, 0, 0.08) 4px
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s;
    clip-path: inset(0);
}

#main > a:hover::after {
    opacity: 1;
}

/* Animated border spans: top, right, bottom, left */
#main > a span {
    position: absolute;
    display: block;
    background: #D49A89;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#main > a span:nth-of-type(1) {
    top: 0; left: 0; right: 0;
    height: 1px;
    transform: scaleX(0);
    transform-origin: right;
}
#main > a span:nth-of-type(2) {
    top: 0; right: 0; bottom: 0;
    width: 1px;
    transform: scaleY(0);
    transform-origin: bottom;
}
#main > a span:nth-of-type(3) {
    bottom: 0; left: 0; right: 0;
    height: 1px;
    transform: scaleX(0);
    transform-origin: left;
}
#main > a span:nth-of-type(4) {
    top: 0; left: 0; bottom: 0;
    width: 1px;
    transform: scaleY(0);
    transform-origin: top;
}

#main > a:hover span:nth-of-type(1) { transform: scaleX(1); transform-origin: left; }
#main > a:hover span:nth-of-type(2) { transform: scaleY(1); transform-origin: top; }
#main > a:hover span:nth-of-type(3) { transform: scaleX(1); transform-origin: right; }
#main > a:hover span:nth-of-type(4) { transform: scaleY(1); transform-origin: bottom; }

#main > a:hover {
    color: #D49A89;
    border-color: rgba(212, 154, 137, 0.3);
    box-shadow: 0 0 20px rgba(212, 154, 137, 0.1);
    animation-play-state: paused;
}

/* --- Day mode --- */

.day-mode .site-title {
    color: rgba(55, 40, 30, 0.85);
}

.day-mode .site-title:hover {
    color: #8B5E3C;
    text-shadow: none;
}

.day-mode #main > a {
    color: rgba(60, 42, 30, 0.75);
    border-color: rgba(90, 65, 45, 0.2);
}

.day-mode #main > a span {
    background: rgba(90, 65, 45, 0.5);
}

.day-mode #main > a:hover {
    color: rgba(45, 30, 18, 0.95);
    border-color: rgba(90, 65, 45, 0.4);
    box-shadow: 0 0 15px rgba(90, 65, 45, 0.1);
}

/* --- Night mode --- */

.night-mode #main > a {
    position: relative;
}

.night-mode #main > a span {
    box-shadow: 0 0 6px rgba(212, 154, 137, 0.5),
                0 0 15px rgba(212, 154, 137, 0.15);
}

.night-mode #main > a::before {
    content: attr(data-text);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
    color: rgba(212, 154, 137, var(--neon-opacity, 0.2));
    filter: blur(var(--neon-blur, 4px));
    transition: opacity 0.5s, filter 0.5s;
    font-family: "Poiret One", "EB Garamond", serif;
    font-size: 20px;
    text-transform: uppercase;
    letter-spacing: 10px;
    pointer-events: none;
}

.night-mode #main > a:hover {
    color: rgba(212, 154, 137, 0.95);
    text-shadow: 0 0 8px rgba(212, 154, 137, 0.4),
                 0 0 25px rgba(212, 154, 137, 0.15);
    box-shadow: 0 0 25px rgba(212, 154, 137, 0.12),
                0 0 60px rgba(212, 154, 137, 0.04);
}

.night-mode #main > a:hover span {
    box-shadow: 0 0 10px rgba(212, 154, 137, 0.7),
                0 0 25px rgba(212, 154, 137, 0.25);
}

/* --- Mode toggle button (tucked behind header) --- */

#indexModeToggle {
    position: relative;
    margin-top: -20px;
    left: 20px;
    padding: 12px 30px;
    font-size: 20px;
    font-weight: bold;
    text-transform: uppercase;
    color: rgba(230, 187, 172, 0.3);
    background: none;
    border: 2px solid rgba(165, 155, 152, 0.3);
    border-radius: 0 0 8px 8px;
    border-top: none;
    cursor: pointer;
    transition: all 0.4s ease-in-out;
    box-shadow: 0 0 5px rgba(231, 158, 133, 0.1);
    backdrop-filter: blur(5px);
    z-index: 8;
}

#indexModeToggle:hover {
    color: #fff;
    background: rgba(231, 158, 133, 0.6);
    border-color: #F4B8A2;
    box-shadow: 0 0 15px rgba(231, 158, 133, 0.8),
                0 0 30px rgba(231, 158, 133, 0.6),
                0 0 50px rgba(231, 158, 133, 0.4);
    transform: scale(1.1);
    animation: neonGlow 1s infinite alternate;
}

.day-mode #indexModeToggle {
    background: rgba(160, 130, 100, 0.15);
    color: rgba(100, 80, 60, 0.4);
    border-color: rgba(140, 115, 85, 0.25);
    box-shadow: 0 0 5px rgba(140, 115, 85, 0.08);
}

.day-mode #indexModeToggle:hover {
    background: rgba(140, 110, 80, 0.3);
    color: rgba(80, 60, 40, 0.9);
    border-color: rgba(140, 115, 85, 0.5);
    box-shadow: 0 2px 12px rgba(140, 115, 85, 0.25);
    animation: none;
}

.night-mode #indexModeToggle {
    background: rgba(255, 155, 80, 0.3);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 155, 80, 0.6);
}

@keyframes neonGlow {
    0% {
        box-shadow: 0 0 10px rgba(231, 158, 133, 0.6),
                    0 0 20px rgba(231, 158, 133, 0.4);
    }
    100% {
        box-shadow: 0 0 15px rgba(231, 158, 133, 0.8),
                    0 0 30px rgba(231, 158, 133, 0.6),
                    0 0 50px rgba(231, 158, 133, 0.4);
    }
}

/* --- Lamp --- */

#lamp-container {
    position: absolute;
    top: 0;
    right: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: grab;
    user-select: none;
    transform-origin: top center;
    z-index: 5;
}

#lamp-string {
    width: 3px;
    height: 100px;
    background: linear-gradient(to bottom, #888, #555);
    border-radius: 1px;
}

#lamp-bulb {
    width: 18px;
    height: 72px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.7), rgba(255, 245, 200, 0.5));
    border-radius: 9px;
    position: relative;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 20px rgba(255, 255, 200, 0.3), 0 0 40px rgba(255, 200, 100, 0.15);
    transition: background 0.5s ease-in-out, box-shadow 0.5s ease-in-out;
    backdrop-filter: blur(4px);
}

#lamp-light {
    position: absolute;
    top: 50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255, 255, 180, 0) 0%, transparent 100%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.5s ease-in-out, background 0.5s ease-in-out;
    pointer-events: none;
}

.lit #lamp-bulb {
    background: linear-gradient(to bottom, rgba(255, 255, 220, 0.9), rgba(255, 230, 150, 0.8));
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 35px rgba(255, 235, 180, 0.8), 0 0 70px rgba(255, 200, 100, 0.4);
}

.lit #lamp-light {
    opacity: 1;
    background: radial-gradient(circle,
        rgba(255, 235, 180, 0.5) 0%,
        rgba(255, 200, 100, 0.25) 40%,
        rgba(255, 180, 90, 0.1) 70%,
        transparent 100%
    );
    filter: blur(10px);
    box-shadow: 0 0 50px rgba(255, 220, 150, 0.4),
                0 0 100px rgba(255, 200, 100, 0.3);
}

/* --- Page transitions --- */

.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.fade-in {
    opacity: 0;
    animation: fadeIn 0.8s ease-in-out forwards;
}

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

/* --- Responsive --- */

@media (max-width: 768px) {
    .site-title {
        font-size: 22px;
    }

    #main > a {
        font-size: 18px;
        padding: 14px 36px;
        letter-spacing: 4px;
    }

    #main {
        gap: 22px;
    }

    #lamp-container {
        right: 20px;
    }

    #lamp-string {
        height: 70px;
    }

    #lamp-bulb {
        width: 14px;
        height: 56px;
    }
}
