/* ================================================
   Pinterest-Style Grid für BLATTWEISE Bibliothek
   ================================================ */

/* Section Styling */
.pinterest-library {
    padding: 4rem 0;
    background: #ffffff;
}

/* Filter-Leiste */
.pinterest-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    border-bottom: 1px solid #eef0f3;
    align-items: center;
}

.filter-search {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    min-width: 200px;
    padding: 0.625rem 1rem;
    background: #f7f7f8;
    border-radius: 24px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.filter-search:focus-within {
    border-color: #d1d5db;
    background: white;
}

.filter-search svg {
    color: #6b7280;
    flex-shrink: 0;
}

.filter-input {
    border: none;
    background: transparent;
    font-size: 1rem;
    color: #1f2937;
    width: 100%;
    outline: none;
}

.filter-input::placeholder {
    color: #9ca3af;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    padding: 0.5rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: white;
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-tag:hover {
    border-color: #9ca3af;
    color: #1f2937;
}

.filter-tag.active {
    background: #1f2937;
    border-color: #1f2937;
    color: white;
}

.age-select {
    padding: 0.5rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    background: white;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    min-width: 160px;
    outline: none;
    transition: all 0.2s ease;
}

.age-select:hover,
.age-select:focus {
    border-color: #9ca3af;
}

/* Grid Layout */
.pinterest-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: auto;
    grid-auto-flow: dense;
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 1300px) {
    .pinterest-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .pinterest-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 500px) {
    .pinterest-grid { grid-template-columns: 1fr; gap: 0.75rem; }
}

/* Pin Card */
.pin-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 40px -36px rgba(17, 24, 39, 0.55);
    border: 1px solid #edf1f5;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    margin: 0;
    width: 100%;
    height: fit-content;
}

.pin-card:hover {
    box-shadow: 0 26px 56px -38px rgba(17, 24, 39, 0.45);
    transform: translateY(-3px);
    border-color: #dbe2ea;
}

.pin-card.featured {
    box-shadow: none;
}

.pin-card.featured:hover {
    box-shadow: 0 4px 14px rgba(17, 12, 34, 0.12);
}

.pin-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.pin-link.locked {
    position: relative;
}

/* Pin Image / Icon Area */
.pin-image {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    overflow: hidden;
}

/* Hochformat: 1 Spalte, A4 hoch (210:297) */
.pin-portrait .pin-image {
    aspect-ratio: 210 / 297;
    min-height: unset;
}

/* Querformat: 2 Spalten, A4 quer (297:210) */
.pin-landscape {
    grid-column: span 2;
}
.pin-landscape .pin-image {
    aspect-ratio: 297 / 210;
    min-height: unset;
}

@media (max-width: 900px) {
    .pin-landscape { grid-column: span 2; }
}

@media (max-width: 500px) {
    .pin-landscape { grid-column: span 1; }
    .pin-landscape .pin-image { aspect-ratio: 297 / 210; }
}

