/* 시민누리애 플립북 - Base Styles */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* === Header === */
.site-header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 1rem 0;
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}
.site-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    text-decoration: none;
}

/* === Main === */
.site-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 60vh;
}

/* === Footer === */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: #999;
    font-size: 0.85rem;
    border-top: 1px solid #e0e0e0;
    margin-top: 2rem;
}

/* === Archive === */
.archive-header {
    text-align: center;
    margin-bottom: 2rem;
}
.archive-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
.archive-header p {
    color: #666;
}

.book-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.book-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}
.book-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.card-cover {
    position: relative;
    aspect-ratio: 3/4;
    background: #e8e8e8;
    overflow: hidden;
}
.card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cover-fallback-text {
    display: none;
    position: absolute;
    inset: 0;
    padding: 1rem;
    font-size: 0.9rem;
    color: #666;
    text-align: center;
    align-content: center;
}
.cover-fallback .cover-fallback-text {
    display: block;
}

.card-info {
    padding: 0.8rem 1rem;
}
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-volume {
    font-size: 0.8rem;
    color: #4a90d9;
    margin-right: 0.5rem;
}
.card-date {
    font-size: 0.8rem;
    color: #999;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: #999;
    font-size: 1.1rem;
}

/* === Error Pages === */
.error-page {
    text-align: center;
    padding: 4rem 1rem;
}
.error-page h1 {
    font-size: 3rem;
    color: #ccc;
    margin-bottom: 1rem;
}
.error-page p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 2rem;
}
.btn-home {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    background: #4a90d9;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
}
.btn-home:hover {
    background: #3a7bc8;
}

/* === Viewer === */
.viewer-container {
    position: fixed;
    inset: 0;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.8);
    color: #fff;
    z-index: 110;
}
.viewer-toolbar .toolbar-left,
.viewer-toolbar .toolbar-center,
.viewer-toolbar .toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.toolbar-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.toolbar-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
}
.toolbar-btn:hover {
    background: rgba(255,255,255,0.15);
}
.page-indicator {
    font-size: 0.85rem;
    white-space: nowrap;
}
.page-input {
    width: 3rem;
    text-align: center;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    border-radius: 3px;
    padding: 0.15rem;
    font-size: 0.85rem;
}

.flipbook-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

/* TOC Side Panel */
.toc-panel {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background: #fff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    transition: left 0.3s ease;
    z-index: 120;
    display: flex;
    flex-direction: column;
}
.toc-panel.open {
    left: 0;
}
.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
}
.toc-header h3 {
    font-size: 1rem;
}
.toc-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #666;
}
.toc-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}
.toc-list li {
    border-bottom: 1px solid #f0f0f0;
}
.toc-list a {
    display: flex;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    text-decoration: none;
    color: #333;
    font-size: 0.9rem;
}
.toc-list a:hover {
    background: #f5f5f5;
}
.toc-page-num {
    color: #999;
    font-size: 0.85rem;
}

/* TOC overlay */
.toc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 115;
}
.toc-overlay.active {
    display: block;
}

/* Flipbook loading spinner */
.flipbook-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    z-index: 5;
}
.flipbook-loading.hidden { display: none; }
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 0.8rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Image load error fallback */
.page img.img-error {
    opacity: 0.3;
    filter: grayscale(1);
}

/* Zoom overlay */
.zoom-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 130;
    cursor: zoom-out;
    overflow: auto;
}
.zoom-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}
.zoom-overlay img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    touch-action: pinch-zoom;
}

/* === Responsive === */
@media (max-width: 1023px) {
    .book-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 767px) {
    .book-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar-title { max-width: 120px; }
}
@media (max-width: 479px) {
    .book-grid { grid-template-columns: 1fr; }
}
