/* ==========================================================================
   وعد — Design system ("Premium Arabic Editorial Bookstore")
   Forest green · deep green · cream · beige · antique gold. RTL first.
   Loaded after every page's own styles so it can unify them.
   ========================================================================== */

:root {
    --w-green: #102D20;
    --w-deep: #092318;
    --w-cream: #F8F0E2;
    --w-beige: #EADCC5;
    --w-gold: #C9A45C;
    --w-gold-dark: #8a6a22;
    --w-ink: #1c2a22;
    --w-muted: #6b6254;
    --w-paper: #fffdf8;
    --w-danger: #b3261e;
    --w-radius: 14px;
    --w-shadow: 0 10px 30px rgba(16, 45, 32, .10);
    --w-shadow-lg: 0 22px 50px rgba(9, 35, 24, .22);

    --font-ui: 'IBM Plex Sans Arabic', 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    --font-display: 'Amiri', 'Times New Roman', serif;
    --font-serif: 'Amiri', 'Times New Roman', serif;

    --primary-color: var(--w-green);
    --secondary-color: var(--w-gold);
    --accent-color: var(--w-deep);
    --dark-color: var(--w-green);
    --light-color: var(--w-cream);
}

/* ---------- base ---------- */
html { scroll-behavior: smooth; }
body {
    font-family: var(--font-ui);
    background: var(--w-cream);
    color: var(--w-ink);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--w-green); letter-spacing: 0; }
h5, h6 { font-family: var(--font-ui); color: var(--w-green); font-weight: 700; }
a { color: var(--w-green); }
a:hover { color: var(--w-gold-dark); }
::selection { background: rgba(201, 164, 92, .35); }
:focus-visible { outline: 3px solid var(--w-gold); outline-offset: 2px; }
img { max-width: 100%; }
main { min-height: 50vh; }

/* header / footer / phone tab bar: see waad-chrome.css */

