/* 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;
}

body, html {
    margin: 0;
    padding: 0;
    height: 100vh;
    background-color: #000;
    color: #FFD700;
    font-family: Arial, 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-color: rgba(0, 0, 0, 0.7);
    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: #333;
    height: 5px;
    z-index: 2;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: #FFD700;
    transition: width 0.5s ease;
}

/* 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-color: rgba(0, 0, 0, 0.7);
    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;
}

.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;
}

/* Special Modes */
/* 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;
}

/* Screensaver Mode */
.screensaver .poster-image {
    max-height: 100vh;
    width: auto;
    height: 100vh;
}

.screensaver .movie-info,
.screensaver .custom-text-container {
    display: none;
}

/* Override for active movie mode */
.poster-container:not(.default-poster):not(.screensaver) .custom-text-container {
    display: none !important;
}

/* Media Queries */
@media (orientation: portrait) {
    .poster-container:not(.screensaver):not(.default-poster) .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 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 .poster-image {
            height: 100vh !important;
            height: 100dvh !important;
            max-height: 100dvh !important;
            width: auto;
            object-fit: contain;
        }

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

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