/* Vollflächiger farbiger Platzhalter (statt kleinem Icon), wenn kein Bild vorhanden ist */
.pin-image-placeholder {
    background: linear-gradient(135deg, #fde68a 0%, #fbbf24 100%);
}
.pin-image-placeholder.mathe { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); }
.pin-image-placeholder.deutsch { background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%); }
.pin-image-placeholder.science { background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%); }
.pin-image-placeholder.kunst { background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%); }
.pin-image-placeholder.coding { background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%); }
.pin-image-placeholder.natur { background: linear-gradient(135deg, #ecfccb 0%, #d9f99d 100%); }
.pin-image-placeholder.ki { background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%); }

.pin-image-placeholder .pin-icon-wrapper {
    width: 72px;
    height: 72px;
    background: rgba(255, 255, 255, 0.55) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.pin-image-placeholder .pin-icon-wrapper svg {
    width: 40px;
    height: 40px;
}

.pin-preview-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Live-Vorschau des gesamten Arbeitsblatts (statt nur Vorschaubild) für Items mit Editor-Modus */
.pin-worksheet-preview {
    width: 100%;
    height: 100%;
    min-height: inherit;
    background: #F7F8FC;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10px;
}
.pin-worksheet-preview .ws-preview-page {
    position: relative;
    background: #fff;
    box-shadow: 0 6px 16px -8px rgba(32,31,51,0.18);
    border-radius: 3px;
    flex: 0 0 auto;
    transform-origin: top center;
    overflow: hidden;
}
.pin-worksheet-preview .ws-preview-element {
    position: absolute;
    overflow: hidden;
    pointer-events: none;
}
.pin-worksheet-preview .ws-preview-loading {
    align-self: center;
    color: #B7B5CC;
    font-size: 12px;
}

.pin-icon-wrapper {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    box-shadow: none;
    transition: all 0.3s ease;
}

.pin-icon-wrapper svg {
    width: 32px;
    height: 32px;
    transition: all 0.3s ease;
}

.pin-icon-wrapper svg {
    transition: all 0.3s ease;
}

.pin-card:hover .pin-icon-wrapper svg {
    transform: scale(1.1);
}

/* Category Colors */
.pin-icon-wrapper.mathe {
    background: #fde68a;
}
.pin-icon-wrapper.mathe svg {
    stroke: #92400e;
}

.pin-icon-wrapper.deutsch {
    background: #bfdbfe;
}
.pin-icon-wrapper.deutsch svg {
    stroke: #1e40af;
}

.pin-icon-wrapper.science {
    background: #a7f3d0;
}
.pin-icon-wrapper.science svg {
    stroke: #065f46;
}

.pin-icon-wrapper.kunst {
    background: #fbcfe8;
}
.pin-icon-wrapper.kunst svg {
    stroke: #9d174d;
}

.pin-icon-wrapper.coding {
    background: #ddd6fe;
}
.pin-icon-wrapper.coding svg {
    stroke: #5b21b6;
}

.pin-icon-wrapper.natur {
    background: #d9f99d;
}
.pin-icon-wrapper.natur svg {
    stroke: #3f6212;
}

.pin-icon-wrapper.ki {
    background: #c7d2fe;
}
.pin-icon-wrapper.ki svg {
    stroke: #3730a3;
}

/* Lock Overlay */
.pin-link.locked .pin-icon-wrapper {
    opacity: 0;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(31, 27, 46, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease;
    border-radius: inherit;
}

.pin-link.locked .lock-overlay {
    opacity: 1;
}

.pin-link.locked:hover .lock-overlay {
    background: rgba(31, 27, 46, 0.7);
}

.lock-overlay svg {
    fill: white;
    width: 40px;
    height: 40px;
}

/* Pin Content */
.pin-content {
    padding: 0.6rem 0.75rem 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pin-category {
    display: none;
}

.category-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.category-badge.mathe {
    background: #fef3c7;
    color: #92400e;
}

.category-badge.deutsch {
    background: #dbeafe;
    color: #1e40af;
}

.category-badge.science {
    background: #d1fae5;
    color: #065f46;
}

.category-badge.kunst {
    background: #fce7f3;
    color: #9d174d;
}

.category-badge.coding {
    background: #ede9fe;
    color: #5b21b6;
}

.category-badge.natur {
    background: #ecfccb;
    color: #3f6212;
}

.category-badge.ki {
    background: #e0e7ff;
    color: #3730a3;
}

.featured-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    border-radius: 8px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
}

.pin-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pin-description {
    display: none;
}

.pin-meta {
    display: flex;
    gap: 0.5rem;
    margin-top: 0;
    padding-top: 0;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    color: #9ca3af;
}

.meta-item svg {
    color: #9ca3af;
}



/* Load More Button */
.load-more-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 3rem;
}

/* Empty State */
.pinterest-library .empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: #9ca3af;
}

.pinterest-library .empty-state svg {
    stroke: #d1d5db;
    margin-bottom: 1rem;
}

/* Animation für Cards */
.pin-card {
    animation: fadeInUp 0.4s ease-out both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Hidden Cards (für Load More) */
.pin-card.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .pinterest-library {
        padding: 3rem 0;
    }

    .pinterest-filters {
        flex-direction: column;
        gap: 1rem;
    }

    .filter-search {
        width: 100%;
    }

    .filter-tags {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.5rem;
    }

    .filter-tag {
        flex-shrink: 0;
    }

    .age-select {
        width: 100%;
    }

    .pin-content {
        padding: 0.5rem 0.625rem 0.5rem;
    }

    .pin-title {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .pinterest-grid {
        grid-template-columns: 1fr;
    }
    .pin-landscape { grid-column: span 1; }
}

/* Filter-Animation */
.pin-card.filter-hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    position: absolute;
}

.pin-card.filter-visible {
    opacity: 1;
    transform: scale(1);
    transition: all 0.3s ease;
}

/* ================================================
   Inline Expand-Panel (Pinterest-Style: große Kachel im Grid statt Popup)
   ================================================ */
.pin-expanded-panel {
    display: none;
    flex: 1 1 50%;
    min-width: 0;
    flex-direction: column;
    padding: 1.25rem 1.25rem 1.25rem 1rem;
    border-left: 1px solid #edf1f5;
    background: #fff;
    overflow-y: auto;
    position: relative;
}

.pinterest-grid {
    position: relative;
}

.pin-expanded-panel.active {
    display: flex;
    flex-direction: column;
    animation: expandIn 0.2s ease-out;
}

@keyframes expandIn {
    from {
        opacity: 0;
        transform: scale(0.97);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.pin-card.pin-card-active {
    grid-column: span 2;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    height: auto;
    overflow: hidden;
    box-shadow: 0 36px 72px -42px rgba(17, 24, 39, 0.55);
    border-color: #cfd8e3;
    transition: none;
}

.pin-card.pin-card-active > .pin-link {
    flex: 0 0 50%;
    min-width: 0;
    height: auto;
}

.pin-card.pin-card-active .pin-title {
    font-size: 1.0625rem;
}

.pin-expanded-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #1f2937;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.pin-expanded-close:hover {
    background: white;
}

.pin-expanded-image {
    flex: 1 1 54%;
    min-width: 0;
    min-height: 0;
    background: linear-gradient(135deg, #eef2f7 0%, #dbe4ef 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-height: 380px;
    position: relative;
}

.pin-expanded-image img {
    width: 100%;
    height: 100%;
    max-height: 380px;
    object-fit: cover;
    display: block;
}

.pin-expanded-worksheet-preview {
    width: 100%;
    height: 100%;
    max-height: 380px;
    background: #F7F8FC;
    overflow: hidden;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.pin-expanded-worksheet-preview .ws-preview-page {
    position: relative;
    background: #fff;
    box-shadow: 0 6px 18px -8px rgba(32,31,51,0.22);
    border-radius: 4px;
    flex: 0 0 auto;
    transform-origin: top center;
    overflow: hidden;
}

.pin-expanded-worksheet-preview .ws-preview-element {
    position: absolute;
    overflow: hidden;
    pointer-events: none;
}

.pin-expanded-worksheet-preview .ws-preview-loading {
    margin: 1rem auto;
    color: #B7B5CC;
    font-size: 13px;
}

.pin-expanded-details {
    flex: 1 1 46%;
    min-width: 280px;
    padding: 1.25rem 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    overflow-y: auto;
}

.pin-expanded-details h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1f2937;
    margin: 0;
}

.pin-expanded-details p {
    color: #4b5563;
    font-size: 0.9375rem;
    line-height: 1.5;
    margin: 0;
}

.pin-expanded-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.25rem;
}

.pin-expanded-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.75rem;
}

.pin-expanded-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 24px;
    font-weight: 700;
    font-size: 0.9375rem;
    text-decoration: none;
    border: 1px solid #e5e7eb;
    color: #1f2937;
    background: white;
    transition: all 0.2s ease;
}

.pin-expanded-btn:hover {
    border-color: #9ca3af;
    background: #f9fafb;
}

.pin-expanded-btn.primary {
    background: #1f2937;
    color: white;
    border-color: #1f2937;
}

.pin-expanded-btn.primary:hover {
    background: #111827;
}

@media (max-width: 768px) {
    .pin-card.pin-card-active {
        grid-column: span 1;
    }

    .pin-expanded-panel.active {
        flex-direction: column;
    }

    .pin-expanded-image {
        min-height: 160px;
        max-height: 220px;
    }

    .pin-expanded-image img,
    .pin-expanded-worksheet-preview {
        max-height: 220px;
    }

    .pin-expanded-details {
        min-width: 0;
        padding: 1rem 1rem 1.2rem;
    }
}

