/* ===========================================================
   Big Bad Wolf Books Catalogue — "Warehouse Sale" design system
   Ink espresso + kraft paper + burnt-orange clearance stickers
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;0,9..144,900;1,9..144,500&family=Inter:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  --ink: #201A15;
  --ink-light: #4A4038;
  --paper: #F2E9D8;
  --paper-dark: #E7DAC0;
  --cream: #FBF6EC;
  --orange: #C97B3D;
  --orange-dark: #A8622C;
  --forest: #3F5D4E;
  --forest-dark: #2E4739;
  --red: #A83E33;
  --border: rgba(32, 26, 21, 0.14);
  --shadow: 0 4px 14px rgba(32, 26, 21, 0.12);
  --radius: 6px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Fraunces', serif;
  color: var(--ink);
  margin: 0;
  line-height: 1.1;
}

a { color: inherit; text-decoration: none; }

button {
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
}

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Layout shells ---------- */

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Top bar ---------- */

.topbar {
  background: var(--ink);
  color: var(--paper);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 3px solid var(--orange);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  max-width: 1180px;
  margin: 0 auto;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.brand-logo {
  height: 32px;
  width: auto;
  display: block;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border-radius: 999px;
  border: none;
  background: rgba(242, 233, 216, 0.14);
  color: var(--paper);
  font-size: 0.92rem;
}

.topbar-search input::placeholder { color: rgba(242, 233, 216, 0.55); }

.topbar-search input:focus {
  background: var(--cream);
  color: var(--ink);
}

.topbar-search::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid rgba(242, 233, 216, 0.6);
  border-radius: 50%;
}

.topbar-search::after {
  content: "";
  position: absolute;
  left: 25px;
  top: 65%;
  width: 6px;
  height: 2px;
  background: rgba(242, 233, 216, 0.6);
  transform: rotate(45deg);
}

.cart-btn {
  background: var(--orange);
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease;
}

.cart-btn:hover { background: #DB8C4C; transform: translateY(-1px); }

.cart-count {
  background: var(--ink);
  color: var(--orange);
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  font-size: 0.72rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  padding: 0 5px;
}

/* ---------- Hero ---------- */

.carousel-section {
  padding: 20px 24px 0;
  max-width: 1100px;
  margin: 0 auto;
}

.carousel {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--paper-dark);
}

.carousel-track {
  display: flex;
  transition: transform 0.45s ease;
}

.carousel-slide {
  flex: 0 0 100%;
  position: relative;
  display: block;
  height: 320px;
  text-decoration: none;
  color: inherit;
  background: var(--ink);
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.carousel-caption {
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  padding: 28px 32px;
  background: linear-gradient(to top, rgba(32, 26, 21, 0.85), rgba(32, 26, 21, 0));
  color: var(--paper);
}

.carousel-caption-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
  max-width: 600px;
}

.carousel-caption-cta {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  color: var(--orange);
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(251, 246, 236, 0.85);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.carousel-arrow:hover {
  background: var(--cream);
}

.carousel-arrow.prev { left: 16px; }
.carousel-arrow.next { right: 16px; }

.carousel-dots {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(251, 246, 236, 0.5);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, transform 0.15s ease;
}

.carousel-dot.active {
  background: var(--orange);
  transform: scale(1.3);
}

@media (max-width: 640px) {
  .carousel-slide { height: 220px; }
  .carousel-caption-title { font-size: 1.1rem; }
}

.hero {
  padding: 64px 24px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-eyebrow {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange-dark);
  margin-bottom: 14px;
  display: block;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  max-width: 780px;
  margin: 0 auto 18px;
}

.hero h1 em {
  font-style: italic;
  color: var(--orange-dark);
}

.hero p {
  max-width: 540px;
  margin: 0 auto;
  color: var(--ink-light);
  font-size: 1.05rem;
  line-height: 1.55;
}

/* ---------- Category grid (index page) ---------- */

.shelf-section { padding: 8px 24px 80px; }

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px;
}

