@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:wght@400;500;600;700&display=swap');

/* === Design Tokens === */
:root {
  --brand-50: #faf8f5;
  --brand-100: #f0ebe3;
  --brand-200: #e0d5c7;
  --brand-300: #c9b89e;
  --brand-400: #b09a78;
  --brand-500: #96805e;
  --brand-600: #7a6748;
  --brand-700: #5e4f38;
  --brand-800: #433929;
  --brand-900: #2c2518;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --max-w: 72rem;
  --max-w-narrow: 42rem;
  --px: 2rem;
  --transition: 300ms ease;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--brand-50);
  color: var(--brand-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

/* === Header === */
header { border-bottom: 1px solid rgba(224, 213, 199, 0.6); }
header > div {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem var(--px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header h1,
header > div > a {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--brand-900);
  transition: color var(--transition);
}
header > div > a:hover { color: var(--brand-600); }
header nav { display: flex; gap: 2rem; }
header nav a {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--brand-600);
  transition: color var(--transition);
}
header nav a:hover { color: var(--brand-900); }

/* === Footer === */
footer { border-top: 1px solid rgba(224, 213, 199, 0.6); margin-top: auto; }
footer > div {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 1.5rem var(--px);
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-400);
}

/* === Main === */
main {
  flex: 1;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 4rem var(--px);
  width: 100%;
}

/* === Breadcrumb nav (main > nav:first-child) === */
main > nav:first-child {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  margin-bottom: 3rem;
}
main > nav:first-child a {
  color: var(--brand-400);
  text-decoration: none;
  transition: color var(--transition);
}
main > nav:first-child a:hover { color: var(--brand-900); }
main > nav:first-child span {
  margin: 0 0.75rem;
}
main > nav:first-child span:last-child {
  color: var(--brand-700);
  margin: 0;
  margin-left: 0.75rem;
}

/* === Divider (hr) === */
hr {
  max-width: 4rem;
  margin: 5rem auto;
  border: none;
  border-top: 1px solid var(--brand-300);
}

/* ===========================
   Home Page (index.html)
   =========================== */

/* Hero title */
main > h1.Home {
  font-family: var(--font-display);
  font-size: 3.75rem;
  font-weight: 500;
  color: var(--brand-900);
  text-align: center;
  margin-bottom: 1.5rem;
  padding-top: 4rem;
  line-height: 1.1;
}
/* Hero subtitle */
main > h1.Home + p {
  font-size: 1.125rem;
  color: var(--brand-500);
  max-width: 32rem;
  margin: 0 auto 3rem;
  text-align: center;
  line-height: 1.7;
  font-weight: 300;
}

/* Featured Books grid */
main > .goSearchBooks ~ section > div {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3rem;
}
main > .goSearchBooks ~ section > h2 {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  margin-bottom: 2rem;
}

/* View All Books link */
main > a.goToCatalog {
  display: inline-block;
  border: 1px solid var(--brand-900);
  color: var(--brand-900);
  padding: 1rem 2.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  background: transparent;
  transition: all var(--transition);
  margin-top: 3rem;
}
main > a.goToCatalog:hover {
  background: var(--brand-900);
  color: var(--brand-50);
}

/* ===========================
   Catalog Page
   =========================== */
.Catalog {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 500;
  margin-bottom: 1rem;
}
/* Catalog intro paragraph */
.Catalog + p {
  color: var(--brand-500);
  font-weight: 300;
  margin-bottom: 3rem;
  max-width: 32rem;
}

/* Search form */
.goSearchBooks {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 4rem;
}
.goSearchBooks .query {
  border: none;
  border-bottom: 1px solid var(--brand-300);
  background: transparent;
  padding: 0.25rem 0.25rem 0.5rem;
  font-size: 0.875rem;
  width: 18rem;
  font-family: var(--font-sans);
  color: var(--brand-900);
  outline: none;
  transition: border-color var(--transition);
}
.goSearchBooks .query::placeholder { color: var(--brand-300); }
.goSearchBooks .query:focus { border-bottom-color: var(--brand-900); }
.goSearchBooks button {
  background: none;
  border: none;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-600);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color var(--transition);
}
.goSearchBooks button:hover { color: var(--brand-900); }

