/* Matiak Archive Styles */

.matiak-archive {
    max-width: 100%;
}

.matiak-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
    gap: 2rem 2rem;
    padding: 0.5rem 0;
}

.matiak-booklet {
    cursor: pointer;
    transition: transform 0.3s ease;
    perspective: 1000px;
}

.matiak-booklet:hover {
    transform: translateY(-5px);
}

.matiak-booklet-inner {
    position: relative;
    width: 100%;
    padding-bottom: 141%; /* A4 ratio */
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.matiak-booklet:hover .matiak-booklet-inner {
    transform: rotateY(-10deg);
}

.matiak-booklet-cover {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1), 0 6px 20px rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.matiak-booklet:hover .matiak-booklet-cover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15), 0 12px 40px rgba(0, 0, 0, 0.15);
}

.matiak-booklet-spine {
    order:2;
    width: 3%;
    --c1:#999;
    --c2:#fff;
    background: linear-gradient(to right,
        var(--c1),
        var(--c2),
        var(--c1),
        var(--c2),
        var(--c1),
        var(--c2),
          var(--c1)
    );
    border-right: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: inset -2px 0 4px rgba(0, 0, 0, 0.3);
}

.matiak-booklet-front {
    flex: 1;
    background: linear-gradient(135deg, #3c7e71 0%, #2d6056 100%);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Thumbnail image styling */
.matiak-booklet-front.has-thumbnail {
    padding: 0;
    background: #fff;
}

.matiak-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Decorative pattern on cover (only for non-thumbnail covers) */
.matiak-booklet-front:not(.has-thumbnail)::before {
    content: '♟';
    position: absolute;
    font-size: 8rem;
    opacity: 0.08;
    right: -1rem;
    bottom: -1rem;
    transform: rotate(-15deg);
}

.matiak-booklet-front:not(.has-thumbnail)::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.02) 10px,
        rgba(255, 255, 255, 0.02) 20px
    );
    pointer-events: none;
}

.matiak-booklet-title {
    position: relative;
    z-index: 1;
    text-align: center;
    color: #EBE9E7;
}

.matiak-booklet-title h3 {
    font-size: 1.8rem;
    font-weight: bold;
    margin: 0 0 0.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    color: #EBE9E7;
}

.matiak-booklet-subtitle {
    font-size: 1.1rem;
    margin: 0.5rem 0;
    font-weight: 500;
    color: #EBE9E7;
    opacity: 0.95;
}

.matiak-booklet-year {
    font-size: 2rem;
    font-weight: bold;
    margin-top: 1rem;
    color: #EBE9E7;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.3);
}

.matiak-booklet-info {
    margin-top: 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

#pdf-viewer-modal{
    padding-right:0 !important;
    --bs-modal-header-padding:0.5rem;
    --bs-modal-padding:0.5rem;
}

/* PDF Viewer Modal Styles */
#pdf-viewer-modal .modal-header {
    background-color: #3c7e71;
    color: white;
    border-bottom: 2px solid #2d6056;
}

#pdf-viewer-modal .modal-header .btn-close {
    filter: brightness(0) invert(1);
}

#pdf-viewer-modal .modal-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

#pdf-viewer-modal .modal-body {
    background-color: #525659;
    padding: 1rem;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    height: calc(100vh - 120px); /* Viewport height minus header and footer */
}

#pdf-viewer-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
}

#pdf-canvas-wrapper {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: flex-start;
    max-height: 100%;
    transition: transform 0.2s ease;
}

#pdf-canvas-wrapper.single-page #pdf-canvas-right {
    display: none;
}

#pdf-canvas-left,
#pdf-canvas-right {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    background: white;
    max-height: 100%;
    height: auto;
    width: auto;
    display: none;
}

#pdf-canvas-left.loaded,
#pdf-canvas-right.loaded {
    display: block;
}

#pdf-viewer-modal .modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    justify-content: center;
    padding-bottom:calc(.5rem + env(safe-area-inset-bottom, 0))
}

#pdf-page-info {
    font-weight: 500;
    user-select: none;
}

#pdf-download {
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
}

#pdf-download:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: white;
    color: white;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .matiak-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
        gap: 2rem 1.5rem;
    }

    .matiak-booklet-title h3 {
        font-size: 1.4rem;
    }

    .matiak-booklet-subtitle {
        font-size: 0.95rem;
    }

    .matiak-booklet-year {
        font-size: 1.5rem;
    }

    .matiak-booklet-front {
        padding: 1rem 0.75rem;
    }

    #pdf-viewer-modal .modal-body {
        padding: 0.5rem;
    }

    #pdf-viewer-modal .modal-header {
        flex-wrap: wrap;
    }

    #pdf-viewer-modal .modal-controls {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #spread-label {
        display: none;
    }

    #pdf-viewer-modal .modal-title {
        display: none;
    }
}

@media (max-width: 480px) {
    .matiak-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
        gap: 1.5rem 1rem;
    }

    .matiak-booklet-title h3 {
        font-size: 1.2rem;
    }

    .matiak-booklet-subtitle {
        font-size: 0.85rem;
    }

    .matiak-booklet-year {
        font-size: 1.3rem;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#pdf-loading {
    animation: pulse 2s ease-in-out infinite;
}
