/* Root color variables based on the Santa Sylva palette */
:root {
  --background: #f5f0d7;
  --foreground: #556b2f;
  --primary: #9b1c2f;
  --secondary: #556b2f;
  --muted: #8c5528;
  --border: #d8cbb6;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: 'Cinzel', serif;
  margin: 0;
}

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.header {
  background-color: var(--background);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
}
/* Top header: shrink padding to reduce overall header height */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Reduce top/bottom padding to save vertical space.  A smaller padding helps
     shorten the overall header height. */
  padding: 0.25rem 0;
}

/* Icons container on the right of the header */
.header-icons {
  display: flex;
  align-items: center;
  /* Reduce gap and icon size so the icons are closer to the logo and
     fit better on smaller screens without causing horizontal scroll. */
  gap: 0.75rem;
  font-size: 1.2rem;
  padding-right: 0.5rem;
}

/* Search icon placeholder */
.search-icon {
  color: var(--foreground);
  text-decoration: none;
  cursor: pointer;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
}
/* Shrink logo slightly so the header occupies less vertical space */
.logo img {
  /* Enlarge the logo slightly */
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin-right: 0.75rem;
}
.logo-text h1 {
  /* Larger brand name */
  font-size: 2.2rem;
  color: var(--foreground);
}
.logo-text p {
  /* Slightly larger tagline */
  font-size: 1rem;
  color: var(--muted);
}
/* Category navigation bar below the top header */
.nav {
  /* Use CSS grid to lay out the category links. The minimum column width is
     intentionally small so that more items fit on a single row, reducing
     the overall height of the navigation. */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  column-gap: 0.5rem;
  row-gap: 0;
  border-top: 1px solid var(--border);
  /* Slight padding so links aren’t cramped but the bar remains compact */
  padding: 0.2rem 0;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
}
.nav a {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition: background-color 0.2s ease;
  color: var(--foreground);
  white-space: normal;
}
.nav a:hover {
  background-color: rgba(85, 107, 47, 0.1);
}
.cart-button {
  position: relative;
  font-size: 1.2rem;
}
.cart-button span {
  background-color: var(--primary);
  color: #fff;
  border-radius: 50%;
  padding: 0 6px;
  font-size: 0.75rem;
  position: absolute;
  top: -8px;
  right: -12px;
}

/* Hero section */
.hero {
  padding: 4rem 1rem;
  text-align: center;
  background-image: radial-gradient(circle at 25px 25px, rgba(85, 107, 47, 0.1) 2px, transparent 0);
  background-size: 50px 50px;
}
.hero h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: var(--foreground);
}
.hero p {
  max-width: 600px;
  margin: 0 auto;
  color: var(--muted);
}
/* Hero button */
.hero-button {
  display: inline-block;
  margin-top: 1.5rem;
  background-color: var(--primary);
  color: #fff;
  padding: 0.6rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 500;
  transition: background-color 0.2s ease;
}
.hero-button:hover {
  background-color: #761725;
}

/* Alchemy section */
.alchemy {
  background-color: var(--muted);
  color: #fff;
  text-align: center;
  padding: 4rem 1rem;
}
.alchemy h2 {
  font-family: 'Cinzel', serif;
  font-size: 2rem;
  margin-bottom: 1rem;
}
.alchemy p {
  max-width: 700px;
  margin: 0 auto 2rem auto;
  font-size: 1rem;
  line-height: 1.5;
}
.alchemy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}
.alchemy-item h3 {
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  color: #fff;
}
.alchemy-item p {
  font-size: 0.9rem;
  margin: 0;
  color: #fef9f2;
}
.icon-wrapper {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  font-size: 1.5rem;
  color: #fff;
}
.icon-green {
  background-color: var(--secondary);
}
.icon-red {
  background-color: var(--primary);
}
.icon-blue {
  background-color: #2c3e50;
}

/* Adjust WhatsApp floating icon svg sizing */
.whatsapp-float svg {
  width: 28px;
  height: 28px;
}

