/* ============================================
   ENARGEIA — The Gate (index.html)
   Looking up through a grate at a night sky.
   The grate is a black silhouette. Stars 
   shine through the gaps. Text below.
   ============================================ */

/* --- No scrolling on this page --- */
.gate-page,
.gate-page body {
    overflow: hidden;
}

/* Also set on html for this page via a class or direct */
html:has(.gate-page) {
    overflow: hidden;
}

/* --- Page Container --- */
.gate-page {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #000000;
}

/* --- Starfield (the night sky — behind everything) --- */
#starfield {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(
        ellipse at 50% 30%,
        #0d0a1a 0%,
        #050208 40%,
        #000000 100%
    );
}

.star {
    position: absolute;
    border-radius: 50%;
    animation: twinkle 4s ease-in-out infinite alternate;
}

.star--bright {
    box-shadow: 0 0 6px 2px currentColor;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

/* --- Grate Overlay (black silhouette) --- */
.grate-overlay {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

/* The actual grate bars — drawn with box shadows on a pseudo-element */
/* This gives us thick, fully opaque black bars */
.grate-overlay::before {
    content: '';
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;

    /* Thick vertical bars + horizontal crossbars */
    background:
        /* Vertical bars — thick and black */
        repeating-linear-gradient(
            90deg,
            #000000 0px,
            #000000 12px,
            transparent 12px,
            transparent 44px
        ),
        /* Horizontal bars — thicker, fewer */
        repeating-linear-gradient(
            0deg,
            #000000 0px,
            #000000 10px,
            transparent 10px,
            transparent 120px
        );

    /* Fade grate from fully visible at top to gone at ~60% down */
    -webkit-mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 25%,
        rgba(0, 0, 0, 0.8) 40%,
        rgba(0, 0, 0, 0.4) 55%,
        transparent 70%
    );
    mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 25%,
        rgba(0, 0, 0, 0.8) 40%,
        rgba(0, 0, 0, 0.4) 55%,
        transparent 70%
    );
}

/* Subtle iridescent sheen on the metal */
.grate-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        160deg,
        transparent 0%,
        rgba(196, 181, 253, 0.06) 20%,
        rgba(94, 234, 212, 0.04) 35%,
        transparent 50%,
        rgba(253, 230, 138, 0.04) 65%,
        rgba(255, 126, 179, 0.05) 80%,
        transparent 100%
    );
    background-size: 200% 200%;
    animation: sheen-shift 15s ease-in-out infinite alternate;
    pointer-events: none;

    /* Same fade mask as the bars */
    -webkit-mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 25%,
        rgba(0, 0, 0, 0.8) 40%,
        rgba(0, 0, 0, 0.4) 55%,
        transparent 70%
    );
    mask-image: linear-gradient(
        to bottom,
        black 0%,
        black 25%,
        rgba(0, 0, 0, 0.8) 40%,
        rgba(0, 0, 0, 0.4) 55%,
        transparent 70%
    );
}

@keyframes sheen-shift {
    0% { background-position: 0% 0%; }
    100% { background-position: 100% 100%; }
}

/* --- Vignette (darkens edges, focuses center) --- */
.gate-page::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: radial-gradient(
        ellipse at 50% 30%,
        transparent 15%,
        rgba(0, 0, 0, 0.3) 50%,
        rgba(0, 0, 0, 0.8) 100%
    );
}

/* --- Ambient pulse --- */
.gate-page::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(
        circle at 50% 35%,
        rgba(196, 181, 253, 0.03) 0%,
        transparent 50%
    );
    animation: ambient-pulse 8s ease-in-out infinite alternate;
}

@keyframes ambient-pulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }
    100% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* --- Dark ground beneath the grate --- */
/* A gradient from transparent at grate level to solid black below */
.gate-ground {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(0, 0, 0, 0.5) 20%,
        rgba(5, 2, 8, 0.85) 40%,
        #050208 60%,
        #050208 100%
    );
}

/* --- Content (lives above everything) --- */
.gate-content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-lg);
    max-width: 600px;
    /* Push content to the lower portion (below the grate) */
    margin-top: 15vh;
}

/* --- Title --- */
.gate-title {
    font-family: 'kingjola', serif;
    font-size: clamp(2.5rem, 8vw, 5rem);
    letter-spacing: 0.35em;
    margin-bottom: var(--space-sm);
    filter: drop-shadow(0 0 30px rgba(196, 181, 253, 0.3));
    animation: gate-title-breathe 6s ease-in-out infinite;
}

