/* Base styles for HTML and body */
html, body {
    height: 100%;
    margin: 0;
    font-family: "Anuphan", sans-serif;
    font-size: 1em;
    line-height: 1; /* Adjusted line height */
}

/* Black background as ultimate fallback */
#bg-black {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgb(0, 0, 0);
    z-index: -60;
}

/* Fallback image (YouTube thumbnail) during loading, set dynamically via JavaScript */
#bg-fallback {
    position: fixed;
    background: center/cover no-repeat;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -50;
    opacity: 1;
    transition: opacity 1s ease;
    animation: kenburns-top 15s infinite alternate ease 2s; /* Ken Burns animation */
}

/* Wrapper for YouTube video to ensure proper scaling */
.video-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: -40;
    pointer-events: none;
}

/* YouTube video, scaled to fill the window */
#bg-video {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vw;
    height: calc(100vw * 9 / 16); /* 16:9 aspect ratio */
    min-height: 100vh;
    min-width: calc(100vh * 16 / 9);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 1s ease;
}

/* Ken Burns animation for the fallback image */
@-webkit-keyframes kenburns-top {
    0% {
        transform: scale(1) translateY(0);
        transform-origin: 50% 16%;
    }
    100% {
        transform: scale(1.25) translateY(-15px);
        transform-origin: center;
    }
}

@keyframes kenburns-top {
    0% {
        transform: scale(1) translateY(0);
        transform-origin: 50% 16%;
    }
    100% {
        transform: scale(1.25) translateY(-15px);
        transform-origin: center;
    }
}

/* Main container for content, vertically centered with right-aligned children */
.flex-container {
    min-height: 100%; /* Allow content to exceed viewport height */
    padding: 20px 20px 20px 0; /* Add padding: top, right, bottom, left */
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* Right-align children horizontally */
    justify-content: center; /* Vertically center content */
}

/* Glassmorphism style for form and video info box */
.glass-form, .glass-box {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    max-width: 30vw; /* Set width to ~30% of viewport width */
    min-width: 400px; /* Ensure minimum width of 400px */
    width: 100%;
    z-index: 10;
    margin-bottom: 20px;
    text-align: left;
    color: white;
    box-sizing: border-box;
}

/* Specific styling for video info box */
.glass-box {
    text-align: center;
    line-height: 1.2;
    font-size: 1.2em;
}

/* YouTube link in the info box */
.glass-box a {
    color: white;
    text-decoration: underline;
}

/* Video icon in the info box */
.video-icon {
    margin-right: 5px;
    font-size: 1.2em;
    color: rgba(255, 255, 255, 0.6);
}

/* Form heading "Grüezi" */
.flex-item-head {
    padding-bottom: 50px;
    margin: 10px;
    line-height: 1.0;
    color: white;
    font-size: 3.0em;
    text-align: center;
    text-shadow: 1px 2px 2px black;
}

/* Subtitle below the form */
.flex-item-sub {
    padding: 5px;
    margin: 5px;
    line-height: 1.2;
    font-size: 1.2em;
    color: white;
    text-align: center;
    text-shadow: 1px 1px 1px #000000;
}

/* Container for form fields */
.flex-item {
    background-color: transparent;
    padding: 0px;
    margin: 5px;
    line-height: 1.5;
    color: white;
    text-align: left;
}

/* Container for submit button */
.flex-item-button {
    background-color: transparent;
    padding: 25px 0;
    line-height: 1.5;
    color: white;
    font-size: 3.0em;
    text-align: center;
}

/* Form fields (input and textarea) */
.imps {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    box-sizing: border-box;
    font-family: "Anuphan", sans-serif;
    font-size: 1.2em;
    color: white;
    text-shadow: 1px 1px 1px black;
    transition: all 0.3s ease;
}

/* Placeholder text in form fields */
.imps::placeholder {
    font-family: "Anuphan", sans-serif;
    font-size: 1.2em;
    color: rgba(185, 183, 183, 0.8);
    text-shadow: 1px 1px 1px black;
}

/* Hover effect for form fields */
.imps:not([disabled]):hover {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.8);
    color: rgba(60, 60, 60, 0.8);
}

/* Disabled form field */
.imps[disabled] {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    opacity: 0.6;
}

/* Invalid form field */
.imps:invalid:not(:placeholder-shown):not(:focus) {
    border: 1px solid rgba(255, 0, 0, 0.6);
    background: rgba(255, 0, 0, 0.2);
}

/* Textarea specific */
textarea {
    height: 135px;
    resize: none;
}

/* Labels for form fields */
label {
    text-transform: uppercase;
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Submit button */
input[type=submit] {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgb(255, 255, 255);
    width: 200px;
    height: 50px;
    font-size: 0.8em;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Hover effect for active submit button */
form:valid input[type=submit]:hover {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Disabled submit button */
form:invalid input[type=submit] {
    pointer-events: none;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
}
