/* =========================================================================
   Videoliste – Stylesheet
   Schlichtes Design in Grautönen, dezente Pastellfarben für Links/Checkboxen
   ========================================================================= */

:root {
    --gray-50:  #fafafa;
    --gray-100: #f0f0f0;
    --gray-200: #e2e2e2;
    --gray-300: #cfcfcf;
    --gray-400: #a3a3a3;
    --gray-600: #6b6b6b;
    --gray-700: #4d4d4d;
    --gray-800: #333333;
    --gray-900: #1c1c1c;

    --pastel-blue:      #b7d3ec;
    --pastel-blue-dark: #6f9dc4;
    --pastel-blue-text: #3f6b8e;

    --header-footer-height: 3.25rem;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
}

a {
    color: var(--pastel-blue-text);
}

a:hover,
a:focus-visible {
    color: var(--pastel-blue-dark);
}

small {
	font-size: 0.7rem;
}

/* ---- Kopf- und Fußzeile ------------------------------------------------- */

.site-header,
.site-footer {
    flex: 0 0 auto;
    background: var(--gray-800);
    color: var(--gray-50);
    align-items: center;
    min-height: var(--header-footer-height);
    padding: 0 1.25rem;
}

.site-header {
    width: 100%;
    max-width: 2000px;
    margin: 0 auto;
    justify-content: center;
		display: table;
		height: 3.25rem;
}

.site-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.02em;
}

.site-footer {
    display: flex;
    width: 100%;
    max-width: 2000px;
    margin: 0 auto;
    margin-top: auto; /* Fußzeile bleibt unten, auch wenn der Inhalt kürzer als der Viewport ist */
    justify-content: center;
}

.site-footer p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--gray-300);
}

/* ---- Hauptbereich: Player + Playlist ------------------------------------ */

.content {
    /* Standard (Desktop, Reihen-Layout): Höhe richtet sich nach dem Player
       (16:9), die Playlist übernimmt per Stretch genau diese Höhe.        */
    flex: 0 1 auto;
    width: 100%;
    max-width: 2000px;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 1rem;
    padding: 1rem 1.25rem;
}

#player-wrapper {
    flex: 2 1 0;
    min-width: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 9;
    max-height: 100%;
    /* Wichtig: verhindert, dass der Flex-Stretch der Zeile die per aspect-ratio
       berechnete Höhe überschreibt (in manchen Browsern setzt sich sonst die
       volle Zeilenhöhe durch statt der 16:9-Höhe -> riesiges Video mit
       schwarzen Balken). Die Höhe ergibt sich dadurch ausschließlich aus
       der Breite + aspect-ratio.                                            */
    align-self: flex-start;
}

#video {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

/* Fullscreen: Video nie größer als 1920x1080 darstellen, Rest schwarz lassen */
#player-wrapper:fullscreen,
#player-wrapper:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-height: none;
    aspect-ratio: auto;
    background: #000;
}

#player-wrapper:fullscreen #video,
#player-wrapper:-webkit-full-screen #video {
    width: auto;
    height: auto;
    max-width: 1920px;
    max-height: 1080px;
}

#playlist-panel {
    flex: 1 1 0;
    min-width: 0;
    /* Ohne min-height:0 würde diese Box (als Flex-Item der Zeile) auf die
       volle Höhe ALLER Playlist-Einträge aufgeblasen statt sich auf die
       Player-Höhe zu begrenzen -> Player und Playlist scrollten dann
       gemeinsam als eine lange Seite. Mit min-height:0 bleibt die Box exakt
       so hoch wie der Player, und nur die Liste darin scrollt.            */
    min-height: 0;
    /* Zeilen-Layout: Höhe kommt exakt vom Player (per JS gemessen, siehe
       script.js). Fällt --player-height (noch) nicht vor, bleibt es bei
       auto.                                                               */
    height: var(--player-height, auto);
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
}

.options {
    flex: 0 0 auto;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--gray-300);
    display: inline;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    background: var(--gray-100);
}

