/* =========================================
   BASE
========================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --color-primary: #1e2a78;
  --color-primary-dark: #16205d;
  --color-accent: #f36c21;
  --color-accent-dark: #d95f1c;

  --color-bg: #f8f6f1;
  --color-surface: #ffffff;

  --color-text: #222222;
  --color-text-soft: #666f7a;

  --color-border: #d9dff5;
  --color-border-soft: #e8ebf8;

  --color-success-bg: #e8f7ed;
  --color-success-text: #18794e;

  --color-danger-bg: #fdecec;
  --color-danger-text: #b42318;

  --shadow-soft: 0 8px 24px rgba(21, 32, 87, 0.06);
  --shadow-medium: 0 14px 34px rgba(21, 32, 87, 0.1);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;

  --transition: 0.28s ease;

  --container-width: 1120px;
  --header-height: 82px;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;

  display: flex;
  flex-direction: column;

  padding-top: var(--header-height);

  font-family: Arial, sans-serif;

  background: var(--color-bg);
  color: var(--color-text);

  line-height: 1.4;
}

img {
  display: block;
  max-width: 100%;
}

a {
  text-decoration: none;
}

ul,
ol {
  margin: 0;
  padding: 0;

  list-style: none;
}

main,
.site-main {
  flex: 1;
}

.container {
  width: min(var(--container-width), 92%);
  margin: 0 auto;
}

/* =========================================
   SECTION HEAD
========================================= */

.section-head {
  margin-bottom: 26px;
}

.section-head h2 {
  margin: 0 0 8px;

  color: var(--color-primary);

  font-size: clamp(1.8rem, 2vw, 2.2rem);
  line-height: 1.2;
}

.section-head p {
  margin: 0;

  color: var(--color-text-soft);
}
/* =========================================
   FINAL MOBILE NAV FIX
   Header stays above scrolling menu
========================================= */

@media (max-width: 700px) {
  /* Header must stay above menu */
  .site-header {
    z-index: 9999;
  }

  /* Hamburger stays clickable */
  .menu-toggle {
    position: relative;
    z-index: 10001;
  }

  /* Mobile menu starts BELOW header */
  .main-nav {
    position: fixed;

    top: 74px;
    left: 0;

    width: 70%;
    max-width: 320px;

    height: calc(100vh - 74px);

    padding: 16px 16px 30px;

    background: var(--color-primary);

    transform: translateX(-100%);
    transition: transform 0.28s ease;

    overflow-y: auto;
    overflow-x: hidden;

    box-shadow: 8px 8px 24px rgba(0, 0, 0, 0.18);

    /* IMPORTANT: below header */
    z-index: 9998;
  }

  .main-nav.is-open {
    transform: translateX(0);
  }
}

/* WordPress admin bar when logged in */
@media (max-width: 782px) {
  body.admin-bar .main-nav {
    top: 120px;
    height: calc(100vh - 120px);
  }
}
/* =========================================
   HEADER
========================================= */

.site-header {
  position: fixed;

  top: 0;
  left: 0;

  width: 100%;

  z-index: 9999;

  background: var(--color-primary);

  border-bottom: 3px solid var(--color-accent);

  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

body.admin-bar .site-header {
  top: 32px;
}

.header-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: var(--header-height);

  gap: 20px;
}

.logo {
  color: #ffffff;

  font-size: 1.5rem;
  font-weight: 800;

  letter-spacing: 0.3px;

  text-decoration: none;

  white-space: nowrap;
}

.logo:hover {
  opacity: 0.92;
}

/* =========================================
   HAMBURGER
========================================= */

.menu-toggle {
  display: none;

  padding: 4px;

  border: none;

  background: transparent;
  color: #ffffff;

  font-size: 1.8rem;

  cursor: pointer;
}

/* =========================================
   MAIN NAV
========================================= */

.main-nav {
  display: flex;
  align-items: center;
}

.menu-list.custom-header-menu {
  display: flex;
  align-items: center;

  gap: 22px;

  margin: 0;
  padding: 0;

  list-style: none;
}

