/* Typography */
@font-face {
    font-family: "Blackwood Castle";
    src: url("blackwood-castle.regular.ttf") format("truetype");
}

/* Reset and Base Styles */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    cursor: url('cursor.png'), auto;
    /* Improve mobile performance */
    -webkit-transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    body, html {
        /* Prevent zoom on double tap */
        touch-action: manipulation;
        /* Optimize scrolling performance */
        -webkit-overflow-scrolling: touch;
    }
    
    .parallax-layer, .layer {
        /* Optimize transform performance on mobile */
        transform: translate3d(-50%, -50%, 0) scale(1.05);
        -webkit-transform: translate3d(-50%, -50%, 0) scale(1.05);
        will-change: transform;
        -webkit-backface-visibility: hidden;
    }
    
    /* Ensure vmframes and sword maintain perfect positioning on mobile */
    #viewmodel-animation {
        /* Mobile: use original centered position */
        transform: translate3d(-50%, -50%, 0) scale(1.05);
        -webkit-transform: translate3d(-50%, -50%, 0) scale(1.05);
        will-change: transform;
        -webkit-backface-visibility: hidden;
        /* Ensure background sizing works consistently on mobile */
        background-size: contain;
        background-position: center center;
    }
    
    #sword-static {
        transform: translate3d(calc(-50% + 50px), calc(-50% + 50px), 0) scale(1.05);
        -webkit-transform: translate3d(calc(-50% + 50px), calc(-50% + 50px), 0) scale(1.05);
        will-change: transform;
        -webkit-backface-visibility: hidden;
        /* Ensure background sizing works consistently on mobile */
        background-size: contain;
        background-position: center center;
    }
}

/* Initial Loading Screen */
#initial-interaction-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: black;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    cursor: url('cursor.png'), auto;
    transition: opacity 1s ease;
}

#door-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Door Dialog Styles */
.door-dialog-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    width: 100%;
    max-width: 600px;
    text-align: center;
}

.door-dialogbox {
    cursor: url('cursor.png'), auto;
    font-size: 18px;
    font-family: "Blackwood Castle", Arial, sans-serif;
    border-radius: 2px;
    padding: 8px;
    position: relative;
    width: 250px;
    min-height: 55px;
    line-height: 16px;
    margin: auto;
    background: white;
    border: 1px solid white;
    box-shadow: 0 1px 0 1px black,
                inset 0 1px 0 1px black,
                0 0 0 1px black,
                inset 0 0 0 1px black;
    transform: scale(1.5);
    user-select: none;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

/* White Flash Transition */
.white-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 10002;
    opacity: 0;
    pointer-events: none;
}

.white-flash.active {
    animation: whiteFlashTransition 1s ease-out forwards;
}

@keyframes whiteFlashTransition {
    0% { opacity: 0; }
    50% { opacity: 0.5; }
    80% { opacity: 0.9; }
    100% { opacity: 1; }
}

@media (max-width: 768px) {
    .door-dialogbox {
        transform: scale(1);
        width: calc(100% - 40px);
        max-width: 300px;
        height: auto;
        min-height: 55px;
        font-size: 16px;
        line-height: 24px;
        opacity: 0;
        transition: opacity 0.6s ease-in-out;
    }
}

/* Main Container */
.container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0;
    transition: opacity 2s ease;
}

/* Base Layer Style */
.layer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.1s ease-out;
    transform: translate3d(-50%, -50%, 0) scale(1.05);
    will-change: transform;
}

/* Cloud Animations */
#clouds-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 300%;
    height: 100%;
    z-index: 1;
    animation: none;
    transform: translateZ(0);
}

.cloud-image {
    position: absolute;
    top: 0;
    height: 100%;
    width: 33.33%;
    background-image: url('clouds.webp');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    transform: translateZ(0);
}

#extraclouds-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 300%;
    height: 100%;
    z-index: 4;
    animation: none;
    transform: translateZ(0);
}

.extracloud-image {
    position: absolute;
    top: 0;
    height: 100%;
    width: 33.33%;
    background-image: url('extraclouds.webp');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    transform: translateZ(0);
}

/* Parallax Layers */
.parallax-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.1s ease-out;
    transform: translate3d(-50%, -50%, 0) scale(1.05);
    will-change: transform;
}

/* Background Layers (back to front) */
#layer8 {
    background-image: url('layer8.webp');
    z-index: 1;
}

#layer7 {
    background-image: url('layer7.webp');
    z-index: 2;
}

#light-flicker {
    z-index: 3;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-image: none;
    opacity: 0;
    transition: opacity 2s ease;
}

#layer6 {
    background-image: url('layer6.webp');
    z-index: 4;
}

#layer5 {
    background-image: url('layer5.webp');
    z-index: 5;
}

#layer4 {
    background-image: url('layer4.webp');
    z-index: 6;
}

#layer3 {
    background-image: url('layer3.webp');
    z-index: 8;
}

#layer2 {
    background-image: url('layer2.webp');
    z-index: 9;
}

#layer1 {
    background-image: url('layer1.webp');
    z-index: 10;
}

/* Character Elements */
#viewmodel-animation {
    z-index: 11; /* viewmodel gets z-index 11 */
    /* Use contain to maintain aspect ratio while centering */
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    /* Remove any background image initially */
    background-image: none;
    opacity: 0;
    transition: opacity 2s ease;
    
    /* Perfect centering and consistent scaling */
    width: 100%;
    height: 100%;
    /* Desktop positioning: moved up 40px and left 50px from lowered position */
    transform: translate3d(calc(-50% - 50px), calc(-50% + 10px), 0) scale(1.05);
}