.shelf-card {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  position: relative;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 128px;
}

.shelf-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--orange);
}

.shelf-card::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 0;
  width: 34px;
  height: 8px;
  background: var(--orange);
  border-radius: 0 0 4px 4px;
}

.shelf-card h3 {
  font-size: 1.22rem;
  font-weight: 600;
  margin-top: 6px;
}

.shelf-card .count {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-light);
}

/* ---------- Category / browse page ---------- */

.browse-header {
  padding: 40px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.breadcrumb {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-light);
  margin-bottom: 10px;
}

.breadcrumb a { color: var(--orange-dark); }

.browse-header h1 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }

.browse-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.browse-count { color: var(--ink-light); font-size: 0.92rem; }

.browse-search {
  position: relative;
  width: 100%;
  max-width: 320px;
}

.browse-search input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--cream);
  font-size: 0.9rem;
}

.sort-select {
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--cream);
  font-size: 0.88rem;
  color: var(--ink);
}

.book-grid-section { padding: 30px 24px 80px; }

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 22px 18px;
}

.book-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
}

.book-cover-wrap {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background: var(--cream);
  border: 1px solid var(--border);
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.book-card:hover .book-cover-wrap {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.book-cover-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.book-cover-wrap .no-image {
  font-family: 'Fraunces', serif;
  font-size: 0.78rem;
  color: var(--ink-light);
  text-align: center;
  padding: 10px;
  line-height: 1.3;
}

.stock-flag {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Space Mono', monospace;
  font-size: 0.62rem;
  padding: 3px 7px;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.stock-flag.out { background: var(--red); }

.book-title {
  margin-top: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-brand {
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--forest);
  font-weight: 600;
}

.book-price-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.book-price-box {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--cream);
}

.quick-add-btn {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1.5px solid var(--forest);
  background: var(--cream);
  color: var(--forest);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.quick-add-btn:hover:not(:disabled) {
  background: var(--forest);
  color: var(--cream);
}

.quick-add-btn:active:not(:disabled) {
  transform: scale(0.92);
}

.quick-add-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.quick-add-btn.added {
  background: var(--orange);
  border-color: var(--orange);
  color: var(--cream);
  animation: bbwQuickAddPulse 0.4s ease;
}

@keyframes bbwQuickAddPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---------- Load more ---------- */

.load-more-wrap {
  text-align: center;
  margin-top: 40px;
}

.load-more-btn {
  background: var(--ink);
  color: var(--paper);
  padding: 13px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
}

.load-more-btn:hover { background: #33291f; }

.pagination-wrap {
  margin-top: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--cream);
  color: var(--ink);
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--orange);
}

.page-btn.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-ellipsis {
  color: var(--ink-light);
  padding: 0 4px;
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
}

.show-more-btn {
  min-width: 200px;
  height: 46px;
  padding: 0 28px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.show-more-btn:hover {
  background: var(--orange);
  border-color: var(--orange);
}

.show-more-btn:active {
  transform: scale(0.98);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-light);
}

.empty-state h3 { margin-bottom: 8px; }

/* ---------- Product modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 26, 21, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--cream);
  border-radius: 10px;
  max-width: 760px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 260px 1fr;
  position: relative;
}

@media (max-width: 640px) {
  .modal-box { grid-template-columns: 1fr; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--ink);
  color: var(--paper);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.modal-cover {
  background: var(--paper-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-cover img { max-width: 100%; max-height: 340px; border-radius: 4px; box-shadow: var(--shadow); }

.modal-isbn {
  margin-top: 12px;
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--ink-light);
}

.modal-details { padding: 32px 28px; }

.modal-details h2 { font-size: 1.5rem; margin-bottom: 10px; }

.modal-price {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--orange-dark);
  margin-bottom: 14px;
}

.modal-desc {
  color: var(--ink-light);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 22px;
}

.modal-desc p { margin: 0 0 12px; }

.modal-add-row { display: flex; align-items: center; gap: 12px; }

.qty-input {
  width: 60px;
  padding: 9px;
  border-radius: 4px;
  border: 1px solid var(--border);
  text-align: center;
  font-family: 'Space Mono', monospace;
}

.modal-add-btn {
  background: var(--forest);
  color: var(--cream);
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}

.modal-add-btn:hover { background: var(--forest-dark); }

/* ---------- Cart drawer ---------- */

.cart-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 26, 21, 0.5);
  display: none;
  z-index: 90;
}

