/* Fighting Fantasy Book Grid CSS */

* {
    box-sizing: border-box;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Make blurb text match container width */
.blurb {
    max-width: 1200px;
    margin: 10px auto;
    padding: 0 20px;
}

/* Style SIGN UP link with gold theme color */
#content .blurb a:link,
#content .blurb a:visited {
    color: #ffae00 !important;
    font-weight: 600;
}

#content .blurb a:hover {
    color: #c18608 !important;
}

h1 {
    color: #003129;
    text-align: center;
    margin-bottom: 40px;
    font-size: clamp(1.5rem, 4vw, 2.5rem);
}

/* Logo styling fixes */
#header img {
    max-width: 600px;
    width: 70%;
    filter: drop-shadow(2px 2px 4px rgba(193, 134, 8, 0.8)) 
            drop-shadow(-1px -1px 2px rgba(222, 215, 189, 0.9));
}


.book-grid {
    display: grid;
    gap: 25px;
    animation: fadeIn 0.6s ease;
    /* Default: 3 columns for most screens */
    grid-template-columns: repeat(3, 1fr);
}

/* Responsive breakpoints */
@media (min-width: 1600px) {
    .book-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 25px;
    }
}

@media (max-width: 768px) {
    .book-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (max-width: 500px) {
    .book-grid {
        grid-template-columns: 1fr;
        max-width: 320px;
        margin: 0 auto;
    }
}

.book-card {
    background: #ded7bd;
    border: 3px solid #c18608;
    color: #003129;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.5s ease backwards;
    position: relative;
}

.book-card:nth-child(n) {
    animation-delay: calc(var(--i) * 0.03s);
}

.book-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.book-cover {
    position: relative;
    padding-top: 140%;
    background: linear-gradient(135deg, #003129, #026a59);
    overflow: hidden;
}

.book-cover::before {
    content: '📚';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.3;
}

.book-cover img {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    object-fit: cover;
}

/* Special handling for slipcase images - show full image without cropping */
.slipcase-card .book-cover img {
    object-fit: contain;
}

.book-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.book-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #003129;
    margin-bottom: 10px;
    line-height: 1.3;
    text-align: center;
}

.book-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid #c18608;
}

.book-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.book-price {
    font-weight: 600;
    color: #003129;
}

.book-stock {
    color: #026a59;
}

.book-status {
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    padding: 4px 8px;
    background: linear-gradient(135deg, #003129, #026a59);
    color: #ded7bd;
    border-radius: 8px;
}

.lazy-load {
    opacity: 0;
    transform: translateY(20px);
}

.lazy-load.loaded {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.load-more {
    display: block;
    margin: 40px auto;
    padding: 12px 40px;
    background: #c18608;
    color: #003129;
    border: 2px solid #003129;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.load-more:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

/* Performance optimization for mobile */
@media (hover: none) {
    .book-card:hover {
        transform: none;
    }
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   MODAL STYLES
   ======================================== */

/* Modal overlay - dark backdrop */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 49, 41, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

/* Modal container - cream box with gold border */
.modal-container {
    background: #ded7bd;
    border: 5px solid #c18608;
    border-radius: 16px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.3);
    animation: slideUp 0.4s ease;
}

/* Close button */
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #c18608;
    color: #003129;
    border: 2px solid #003129;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.modal-close:hover {
    background: #003129;
    color: #ded7bd;
    transform: rotate(90deg);
}

/* Modal content layout - VERTICAL FOR ALL SCREENS */
.modal-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding: 40px;
    align-items: center;
}

/* Modal image section - CENTERED */
.modal-image {
    position: relative;
    width: 100%;
    max-width: 350px;
    margin: 0 auto;
    flex-shrink: 0;
}

.modal-image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    border-radius: 8px;
    border: 3px solid #c18608;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.modal-image img:hover {
    transform: scale(1.05);
}

/* Modal details section */
.modal-details {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-title {
    font-size: 1.8rem;
    color: #000;
    margin: 0;
    line-height: 1.3;
    font-weight: 700;
}

.modal-subtitle {
    font-size: 1rem;
    color: #000;
    font-style: italic;
    margin: 0;
    font-weight: 500;
}

.modal-author {
    font-size: 0.95rem;
    color: #000;
    font-weight: 600;
    margin-bottom: 5px;
}

.modal-author::before {
    content: "By ";
    font-weight: normal;
    color: #000;
}

.modal-description {
    font-size: 0.95rem;
    color: #000;
    line-height: 1.7;
    margin: 15px 0;
}

/* Style HTML elements within description */
.modal-description h3 {
    font-size: 1.2rem;
    color: #000;
    margin: 20px 0 10px 0;
    font-weight: 700;
    line-height: 1.3;
}

.modal-description h3:first-child {
    margin-top: 0;
}

.modal-description p {
    margin: 12px 0;
    line-height: 1.7;
}

.modal-description i {
    color: #000;
}

.modal-description b {
    color: #000;
    font-weight: 700;
}

.modal-meta {
    display: flex;
    gap: 35px;
    padding: 15px 0;
    flex-wrap: wrap;
    margin: 5px 0;
}

/* Credits row - appears first under author */
.modal-meta-credits {
    padding-bottom: 10px;
}

/* Purchase info row - secondary reference data */
.modal-meta-purchase {
    border-top: 1px solid rgba(193, 134, 8, 0.2);
    border-bottom: 1px solid rgba(193, 134, 8, 0.2);
    padding-top: 12px;
    padding-bottom: 12px;
    margin-top: 5px;
}

.modal-meta-purchase .modal-meta-label {
    font-size: 0.65rem;
    opacity: 0.9;
}

.modal-meta-purchase .modal-meta-value {
    font-size: 1rem;
}

.modal-meta-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modal-meta-label {
    font-size: 0.7rem;
    color: #000;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.modal-meta-value {
    font-size: 1.1rem;
    color: #000;
    font-weight: 700;
}

/* Credits section - secondary to author, normal weight */
.modal-meta-credits .modal-meta-label {
    text-transform: none;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0;
}

.modal-meta-credits .modal-meta-value {
    font-weight: 500;
    font-size: 1rem;
}

.modal-buy-button {
    display: inline-block;
    padding: 15px 40px;
    background: linear-gradient(135deg, #c18608, #ffae00);
    color: #003129;
    border: 3px solid #003129;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-top: 10px;
}

.modal-buy-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #ffae00, #c18608);
}

/* Tablet and mobile adjustments */
@media (max-width: 767px) {
    .modal-overlay {
        padding: 10px;
        align-items: flex-start;
    }

    .modal-container {
        max-height: 95vh;
        margin-top: 10px;
    }

    .modal-content {
        padding: 20px;
        padding-top: 60px; /* Space for close button */
        gap: 20px;
    }

    .modal-image {
        max-width: 280px;
    }

    .modal-title {
        font-size: 1.5rem;
    }

    .modal-subtitle {
        font-size: 1rem;
    }

    .modal-meta {
        gap: 15px;
    }

    .modal-buy-button {
        width: 100%;
        padding: 15px 20px;
    }
}

/* Small mobile adjustments */
@media (max-width: 480px) {
    .modal-content {
        padding: 15px;
        padding-top: 55px;
        gap: 15px;
    }

    .modal-title {
        font-size: 1.3rem;
    }

    .modal-image {
        max-width: 240px;
    }
}