.menu-list.custom-header-menu > li {
  position: relative;
}
.menu-list.custom-header-menu a,
.categories-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;

  width: 100%;
  gap: 8px;

  padding: 13px 8px;

  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);

  background: transparent;
  color: #ffffff;

  font-size: 0.94rem;
  font-weight: 600;

  text-align: left;
  white-space: normal;
}
.header-icon {
  flex: 0 0 auto;
  margin: 0;
}

.header-cart-link span:not(.cart-count-badge),
.header-account-link span,
.header-seller-link span {
  margin: 0;
}
.menu-list.custom-header-menu a::after,
.categories-toggle::before {
  content: "";

  position: absolute;

  left: 0;
  bottom: -6px;

  width: 0;
  height: 2px;

  background: var(--color-accent);

  transition: width var(--transition);
}

.menu-list.custom-header-menu a:hover,
.categories-toggle:hover,
.categories-dropdown.is-open > .categories-toggle {
  color: #ffffff;
}

.menu-list.custom-header-menu a:hover::after,
.categories-toggle:hover::before,
.categories-dropdown.is-open > .categories-toggle::before {
  width: 100%;
}

/* =========================================
   CATEGORY DROPDOWN
========================================= */

.categories-dropdown {
  position: relative;
}

.categories-toggle::after {
  content: "▾";

  margin-left: 6px;

  font-size: 0.78rem;
}

.categories-panel {
  position: absolute;

  top: calc(100% + 12px);
  left: 0;

  z-index: 9999;

  display: none;

  min-width: 180px;

  padding: 6px;

  border-radius: 7px;

  background: rgba(28, 48, 113, 0.92);

  box-shadow: var(--shadow-soft);
}

.categories-dropdown.is-open .categories-panel {
  display: block;
}

.header-category-grid {
  display: flex;
  flex-direction: column;

  gap: 6px;
}

.header-category-link {
  position: relative;

  display: block;

  width: 100%;

  padding: 8px 0;

  color: #ffffff;

  font-size: 0.95rem;
  font-weight: 700;

  text-align: left;

  transition: color var(--transition);
}

.header-category-link::after {
  content: "";

  position: absolute;

  left: 0;
  bottom: 2px;

  width: 0;
  height: 2px;

  background: var(--color-accent);

  transition: width var(--transition);
}

.header-category-link:hover {
  color: var(--color-accent);
}

.header-category-link:hover::after {
  width: 100%;
}

/* =========================================
   HEADER CART
========================================= */

.header-cart-link {
  position: relative;

  display: inline-flex;
  align-items: center;

  gap: 8px;
}

.cart-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 20px;
  height: 20px;

  padding: 0 6px;

  margin-left: 2px;

  border-radius: 999px;

  background: var(--color-accent);
  color: #ffffff;

  font-size: 12px;
  font-weight: 700;

  line-height: 1;
}

/* =========================================
   BUTTONS
========================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 12px 20px;

  border: none;
  border-radius: 12px;

  font-weight: 700;

  cursor: pointer;

  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background var(--transition),
    color var(--transition),
    border-color var(--transition);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--color-accent);
  color: #ffffff;

  box-shadow: 0 10px 24px rgba(243, 108, 33, 0.22);
}

.btn-primary:hover {
  background: var(--color-accent-dark);
}

.btn-secondary {
  border: 1px solid var(--color-primary);

  background: transparent;
  color: var(--color-primary);
}

.btn-secondary:hover {
  background: var(--color-primary);
  color: #ffffff;
}

.small {
  margin-top: 12px;

  padding: 10px 16px;
}

/* =========================================
   SECTIONS
========================================= */

.categories,
.featured-books,
.related-books,
.single-book-section {
  padding: 44px 0 24px;
}

.seller-buyer {
  padding: 44px 0 60px;
}

/* =========================================
   BOOK GRID
========================================= */

.book-grid {
  display: grid;

  grid-template-columns: repeat(auto-fill, minmax(240px, 240px));

  gap: 24px;

  margin-top: 32px;

  justify-content: start;
}

/* =========================================
   BOOK CARD
========================================= */

.book-card {
  position: relative;

  overflow: hidden;

  border: 1px solid #e6e6e6;
  border-radius: 18px;

  background: #ffffff;

  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);

  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
}

