/* 
 * Magazine Archive Site - Main Styles
 * Clean, elegant design with responsive layouts for desktop and mobile
 */

/* ============================================================================
   Reset and Base Styles
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background-color: #ffffff;
    color: #1a1a1a;
    line-height: 1.6;
    font-size: 16px;
}

a {
    color: #0066cc;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #0052a3;
}

button {
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ============================================================================
   Header and Navigation
   ============================================================================ */

header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    padding: 2rem 1rem;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #1a1a1a;
}

header .subtitle {
    font-size: 1.1rem;
    color: #666;
    font-weight: 400;
}

header nav {
    padding: 1rem 0 0 0;
}

header nav a {
    font-size: 0.95rem;
    color: #0066cc;
}

header nav a:hover {
    color: #0052a3;
}

/* ============================================================================
   Main Content Areas
   ============================================================================ */

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.index-page {
    width: 100%;
}

.issue-page {
    width: 100%;
}

.issue-header {
    margin-bottom: 2rem;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 1rem;
}

.issue-header h1 {
    font-size: 2rem;
    font-weight: 600;
    color: #1a1a1a;
}

/* ============================================================================
   Index Page - Year Sections
   ============================================================================ */

.year-section {
    margin-bottom: 3rem;
}

.year-section h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1a1a1a;
}

/* Publication Filter Buttons */

.pub-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.pub-filter {
    padding: 0.6rem 1.2rem;
    border: 1px solid #d0d0d0;
    background-color: #ffffff;
    color: #1a1a1a;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pub-filter:hover {
    background-color: #f0f0f0;
    border-color: #0066cc;
    color: #0066cc;
}

.pub-filter.active {
    background-color: #0066cc;
    color: #ffffff;
    border-color: #0066cc;
}

/* Issue Cards Grid */

.issues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.issue-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.issue-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-color: #0066cc;
    transform: translateY(-4px);
}

.issue-cover {
    width: 100%;
    aspect-ratio: 3/4;
    background-color: #f5f5f5;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.issue-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.issue-info {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.pub-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #0066cc;
    margin-bottom: 0.25rem;
}

.issue-date {
    font-size: 0.9rem;
    color: #666;
}

/* ============================================================================
   Image Gallery (Issue Pages)
   ============================================================================ */

.gallery {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background-color: #f5f5f5;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.2s ease;
}

.gallery-item img:hover {
    transform: scale(1.02);
}

.page-number {
    position: absolute;
    bottom: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 4px 0 0 0;
}

/* Desktop: Grid of 200px images */
@media (min-width: 769px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1.5rem;
    }

    .gallery-item {
        aspect-ratio: 3/4;
    }

    .gallery-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .gallery-item:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

/* Mobile: Single column, full width */
@media (max-width: 768px) {
    .gallery {
        grid-template-columns: 1fr;
    }

    .gallery-item {
        aspect-ratio: auto;
    }

    .gallery-item img {
        width: 100%;
        height: auto;
    }
}

/* ============================================================================
   Modal - Image Pop-up (Desktop Only)
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 90%;
    max-width: 1200px;
    max-height: 85vh;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translate(-50%, -55%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

.modal-content {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    cursor: grab;
    user-select: none;
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: #ffffff;
    font-size: 2.5rem;
    font-weight: 300;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.2s ease;
    line-height: 1;
}

.close:hover {
    color: #ddd;
}

.modal-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1001;
}

/* Hide modal on mobile */
@media (max-width: 768px) {
    .modal {
        display: none !important;
    }
}

/* ============================================================================
   Back to Top Button
   ============================================================================ */

.back-to-top {
    display: block;
    margin: 2rem auto;
    padding: 0.8rem 2rem;
    background-color: #f0f0f0;
    color: #1a1a1a;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.back-to-top:hover {
    background-color: #0066cc;
    color: #ffffff;
    border-color: #0066cc;
}

.back-to-top:active {
    transform: scale(0.98);
}

/* ============================================================================
   Footer
   ============================================================================ */

footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    padding: 2rem 1rem;
    text-align: center;
    margin-top: 3rem;
}

footer p {
    font-size: 0.9rem;
    color: #666;
}

footer a {
    color: #0066cc;
}

footer a:hover {
    color: #0052a3;
}

/* ============================================================================
   Utilities and Responsive
   ============================================================================ */

@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .issue-header h1 {
        font-size: 1.5rem;
    }

    .year-section h2 {
        font-size: 1.5rem;
    }

    main {
        padding: 1rem 0.75rem;
    }

    .issues-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .issue-header h1 {
        font-size: 1.25rem;
    }

    .year-section h2 {
        font-size: 1.25rem;
    }

    .pub-filters {
        gap: 0.5rem;
    }

    .pub-filter {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .issues-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Print styles */
@media print {
    .modal {
        display: none !important;
    }

    .back-to-top {
        display: none !important;
    }

    header nav {
        display: none;
    }
}
