/* Base styles */
:root {
    --info-height-top: 70px;
    --info-height-bottom: 50px;
    --total-info-height: calc(var(--info-height-top) + var(--info-height-bottom));
    --info-height-top-portrait: 60px;
    --info-height-bottom-portrait: 40px;
    --total-info-height-portrait: calc(var(--info-height-top-portrait) + var(--info-height-bottom-portrait));
    --viewport-height: 100vh;
    --safe-height: 100vh;
    --cinema-overlay-padding: clamp(15px, 3vh, 50px);
    --director-font-size: clamp(0.9rem, 2vh, 2.5rem);
    --description-font-size: clamp(0.8rem, 1.6vh, 1.8rem);
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100vh;
    background-color: #000;
    color: #FFD700;
    font-family: 'Geist', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.poster-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #000;
}

/* Movie Info Elements */
.movie-info {
    display: flex;
    z-index: 2;
    width: 100%;
}

.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

.time-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.time-info.end {
    align-items: flex-end;
}

.time-label {
    font-size: 0.8em;
}

.time {
    font-size: 1.2em;
}

.playback-status {
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
    flex-grow: 1;
    margin: 0 20px;
}

.paused {
    color: #FFA500;
}

.ending {
    color: #FF4500;
}

.stopped {
    color: #DC143C;
}

.progress-container {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.1);
    height: 5px;
    z-index: 2;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: #E5A00D;
    transition: width 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Poster image */
.poster-image {
    width: auto;
    height: calc(100vh - var(--total-info-height));
    object-fit: contain;
    transition: opacity 0.5s ease-in-out;
    z-index: 1;
    max-width: 100%;
    background-color: #000;
    max-height: 100dvh;
}

.bottom-info {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    width: 100%;
    box-sizing: border-box;
    z-index: 2;
}

.info-item {
    text-align: center;
    margin: 0 20px;
}

.info-item-rotating {
    text-align: center;
    margin: 0 20px;
    transition: opacity 0.5s ease;
}

.info-label {
    font-size: 0.8em;
    display: block;
}

.info-value {
    font-size: 1.2em;
}

/* Custom Text Container */
.custom-text-container {
    position: absolute;
    top: 24.475%;
    left: 30.62%;
    width: 38.96%;
    height: 17.04%;
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    z-index: 3;
}

.custom-text {
    color: white;
    line-height: 1.2;
    white-space: pre-wrap;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    word-break: break-word;
    margin: 0;
}

.cinema-overlay {
    display: none;
    justify-content: center;
    align-items: center;
    text-align: center;
    width: 100%;
    z-index: 2;
    box-sizing: border-box;
    flex-shrink: 0;
}

.cinema-overlay-top {
    padding: var(--cinema-overlay-padding) 0;
}

.cinema-overlay-bottom {
    padding: var(--cinema-overlay-padding) clamp(20px, 5vw, 80px);
    flex-direction: column;
    overflow: hidden;
}

.cinema-overlay-bottom.has-cast {
    justify-content: space-around;
}

.cinema-overlay-bottom:not(.has-cast) {
    justify-content: center;
}

.director-text {
    color: #fff;
    font-weight: 300;
    font-size: var(--director-font-size);
    font-family: 'Instrument Serif', serif;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3em;
}

.director-role {
    font-family: 'Geist Mono', monospace;
    font-size: 0.42em;
    font-weight: 400;
    letter-spacing: 0.5em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
}

.director-name {
    letter-spacing: clamp(0.1em, 0.3vw, 0.25em);
    text-transform: uppercase;
    line-height: 1.2;
}

.tagline-text {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 300;
    font-style: italic;
    font-size: var(--description-font-size);
    letter-spacing: 0.05em;
    line-height: 1.6;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    max-width: 80%;
    text-align: center;
}

.cast-text {
    display: none;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 300;
    font-size: clamp(0.6rem, 1vw, 1.2rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    text-align: center;
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tech-text {
    display: none;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 300;
    font-size: clamp(0.5rem, 0.8vw, 1rem);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    text-align: center;
}

.poster-container.cinema-info .cast-text,
.poster-container.cinema-info .tech-text {
    display: block;
}

.poster-container.cinema-info .cinema-overlay {
    display: flex;
}

.poster-container.cinema-info .cinema-overlay-top {
    order: -1;
}

.poster-container.cinema-info .cinema-overlay-bottom {
    order: 1;
}

.poster-container.cinema-info .movie-info {
    display: none !important;
}

.poster-container.cinema-info .poster-image {
    order: 0;
    flex: 1;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    position: relative;
    z-index: 2;
}

.poster-backdrop {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(50px) brightness(0.3) saturate(1.8);
    transform: scale(1.08);
    opacity: 0;
    transition: opacity 0.7s ease;
    z-index: 0;
    pointer-events: none;
}

.poster-container.cinema-info .poster-backdrop {
    opacity: 1;
}

.poster-container.cinema-info::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 65% 65% at center,
            transparent 30%,
            rgba(0, 0, 0, 0.45) 75%,
            rgba(0, 0, 0, 0.72) 100%);
    z-index: 1;
    pointer-events: none;
}

.poster-container.cinema-info .cinema-overlay {
    z-index: 3;
}

/* Default Poster Mode */
.default-poster .poster-image {
    max-height: 100vh;
    width: auto;
    height: 100vh;
}

.default-poster .movie-info {
    display: none;
}

.default-poster .custom-text-container {
    display: flex;
}

.default-poster .cinema-overlay {
    display: none !important;
}

