/* ============================================================
   PDF Flipbook – Frontend Styles
   ============================================================ */

/* --- Wrapper & Cover ---------------------------------------- */
.pdf-flipbook-wrapper {
    display: inline-block;
    max-width: 100%;
}

.pdf-flipbook-cover {
    position: relative;
    display: inline-block;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    transition: box-shadow .25s ease, transform .25s ease;
    max-width: 100%;
}

.pdf-flipbook-cover:hover,
.pdf-flipbook-cover:focus {
    box-shadow: 0 8px 32px rgba(0,0,0,.35);
    transform: translateY(-3px);
    outline: none;
}

.pdf-flipbook-cover-img,
.pdf-flipbook-auto-canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Auto-Cover Loading State */
.pdf-flipbook-auto-cover .pdf-flipbook-auto-canvas {
    background: #f0f0f0;
    min-width: 200px;
    min-height: 280px;
}

/* Overlay */
.pdf-flipbook-cover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0);
    transition: background .25s ease;
}

.pdf-flipbook-cover:hover .pdf-flipbook-cover-overlay,
.pdf-flipbook-cover:focus .pdf-flipbook-cover-overlay {
    background: rgba(0,0,0,.35);
}

.pdf-flipbook-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    background: #fff;
    color: #222;
    font-size: 14px;
    font-weight: 600;
    border-radius: 3px;
    letter-spacing: .02em;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .2s ease, transform .2s ease;
    white-space: nowrap;
    pointer-events: none;
}

.pdf-flipbook-cover:hover .pdf-flipbook-open-btn,
.pdf-flipbook-cover:focus .pdf-flipbook-open-btn {
    opacity: 1;
    transform: translateY(0);
}

/* --- Lightbox ------------------------------------------------ */
.pdf-flipbook-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-flipbook-lightbox[hidden] {
    display: none;
}

.pdf-flipbook-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.85);
    cursor: pointer;
}

.pdf-flipbook-lb-inner {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 900px;
    max-height: 95vh;
    padding: 0 16px;
    box-sizing: border-box;
}

/* Close button */
.pdf-flipbook-lb-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    opacity: .8;
    transition: opacity .15s;
}
.pdf-flipbook-lb-close:hover { opacity: 1; }

/* Title */
.pdf-flipbook-lb-title {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: center;
    max-width: 100%;
    opacity: .9;
    min-height: 20px;
}

/* Viewer row */
.pdf-flipbook-lb-viewer {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    justify-content: center;
}

/* Canvas container */
.pdf-flipbook-canvas-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: hidden;
    max-height: 75vh;
    border-radius: 3px;
    box-shadow: 0 2px 24px rgba(0,0,0,.6);
    background: #fff;
    position: relative;
}

.pdf-flipbook-main-canvas {
    display: block;
    max-width: 100%;
    max-height: 75vh;
    width: auto !important;
    height: auto !important;
}

/* Loading spinner overlay */
.pdf-flipbook-canvas-wrap::after {
    content: '';
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Ccircle cx='20' cy='20' r='16' fill='none' stroke='%23666' stroke-width='3' stroke-dasharray='80' stroke-dashoffset='60'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 20 20' to='360 20 20' dur='.8s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E") center/40px no-repeat;
}
.pdf-flipbook-canvas-wrap.is-loading::after {
    display: block;
}

/* Navigation */
.pdf-flipbook-nav {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.5);
    background: rgba(255,255,255,.15);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, border-color .15s;
}
.pdf-flipbook-nav:hover:not(:disabled) {
    background: rgba(255,255,255,.3);
    border-color: rgba(255,255,255,.9);
}
.pdf-flipbook-nav:disabled {
    opacity: .3;
    cursor: default;
}

/* Footer */
.pdf-flipbook-lb-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: 12px;
    padding: 0 4px;
    box-sizing: border-box;
}

.pdf-flipbook-page-info {
    color: rgba(255,255,255,.8);
    font-size: 13px;
}

