/* --- Base & Fonts --- */

:root {
    --dark-bg: #12101a;
    --glass-bg: rgba(36, 32, 51, 0.6);
    --border-color: rgba(122, 102, 204, 0.4);
    --primary-purple: #9370db;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    margin: 0;
    background-color: var(--dark-bg);
    color: var(--text-primary);
    transition: background-color 0.3s ease;
}

/* --- Main Layout --- */
.container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 20px;
    transition: all 0.3s ease;
}

.container.reader-mode {
    max-width: 100%;
    padding: 0;
    margin: 0;
}

/* --- Bookshelf / Album List --- */
.bookshelf-header {
    margin-bottom: 25px;
}

#search-input {
    width: 100%;
    padding: 12px 15px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    backdrop-filter: blur(10px);
    box-sizing: border-box;
    transition: all 0.3s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary-purple);
    box-shadow: 0 0 15px rgba(147, 112, 219, 0.3);
}
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 25px;
}

.album-item {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    font-size: 1.1em;
    font-weight: bold;
    min-height: 220px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.album-item:hover {
    transform: translateY(-8px);
    border-color: var(--primary-purple);
    box-shadow: 0 8px 30px rgba(147, 112, 219, 0.3);
}

/* --- Reader View --- */
.reader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.reader-image-item {
    position: relative; /* For progress bar positioning */
    line-height: 0;
    width: 100%;
    text-align: center;
    margin-bottom: 4px; /* A small gap between images */
}

.reader-image-item img {
    max-width: 100%;
    height: auto;
}

.virtualized-item {
    min-height: 400px; /* Placeholder height for virtualized items */
}

/* For Lazy Loading */
.per-image-progress-container {
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    transform: translateY(-50%);
    z-index: 2;
}

.per-image-progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--primary-purple);
    border-radius: 3px;
    transition: width 0.2s linear;
}
.spinner-wrapper {
    min-height: 300px; /* Placeholder height */
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    border: 4px solid rgba(147, 112, 219, 0.2);
    border-left-color: var(--primary-purple);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (min-width: 900px) {
    .reader-image-item img,
    .reader-image-item .spinner-wrapper {
        max-width: 900px;
    }

    .reader-image-item.single-page-mode img {
        max-width: none; /* Override for single page */
        max-height: 95vh; /* Ensure it fits vertically */
    }
}

/* --- Reader Controls --- */
#reader-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translate(-50%, 100px); /* Start off-screen */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    backdrop-filter: blur(12px);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
}

#progress-bar-container {
    position: absolute;
    top: -10px; /* Position above the control bar */
    left: 15%;
    width: 70%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
    transition: opacity 0.5s ease 1s; /* Fade out after a delay */
}

#progress-bar {
    width: 0%;
    height: 100%;
    background-color: var(--primary-purple);
    transition: width 0.4s ease-out;
    border-radius: 2px;
}

#reader-controls.visible {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

#reader-controls.hidden {
    /* The default state is hidden, so no extra class needed for hiding */
}

#reader-controls button {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
}

#reader-controls button.active {
    color: var(--primary-purple);
}

#reader-controls button:hover {
    background: rgba(147, 112, 219, 0.2);
}

#page-display {
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    padding: 5px 15px;
    min-width: 60px;
    text-align: center;
}

.page-slider {
    flex-grow: 1;
    margin: 0 10px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
}

.page-slider::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    border-radius: 2px;
}

.page-slider::-moz-range-track {
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    border-radius: 2px;
}

.page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -6px; /* (thumb height - track height) / -2 */
    background-color: var(--primary-purple);
    height: 16px;
    width: 16px;
    border-radius: 50%;
    border: 2px solid var(--dark-bg);
}

.page-slider::-moz-range-thumb {
    background-color: var(--primary-purple);
    height: 16px;
    width: 16px;
    border-radius: 50%;
    border: 2px solid var(--dark-bg);
}

/* --- Single Page Mode Click Navigation ---
.click-nav {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    cursor: pointer;
}

#nav-prev { left: 0; }
#nav-next { right: 0; }

/* --- Password Modal --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(18, 16, 26, 0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    width: 90%;
    max-width: 400px;
}

.modal-content input, .modal-content button {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    color: var(--text-primary);
    font-size: 16px;
}

.modal-content button {
    background: var(--primary-purple);
    border: none;
    cursor: pointer;
    margin-top: 15px;
}

.error-message {
    color: #ff8a8a;
    margin-top: 10px;
    height: 20px;
}

/* Hide scrollbar */
::-webkit-scrollbar { display: none; }


/* --- Accessibility Helper --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