/* ---------- buttons ---------- */
.btn { font-family: var(--font-ui); font-weight: 700; }
.btn-primary, .btn-primary:focus {
    background: var(--w-green) !important; background-image: none !important; color: var(--w-cream) !important;
    border: 1.5px solid var(--w-gold) !important; border-radius: 12px; padding: .65rem 1.4rem; box-shadow: none; transform: none;
}
.btn-primary:hover, .btn-primary:active { background: var(--w-deep) !important; color: #fff !important; transform: translateY(-1px); box-shadow: 0 8px 20px rgba(16, 45, 32, .25); }
.btn-primary:disabled, .btn-primary.disabled { opacity: .55; }
.btn-outline-primary { border: 1.5px solid var(--w-green) !important; color: var(--w-green) !important; border-radius: 12px; padding: .6rem 1.3rem; background: transparent; }
.btn-outline-primary:hover { background: var(--w-green) !important; color: var(--w-cream) !important; transform: none; }
.btn-success { background: #1f6b43; border-color: #1f6b43; border-radius: 12px; }
.btn-outline-secondary { border-radius: 12px; }
.btn-outline-danger { border-radius: 12px; }
.btn-gold { background: var(--w-gold); color: var(--w-deep); border: 1.5px solid var(--w-gold); border-radius: 12px; }
.btn-gold:hover { filter: brightness(1.06); color: var(--w-deep); }
.btn-ghost-gold { background: transparent; color: var(--w-cream); border: 1.5px solid var(--w-gold); border-radius: 12px; }
.btn-ghost-gold:hover { background: rgba(201, 164, 92, .15); color: #fff; }
.view-all-btn {
    background: var(--w-green) !important; color: var(--w-cream) !important; border: 1.5px solid var(--w-gold) !important; border-radius: 12px !important;
    padding: .7rem 1.8rem !important; font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; box-shadow: none !important;
}
.view-all-btn:hover { background: var(--w-deep) !important; color: #fff !important; transform: translateY(-1px); }

/* ---------- section headings (diamond rules like the reference) ---------- */
.section-title, .wsec-title {
    font-family: var(--font-display); font-weight: 700; color: var(--w-green); text-align: center; font-size: clamp(1.5rem, 3.2vw, 2.1rem);
    display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 0 0 .4rem; background: none; -webkit-text-fill-color: initial;
}
.section-title::before, .section-title::after, .wsec-title::before, .wsec-title::after {
    content: ''; flex: 0 1 120px; height: 1.5px; background: linear-gradient(90deg, transparent, var(--w-gold)); position: static; width: auto; transform: none; bottom: auto; left: auto;
}
.section-title::after, .wsec-title::after { background: linear-gradient(270deg, transparent, var(--w-gold)); }
.wsec-sub { text-align: center; color: var(--w-muted); margin: 0 0 1.6rem; font-size: .95rem; }

/* ---------- surfaces ---------- */
.card { border: 1px solid var(--w-beige); border-radius: var(--w-radius); background: var(--w-paper); box-shadow: none; }
.card-header { background: transparent; border-bottom: 1px solid var(--w-beige); font-family: var(--font-ui); }
.card-header h5, .card-header h4 { color: var(--w-green); margin: 0; }
.form-control, .form-select { border: 1.5px solid var(--w-beige); border-radius: 10px; font-family: var(--font-ui); background-color: #fff; }
.form-control:focus, .form-select:focus { border-color: var(--w-gold); box-shadow: 0 0 0 .2rem rgba(201, 164, 92, .25); }
.form-label { font-weight: 600; color: var(--w-green); }
.alert { border-radius: var(--w-radius); font-family: var(--font-ui); border: 1px solid transparent; box-shadow: none; }
.alert-success { background: #e8f3ea; color: #14532d; border-color: #bcdcc4; border-right: 4px solid #1f6b43; }
.alert-danger { background: #fbe9e7; color: #7a1d17; border-color: #f2c4bf; border-right: 4px solid var(--w-danger); }
.alert-info { background: #eef4f1; color: var(--w-green); border-color: #cfe0d6; }
.alert-warning { background: #fbf3df; color: #6b4e0b; border-color: #ecd9a4; }
.badge { font-family: var(--font-ui); font-weight: 700; }
.page-link { color: var(--w-green); border-color: var(--w-beige); }
.page-item.active .page-link { background: var(--w-green); border-color: var(--w-green); color: var(--w-cream); }
.dropdown-menu { border: 1px solid var(--w-beige); border-radius: var(--w-radius); box-shadow: var(--w-shadow-lg); font-family: var(--font-ui); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--w-cream); color: var(--w-green); }
.text-primary { color: var(--w-green) !important; }
.bg-primary { background-color: var(--w-green) !important; }
.table > :not(caption) > * > * { border-color: var(--w-beige); }

/* page heroes on dark green: headings inherit the light text colour the page sets */
.categories-hero h1, .categories-hero .lead, .hero-section:not(.hero) h1, .hero-section:not(.hero) h2, .hero-section:not(.hero) .lead,
.category-hero h1, .category-hero h2, .category-hero .lead, .category-title { color: var(--w-cream); }
.categories-hero .breadcrumb a, .category-hero .breadcrumb a, .hero-section:not(.hero) .breadcrumb a { color: rgba(248, 240, 226, .75) !important; }

/* headings that sit on dark green surfaces must stay light (generic h-colors above are for light surfaces) */
.filter-header h5, .filter-header h4, .card-header[style*="#102D20"] *, .card-header[style*="#092318"] *, .bg-dark h1, .bg-dark h2, .bg-dark h3, .bg-dark h4, .bg-dark h5,
.page-header.dark h1, [class*="hero"] h1.hero-title, .story h2 { color: var(--w-cream) !important; }
.filter-header { border-bottom: 2px solid var(--w-gold); }
body .page-header { background: var(--w-paper); border: 1px solid var(--w-beige); border-radius: var(--w-radius); }
body .page-header h1 { color: var(--w-green) !important; }

/* ---------- unified product cards (home, lists, author/publisher/category pages) ---------- */
body .book-card, body .category-book-card {
    background: var(--w-paper); border: 1px solid var(--w-beige); border-radius: 16px !important; overflow: hidden;
    box-shadow: 0 4px 16px rgba(16, 45, 32, .06); transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; height: 100%;
}
body .book-card:hover, body .category-book-card:hover { transform: translateY(-5px); box-shadow: 0 18px 36px rgba(16, 45, 32, .16); border-color: var(--w-gold); }
body .book-card img.card-img-top, body .book-card-img, body .category-book-img {
    width: 100%; aspect-ratio: 2 / 3; height: auto !important; object-fit: cover; background: var(--w-beige); display: block;
}
body .book-card .card-body, body .book-card-body, body .category-book-body { padding: 1rem; font-family: var(--font-ui); }
body .book-card .card-title, body .book-card-title, body .category-book-title {
    font-family: var(--font-ui); font-weight: 700; color: var(--w-green); font-size: 1rem; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em;
}
body .book-author, body .category-book-author { color: var(--w-muted); font-size: .88rem; margin-bottom: .35rem; }
body .book-category { color: var(--w-gold-dark); font-size: .8rem; font-weight: 600; margin-bottom: .2rem; }
body .book-price, body .category-book-price { color: var(--w-green) !important; font-family: var(--font-ui); font-weight: 800; font-size: 1.15rem; }
body .btn-details, body .category-btn-details {
    background: transparent; color: var(--w-green); border: 1.5px solid var(--w-green); border-radius: 10px; font-weight: 700; font-size: .85rem; padding: .45rem .8rem; text-decoration: none; text-align: center;
}
body .btn-details:hover, body .category-btn-details:hover { background: var(--w-green); color: var(--w-cream); }
body .btn-cart, body .category-btn-cart {
    background: var(--w-gold) !important; color: var(--w-deep) !important; border: 1.5px solid var(--w-gold) !important; border-radius: 10px !important; font-weight: 700; min-width: 44px; min-height: 40px;
}
body .btn-cart:hover, body .category-btn-cart:hover { background: var(--w-green) !important; color: var(--w-gold) !important; border-color: var(--w-green) !important; }

body .bc-title-link { color: inherit; text-decoration: none; }
body .bc-title-link:hover { color: var(--w-gold-dark); }

/* product page */
img.book-cover-img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 12px; background: var(--w-beige); display: block; }
@media (min-width: 992px) { .container > .row > .col-lg-4 > .card:has(.book-cover-img) { position: sticky; top: 120px; padding: .6rem; } }
.container .card h1.card-title { font-family: var(--font-display); font-size: clamp(1.5rem, 3vw, 2.2rem); }
body .related-books-mobile-grid, body .books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.2rem; }
.cart-thumb { width: 100%; height: auto !important; aspect-ratio: 2 / 3; max-width: 104px; margin-inline: auto; }

/* image fallback used by the cover-fallback script */
.img-fallback {
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .6rem; padding: 1rem;
    background: linear-gradient(160deg, #173a2a, #092318); color: var(--w-gold); border: 1px solid rgba(201, 164, 92, .45); font-family: var(--font-display);
    aspect-ratio: 2 / 3; width: 100%; overflow: hidden; line-height: 1.4; font-size: .95rem;
}
.img-fallback i { font-size: 1.6rem; opacity: .85; }
.img-fallback span { color: #efe2c3; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* list-page headings & filters */
body .books-title, body .books-header h1, body .books-header h2 { font-family: var(--font-display); color: var(--w-green); background: none; -webkit-text-fill-color: initial; }
body .filter-btn, body .empty-btn {
    background: var(--w-green) !important; color: var(--w-cream) !important; border: 1.5px solid var(--w-gold) !important; border-radius: 12px !important; font-weight: 700;
}
body .filter-btn:hover, body .empty-btn:hover { background: var(--w-deep) !important; color: #fff !important; }

.scroll-top { background: var(--w-green) !important; border: 1.5px solid var(--w-gold) !important; color: var(--w-gold) !important; box-shadow: var(--w-shadow); }
.loading-spinner { border-top-color: var(--w-gold) !important; }

/* checkout / cart / order pages: keep prices & headings on-brand */
.container > h2.mb-4 { font-family: var(--font-display); }
.list-group-item { border-color: var(--w-beige); }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    body .book-card:hover, body .category-book-card:hover { transform: none; }
}