.cart-drawer-overlay.open { display: block; }

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100%);
  background: var(--paper);
  z-index: 95;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

.cart-drawer.open { transform: translateX(0); }

.cart-drawer-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-drawer-header h2 { font-size: 1.3rem; }

.cart-drawer-close {
  background: none;
  font-size: 1.4rem;
  color: var(--ink);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px;
}

.cart-item {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.cart-item img {
  width: 52px;
  height: 68px;
  object-fit: cover;
  border-radius: 3px;
  background: var(--cream);
}

.cart-item-title {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}

.cart-item-price {
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
  color: var(--ink-light);
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.qty-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--border);
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item-remove {
  justify-self: end;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 600;
  background: none;
}

.cart-drawer-footer {
  padding: 20px 22px 24px;
  border-top: 1px solid var(--border);
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-family: 'Space Mono', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.checkout-btn {
  width: 100%;
  background: var(--orange);
  color: var(--ink);
  padding: 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.96rem;
}

.checkout-btn:hover { background: #DB8C4C; }

.cart-empty {
  text-align: center;
  color: var(--ink-light);
  padding: 60px 20px;
}

/* ---------- Checkout page ---------- */

.checkout-section { padding: 50px 24px 90px; max-width: 640px; margin: 0 auto; }

.checkout-section h1 { margin-bottom: 26px; font-size: 2rem; }

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-light);
}

.form-group input, .form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--cream);
  font-family: 'Inter', sans-serif;
  font-size: 0.94rem;
}

.checkout-summary {
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  margin-bottom: 26px;
  overflow: hidden;
}

.checkout-summary-table {
  width: 100%;
  border-collapse: collapse;
}

.checkout-summary-table thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-light);
  font-weight: 700;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.checkout-summary-table thead th:not(:first-child) {
  text-align: right;
}

.checkout-summary-table tbody td {
  padding: 14px 16px;
  font-size: 0.9rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.checkout-summary-table tbody tr:last-child td {
  border-bottom: none;
}

.checkout-summary-table tbody td:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

.checkout-summary-table .item-title {
  font-weight: 600;
  line-height: 1.35;
}

.checkout-summary-table tfoot td {
  padding: 14px 16px;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 1.05rem;
  border-top: 2px solid var(--border);
}

.checkout-summary-table tfoot td:first-child {
  text-transform: uppercase;
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  letter-spacing: 0.03em;
}

.checkout-summary-table tfoot td:not(:first-child) {
  text-align: right;
}

.submit-order-btn {
  width: 100%;
  background: var(--forest);
  color: var(--cream);
  padding: 15px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
}

.submit-order-btn:hover { background: var(--forest-dark); }

.submit-order-btn:disabled {
  background: var(--border);
  color: var(--ink-light);
  cursor: not-allowed;
}

.order-status {
  margin-top: 16px;
  padding: 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  display: none;
}

.order-status.show { display: block; }

.order-status.success { background: rgba(63, 93, 78, 0.15); color: var(--forest-dark); }
.order-status.error { background: rgba(168, 62, 51, 0.15); color: var(--red); }

/* ---------- Footer ---------- */

footer {
  background: var(--ink);
  color: var(--paper);
  padding: 34px 24px;
  text-align: center;
  font-size: 0.85rem;
}

footer .tag {
  font-family: 'Space Mono', monospace;
  font-size: 0.72rem;
  color: rgba(242,233,216,0.6);
  margin-top: 6px;
  display: block;
}

/* ---------- Loading ---------- */

.loading-row {
  text-align: center;
  padding: 40px;
  color: var(--ink-light);
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
}