#sword-static {
    z-index: 12; /* sword on top */
    background-image: url('sword.webp');
    /* Use contain to maintain aspect ratio while centering */
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    opacity: 0;
    transition: opacity 2s ease;
    
    /* Perfect centering and consistent scaling */
    width: 100%;
    height: 100%;
    /* Keep sword at lowered position, moved 50px right */
    transform: translate3d(calc(-50% + 50px), calc(-50% + 50px), 0) scale(1.05);
}

/* Bird Animation */
#birds-animation {
    z-index: 7;
    background-size: contain;
    background-repeat: no-repeat;
    animation: moveHorizontally 20s linear infinite;
    top: 55%;
    will-change: transform;
    opacity: 0;
    transition: opacity 2s ease;
}

/* Animations */
@keyframes moveHorizontally {
    0% { transform: translate3d(-75%, -50%, 0) scale(1.05); }
    100% { transform: translate3d(40%, -50%, 0) scale(1.05); }
}

@keyframes moveHorizontallyMobile {
    0% { transform: translate3d(-110vw, -50%, 0) scale(1.05); }
    100% { transform: translate3d(40vw, -50%, 0) scale(1.05); }
}

@keyframes moveCloud {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-33.33%, 0, 0); }
}

@keyframes moveExtraCloud {
    0% { transform: translate3d(10%, 0, 0); }
    100% { transform: translate3d(-43.33%, 0, 0); }
}

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

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

/* Game Title */
#game-title {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'ITC Benguiat', serif;
    font-size: 7vw;
    color: #FFFFFF;
    text-shadow: 
        0 0 5px rgba(255, 165, 0, 0.9),
        0 0 15px rgba(255, 165, 0, 0.8),
        0 0 30px rgba(255, 165, 0, 0.7),
        0 0 40px rgba(255, 165, 0, 0.6),
        0 0 50px rgba(255, 140, 0, 0.5),
        0 0 60px rgba(255, 140, 0, 0.4);
    opacity: 0;
    z-index: 15;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
}

@media (max-width: 768px) {
    #game-title {
        font-size: 12vw;
    }
    
    #birds-animation {
        animation: moveHorizontallyMobile 20s linear infinite;
    }
}

/* Sound Button */
#soundButton {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 60px;
    height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    cursor: url('cursor.png'), auto;
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0;
    transition: opacity 2s ease;
}

@media (max-width: 768px) {
    #soundButton {
        top: auto;
        left: auto;
        bottom: 20px;
        right: 20px;
    }
}

#soundButton span {
    width: 3px;
    height: 2px;
    background-color: #fff;
    transition: height 0.3s ease;
}

/* Dialog System */
#game-container {
    position: absolute;
    width: 100%;
    max-width: 600px;
    text-align: center;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 10001;
    display: none;
    opacity: 0;
    transition: opacity 1s ease;
}

#dialogbox {
    cursor: url('cursor.png'), auto;
    font-size: 18px;
    font-family: "Blackwood Castle", Arial, sans-serif;
    border-radius: 2px;
    padding: 8px;
    position: relative;
    width: 250px;
    min-height: 55px;
    line-height: 16px;
    margin: auto;
    background: white;
    border: 1px solid white;
    box-shadow: 0 1px 0 1px black,
                inset 0 1px 0 1px black,
                0 0 0 1px black,
                inset 0 0 0 1px black;
    transform: scale(1.5);
    user-select: none;
    text-align: left;
    margin-bottom: 20px;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    #dialogbox {
        transform: scale(1);
        width: calc(100% - 40px);
        max-width: 300px;
        height: auto;
        min-height: 55px;
        font-size: 16px;
        line-height: 24px;
    }
}

/* Dialog Arrow */
#arrow, #door-arrow {
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-top-color: black;
    position: absolute;
    bottom: 8px;
    right: 8px;
    animation: bounce .3s steps(3) infinite;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
    100% { transform: translateY(0); }
}

/* Email Form */
.email-form {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.email-input {
    font-family: "Blackwood Castle", Arial, sans-serif;
    font-size: 16px;
    padding: 8px;
    border: 1px solid black;
    border-radius: 2px;
    background: white;
    box-shadow: 0 1px 0 1px black,
                inset 0 1px 0 1px black,
                0 0 0 1px black,
                inset 0 0 0 1px black;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.email-input:focus {
    background-color: #f9f9f9;
}

.accept-quest-btn {
    font-family: "Blackwood Castle", Arial, sans-serif;
    font-size: 16px;
    padding: 8px 16px;
    background: white;
    border: 1px solid black;
    border-radius: 2px;
    cursor: url('cursor.png'), auto;
    transition: all 0.2s ease;
    box-shadow: 0 1px 0 1px black,
                inset 0 1px 0 1px black,
                0 0 0 1px black,
                inset 0 0 0 1px black;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.accept-quest-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-1px);
    box-shadow: 0 2px 0 1px black,
                inset 0 1px 0 1px black,
                0 0 0 1px black,
                inset 0 0 0 1px black,
                0 0 8px rgba(255, 215, 0, 0.4);
}

.accept-quest-btn:active {
    background-color: #e0e0e0;
    transform: translateY(1px);
    box-shadow: 0 0px 0 1px black,
                inset 0 1px 0 1px black,
                0 0 0 1px black,
                inset 0 0 0 1px black;
}

.accept-quest-btn.quest-accepted {
    animation: questAccepted 0.4s ease;
}

@keyframes questAccepted {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); background-color: #90EE90; box-shadow: 0 0 15px rgba(144, 238, 144, 0.8); }
    100% { transform: scale(1); }
} 