/* Gestaltung angelehnt an epaper.freiepresse.de */

@font-face {
    font-family: Heebo;
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('font/Heebo-VariableFont_wght.woff2') format('woff2');
}

:root {
    --primary-color: #0068b4;
    --primary-color-rgb: 0, 104, 180;
    --text-color: #333;
    --bg-color: #f0f0f0;
    --header-bg: #ffffff;
    --border-color: #eeeeee;
    --stage-bg: #404040;
}

*, *::before, *::after { box-sizing: border-box; }

button, select, input { font-family: inherit; }

[hidden] { display: none !important; }

html, body {
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    font-family: Heebo, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* --- Kopfzeile ------------------------------------------------------------ */

.app__header {
    background: var(--header-bg);
    color: var(--text-color);
    padding: 12px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    position: relative;
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    min-height: 45px;
}

.app__logo { display: flex; align-items: center; }
.app__logo a { display: block; }

.app__logo-img {
    height: 28px;
    width: auto;
    display: block;
}

.app__controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.app__controls-toggle {
    display: none;
    background: transparent;
    border: none;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 22px;
    color: var(--text-color);
    cursor: pointer;
    line-height: 1;
    width: 36px;
    height: 36px;
    text-align: center;
}

.app__select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #f5f5f5;
    border: 1px solid #dddddd;
    color: var(--text-color);
    padding: 8px 35px 8px 15px;
    font-size: 14px;
    border-radius: 20px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 10px auto;
}

.app__select:focus-visible { border-color: var(--primary-color); }
.app__select--date { min-width: 140px; }
.app__select option { background-color: #ffffff; color: var(--text-color); }

.app__nav-btn {
    background: transparent;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.app__nav-btn:hover:not(:disabled) { background-color: rgba(var(--primary-color-rgb), 0.1); }
.app__nav-btn--logout { margin-left: 10px; color: #666; }

/* Leseansicht-Kopfzeile: Schließen | "1 von 24" | Download */
.app__header--reader {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.reader-header__close {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 6px 4px;
    font-size: 15px;
    white-space: nowrap;
}

.reader-header__page-indicator {
    justify-self: center;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.app__header--reader .app__nav-btn { justify-self: end; }

/* --- Bühne ---------------------------------------------------------------- */

.viewer-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: var(--stage-bg);
}

.cover-preview {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    border: none;
    background: var(--stage-bg);
    cursor: pointer;
    font: inherit;
}

.cover-preview__img {
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    background: white;
}

.cover-preview__meta { text-align: center; }

.cover-preview__edition {
    color: #ffffff;
    font-size: 1.6em;
    font-weight: 700;
}

.cover-preview__date {
    color: #ffffff;
    font-size: 1.2em;
    margin-top: 4px;
}

.viewer {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

.viewer__container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--stage-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.viewer__page {
    position: relative;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    background: white;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.viewer__page--loading { opacity: 0.3; transition: opacity 0.2s 0.15s; }

.viewer__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    transition: background 0.2s, transform 0.2s, opacity 0.2s;
}

.viewer__nav--prev { left: 20px; }
.viewer__nav--next { right: 20px; }

.viewer__nav:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.75);
    transform: translateY(-50%) scale(1.03);
}

.viewer__nav:disabled { opacity: 0.35; cursor: not-allowed; }

/* Ladeanzeige: verzögert eingeblendet, damit schnelle Seitenwechsel nicht flackern */
.viewer__loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    padding: 24px 36px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    pointer-events: none;
    animation: viewer-loading-in 0.2s 0.15s both;
}

.viewer__spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: viewer-spin 0.8s linear infinite;
}

@keyframes viewer-spin { to { transform: rotate(360deg); } }
@keyframes viewer-loading-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .viewer__spinner { animation-duration: 2.4s; }
}

.viewer__error {
    color: #fff;
    text-align: center;
    padding: 20px;
}

/* --- Login ---------------------------------------------------------------- */

.login {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10vh 16px 16px;
    overflow-y: auto;
}

.login__box {
    width: 100%;
    max-width: 360px;
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
}

.login__title { margin: 0 0 20px; font-size: 20px; font-weight: 700; }
.login__error { color: #b00020; font-size: 14px; margin-bottom: 14px; }

.login__input {
    display: block;
    width: 100%;
    padding: 10px 15px;
    margin-bottom: 12px;
    font-size: 15px;
    border: 1px solid #dddddd;
    border-radius: 20px;
    background: #f5f5f5;
    color: var(--text-color);
    outline: none;
}

.login__input:focus { border-color: var(--primary-color); background: #fff; }

.login__btn {
    display: block;
    width: 100%;
    padding: 10px 15px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 20px;
    cursor: pointer;
    border: 1px solid var(--primary-color);
    background: var(--primary-color);
    color: #fff;
}

.login__btn--secondary { background: #fff; color: var(--primary-color); margin-bottom: 12px; }
.login__btn:hover { filter: brightness(1.08); }

.login__divider {
    text-align: center;
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 22px 0 14px;
}

/* --- Schmale Bildschirme: Ausgabenwahl hinter dem Menü-Knopf ---------------- */

@media (max-width: 1060px) {
    .app__header { padding: 10px 14px; gap: 10px; }

    .app__controls {
        width: 100%;
        gap: 10px;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--header-bg);
        padding: 12px 14px;
        box-shadow: 0 6px 12px rgba(0,0,0,0.08);
        border-bottom: 1px solid var(--border-color);
        overflow: hidden;
        max-height: 420px;
        opacity: 1;
        transform: translateY(0);
        transition: max-height 0.25s ease, opacity 0.2s ease, transform 0.25s ease;
    }

    .app__controls-toggle { display: inline-flex; align-items: center; justify-content: center; }

    .app__controls--collapsed {
        max-height: 0;
        opacity: 0;
        transform: translateY(-6px);
        pointer-events: none;
        padding-top: 0;
        padding-bottom: 0;
    }

    .app__select, .app__select--date { width: 100%; min-width: 0; }
    .app__nav-btn--logout { margin-left: 0; }

    .viewer__nav { width: 44px; height: 44px; }
    .viewer__nav--prev { left: 8px; }
    .viewer__nav--next { right: 8px; }
    .viewer__container { padding: 12px; }
}

/* Breite Bildschirme: Ausgabenwahl immer sichtbar */
@media (min-width: 1061px) {
    .app__controls--collapsed { display: flex; }
}