/* Category filter nav (catalog page, nav after form) */
.goSearchBooks + nav {
  margin-bottom: 4rem;
}
.goSearchBooks + nav > span {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  display: block;
  margin-bottom: 1rem;
}
.goToCategory {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--brand-200);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-600);
  text-decoration: none;
  transition: all var(--transition);
  margin-right: 0.75rem;
  margin-bottom: 0.75rem;
}
.goToCategory:hover {
  border-color: var(--brand-900);
  color: var(--brand-900);
}

/* Book grid: div containing article.Book elements (catalog & category) */
.goSearchBooks + nav + div,
.Category > div {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3rem;
}

/* === Book Card (list view) === */
.Book { cursor: pointer; }
.Book > div:first-child {
  background: var(--brand-100);
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.75rem;
  color: var(--brand-300);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.Book .title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  transition: color var(--transition);
}
.Book:hover .title { color: var(--brand-600); }
.Book .author {
  font-size: 0.875rem;
  color: var(--brand-400);
  font-weight: 300;
  margin-bottom: 0.75rem;
}
.Book .price {
  font-size: 0.875rem;
  color: var(--brand-700);
  font-weight: 500;
  letter-spacing: 0.05em;
}
.Book .goToBookDetails {
  margin-top: 1rem;
  display: inline-block;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-500);
  text-decoration: none;
  border-bottom: 1px solid var(--brand-300);
  padding-bottom: 2px;
  transition: all var(--transition);
}
.Book .goToBookDetails:hover {
  color: var(--brand-900);
  border-bottom-color: var(--brand-900);
}

/* ===========================
   Book Detail Page
   =========================== */

/* Book detail layout: article.Book in book.html has two child divs */
main > article.Book {
  display: flex;
  gap: 4rem;
}
main > article.Book > div:first-child {
  width: 40%;
  background: var(--brand-100);
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6rem;
  color: var(--brand-300);
  flex-shrink: 0;
}
main > article.Book > div:nth-child(2) {
  flex: 1;
  padding-top: 1rem;
}
main > article.Book > div:nth-child(2) .title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  line-height: 1.2;
}
main > article.Book > div:nth-child(2) .author {
  color: var(--brand-500);
  font-size: 1.125rem;
  font-weight: 300;
  margin-bottom: 2rem;
}
main > article.Book dl {
  border-top: 1px solid rgba(224, 213, 199, 0.6);
  padding-top: 1.5rem;
  margin-bottom: 2rem;
}
main > article.Book dl > div {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--brand-100);
}
main > article.Book dt {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
}
main > article.Book dd {
  font-size: 0.875rem;
  color: var(--brand-700);
}
main > article.Book .isbn { font-family: monospace; font-size: 0.875rem; }
main > article.Book > div:nth-child(2) > .price {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 500;
  color: var(--brand-900);
  margin-top: 1.5rem;
  margin-bottom: 2rem;
}

/* Add to Cart form */
.doAddToCart {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.doAddToCart label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
}
.doAddToCart .quantity {
  border: none;
  border-bottom: 1px solid var(--brand-300);
  background: transparent;
  width: 4rem;
  text-align: center;
  padding: 0.5rem 0;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--brand-900);
  outline: none;
  transition: border-color var(--transition);
}
.doAddToCart .quantity:focus { border-bottom-color: var(--brand-900); }
.doAddToCart button {
  display: inline-block;
  border: 1px solid var(--brand-900);
  color: var(--brand-900);
  padding: 1rem 2.5rem;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--transition);
}
.doAddToCart button:hover {
  background: var(--brand-900);
  color: var(--brand-50);
}

/* ===========================
   Category Page
   =========================== */
.Category .title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 500;
  margin-bottom: 3rem;
}

/* ===========================
   Shopping Cart Page
   =========================== */
.ShoppingCart {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 500;
  margin-bottom: 4rem;
}

/* Cart layout: main > div containing section + aside */
.ShoppingCart + div {
  display: flex;
  gap: 4rem;
}
.ShoppingCart + div > section { flex: 1; }

/* Cart header row: section > div:first-child with column labels */
.ShoppingCart + div > section > div:first-child {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--brand-200);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
}
.ShoppingCart + div > section > div:first-child span:nth-child(1) { grid-column: span 6; }
.ShoppingCart + div > section > div:first-child span:nth-child(2) { grid-column: span 2; }
.ShoppingCart + div > section > div:first-child span:nth-child(3) { grid-column: span 2; }
.ShoppingCart + div > section > div:first-child span:nth-child(4) { grid-column: span 2; text-align: right; }