.book-card:hover {
  transform: translateY(-6px);

  border-color: #d8def3;

  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.12);
}

.book-rank {
  position: absolute;

  top: 14px;
  left: 14px;

  z-index: 2;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;

  border-radius: 4px;

  background: #4a2c2a;
  color: #ffffff;

  font-size: 1.1rem;
  font-weight: 700;
}

.book-image {
  display: flex;
  align-items: flex-start;
  justify-content: center;

  min-height: 290px;

  padding: 20px 20px 10px;

  background: #f4f4f4;
}

.book-image img,
.book-card img {
  width: 100%;

  max-width: 170px;

  height: 250px;

  object-fit: cover;
}

.book-info {
  display: flex;
  flex-direction: column;

  flex-grow: 1;

  padding: 14px 18px 20px;

  background: #ffffff;
}

.book-badge {
  display: inline-block;
  align-self: flex-start;

  margin: 0 0 14px;

  padding: 5px 10px;

  border-radius: 8px;

  background: #edf3ff;
  color: #4d6790;

  font-size: 0.82rem;
  font-weight: 600;
}

.book-title {
  margin: 0 0 10px;

  min-height: 56px;

  color: #222222;

  font-size: 1.05rem;
  font-weight: 700;

  line-height: 1.35;
}

.book-title a {
  color: inherit;

  text-decoration: none;
}

.book-author {
  margin: 0 0 6px;

  color: #666666;

  font-size: 0.95rem;
}

/* =========================================
   STOCK
========================================= */

.stock {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: fit-content;

  padding: 6px 12px;

  border-radius: 999px;

  font-size: 0.85rem;
  font-weight: 700;

  letter-spacing: 0.2px;
}

.in-stock {
  background: var(--color-success-bg);
  color: var(--color-success-text);
}

.out-stock {
  background: var(--color-danger-bg);
  color: var(--color-danger-text);
}

/* =========================================
   BOOK ACTIONS
========================================= */

.book-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 12px;

  margin-top: 12px;
}

.book-price {
  margin: 0;

  color: #222222;

  font-size: 1.6rem;
  font-weight: 800;
}

.add-cart-btn {
  padding: 10px 16px;

  border: none;
  border-radius: 10px;

  background: #d62828;
  color: #ffffff;

  font-weight: 700;

  cursor: pointer;

  white-space: nowrap;
}

.add-cart-btn:hover {
  background: #b71f1f;
}

/* =========================================
   FOOTER
========================================= */

.site-footer {
  margin-top: auto;

  padding: 20px 0;

  border-top: 3px solid var(--color-accent);

  background: var(--color-primary);
  color: #ffffff;
}

.footer-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;

  gap: 16px;
}

.footer-wrap p {
  margin: 0;

  max-width: 320px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;

  gap: 14px 18px;
}

.footer-links a {
  color: #ffffff;

  transition: color var(--transition);
}

.footer-links a:hover {
  color: #ffd9c6;
}

/* =========================================
   RESPONSIVE - TABLET
========================================= */

@media (max-width: 992px) {
  .hero-grid,
  .single-book-grid {
    grid-template-columns: 1fr;
  }

  .hero-grid {
    gap: 28px;
  }

  .hero-image img {
    height: 380px;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .seller-buyer-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: 2.4rem;
  }
}

@media (max-width: 782px) {
  body.admin-bar .site-header {
    top: 46px;
  }
}

/* =========================================
   MOBILE
========================================= */