/* Products */
#products-container {
  padding: 2rem 1rem;
}
/* Category section: provide margin bottom and offset for anchored scrolling */
.category-section {
  margin-bottom: 3rem;
  /* Offset anchor targets so that the fixed header and navigation bar do not obscure
     the section titles when navigating via anchor links.  A generous value here
     accounts for the two‑row header/nav combination, ensuring the heading isn’t
     covered by the menu on smaller screens. */
  scroll-margin-top: 20rem;
}
.category-section h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  /* Align category titles to the left rather than centered */
  text-align: left;
  color: var(--foreground);
}
.product-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  /* Center the grid within the page and limit maximum width */
  max-width: 1200px;
  margin: 0 auto;
  /* When there are fewer cards than available columns, center them. We also
     center the entire grid horizontally so leftover space is evenly
     distributed on both sides. */
  justify-items: center;
  justify-content: center;
}
.product-card {
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease;
}
.product-card:hover {
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}
.product-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}
.product-info {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.product-info h4 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.product-info .price {
  margin-bottom: 1rem;
  color: var(--foreground);
}
.product-info .price .old-price {
  text-decoration: line-through;
  color: var(--muted);
  margin-left: 0.5rem;
}
.product-info button {
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-weight: 500;
}
.product-info button:hover {
  background-color: #761725;
}

/* Cart sidebar */
.cart-sidebar {
  position: fixed;
  /* Anchor the sidebar to the very top of the viewport so nothing is cut off */
  top: 0;
  right: 0;
  /* Use full viewport height so the entire cart is visible and scrollable */
  height: 100vh;
  width: 320px;
  background-color: var(--background);
  border-left: 1px solid var(--border);
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  /* Ensure the cart appears above the header and nav when opened */
  z-index: 2000;
  /* Add a bit of internal padding for breathing room */
  padding: 1rem;

  /* Allow scrolling if the cart contents exceed the viewport height. Without
     this, part of the cart could be hidden behind the viewport. */
  overflow-y: auto;
}
.cart-sidebar.open {
  transform: translateX(0);
}
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.close-cart {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}
.cart-items {
  flex: 1;
  overflow-y: auto;
}
.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.cart-item img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-right: 0.5rem;
}
.cart-item-info {
  flex: 1;
  margin-right: 0.5rem;
}
.cart-item-info h5 {
  margin: 0;
  font-size: 0.9rem;
}
.cart-item-info p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.cart-item-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 1rem;
}
.cart-footer {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.cart-footer p {
  margin: 0 0 1rem 0;
  font-size: 1rem;
}
.cart-footer button {
  width: 100%;
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
}
.cart-footer button:hover {
  background-color: #761725;
}

/* WhatsApp button */
.whatsapp-float {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  background-color: #25d366;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  text-decoration: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
  z-index: 1000;
}
.whatsapp-float:hover {
  transform: scale(1.1);
}

/* Cart quantity controls */
.cart-qty-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.qty-btn {
  border: none;
  background-color: var(--border);
  color: var(--foreground);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
}
.qty-btn:hover {
  background-color: var(--secondary);
  color: #fff;
}
.qty-count {
  min-width: 1.2rem;
  text-align: center;
}

/* Checkout button styling */
.checkout-btn {
  display: block;
  width: 100%;
  margin-bottom: 0.5rem;
  background-color: var(--primary);
  color: #fff;
  padding: 0.5rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
}
.checkout-btn:hover {
  background-color: #761725;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.modal.open {
  display: flex;
}
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
}
.modal-content {
  position: relative;
  background-color: var(--background);
  border-radius: var(--radius);
  padding: 1rem;
  max-width: 600px;
  width: 90%;
  max-height: 90%;
  overflow-y: auto;
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--foreground);
}
.modal-image-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-image-container img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--foreground);
}
#modal-prev {
  left: 0;
}
#modal-next {
  right: 0;
}
.modal-add-btn {
  margin-top: 1rem;
  background-color: var(--primary);
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 500;
}
.modal-add-btn:hover {
  background-color: #761725;
}