/* Main gallery styles */
main.gallery {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px 20px;
    position: relative;
}

.gallery-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    width: 100%;
}

/* Book styles */
.book {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 4 / 5;
    justify-self: center;
    cursor: pointer;
    transition: all 0.3s ease;
    perspective: 1000px;
    outline: none;
}

.book:hover {
    transform: translateY(-10px) rotateY(-5deg);
}

.book:focus {
    outline: 3px solid #daa520;
    outline-offset: 4px;
}

.book:active {
    transform: translateY(-5px) rotateY(-2deg);
}

.book-spine {
    flex-shrink: 0;
    width: 18px;
    height: 100%;
    background-color: #734f30;
    border: 2px solid #daa520;
    border-right: none;
    border-radius: 5px 0 0 5px;
    box-shadow: -3px 0 8px rgba(0, 0, 0, 0.3);
}

.book-cover {
    flex: 1;
    height: 100%;
    background-color: #3a4d39;
    border: 4px solid #daa520;
    border-radius: 0 15px 15px 0;
    box-shadow: 4px 10px 25px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 14px;
    position: relative;
    overflow: hidden;
}

.book-cover h2 {
    font-family: 'Bubblegum Sans', cursive;
    font-size: clamp(20px, 2.2vw, 25px);
    color: #daa520;
    text-align: center;
    text-shadow: 1px 1px 0 #331a00;
    position: relative;
    z-index: 2;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.book-cover h3 {
    font-family: 'Bubblegum Sans', cursive;
    font-size: clamp(22px, 2.8vw, 29px);
    color: #f5f5dc;
    text-align: center;
    text-shadow: 2px 2px 0 #331a00;
    position: relative;
    z-index: 2;
    line-height: 1.2;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.book-image-placeholder {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    border: 3px solid #daa520;
    border-radius: 50%;
    background-color: #734f30;
    background-size: cover;
    background-position: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Book detail modal */
.book-detail {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.book-detail.active {
    display: flex;
    opacity: 1;
}

.book-open {
    border: 5px solid #daa520;
    background: #e6d2b5;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    max-width: 900px;
    width: 100%;
    height: 90vh;
    overflow: hidden;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    flex-direction: column; /* spread mengisi secara vertikal */
}

.book-detail.active .book-open {
    transform: scale(1);
}

.dinosaur-title {
    font-family: 'Bubblegum Sans', cursive;
    font-size: 36px;
    color: #3a4d39;
    text-shadow: 2px 2px 0 #daa520;
    margin-bottom: 5px;
    text-align: center;
}

.dinosaur-pronounciation {
    font-family: 'Bubblegum Sans', cursive;
    font-size: 20px;
    color: #566E52;
    margin-bottom: 2px;
    text-align: center;
}

.page-title-detail {
    font-family: 'Bubblegum Sans', cursive;
    font-size: 28px;
    color: #3a4d39;
    text-shadow: 2px 2px 0 #daa520;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid #734f30;
    padding-bottom: 10px;
}

.image {
    width: auto;
    height: auto;
    max-width: 200px;
    max-height: 150px;
    object-fit: contain;
    border: 0px solid #734f30;
    border-radius: 15px;
    margin: 10px auto;
    display: block;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.classification-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.tag {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    color: #f5f5dc;
}

.tag.carnivore { background-color: #d32f2f; }
.tag.herbivore { background-color: #388e3c; }
.tag.omnivore { background-color: #f57c00; }
.tag.cretaceous { background-color: #7b1fa2; }
.tag.jurassic { background-color: #1976d2; }
.tag.triassic { background-color: #e64a19; }
.tag.large { background-color: #f57c00; }
.tag.small { background-color: #795548; }
.tag.medium { background-color: #607d8b; }

.stats-box {
    background: rgba(58, 77, 57, 0.1);
    border: 2px solid #734f30;
    border-radius: 15px;
    padding: 10px;
    margin: 10px 0px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 16px;
    padding: 5px 0;
    border-bottom: 1px dotted rgba(115, 79, 48, 0.3);
}

.stat-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.stat-label {
    font-weight: 600;
    color: #3a4d39;
    flex: 1;
}

.stat-value {
    font-weight: 700;
    color: #734f30;
    text-align: right;
    flex: 1;
}

.discovery-info {
    background: rgba(58, 77, 57, 0.1);
    border: 2px solid #734f30;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 10px;
}

.additional-images-gallery {
    margin-top: 20px;
}

.gallery-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    margin: 5px 0;
    border: 2px solid #734f30;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-image:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.page-footer {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.page-indicator {
    font-family: 'Bubblegum Sans', cursive;
    color: #734f30;
    font-size: 14px;
    font-weight: 600;
}

/* Loading and error states */
#loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(230, 210, 181, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    text-align: center;
    z-index: 100;
}

.round-btn {
    position: absolute;
    background: #734f30;
    color: #f5f5dc;
    border: 2px solid #daa520;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-weight: bold;
    font-size: 24px;
}

.close-btn {
    top: 15px;
    right: 15px;
    font-weight: lighter;
}

.close-btn:hover {
    background: #8b5a2b;
    transform: scale(1.1);
}

.nav-btn {
    top: 50%;
}

.nav-btn:hover:not(:disabled) {
    background: #8b5a2b;
    transform: scale(1.1);
}

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

.page-counter-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(115, 79, 48, 0.9);
    color: #f5f5dc;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
}

/* Page spread management */
.book-page-spread {
    display: none;
    width: 100%;
    flex: 1;               /* mengisi penuh book-open */
    height: 100%;
    min-height: 0;  
}

.book-page-spread.active {
    display: flex;
    height: 100%;
}

.book-page-spread .book-page {
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;        /* ganti dari overflow-y: auto */
    padding: 30px 30px 0px;
    margin-bottom: 0px;
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* konten tersebar merata */
}

.book-page-spread .book-page.left-page {
    border-right: 3px solid #daa520;
}

/* Enhanced content sections */
.discovery-story,
.physical-description,
.behavior-info,
.diet-info,
.habitat-info {
    background: rgba(58, 77, 57, 0.05);
    border-left: 4px solid #734f30;
    padding: 15px;
    margin: 15px 0;
    border-radius: 0 10px 10px 0;
}

.discovery-story h4,
.physical-description h4,
.behavior-info h4,
.diet-info h4,
.habitat-info h4 {
    font-family: 'Bubblegum Sans', cursive;
    font-size: 18px;
    color: #3a4d39;
    margin-bottom: 10px;
    text-shadow: 1px 1px 0 #daa520;
}

.feature-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 16px;
}

.feature-label {
    font-weight: 600;
    color: #3a4d39;
}

.feature-value {
    font-weight: 700;
    color: #734f30;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Notification styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    padding: 15px 20px;
    border-radius: 10px;
    color: white;
    font-family: 'Cabin', sans-serif;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.notification.info { background: #3a4d39; }
.notification.error { background: #d32f2f; }
.notification.success { background: #388e3c; }

/* Expanded image modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    cursor: pointer;
}

.image-modal img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.image-modal .close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    font-size: 30px;
}

/* Responsive styles */
@media (max-width: 768px) {
    header {
        padding: 12px 15px;
        border-radius: 20px;
    }

    .back-btn {
        width: 55px;
        height: 55px;
        font-size: 24px;
        margin-right: 15px;
    }

    .logo h1 {
        font-size: 36px;
    }

    .gallery-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .book {
        max-width: 280px;
    }

    .book-spine {
        width: 15px;
    }

    .book-cover {
        padding: 14px 10px;
    }

    .book-image-placeholder {
        width: 80px;
        height: 80px;
    }

    .book-open {
        flex-direction: column;
        max-height: 95vh;
    }

    .book-page-spread {
        flex-direction: column;
        overflow-y: auto;
        height: 100%;
    }

    .book-page-spread .book-page {
        padding: 40px 15px 20px;
        flex: none;
    }

    /* On mobile, show only one page at a time */
    .book-page-spread .book-page.left-page {
        border-right: none;
        border-bottom: none;
    }

    /* Hide right page by default on mobile - JS will show single pages */
    .book-page-spread.mobile-left .book-page.right-page {
        display: none;
    }

    .book-page-spread.mobile-right .book-page.left-page {
        display: none;
    }

    .dinosaur-title {
        font-size: 28px;
    }

    .stat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .stat-value {
        text-align: left;
    }

    .page-title {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    header {
        padding: 10px 12px;
        border-radius: 18px;
    }

    .back-btn {
        width: 48px;
        height: 48px;
        font-size: 20px;
        margin-right: 12px;
    }

    .logo h1 {
        font-size: 28px;
    }

    .gallery-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .book {
        max-width: 100%;
    }

    .book-spine {
        width: 13px;
    }

    .book-cover {
        padding: 12px 8px;
    }

    .book-image-placeholder {
        width: 60px;
        height: 60px;
    }

    .book-page-spread .book-page {
        padding: 35px 12px 15px;
    }

    .dinosaur-title {
        font-size: 24px;
    }

    .classification-tags {
        gap: 8px;
    }

    .tag {
        padding: 6px 12px;
        font-size: 12px;
    }

    .stats-box, .discovery-info {
        padding: 15px;
    }

    .stat-item {
        font-size: 14px;
    }

    .notification {
        max-width: 250px;
        font-size: 14px;
        padding: 12px 16px;
    }

    .page-title {
        font-size: 20px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .book-cover { border-width: 6px; }
    .tag { border-width: 3px; }
    .stats-box, .discovery-info { border-width: 3px; }
}

/* Print styles */
@media print {
    header {
        position: relative;
        width: 100%;
        margin: 0;
        box-shadow: none;
    }

    .book-detail {
        position: relative;
        background: white;
        padding: 0;
    }

    .book-open {
        box-shadow: none;
        border: 2px solid #333;
    }

    .close-btn {
        display: none;
    }
}