.option {
    display: inline-block;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    color: var(--gray-700);
}

.option input[type="checkbox"] {
    accent-color: var(--pastel-blue-dark);
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

#playlist {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

#playlist .playlist-item a {
    display: block;
    padding: 0.55rem 0.85rem;
    text-decoration: none;
    border-bottom: 1px solid var(--gray-200);
    font-size: 1rem;
    line-height: 1.3;
}

#playlist .playlist-item a:hover,
#playlist .playlist-item a:focus-visible {
    background: var(--gray-200);
}

#playlist .playlist-item a.active {
    background: var(--pastel-blue);
    color: var(--gray-900);
    font-weight: 600;
}

#playlist .year-separator {
    position: sticky;
    top: 0;
    padding: 0.4rem 0.85rem;
    background: var(--gray-300);
    color: var(--gray-700);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.03em;
}

#playlist .playlist-empty {
    padding: 0.85rem;
    color: var(--gray-600);
    font-size: 0.9rem;
}

/* ---- Layout-Umschaltung: Playlist immer unten (Checkbox) ---------------- */

body.force-bottom .content {
    /* Gestapeltes Layout: Playlist füllt die verbleibende Resthöhe          */
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
}

body.force-bottom #player-wrapper {
    flex: 0 0 auto;
    width: auto;
    max-width: 100%;
    /* Begrenzung, damit bei voller Breite (und damit großer 16:9-Höhe)
       immer sichtbarer Platz für die Playlist übrig bleibt. Die Breite
       wird dann passend zur Höhe automatisch (unter Beibehaltung von
       16:9) verkleinert und zentriert.                                   */
    max-height: 60%;
    margin: 0 auto;
}

body.force-bottom #playlist-panel {
    flex: 1 1 auto;
    min-height: 0;
    height: auto; /* die vom Player übernommene Höhe hier bewusst nicht verwenden */
}

/* Nur oberhalb des Breakpoints (Desktop, Fenster breiter als der begrenzte
   Player): Playlist optisch nicht breiter als der Player darstellen. Per JS
   gemessene Player-Breite, siehe script.js. Unterhalb des Breakpoints bleibt
   es bei der vollen Breite (siehe Media-Query weiter unten).              */
@media (min-width: 800.02px) {
    body.force-bottom #playlist-panel {
        width: var(--player-width, 100%);
        max-width: 100%;
        margin: 0 auto;
    }
}

/* ---- Cookie-Banner ------------------------------------------------------- */

.cookie-banner {
    position: fixed;
    left: 50%;
    bottom: 1rem;
    transform: translateX(-50%);
    max-width: min(90vw, 480px);
    background: var(--gray-800);
    color: var(--gray-50);
    padding: 0.9rem 1.1rem;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 100;
    font-size: 0.85rem;
}

.cookie-banner p {
    margin: 0 0 0.6rem 0;
}

.cookie-banner-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
}

.cookie-banner-actions button {
    border: none;
    border-radius: 3px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
}

#cookie-accept {
    background: var(--pastel-blue);
    color: var(--gray-900);
}

#cookie-accept:hover {
    background: var(--pastel-blue-dark);
    color: #fff;
}

#cookie-decline {
    background: var(--gray-600);
    color: var(--gray-50);
}

#cookie-decline:hover {
    background: var(--gray-700);
}

/* ---- Responsive: unter 800px Breite -------------------------------------
   Playlist unterhalb des Players, an Resthöhe des Browsers angepasst      */

@media (max-width: 800px) {
    .content {
        /* Playlist soll die Resthöhe des Browsers ausfüllen                  */
        flex: 1 1 auto;
        min-height: 0;
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    #player-wrapper {
        flex: 0 0 auto;
        width: auto;
        max-width: 100%;
        max-height: 60%;
        margin: 0 auto;
    }

    #playlist-panel {
        flex: 1 1 auto;
        min-height: 0;
        height: auto; /* die vom Player übernommene Höhe hier bewusst nicht verwenden */
    }

    .site-header h1 {
        font-size: 1rem;
    }
}