@keyframes gate-title-breathe {
    0%, 100% {
        filter: drop-shadow(0 0 30px rgba(196, 181, 253, 0.3));
        letter-spacing: 0.35em;
    }
    50% {
        filter: drop-shadow(0 0 50px rgba(196, 181, 253, 0.45));
        letter-spacing: 0.38em;
    }
}

/* --- Decorative Divider --- */
.gate-divider {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-md) 0;
    width: 100%;
    max-width: 350px;
    opacity: 0.4;
}

.gate-divider::before,
.gate-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        #c4b5fd,
        transparent
    );
}

.gate-divider-symbol {
    color: #c4b5fd;
    font-size: 0.9rem;
    animation: breathe 4s ease-in-out infinite;
}

/* --- Warning Text --- */
.gate-warning {
    margin-bottom: var(--space-lg);
    animation: fadeIn 2s ease-out 0.5s backwards;
}

.gate-warning p {
    font-family: 'Pixel-LCD-7', cursive;
    font-size: clamp(0.85rem, 2.2vw, 1rem);
    color: #c8bfdb;
    line-height: 1.8;
    margin: 0 auto var(--space-sm);
    max-width: 45ch;
}

.gate-warning .here-be-dragons {
    color: #fca5a5;
    font-family: 'Crusades', serif;
    font-size: clamp(1.6rem, 2.8vw, 1.2rem);
    letter-spacing: 0.15em;
    margin-top: var(--space-sm);
    text-shadow: 0 0 20px rgba(252, 165, 165, 0.3);
}

.gate-warning .gate-reassurance {
    color: #8a8098;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    font-style: italic;
    opacity: 0.7;
}

/* --- Buttons --- */
.gate-choices {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    animation: fadeIn 2s ease-out 1s backwards;
}

/* "okay, let me in" */
.gate-enter {
    position: relative;
    text-decoration: none; 
    display: inline-block;
    padding: var(--space-sm) var(--space-xl);
    font-family: 'Crusades', serif;
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    letter-spacing: 0.2em;
    color: #f0e6ff;
    background: rgba(26, 15, 46, 0.6);
    border: 1px solid rgba(196, 181, 253, 0.3);
    border-radius: 2px;
    transition: all 0.4s ease;
    text-shadow: 0 0 10px rgba(196, 181, 253, 0.2);
    overflow: hidden;
}

.gate-enter:hover {
    color: #ffffff;
    border-color: rgba(196, 181, 253, 0.6);
    background: rgba(26, 15, 46, 0.8);
    text-shadow: 0 0 15px rgba(196, 181, 253, 0.4);
    box-shadow:
        0 0 20px rgba(196, 181, 253, 0.15),
        0 0 40px rgba(196, 181, 253, 0.05),
        inset 0 0 20px rgba(196, 181, 253, 0.05);
    transform: scale(1.03);
}

/* Shimmer sweep on hover */
.gate-enter::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -100%;
    width: 60%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(196, 181, 253, 0.15),
        rgba(94, 234, 212, 0.1),
        transparent
    );
    transition: left 0.6s ease;
    pointer-events: none;
}

.gate-enter:hover::after {
    left: 120%;
}

.gate-enter .button-star {
    display: inline-block;
    transition: transform 0.4s ease;
}

.gate-enter:hover .button-star {
    transform: scale(1.3) rotate(15deg);
}

/* "no thanks" */
.gate-leave {
    font-family: 'kingjola', cursive;
    font-size: clamp(1.5rem, 1.8vw, 0.85rem);
    color: #8a8098;
    opacity: 0.5;
    transition: all 0.3s ease;
    letter-spacing: 0.05em;
    padding: var(--space-xs) var(--space-sm);
}

.gate-leave:hover {
    opacity: 0.9;
    color: #c4b5fd;
    text-shadow: 0 0 8px rgba(196, 181, 253, 0.2);
}

/* --- Transition Overlay --- */
.gate-transition {
    position: fixed;
    inset: 0;
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
    background: #000000;
}

.gate-transition.active {
    pointer-events: all;
    animation: gate-passage 1.4s ease-in-out forwards;
}

@keyframes gate-passage {
    0% {
        opacity: 0;
        background: transparent;
    }
    20% {
        opacity: 0.6;
        background: rgba(196, 181, 253, 0.15);
    }
    40% {
        opacity: 0.8;
        background: rgba(94, 234, 212, 0.1);
    }
    60% {
        opacity: 0.9;
        background: rgba(255, 126, 179, 0.08);
    }
    100% {
        opacity: 1;
        background: #000000;
    }
}

/* --- Responsive --- */
@media (max-width: 500px) {
    .gate-content {
        padding: var(--space-md);
        margin-top: 10vh;
    }

    .gate-divider {
        max-width: 250px;
    }
}