/* Intro Overlay Styles */
#intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide nav bar when intro overlay is visible */
#intro-overlay:not(.fade-out) ~ .main-nav {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none;
}

.intro-background {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url('../img/keyhole-bg.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
}



/* Key container centered */
.key-container {
    position: absolute;
    left: 56%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

/* Key animation */
.key {
    width: min(16vw, 180px);
    height: auto;
    position: relative;
    animation: keyInsert 3s ease-in-out forwards 0.5s; /* 0.5s delay */
}

/* looks like it rises into the keyhole, wiggles, then stops */
@keyframes keyInsert {
    0% {
        transform: translate(-50%, 180px); /* start below */
    }
    55% {
        transform: translate(-50%, 0);     /* inside keyhole */
    }
    70% {
        transform: translate(-50%, 0) rotate(10deg);
    }
    85% {
        transform: translate(-50%, 0) rotate(-8deg);
    }
    100% {
        transform: translate(-50%, 0) rotate(0deg);
    }
}

/* Optional "glow" on unlock */
.intro-background.unlocking {
    filter: brightness(1.4);
    transition: filter 0.5s ease;
}

.skip-intro {
    position: absolute;
    top: 2rem;
    right: 2rem;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-family: 'Source Sans Pro', sans-serif;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    z-index: 4;
}

.skip-intro:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Fade out animation for intro overlay */
#intro-overlay.fade-out {
    animation: fadeOut 0.8s ease-in-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        visibility: hidden;
    }
}

/* Main site reveal animation */
#main-site.reveal {
    animation: reveal 1s ease-in-out forwards;
}

@keyframes reveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Section transitions */
.section {
    display: none;
    animation: sectionFadeIn 0.5s ease-in-out;
}

.section.active {
    display: block;
}

@keyframes sectionFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth hover effects */
.nav-link {
    transition: all 0.3s ease;
}

.book-link {
    transition: all 0.3s ease;
}

.media-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.media-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

/* Loading animation for images */
.author-portrait,
.book-image {
    transition: opacity 0.5s ease;
}

.author-portrait.loaded,
.book-image.loaded {
    opacity: 1;
}

/* Mobile responsive animations */
@media (max-width: 768px) {
    .key {
        width: 150px;
    }

    .skip-intro {
        top: 1rem;
        right: 1rem;
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}
