/* ==========================================================================
   Component: Book Grid
   Grid of book cards with optional tab navigation
   ========================================================================== */

.book-grid {
    /* inherits .section padding and .container width */
}

/* --- Header --- */
.book-grid__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

.book-grid__header-text {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.book-grid__title {
    font-family: var(--font-family-serif);
    font-size: 38px;
    font-weight: 500;
    line-height: 42px;
    color: var(--color-text);
}

.book-grid__subtitle {
    font-family: var(--font-family-serif);
    font-size: 20px;
    font-weight: 400;
    font-style: italic;
    line-height: 24px;
    color: var(--color-dark-500);
}

/* --- Tabs --- */
.book-grid__tabs {
    display: flex;
    gap: var(--spacing-md);
    flex-shrink: 0;
}

.book-grid__tab {
    position: relative;
    padding: var(--spacing-sm) 0;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 500;
    line-height: 1.3;
    color: var(--color-dark-400);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.book-grid__tab:hover {
    color: var(--color-text);
}

.book-grid__tab--active {
    color: var(--color-text);
    border-bottom-color: var(--color-text);
}

/* --- Panels --- */
.book-grid__panel {
    display: none;
}

.book-grid__panel--active {
    display: block;
}

/* --- Grid --- */
.book-grid__items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-xl);
}

/* --- Footer --- */
.book-grid__footer {
    display: flex;
    justify-content: center;
    margin-top: var(--spacing-2xl);
}

.book-grid__more {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 18px 26px;
    font-size: var(--font-size-lg);
    font-weight: 500;
    line-height: 20px;
}

.book-grid__more svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

/* --- Promo Card (inside grid) --- */
.promo-card {
    background: var(--color-accent-100);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 212px;
}

.promo-card__image {
    padding: 8px 8px 0;
    width: 100%;
}

.promo-card__image img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.promo-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: center;
    padding: var(--spacing-md) 12px var(--spacing-lg);
    width: 100%;
}

.promo-card__info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.promo-card__title {
    font-family: var(--font-family-serif);
    font-size: 20px;
    font-weight: 500;
    line-height: 24px;
    color: var(--color-text);
    text-align: center;
}

.promo-card__tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    background: var(--color-accent-700);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--color-text);
    white-space: nowrap;
}

.promo-card__desc {
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 400;
    line-height: 17px;
    color: var(--color-dark-500);
    text-align: center;
    padding: 0 12px;
}

.promo-card__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 15px 18px;
    min-width: 100px;
}

.promo-card__btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* --- Send Gift Card (inside grid) --- */
.send-gift-card {
    background: var(--color-accent-100);
    border: 1px solid var(--color-accent-200);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 248px;
}

.send-gift-card__image {
    padding: 14px 14px 0;
    width: 100%;
}

.send-gift-card__image img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.send-gift-card__body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: center;
    padding: var(--spacing-md) 14px 14px;
    width: 100%;
}

.send-gift-card__info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.send-gift-card__title {
    font-family: var(--font-family-serif);
    font-size: 20px;
    font-weight: 500;
    line-height: 24px;
    color: var(--color-text);
    text-align: center;
}

.send-gift-card__tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    background: var(--color-accent);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--color-text);
    white-space: nowrap;
}

.send-gift-card__desc {
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 400;
    line-height: 20px;
    color: var(--color-dark-500);
    text-align: center;
}

.send-gift-card__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 15px 18px;
    width: 100%;
}

.send-gift-card__btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* --- Modifier: icon-only format tags (Emigrant section) --- */
.book-grid--icon-only-formats .book-card__format {
    padding: 4px;
}

.book-grid--icon-only-formats .book-card__format-label {
    display: none;
}

/* --- Modifier: Related products (product page) --- */
.product-page__related .book-grid__header-text {
    gap: 8px;
}

.product-page__related .book-grid__title {
    font-size: 32px;
    line-height: 40px;
}

.product-page__related .book-grid__header {
    margin-bottom: var(--spacing-xl);
}

.product-page__related .book-grid__items {
    gap: var(--spacing-md);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* --- Tablet: <=1024px --- */
@media (max-width: 1024px) {
    .book-grid__header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }

    .book-grid__items {
        grid-template-columns: repeat(3, 1fr);
    }

    .product-page__related .book-grid__items {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }

    .product-page__related .book-grid__items > * {
        flex: 0 0 calc(25% - 12px);
        min-width: 200px;
        scroll-snap-align: start;
    }
}

/* --- Promo grid: tablet only (3 cols × 2 rows = 6 items) --- */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Push books after position 3 behind promo */
    .book-grid__items--with-promo > :nth-child(n+4):not(.promo-card):not(.send-gift-card) {
        order: 1;
    }
    /* Hide last 2 items (keep 6) */
    .book-grid__items--with-promo > :nth-child(n+7) {
        display: none;
    }
}

/* --- Mobile: <=768px --- */
@media (max-width: 768px) {
    .book-grid__title {
        font-size: var(--font-size-2xl);
        line-height: 1.2;
    }

    .book-grid__subtitle {
        font-size: var(--font-size-lg);
        line-height: 22px;
    }

    .book-grid__tabs {
        gap: var(--spacing-md);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .book-grid__items {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-md);
    }

    .promo-card,
    .send-gift-card {
        min-width: 0;
    }

    /* Promo grid: 2 cols × 2 rows = 4 items */
    /* Hide books 4 and 6+ (keep: book1, book2, promo, book3) */
    .book-grid__items--with-promo > :nth-child(4),
    .book-grid__items--with-promo > :nth-child(n+6) {
        display: none;
    }
    /* Move book3 after promo */
    .book-grid__items--with-promo > :nth-child(3) {
        order: 1;
    }

    .product-page__related {
        padding-top: var(--spacing-xl);
        padding-bottom: var(--spacing-xl);
    }

    .product-page__related .book-grid__header-text {
        gap: 4px;
    }

    .product-page__related .book-grid__title {
        font-size: 22px;
        line-height: 26px;
    }

    .product-page__related .book-grid__subtitle {
        font-size: var(--font-size-lg);
        line-height: 22px;
    }

    .product-page__related .book-grid__items {
        gap: 12px;
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        flex-wrap: nowrap;
    }

    .product-page__related .book-grid__items > * {
        flex: 0 0 calc(33.333% - 8px);
        min-width: 159px;
        scroll-snap-align: start;
    }
}