/* Cart item row: article inside cart section */
.ShoppingCart + div > section > article {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 2rem 0;
  border-bottom: 1px solid var(--brand-100);
}
/* Cart item cover (emoji div) */
.ShoppingCart + div > section > article > div:first-child {
  grid-column: span 2;
  background: var(--brand-100);
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--brand-300);
}
/* Cart item info (title + author div) */
.ShoppingCart + div > section > article > div:nth-child(2) { grid-column: span 4; }
.ShoppingCart + div > section > article > div:nth-child(2) .title { font-weight: 500; font-size: 0.875rem; }
.ShoppingCart + div > section > article > div:nth-child(2) .author {
  font-size: 0.75rem;
  color: var(--brand-400);
  font-weight: 300;
  margin-top: 0.25rem;
}
/* Cart item price */
.ShoppingCart + div > section > article > .price {
  grid-column: span 2;
  font-size: 0.875rem;
  color: var(--brand-700);
}

/* Update quantity form */
.doUpdateQuantity {
  grid-column: span 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.doUpdateQuantity .quantity {
  border: none;
  border-bottom: 1px solid var(--brand-300);
  background: transparent;
  width: 3rem;
  text-align: center;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--brand-900);
  outline: none;
  transition: border-color var(--transition);
}
.doUpdateQuantity .quantity:focus { border-bottom-color: var(--brand-900); }
.doUpdateQuantity button {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: var(--brand-500);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color var(--transition);
}
.doUpdateQuantity button:hover { color: var(--brand-900); }

/* Remove from cart form */
.doRemoveFromCart {
  grid-column: span 2;
  text-align: right;
}
.doRemoveFromCart button {
  background: none;
  border: none;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color var(--transition);
}
.doRemoveFromCart button:hover { color: var(--brand-900); }

/* Continue shopping link */
.ShoppingCart + div > section > a {
  display: inline-block;
  margin-top: 2rem;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-500);
  text-decoration: none;
  border-bottom: 1px solid var(--brand-300);
  padding-bottom: 2px;
  transition: all var(--transition);
}
.ShoppingCart + div > section > a:hover {
  color: var(--brand-900);
  border-bottom-color: var(--brand-900);
}

/* Order summary aside */
.ShoppingCart + div > aside {
  width: 20rem;
  flex-shrink: 0;
}
.ShoppingCart + div > aside h2 {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  margin-bottom: 2rem;
}
.ShoppingCart + div > aside > div {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  padding: 0.5rem 0;
}
.ShoppingCart + div > aside > div span:first-child { color: var(--brand-500); }
/* Total row: last div before checkout link */
.ShoppingCart + div > aside > div:last-of-type {
  padding-top: 1.5rem;
  margin-top: 1rem;
  border-top: 1px solid var(--brand-200);
}
.ShoppingCart + div > aside > div:last-of-type span:first-child {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
}
.totalAmount {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
}

/* Checkout link */
.goToCheckout {
  display: block;
  text-align: center;
  border: 1px solid var(--brand-900);
  color: var(--brand-900);
  padding: 1rem;
  margin-top: 2rem;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  transition: all var(--transition);
}
.goToCheckout:hover {
  background: var(--brand-900);
  color: var(--brand-50);
}

/* ===========================
   Checkout & Payment Pages
   =========================== */
.Checkout, .Payment {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 500;
  margin-bottom: 4rem;
}

/* Form sections (checkout steps) */
main > section {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--brand-100);
}
main > section h2 {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  margin-bottom: 2rem;
}
main > section label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  margin-bottom: 0.5rem;
}

/* Form layout for checkout forms */
.doUserInfo, .doShippingInfo, .doPaymentInfo {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Text inputs */
.userName, .userEmail {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--brand-300);
  background: transparent;
  padding: 0.25rem 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--brand-900);
  outline: none;
  transition: border-color var(--transition);
}
.userName::placeholder, .userEmail::placeholder { color: var(--brand-300); }
.userName:focus, .userEmail:focus { border-bottom-color: var(--brand-900); }

/* Textarea */
.shippingAddress {
  width: 100%;
  border: 1px solid var(--brand-200);
  background: transparent;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--brand-900);
  outline: none;
  resize: vertical;
  transition: border-color var(--transition);
}
.shippingAddress::placeholder { color: var(--brand-300); }
.shippingAddress:focus { border-color: var(--brand-900); }