@media (max-width: 700px) {
  :root {
    --header-height: 74px;
  }

  body {
    padding-top: var(--header-height);
  }

  /* =====================================
     MOBILE HEADER
  ====================================== */

  .header-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;

    flex-wrap: nowrap;

    min-height: 74px;

    padding: 10px 0;
  }

  .logo {
    max-width: calc(100% - 60px);

    overflow: hidden;

    text-overflow: ellipsis;

    font-size: 1.2rem;
  }

  /* =====================================
     HAMBURGER
  ====================================== */

  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;

    width: 44px;
    height: 44px;

    flex: 0 0 44px;

    margin-left: auto;
    padding: 0;

    border: none;

    background: transparent;
    color: #ffffff;

    font-size: 1.7rem;

    line-height: 1;

    cursor: pointer;

    position: relative;

    z-index: 10002;
  }

  /* =====================================
     MOBILE SIDE DRAWER
  ====================================== */

  .main-nav {
    display: block !important;

    position: fixed;

    top: 0;
    left: 0;

    width: 70%;
    max-width: 320px;

    height: 100%;

    padding: 78px 16px 30px;

    background: var(--color-primary);

    transform: translateX(-100%);

    transition: transform 0.28s ease;

    overflow-y: auto;
    overflow-x: hidden;

    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.18);

    z-index: 10000;
  }

  .main-nav.is-open {
    transform: translateX(0);
  }

  /* =====================================
     MOBILE MENU
  ====================================== */

  .menu-list.custom-header-menu {
    display: flex;
    flex-direction: column;
    align-items: stretch;

    width: 100%;

    margin: 0;
    padding: 0;

    gap: 0;
  }

  .menu-list.custom-header-menu > li {
    width: 100%;
  }

  .menu-list.custom-header-menu a,
  .categories-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-start;

    width: 100%;
    gap: 8px;

    padding: 13px 8px;

    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);

    background: transparent;
    color: #ffffff;

    font-size: 0.94rem;
    font-weight: 600;

    text-align: left;
    white-space: normal;
  }

  .menu-list.custom-header-menu a::after,
  .categories-toggle::before {
    display: none;
  }
  .header-icon {
    flex: 0 0 auto;
    margin: 0;
  }

  .header-cart-link span:not(.cart-count-badge),
  .header-account-link span,
  .header-seller-link span {
    margin: 0;
  }

  /* =====================================
     MOBILE CATEGORY DROPDOWN
  ====================================== */

  .categories-panel {
    display: none;

    position: static;

    width: 100%;
    min-width: 0;

    margin: 0;

    padding: 6px 0 6px 10px;

    border-radius: 0;

    background: rgba(255, 255, 255, 0.07);

    box-shadow: none;
  }

  .categories-dropdown.is-open .categories-panel {
    display: block;
  }

  .header-category-grid {
    display: flex;
    flex-direction: column;

    gap: 0;
  }

  .header-category-link {
    display: block;

    width: 100%;

    padding: 10px 8px;

    border-bottom: 1px solid rgba(255, 255, 255, 0.08);

    color: #ffffff;

    font-size: 0.9rem;

    white-space: normal;
  }

  .header-category-link::after {
    display: none;
  }

  /* =====================================
     MOBILE CART
  ====================================== */

  .header-cart-link {
    width: 100%;
  }

  .cart-count-badge {
    margin-left: auto;
  }

  /* =====================================
     MOBILE BOOKS
  ====================================== */

  .book-grid {
    grid-template-columns: 1fr;
  }

  .book-image {
    min-height: 260px;

    padding: 18px 18px 8px;
  }

  .book-image img,
  .book-card img {
    max-width: 150px;

    height: 220px;
  }

  .book-info {
    padding: 14px 16px 18px;
  }

  /* =====================================
     MOBILE FOOTER
  ====================================== */

  .footer-wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-links {
    width: 100%;

    flex-direction: column;
    align-items: flex-start;

    gap: 10px;
  }

  /* =====================================
     MOBILE CATEGORIES
  ====================================== */

  .category-grid {
    grid-template-columns: 1fr;
  }

  /* =====================================
     MOBILE HERO
  ====================================== */

  .hero {
    padding: 34px 0;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero-image img {
    height: 320px;
  }
}

/* =========================================
   SMALL MOBILE
========================================= */

@media (max-width: 480px) {
  .container {
    width: min(var(--container-width), 94%);
  }

  .section-head h2 {
    font-size: 1.6rem;
  }

  .btn {
    width: 100%;
  }

  .hero-buttons {
    flex-direction: column;

    align-items: stretch;
  }

  .footer-wrap p {
    max-width: 100%;
  }

  .main-nav {
    width: 72%;
    max-width: 290px;
  }
}
