:root {
    --success:     #1f6b3a;  /* 4.5:1 contrast on white */
    --error:       #c0524f;
}


.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;
}

.star-fieldset {
    border: none;
    padding: 0;
    margin: 0 0 8px;
}

.book-detail-wrapper {
    max-width: 1080px;
    margin: 0 auto;
    padding: 48px 24px 32px;
}

.book-detail-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 48px;
    align-items: start;
}

.book-cover-col {
    align-self: start;
}

.book-cover-large {
    width: 100%;
    max-width: 320px;
    border-radius: 6px;
    box-shadow: 4px 6px 24px rgba(0,0,0,0.15);
}

@media (max-width: 768px) {
    .book-detail-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    .book-cover-col {
        text-align: center;
    }
    .book-cover-large { max-width: 240px; margin: 0 auto; }
}

.cover-placeholder-lg {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 2/3;
    background: linear-gradient(135deg, #e8e4f0, #d8d0e8);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--navy-mid);
}

.book-genre {
    font-size: 0.7rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 8px;
}

.book-title-lg {
    font-family: 'Playfair Display', serif;
    font-size: 2.4rem;
    font-weight: 400;
    color: var(--ink);
    margin: 0 0 8px;
    line-height: 1.2;
}

.book-author-lg {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 16px;
}

.inline-rating {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.stars-display i {
    color: var(--gold);
    font-size: 1rem;
}

.stars-sm i { font-size: 0.8rem; }

.rating-number {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--ink);
}

.rating-count {
    font-size: 0.85rem;
    color: var(--muted);
}

.book-price-lg {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    font-weight: 400;
    color: var(--ink);
    margin-bottom: 16px;
}

.book-desc {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--muted);
    margin-bottom: 20px;
}

.book-stock {
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 20px;
}
.book-stock.in-stock { color: var(--success); }
.book-stock.out-of-stock { color: var(--error); }

.add-to-cart-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    background: var(--navy);
    color: var(--bg);
    border: none;
    border-radius: 4px;
    font-size: 0.82rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.25s, transform 0.15s;
}
.add-to-cart-btn:hover {
    background: var(--navy-mid);
    transform: translateY(-1px);
    color: var(--bg);
}
.add-to-cart-btn.added {
    background: var(--success);
}

.reviews-section {
    max-width: 1080px;
    margin: 0 auto;
    padding: 48px 24px 80px;
    border-top: 1px solid var(--line);
}

.reviews-heading {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 32px;
}

.reviews-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 48px;
    align-items: start;
}

.rating-summary {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 28px 24px;
    position: sticky;
    top: 24px;
}

@media (max-width: 768px) {
    .reviews-layout {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    .rating-summary {
        position: static;
    }
}

.avg-rating-big {
    text-align: center;
    margin-bottom: 8px;
}

.big-number {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 400;
    color: var(--ink);
}

.out-of {
    font-size: 0.85rem;
    color: var(--muted);
    margin-left: 4px;
}

.avg-stars {
    text-align: center;
    margin-bottom: 8px;
}
.avg-stars i { font-size: 1.2rem; }

.total-ratings {
    text-align: center;
    font-size: 0.82rem;
    color: var(--muted);
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.star-bars { display: flex; flex-direction: column; gap: 10px; }

.star-bar-row {
    display: grid;
    grid-template-columns: 50px 1fr 40px;
    align-items: center;
    gap: 10px;
}

.star-label {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.bar-track {
    height: 10px;
    background: var(--line);
    border-radius: 5px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--gold);
    border-radius: 5px;
    transition: width 0.6s ease;
    min-width: 0;
}

.bar-pct {
    font-size: 0.75rem;
    color: var(--muted);
    text-align: right;
}

.review-form-card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 28px;
    margin-bottom: 28px;
}

.review-form-card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 400;
    margin-bottom: 20px;
}

.form-label-sm {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: 8px;
}

.form-label-sm .req { color: var(--error); }
.form-label-sm .optional {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.75rem;
}

.star-picker {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    cursor: pointer;
}

.star-picker .star-pick {
    font-size: 1.6rem;
    color: var(--muted);
    transition: color 0.15s, transform 0.15s;
    display: inline-flex;
    border-radius: 4px;
    padding: 2px;
    outline: none;
}

.star-picker .star-pick i {
    color: inherit;
    pointer-events: none;
}

.star-picker .star-pick:focus-visible {
    outline: 2px solid var(--navy-mid);
    outline-offset: 2px;
}

.star-picker .star-pick:hover,
.star-picker .star-pick i.bi-star-fill {
    color: var(--gold);
}

.star-picker .star-pick:hover {
    transform: scale(1.15);
}

.star-picker .star-pick[aria-checked="true"] {
    color: var(--gold);
}

