/* ========================================================== */
/* Blätterkatalog-Viewer — Grundgerüst, Farben, Bedienung     */
/* Farben nachempfunden dem FlippingBook-Skin "Office Gray"   */
/* ========================================================== */

:root {
    --bk-fenster-bg: #f2f2f2;
    --bk-fenster-text: #444444;
    --bk-bereich-bg: #5a5f63;
    --bk-bereich-text: #f6f7f7;
    --bk-knopf: #6e6e6e;
    --bk-knopf-aktiv: #1f1f1f;
    --bk-akzent: #3fc7ff;
    --bk-leiste-bg: rgba(255, 255, 255, 0.92);
    --bk-schatten: 0 2px 18px rgba(0, 0, 0, 0.14);
    --bk-radius: 10px;
    --bk-kopf-hoehe: 48px;
    --bk-leiste-hoehe: 56px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background: radial-gradient(circle at 50% 0%, #fafafa 0%, var(--bk-fenster-bg) 70%);
    color: var(--bk-fenster-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    overflow: hidden;
    overscroll-behavior: none;
}

.bk-versteckt {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ========================================================== */
/* Preloader — verschwindet, sobald das Buch steht            */
/* ========================================================== */

.bk-preloader {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
    justify-content: center;
    background: var(--bk-fenster-bg);
    transition: opacity 0.4s ease;
}

.bk-preloader--weg {
    opacity: 0;
    pointer-events: none;
}

.bk-preloader__titel {
    max-width: 80vw;
    color: var(--bk-fenster-text);
    font-size: clamp(18px, 3vw, 28px);
    font-weight: 600;
    text-align: center;
}

.bk-preloader__balken {
    width: 160px;
    height: 3px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
}

.bk-preloader__balken span {
    display: block;
    width: 40%;
    height: 100%;
    background: var(--bk-knopf);
    border-radius: 2px;
    animation: bk-lauf 1.1s ease-in-out infinite;
}

@keyframes bk-lauf {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(350%);
    }
}

/* ========================================================== */
/* Kopfleiste — Titel, Seitenzahl, Suche                      */
/* ========================================================== */

.bk-kopf {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 30;
    display: flex;
    gap: 10px;
    align-items: center;
    height: var(--bk-kopf-hoehe);
    padding: 0 10px 0 16px;
    color: var(--bk-bereich-text);
    background: var(--bk-bereich-bg);
}

.bk-kopf__titel {
    flex: 0 1 auto;
    overflow: hidden;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bk-kopf__rechts {
    display: flex;
    flex: 1 1 auto;
    gap: 4px;
    justify-content: flex-end;
}

.bk-kopf .bk-knopf {
    color: rgba(246, 247, 247, 0.85);
}

.bk-kopf .bk-knopf:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.bk-kopf .bk-knopf[aria-expanded="true"] {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

.bk-pager {
    display: flex;
    flex: 0 0 auto;
    gap: 2px;
    align-items: center;
    padding-left: 10px;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.bk-pager__feld input {
    width: 48px;
    padding: 4px 2px;
    color: var(--bk-fenster-text);
    font-family: inherit;
    font-size: 14px;
    text-align: center;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
}

.bk-pager__feld input:focus-visible {
    outline: 2px solid var(--bk-akzent);
    outline-offset: 1px;
}

.bk-pager__gesamt {
    min-width: 34px;
    color: rgba(246, 247, 247, 0.8);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* ========================================================== */
/* Schaltflächen — monochrome Linien-Icons, nie bunt          */
/* ========================================================== */

.bk-knopf {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    color: var(--bk-knopf);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.bk-knopf:hover {
    color: var(--bk-knopf-aktiv);
    background: rgba(0, 0, 0, 0.06);
}

.bk-knopf:focus-visible {
    outline: 2px solid var(--bk-akzent);
    outline-offset: 1px;
}

.bk-knopf[disabled] {
    opacity: 0.35;
    cursor: default;
}

.bk-knopf[aria-expanded="true"] {
    color: var(--bk-knopf-aktiv);
    background: rgba(0, 0, 0, 0.1);
}

.bk-knopf svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

/* ========================================================== */
/* Bühne und Buch                                             */
/* ========================================================== */

.bk-buehne {
    position: fixed;
    top: var(--bk-kopf-hoehe);
    right: 0;
    bottom: var(--bk-leiste-hoehe);
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    touch-action: none;
}

.bk-zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transform-origin: center center;
    will-change: transform;
}

/* Die Breite des Rahmens setzt viewer.js, damit das Buch auch in der Höhe */
/* in die Bühne passt — bei einem sehr breiten Format wie DIN lang quer    */
/* bindet die Breite, bei einem hochformatigen Katalog die Höhe.           */
.bk-rahmen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
    height: 100%;
}

.bk-buch {
    width: 100%;
    margin: 0 auto;
    transition: transform 0.35s ease;
}

/* Cover und Rückseite stehen allein. FlippingBook rückt sie in die Mitte, */
/* OpenPageFlip lässt die Gegenseite frei — also um eine halbe Seite       */
/* verschieben, sonst klebt das Cover rechts am Rand.                      */
.bk-buch[data-allein="rechts"] {
    transform: translateX(-25%);
}

.bk-buch[data-allein="links"] {
    transform: translateX(25%);
}

.bk-buch .bk-seite {
    overflow: hidden;
    background: #ffffff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
}

.bk-buch .bk-seite img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.bk-buch .bk-seite__text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

/* Linkflächen aus dem PDF, nur beim Überfahren sichtbar */
.bk-buch .bk-seite__link {
    position: absolute;
    background: transparent;
    border-radius: 2px;
    transition: background 0.15s ease;
}

.bk-buch .bk-seite__link:hover {
    background: rgba(63, 199, 255, 0.3);
}

/* ========================================================== */
/* Pfeile am Rand der Bühne                                   */
/* ========================================================== */

.bk-rand {
    position: absolute;
    top: 50%;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 64px;
    color: var(--bk-knopf);
    background: transparent;
    border: 0;
    cursor: pointer;
    transform: translateY(-50%);
    transition: color 0.15s ease, opacity 0.15s ease;
}

.bk-rand:hover {
    color: var(--bk-knopf-aktiv);
}

.bk-rand:focus-visible {
    outline: 2px solid var(--bk-akzent);
    outline-offset: 1px;
}

.bk-rand[disabled] {
    opacity: 0.2;
    cursor: default;
}

.bk-rand svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.bk-rand--links {
    left: 4px;
}

.bk-rand--rechts {
    right: 4px;
}

/* ========================================================== */
/* Untere Leiste                                              */
/* ========================================================== */

.bk-leiste {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 30;
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
    height: var(--bk-leiste-hoehe);
    padding: 0 10px calc(env(safe-area-inset-bottom, 0px) / 2);
    background: var(--bk-leiste-bg);
    backdrop-filter: blur(8px);
    box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.06);
}

.bk-leiste__trenner {
    width: 1px;
    height: 22px;
    margin: 0 8px;
    background: rgba(0, 0, 0, 0.12);
}

/* ========================================================== */
/* Panels — Seitenübersicht und Suche                         */
/* ========================================================== */

.bk-panel {
    position: fixed;
    right: 0;
    bottom: var(--bk-leiste-hoehe);
    left: 0;
    z-index: 40;
    max-height: min(60vh, 520px);
    padding: 12px 16px 18px;
    overflow-y: auto;
    color: var(--bk-bereich-text);
    background: var(--bk-bereich-bg);
    box-shadow: var(--bk-schatten);
}

.bk-panel[hidden] {
    display: none;
}

.bk-panel__kopf {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.bk-panel__kopf h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.bk-panel .bk-knopf {
    color: var(--bk-bereich-text);
}

.bk-panel .bk-knopf:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.bk-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.bk-thumb {
    display: block;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    cursor: pointer;
    text-align: center;
}

.bk-thumb img {
    display: block;
    width: 100%;
    height: auto;
    background: #ffffff;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: border-color 0.15s ease;
}

.bk-thumb:hover img {
    border-color: rgba(255, 255, 255, 0.5);
}

.bk-thumb[aria-current="true"] img {
    border-color: var(--bk-akzent);
}

.bk-thumb span {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.bk-panel--suche input[type="search"] {
    width: 100%;
    padding: 9px 12px;
    color: var(--bk-bereich-text);
    font-family: inherit;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
}

.bk-panel--suche input[type="search"]:focus-visible {
    outline: 2px solid var(--bk-akzent);
    outline-offset: 1px;
}

.bk-treffer {
    margin-top: 12px;
}

.bk-treffer__leer {
    color: rgba(246, 247, 247, 0.7);
    font-size: 14px;
}

.bk-treffer button {
    display: block;
    width: 100%;
    padding: 9px 10px;
    color: inherit;
    font-family: inherit;
    font-size: 14px;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
}

.bk-treffer button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.bk-treffer mark {
    color: #ffffff;
    background: rgba(63, 199, 255, 0.45);
}

.bk-treffer__seite {
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    opacity: 0.75;
}

/* ========================================================== */
/* Kurzmeldung (kopierter Link, Zoomstufe)                    */
/* ========================================================== */

.bk-hinweis {
    position: fixed;
    bottom: calc(var(--bk-leiste-hoehe) + 16px);
    left: 50%;
    z-index: 50;
    padding: 8px 14px;
    color: var(--bk-bereich-text);
    font-size: 14px;
    background: var(--bk-bereich-bg);
    border-radius: 999px;
    box-shadow: var(--bk-schatten);
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.bk-hinweis--an {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ========================================================== */
/* Ohne JavaScript                                            */
/* ========================================================== */

.bk-noscript {
    max-width: 44rem;
    margin: 0 auto;
    padding: 40px 20px;
}

.bk-noscript a {
    color: #0b6f96;
}

/* ========================================================== */
/* Mobil — Pfeile weg, Leisten schmaler                       */
/* ========================================================== */

@media (max-width: 820px) {
    :root {
        --bk-kopf-hoehe: 44px;
        --bk-leiste-hoehe: 52px;
    }

    .bk-kopf__titel {
        font-size: 14px;
    }

    .bk-rand {
        display: none;
    }

    .bk-buehne {
        padding: 8px;
    }

    .bk-buch {
        width: 100%;
    }

    .bk-thumbs {
        grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    }

    /* Auf dem Touchscreen zaehlt die Flaeche, nicht die Zierlinie. */
    .bk-leiste .bk-knopf {
        width: 44px;
        height: 44px;
    }

    .bk-leiste__trenner {
        display: none;
    }
}

@media (max-width: 520px) {
    .bk-kopf__titel {
        display: none;
    }

    /* Ohne Titel steht der Trenner vor dem Nichts - der muss dann weg. */
    .bk-pager {
        flex: 1 1 auto;
        justify-content: center;
        padding-left: 0;
        border-left: 0;
    }
}

/* ========================================================== */
/* Druck — alle Seiten untereinander                          */
/* ========================================================== */

@media print {
    .bk-kopf,
    .bk-leiste,
    .bk-rand,
    .bk-panel,
    .bk-hinweis,
    .bk-preloader {
        display: none !important;
    }

    .bk-buehne {
        position: static;
        display: block;
        padding: 0;
    }
}