/* Screensaver Mode */
.screensaver .movie-info,
.screensaver .custom-text-container {
    display: none;
}

.screensaver:not(.cinema-info) .poster-image {
    max-height: 100vh;
    width: auto;
    height: 100vh;
}

.poster-container:not(.default-poster):not(.screensaver) .custom-text-container {
    display: none !important;
}

@media (orientation: portrait) {
    .poster-container:not(.screensaver):not(.default-poster):not(.cinema-info) .poster-image {
        height: calc(100vh - var(--total-info-height-portrait));
    }

    .info-bar,
    .bottom-info {
        padding: 5px;
    }

    .time-label {
        font-size: 0.7em;
    }

    .time,
    .info-value {
        font-size: 1em;
    }

    .playback-status {
        font-size: 1.2em;
        margin: 0 10px;
    }

    .info-item {
        margin: 0 10px;
    }

    .custom-text {
        font-size: 3vw;
    }

    .custom-text-container {
        top: 24.475%;
        left: 30.62%;
        width: 38.96%;
        height: 17.04%;
    }
}

@media (orientation: landscape) {
    .custom-text {
        font-size: 2vw;
    }
}

@media (orientation: portrait) and (max-width: 600px) {
    .custom-text-container {
        top: 20%;
        left: 25%;
        width: 50%;
        height: 20%;
    }

    .info-bar,
    .bottom-info {
        padding: 3px;
    }

    .info-item {
        margin: 0 5px;
    }

    .playback-status {
        margin: 0 5px;
    }
}

@media (orientation: portrait) and (min-height: 2000px) {
    :root {
        --info-height-top: 150px;
        --info-height-bottom: 100px;
        --info-height-top-portrait: 130px;
        --info-height-bottom-portrait: 90px;
        --cinema-overlay-padding: clamp(15px, 1.2vh, 50px);
        --director-font-size: clamp(2rem, 3vw, 4.5rem);
        --description-font-size: clamp(1.2rem, 1.8vw, 2.5rem);
    }

    .time-label,
    .info-label {
        font-size: clamp(0.8em, 1.4vh, 4rem);
        color: #FFD700;
        font-weight: 500;
        letter-spacing: 0.5em;
        opacity: 0.7;
        text-transform: uppercase;
    }

    .info-label {
        letter-spacing: 0.5em;
    }

    .time,
    .info-value {
        font-size: clamp(1.2em, 2.1vh, 5rem);
        color: #fff;
        font-weight: 700;
    }

    .playback-status {
        font-size: clamp(1.5em, 2.7vh, 7rem);
    }

    .progress-container {
        height: clamp(6px, 1vh, 15px);
        width: 100%;
    }

    .poster-container:not(.screensaver):not(.default-poster):not(.cinema-info) .poster-image {
        width: 100%;
        height: calc(100vw * 1.5);
        max-height: none;
        flex: 0 0 auto;
    }

    .poster-container:not(.screensaver):not(.default-poster):not(.cinema-info) .info-bar,
    .poster-container:not(.screensaver):not(.default-poster):not(.cinema-info) .bottom-info {
        flex: 1 0 auto;
    }

    .screensaver:not(.cinema-info) .poster-image,
    .default-poster .poster-image {
        width: 100%;
    }

    .poster-container.cinema-info .poster-image {
        height: calc(100vw * 1.5);
        flex: 0 0 auto;
    }

    .poster-container.cinema-info .cinema-overlay-top {
        flex: 2 0 0;
    }

    .poster-container.cinema-info .cinema-overlay-bottom {
        flex: 3 0 0;
        align-items: center;
        justify-content: center;
        gap: clamp(8px, 1.2vh, 30px);
        padding-top: clamp(15px, 2vh, 50px);
        padding-bottom: clamp(10px, 1.5vh, 40px);
    }

    /* Bottom info typography */
    .info-item-rotating {
        line-height: 1.6;
    }

    .director-text {
        font-weight: 300;
        letter-spacing: 0.6em;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 95%;
    }

    .tagline-text {
        line-height: 1.8;
        letter-spacing: 0.08em;
    }

    .cast-text {
        font-size: clamp(1rem, 1.4vw, 2rem);
        letter-spacing: 0.3em;
    }

    .tech-text {
        font-size: clamp(0.8rem, 1.1vw, 1.5rem);
        letter-spacing: 0.4em;
    }
}

@media screen and (max-width: 768px) {
    .poster-container {
        min-height: var(--safe-height);
        height: var(--safe-height);
        min-height: -webkit-fill-available;
        height: -webkit-fill-available;
        display: flex;
        flex-direction: column;
    }

    .poster-image {
        flex: 1;
        width: auto;
        height: auto;
        max-height: calc(100vh - var(--total-info-height));
        object-fit: contain;
    }

    /* PWA specific adjustments */
    @media all and (display-mode: standalone) {
        .poster-container {
            height: 100vh !important;
            height: 100dvh !important;
            padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
            min-height: -webkit-fill-available;
        }

        .default-poster .poster-image,
        .screensaver:not(.cinema-info) .poster-image {
            height: 100vh !important;
            height: 100dvh !important;
            max-height: 100dvh !important;
            width: auto;
            object-fit: contain;
        }

        .movie-info {
            position: relative;
            z-index: 2;
        }
    }

    @media screen and (orientation: portrait) {
        .poster-container:not(.default-poster):not(.screensaver):not(.cinema-info) .poster-image {
            max-height: calc(100vh - var(--total-info-height-portrait));
        }
    }
}