:root {
  --bg: #faf6ef;
  --bg-alt: #f1ead9;
  --ink: #1b2430;
  --ink-soft: #4b5563;
  --accent: #c1502e;
  --accent-dark: #9c3d21;
  --line: #e4dbc8;
  --white: #fffdf9;
  --radius: 14px;
  --shadow: 0 12px 30px -14px rgba(27, 36, 48, 0.25);
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

h1, h2, h3, .brand {
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
}

img { max-width: 100%; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1.25rem, 4vw, 3rem);
  background: rgba(250, 246, 239, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-size: 1.4rem;
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.brand small {
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cart-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--ink);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.cart-toggle:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.cart-count {
  background: var(--accent);
  color: var(--white);
  border-radius: 999px;
  min-width: 1.4rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  padding: 0 0.35rem;
}

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

.hero {
  padding: clamp(3rem, 8vw, 6rem) clamp(1.25rem, 4vw, 3rem) clamp(2.5rem, 6vw, 4rem);
  text-align: center;
  max-width: 46rem;
  margin: 0 auto;
}

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  margin: 0 0 0.9rem;
}

.hero p {
  color: var(--ink-soft);
  font-size: 1.1rem;
  margin: 0;
}

.cancelled-banner {
  max-width: 46rem;
  margin: 0 auto 1.5rem;
  padding: 0.85rem 1.2rem;
  background: #fbe7d8;
  border: 1px solid #f0c8a4;
  border-radius: var(--radius);
  color: var(--accent-dark);
  font-size: 0.92rem;
  text-align: center;
}

.cancelled-banner[hidden] { display: none; }

/* ---------- Catalog grid ---------- */

.catalog {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 3rem) 5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.75rem;
}

.book-card {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 36px -16px rgba(27, 36, 48, 0.32);
}

.book-cover {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: flex-end;
  padding: 1.1rem;
  color: rgba(255, 255, 255, 0.95);
  font-family: "Fraunces", serif;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.25;
  background-image: linear-gradient(160deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.35));
}

.book-body {
  padding: 1.1rem 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.book-author {
  font-size: 0.85rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.book-blurb {
  font-size: 0.92rem;
  color: var(--ink-soft);
  flex: 1;
}

.book-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.4rem;
}

.book-price {
  font-weight: 700;
  font-size: 1.05rem;
}

.add-btn {
  background: var(--ink);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.add-btn:hover {
  background: var(--accent);
  transform: translateY(-1px);
}

.add-btn.added {
  background: #2f6d4f;
}

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

.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 36, 48, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 30;
}

.cart-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 400px);
  background: var(--white);
  box-shadow: -18px 0 40px -20px rgba(27, 36, 48, 0.4);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 31;
  display: flex;
  flex-direction: column;
}

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

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.3rem 1.4rem;
  border-bottom: 1px solid var(--line);
}

.cart-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.close-cart {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--ink-soft);
  line-height: 1;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cart-empty {
  color: var(--ink-soft);
  text-align: center;
  margin-top: 2rem;
  font-size: 0.95rem;
}

.cart-line {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.cart-line-swatch {
  width: 42px;
  height: 56px;
  border-radius: 6px;
  flex-shrink: 0;
}

.cart-line-info {
  flex: 1;
  min-width: 0;
}

.cart-line-title {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-line-price {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.qty-control button {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.remove-line {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin-top: 0.3rem;
}

.cart-footer {
  border-top: 1px solid var(--line);
  padding: 1.2rem 1.4rem 1.4rem;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.9rem;
}

.checkout-btn {
  width: 100%;
  background: var(--accent);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.9rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.checkout-btn:hover:not(:disabled) {
  background: var(--accent-dark);
}

.checkout-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.checkout-error {
  color: var(--accent-dark);
  font-size: 0.85rem;
  margin-top: 0.6rem;
  text-align: center;
}

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

.site-footer {
  text-align: center;
  padding: 2.5rem 1.5rem 3rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

/* ---------- Success page ---------- */

.success-wrap {
  max-width: 34rem;
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 7rem) 1.5rem;
  text-align: center;
}

.success-wrap h1 {
  font-size: 2.2rem;
  margin-bottom: 0.8rem;
}

.success-wrap p {
  color: var(--ink-soft);
}

.back-link {
  display: inline-block;
  margin-top: 1.5rem;
  background: var(--ink);
  color: var(--white);
  text-decoration: none;
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  font-weight: 600;
}