.review-form-card textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 12px 14px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.88rem;
    resize: vertical;
    min-height: 70px;
    max-height: 140px;
    outline: none;
    transition: border-color 0.2s;
}
.review-form-card textarea:focus { border-color: var(--navy-mid); }

.char-counter {
    text-align: right;
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 4px;
    margin-bottom: 16px;
}

.review-error {
    color: var(--error);
    font-size: 0.82rem;
    margin-bottom: 12px;
    min-height: 0;
}

.submit-review-btn {
    padding: 12px 28px;
    background: var(--navy);
    color: var(--bg);
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.25s;
}
.submit-review-btn:hover { background: var(--navy-mid); }
.submit-review-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.review-notice {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px 20px;
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 28px;
}
.review-notice i { margin-right: 6px; }
.review-notice a { color: var(--navy-mid); }

.review-card {
    padding: 20px 0;
    border-bottom: 1px solid var(--line);
}
.review-card:last-child { border-bottom: none; }

.review-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.review-avatar {
    font-size: 1.6rem;
    color: var(--muted);
}

.reviewer-name {
    font-weight: 500;
    font-size: 0.88rem;
    display: block;
    line-height: 1.2;
}

.review-date {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--muted);
}

.review-comment {
    font-size: 0.88rem;
    color: var(--ink);
    line-height: 1.6;
    margin: 0;
    padding-left: 42px;
}

.no-reviews {
    text-align: center;
    padding: 40px 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.review-card.new-review {
    animation: highlightNew 1.5s ease;
}

@keyframes highlightNew {
    0%   { background: var(--gold-light); }
    100% { background: transparent; }
}

.add-to-cart-btn:focus-visible,
.submit-review-btn:focus-visible {
    outline: 2px solid var(--navy-mid);
    outline-offset: 2px;
}

.review-form-card textarea:focus-visible {
    outline: 2px solid var(--navy-mid);
    outline-offset: 0;
    border-color: var(--navy-mid);
}

/* Add to cart TOAST */
#cart-toast {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 14px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 14px 18px;
    min-width: 290px;
    max-width: 340px;
    border-left: 4px solid var(--gold, #b8963e);
    transform: translateX(calc(100% + 48px));
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    cursor: pointer;
    overflow: hidden;
}

#cart-toast.show {
    transform: translateX(0);
    opacity: 1;
}

#cart-toast .toast-thumb {
    width: 44px;
    height: 58px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
}

#cart-toast .toast-thumb-fallback {
    width: 44px;
    height: 58px;
    border-radius: 5px;
    flex-shrink: 0;
    background: #f5f0e8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--gold, #b8963e);
}

#cart-toast .toast-body {
    flex: 1;
    min-width: 0;
}

#cart-toast .toast-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--gold, #b8963e);
    margin-bottom: 3px;
}

#cart-toast .toast-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1a1a1a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#cart-toast .toast-sub {
    font-size: 0.74rem;
    color: #888;
    margin-top: 3px;
}

#cart-toast .toast-sub a {
    color: var(--gold, #b8963e);
    text-decoration: none;
    font-weight: 500;
}

#cart-toast .toast-sub a:hover {
    text-decoration: underline;
}

#cart-toast .toast-check {
    color: #2e7d32;
    font-size: 1.4rem;
    flex-shrink: 0;
}

#cart-toast .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: var(--gold, #b8963e);
    transform-origin: left center;
    transform: scaleX(1);
}

#cart-toast.show .toast-progress {
    transition: transform 3s linear;
    transform: scaleX(0);
}

/*You Might Enjoy*/
.related-section {
    border-top: 1px solid var(--line);
    background: var(--bg);
    padding: 3rem 0 4rem;
}
.related-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1.25rem;
    margin-top: 1.5rem;
}
@media (max-width: 1100px) { .related-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 768px)  { .related-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 480px)  { .related-grid { grid-template-columns: repeat(2, 1fr); } }

.related-card {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease;
}
.related-card:hover { transform: translateY(-4px); }

.related-cover {
    aspect-ratio: 2/3;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 2px 10px rgba(26,44,91,0.08);
    display: flex; align-items: center; justify-content: center;
    padding: 0.5rem;
    margin-bottom: 0.65rem;
    transition: box-shadow 0.2s ease;
}
.related-card:hover .related-cover {
    box-shadow: 0 6px 20px rgba(26,44,91,0.14);
}
.related-cover img {
    width: auto; height: 100%; max-width: 100%;
    object-fit: contain;
}
.related-placeholder {
    font-size: 2rem; color: var(--muted);
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
.related-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.88rem; font-weight: 600;
    color: var(--navy); line-height: 1.3;
    margin-bottom: 0.15rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.related-card:hover .related-title { color: var(--navy-mid); }
.related-author {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem; color: var(--muted);
    font-style: italic; margin-bottom: 0.25rem;
}
.related-price {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem; font-weight: 600;
    color: var(--navy); margin-top: auto;
}