/* Save buttons in checkout forms */
.doUserInfo button, .doShippingInfo button, .doPaymentInfo button {
  align-self: flex-start;
  background: none;
  border: none;
  border-bottom: 1px solid var(--brand-300);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-500);
  cursor: pointer;
  padding-bottom: 2px;
  font-family: var(--font-sans);
  transition: all var(--transition);
}
.doUserInfo button:hover, .doShippingInfo button:hover, .doPaymentInfo button:hover {
  color: var(--brand-900);
  border-bottom-color: var(--brand-900);
}

/* Continue to Payment link */
.goToPayment {
  display: block;
  text-align: center;
  border: 1px solid var(--brand-900);
  color: var(--brand-900);
  padding: 1rem;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  transition: all var(--transition);
}
.goToPayment:hover {
  background: var(--brand-900);
  color: var(--brand-50);
}

/* Payment method select */
.paymentMethod {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--brand-300);
  background: transparent;
  padding: 0.25rem 0.25rem 0.75rem;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--brand-900);
  outline: none;
  appearance: none;
  transition: border-color var(--transition);
}
.paymentMethod:focus { border-bottom-color: var(--brand-900); }

/* Order lines (payment page summary) */
.Payment ~ section > div > div {
  display: flex;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--brand-100);
  font-size: 0.875rem;
}
.Payment ~ section > div > div span:first-child { color: var(--brand-500); font-weight: 300; }

/* Order total on payment page */
.Payment ~ section > div:last-child {
  display: flex;
  justify-content: space-between;
  padding-top: 2rem;
  margin-top: 1rem;
}
.Payment ~ section > div:last-child span:first-child {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
}
.Payment ~ section > div:last-child .totalAmount {
  font-family: var(--font-display);
  font-size: 1.875rem;
  font-weight: 500;
}

/* Place order form */
.doPlaceOrder button {
  width: 100%;
  background: var(--brand-900);
  color: var(--brand-50);
  padding: 1.25rem;
  border: none;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  font-family: var(--font-sans);
  margin-top: 3rem;
  transition: background var(--transition);
}
.doPlaceOrder button:hover { background: var(--brand-800); }
.doPlaceOrder p {
  font-size: 0.75rem;
  color: var(--brand-400);
  text-align: center;
  margin-top: 0.75rem;
  font-weight: 300;
}

/* Bottom navigation links (payment page) */
main > nav:last-child {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 3rem;
}
main > nav:last-child a {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brand-400);
  text-decoration: none;
  transition: color var(--transition);
}
main > nav:last-child a:hover { color: var(--brand-900); }

/* === Focus States === */
input:focus, select:focus, textarea:focus {
  outline: none;
}
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* === Responsive === */
@media (max-width: 768px) {
  :root {
    --px: 1.25rem;
  }

  /* Home hero */
  main > h1.Home { font-size: 2.5rem; padding-top: 2rem; }

  /* Featured Books grid */
  main > .goSearchBooks ~ section > div { grid-template-columns: 1fr; }

  /* Book grid */
  .goSearchBooks + nav + div,
  .Category > div { grid-template-columns: 1fr; }

  /* Book detail */
  main > article.Book { flex-direction: column; }
  main > article.Book > div:first-child { width: 100%; }

  /* Cart layout */
  .ShoppingCart + div { flex-direction: column; }
  .ShoppingCart + div > aside { width: 100%; }

  /* Cart header */
  .ShoppingCart + div > section > div:first-child { display: none; }

  /* Cart item rows */
  .ShoppingCart + div > section > article {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .ShoppingCart + div > section > article > div:first-child {
    grid-column: auto;
    max-width: 5rem;
  }
  .ShoppingCart + div > section > article > div:nth-child(2) { grid-column: auto; }
  .ShoppingCart + div > section > article > .price { grid-column: auto; }
  .doUpdateQuantity { grid-column: auto; }
  .doRemoveFromCart { grid-column: auto; text-align: left; }

  /* Page titles */
  .Catalog, .ShoppingCart, .Checkout, .Payment,
  .Category .title { font-size: 2rem; }

  /* Search input */
  .goSearchBooks .query { width: 100%; }
  .goSearchBooks { flex-direction: column; }
}

@media (max-width: 480px) {
  main > h1.Home { font-size: 1.875rem; }
  main > article.Book > div:nth-child(2) .title { font-size: 1.75rem; }
}
