/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #2c1810 0%, #4a2f20 100%);
    color: #f5f5f0;
    padding: 2rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header h1 a {
    color: #f5f5f0;
    text-decoration: none;
    transition: color 0.3s;
}

header h1 a:hover {
    color: #d4af37;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-style: italic;
}

/* Main content */
main {
    flex: 1;
    padding: 2rem 0;
}

/* Index page */
.index-header {
    text-align: center;
    margin-bottom: 2rem;
}

.index-header h2 {
    font-size: 2rem;
    color: #2c1810;
    margin-bottom: 0.5rem;
}

/* Attribution Box */
.attribution-box {
    background: linear-gradient(135deg, #f8f4e6 0%, #f0e6d2 100%);
    border: 2px solid #d4af37;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.attribution-content h3 {
    color: #2c1810;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.attribution-content p {
    color: #444;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.source-link {
    color: #2c1810;
    font-weight: bold;
    text-decoration: none;
    border-bottom: 2px solid #d4af37;
    transition: all 0.3s;
    display: inline-block;
    padding: 0.25rem 0;
}

.source-link:hover {
    color: #d4af37;
    border-bottom-color: #2c1810;
}

.public-domain {
    font-style: italic;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
    margin-top: 1rem;
    margin-bottom: 0;
}

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

.page-thumbnail {
    position: relative;
    display: block;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    text-decoration: none;
}

.page-thumbnail:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

.page-thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 3/4;
    object-fit: cover;
}

.page-number {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(44, 24, 16, 0.9);
    color: white;
    padding: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    background: #2c1810;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
    font-size: 0.9rem;
}

.pagination-btn:hover:not(.disabled) {
    background: #4a2f20;
}

.pagination-btn.disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination-numbers {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-num {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    background: white;
    color: #2c1810;
    text-decoration: none;
    border: 2px solid #2c1810;
    border-radius: 4px;
    transition: all 0.3s;
    min-width: 40px;
    text-align: center;
}

.pagination-num:hover:not(.active) {
    background: #f0e6d2;
}

.pagination-num.active {
    background: #2c1810;
    color: white;
    font-weight: bold;
}

/* Page view */
.page-view {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 16px rgba(0,0,0,0.1);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    color: #2c1810;
    font-size: 1.8rem;
}

.nav-controls {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #2c1810;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
    font-size: 0.9rem;
    white-space: nowrap;
}

.nav-btn:hover:not(.disabled) {
    background: #4a2f20;
}

.nav-btn.disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.nav-btn .arrow {
    font-size: 1.2rem;
    font-weight: bold;
}

.page-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 900px) {
    .page-content {
        grid-template-columns: 1fr;
    }
}

.image-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.image-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.text-container {
    background: #fafafa;
    padding: 1.5rem;
    border-radius: 4px;
    border-left: 4px solid #d4af37;
}

.text-container h3 {
    color: #2c1810;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.text-content {
    color: #444;
    line-height: 1.8;
}

.text-content p {
    margin-bottom: 1rem;
}

.page-footer-nav {
    display: flex;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 2px solid #e0e0e0;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Footer */
footer {
    background: #2c1810;
    color: #f5f5f0;
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
}

footer a {
    color: #d4af37;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Fullscreen Viewer */
.fullscreen-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.fullscreen-viewer.active {
    display: flex;
}

.fullscreen-viewer.active .fullscreen-image-container {
    overflow: hidden;
}

.fullscreen-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    left: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10000;
    pointer-events: none;
}

.fullscreen-controls > * {
    pointer-events: auto;
}

.fullscreen-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #2c1810;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-weight: bold;
    line-height: 1;
    padding: 0;
}

.fullscreen-btn:hover {
    background: white;
    transform: scale(1.1);
}

.fullscreen-info {
    background: rgba(255, 255, 255, 0.9);
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    font-size: 1rem;
    color: #2c1810;
}

#zoomLevel {
    font-weight: bold;
    font-size: 1.2rem;
    min-width: 60px;
    text-align: center;
}

.controls-hint {
    font-size: 0.85rem;
    opacity: 0.8;
}

.fullscreen-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 5rem 2rem 2rem 2rem;
}

#fullscreenImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    transform-origin: center center;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

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

    .attribution-box {
        padding: 1.5rem;
    }

    .attribution-content h3 {
        font-size: 1.25rem;
    }

    .attribution-content p {
        font-size: 0.95rem;
    }

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

    .page-view {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-controls {
        width: 100%;
    }

    .nav-btn {
        flex: 1;
        text-align: center;
    }

    .fullscreen-info {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .controls-hint {
        font-size: 0.7rem;
    }

    .fullscreen-btn {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
}