.pdf-flipbook-download {
    color: rgba(255,255,255,.75);
    font-size: 13px;
    text-decoration: none;
    transition: color .15s;
}
.pdf-flipbook-download:hover { color: #fff; }

/* Error */
.pdf-flipbook-error {
    color: #c00;
    font-style: italic;
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 600px) {
    .pdf-flipbook-nav {
        width: 34px;
        height: 34px;
        font-size: 20px;
    }

    .pdf-flipbook-lb-inner {
        padding: 0 8px;
    }

    .pdf-flipbook-lb-close {
        top: -36px;
        font-size: 28px;
    }
}


/* ============================================================
   PDF Flipbook Grid + Kategorien (v1.1)
   ============================================================ */

.pdf-flipbook-grid-wrap {
    width: 100%;
}

/* --- Filter-Tabs ------------------------------------------- */
.pfb-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
}

.pfb-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border: 2px solid #ddd;
    background: #fff;
    color: #444;
    font-size: 14px;
    font-weight: 500;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color .18s, color .18s, background .18s;
    line-height: 1.3;
}

.pfb-filter-tab:hover {
    border-color: #999;
    color: #111;
}

.pfb-filter-tab.pfb-active {
    border-color: #222;
    background: #222;
    color: #fff;
}

.pfb-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.25);
    color: inherit;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 999px;
    padding: 0 5px;
}

.pfb-filter-tab:not(.pfb-active) .pfb-tab-count {
    background: #eee;
    color: #666;
}

/* --- Kategorie-Abschnitte ---------------------------------- */
.pfb-category-section {
    margin-bottom: 48px;
    transition: opacity .2s ease;
}

.pfb-category-section.pfb-hidden {
    display: none;
}

.pfb-category-title {
    font-size: 1.25em;
    font-weight: 700;
    margin: 0 0 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e8e8e8;
    color: #222;
}

.pfb-category-desc {
    margin: 0 0 20px;
    color: #666;
    font-size: 14px;
}

.pfb-empty-note {
    color: #aaa;
    font-style: italic;
    font-size: 14px;
}

/* --- Grid -------------------------------------------------- */
.pfb-grid {
    display: grid;
    gap: 24px;
}

/* Spalten */
.pfb-cols-1 { grid-template-columns: repeat(1, 1fr); }
.pfb-cols-2 { grid-template-columns: repeat(2, 1fr); }
.pfb-cols-3 { grid-template-columns: repeat(3, 1fr); }
.pfb-cols-4 { grid-template-columns: repeat(4, 1fr); }
.pfb-cols-5 { grid-template-columns: repeat(5, 1fr); }
.pfb-cols-6 { grid-template-columns: repeat(6, 1fr); }

/* --- Karte ------------------------------------------------- */
.pfb-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pfb-card .pdf-flipbook-wrapper {
    display: block;
    width: 100%;
}

.pfb-card .pdf-flipbook-cover {
    width: 100%;
    display: block;
}

/* Coverbild im Grid: feste Höhe, object-fit */
.pfb-card-img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

/* Auto-Canvas im Grid */
.pfb-card-canvas {
    width: 100% !important;
    height: 220px !important;
    object-fit: cover;
    background: #f0f0f0;
    display: block;
}

.pfb-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    text-align: center;
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 900px) {
    .pfb-cols-4,
    .pfb-cols-5,
    .pfb-cols-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
    .pfb-cols-3,
    .pfb-cols-4,
    .pfb-cols-5,
    .pfb-cols-6 { grid-template-columns: repeat(2, 1fr); }

    .pfb-card-img,
    .pfb-card-canvas { height: 160px; }
}

@media (max-width: 420px) {
    .pfb-cols-2,
    .pfb-cols-3,
    .pfb-cols-4,
    .pfb-cols-5,
    .pfb-cols-6 { grid-template-columns: 1fr; }
}
