:root {
  --primary-color: #0066cc;
  --text-color: #333;
  --light-bg: #f9f9f9;
  --border: #ddd;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  color: var(--text-color);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  max-width: 1400px;
  margin: 0 5%;
  padding: 0 1.5rem;
}

.products p,
.subcategory-list {
  max-width: 75ch;
  margin-left: 0;
  margin-right: auto;
}

.products {
  margin-top: -1rem;
  /* pulls products closer if present */
}

/* Let category descriptions use full available width (or a wider limit) */
.category-content {
  max-width: none;
  /* or set to 90ch / 100ch / 65rem if you want a compromise */
  margin-left: 0;
  margin-right: auto;
  margin-top: 0;
  margin-bottom: 3rem;
}

main.container {
  flex: 1 0 auto;
  padding-bottom: 3rem;
}

footer {
  flex-shrink: 0;
  margin-top: 3rem;
  padding: 1.5rem 0;
  background: #f8f8f8;
  border-top: 1px solid #ddd;
  text-align: center;
  width: 100%;
}

footer p {
  margin: 0;
  font-size: 0.95rem;
  color: #666;
}

.product-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin: 2rem 0;
}

.product-image img {
  max-width: 100%;
  height: auto;
  /*  border: 1px solid var(--border);
  border-radius: 8px; */
}

.product-info h1 {
  margin-top: 0;
  font-size: 1.6rem;
}

.stock {
  font-weight: bold;
  color: #388e3c;
}

.add-to-cart {
  background: #0066cc;
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 6px;
  margin: 1rem 0;
  margin-left: 1rem;
}

.add-to-cart:hover {
  background: #0052a3;
}

.meta {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: #555;
}

.product-description {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}

.quantity-container {
  display: inline-flex;
  align-items: center;
  margin: 1rem 0;
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
}

.qty-btn {
  width: 40px;
  height: 40px;
  background: #f0f0f0;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
}

.qty-btn:hover {
  background: #e0e0e0;
}

.qty-input {
  width: 50px;
  text-align: center;
  border: none;
  font-size: 1.1rem;
  background: white;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.site-header {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo a {
  font-size: 1.8rem;
  font-weight: bold;
  color: #0066cc;
  text-decoration: none;
}

.header-nav ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.5rem;
}

.header-nav a {
  color: #333;
  text-decoration: none;
  font-weight: 500;
}

.header-nav a:hover {
  color: #0066cc;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: nowrap !important;
  min-width: 0;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.search-form input[type="search"] {
  padding: 0.6rem 1rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
  width: 200px;
}

.search-form button {
  padding: 0.6rem 1rem;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.cart-link {
  font-weight: 500;
  color: #333;
  text-decoration: none;
}

.cart-link:hover {
  color: #0066cc;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.5rem;
  /* ← reduced from 1.25rem if overlap was bad; increase if you want more horizontal breathing */
  margin: 1.5rem 0 3rem 0;
  justify-content: start;
}

.product-card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem;
  /* ← keep or reduce to 0.9rem if still too roomy */
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  height: 100%;
  /* ← this + flex helps prevent overlap in rows */
  justify-content: space-between;
  /* distributes space evenly */
}

.product-image-container {
  width: 100%;
  height: 160px;
  /* ← reduced from 180px to pull title up */
  margin-bottom: 0.5rem;
  /* ← big reduction from 0.75rem */
  text-align: center;
  overflow: hidden;
  padding-top: 0.3rem;
  /* minimal top buffer instead of large margin */
}

.product-image {
  width: 85%;
  height: 100%;
  object-fit: contain;
  margin: 0 auto;
}

.product-image.placeholder {
  opacity: 0.7;
  width: 70%;
}

.product-card h3 {
  margin: 0.4rem 0 0.6rem;
  /* ← much tighter: top 0.4rem (from title to image), bottom 0.6rem (to price) */
  font-size: 1.15rem;
  line-height: 1.3;
  text-align: center;
}

.product-card h3 a {
  color: #0066cc;
  /* same blue as site links */
  text-decoration: none;
  /* no underline */
  font-weight: 500;
}

.product-card h3 a:hover {
  text-decoration: underline;
  /* underline on hover for clarity */
}

.price {
  margin: 0.4rem 0 0.75rem;
  /* ← reduced top margin from 0.5rem+ */
  font-size: 1.75rem;
  font-weight: bold;
  color: #b12704;
  text-align: center;
  font-style: normal !important;
}

.price-updated {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.65rem;
  font-weight: normal;
  color: #000000;
  text-align: center;
  font-style: normal !important;
}

.tooltip-wrapper {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted #999;
}

.tooltip {
  visibility: hidden;
  width: auto;
  max-width: 320px;
  min-width: 240px;
  background-color: #333;
  color: white;
  text-align: left;
  border-radius: 6px;
  padding: 12px 16px;
  position: absolute;
  z-index: 10;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: normal;
  word-wrap: break-word;
  line-height: 1.45;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip-wrapper:hover .tooltip,
.tooltip-wrapper:focus .tooltip {
  visibility: visible;
  opacity: 1;
}

.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -8px;
  border-width: 8px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}

.product-meta {
  font-size: 0.9rem;
}

.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.or-text {
  font-weight: bold;
  color: #666;
  white-space: nowrap;
}

.amazon-buy-button {
  display: inline-block;
  background-color: #FF9900;
  color: black !important;
  border: 1px solid black;
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  font-size: 1.1rem;
  font-weight: normal;
  text-decoration: none;
  text-align: center;
  transition: background-color 0.2s;
}

.amazon-buy-button:hover {
  background-color: #FFB733;
}

.sub-categories {
  margin: 2rem 0 3rem;
}

.sub-categories h2 {
  margin-top: 0;
  font-size: 1.8rem;
}

.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem 0;
}

.price-main {
  font-weight: bold;
  color: #b12704;
  white-space: nowrap;
  font-size: 2.8rem;
  line-height: 1;
}

.price-symbol {
  font-size: 1.2rem;
  vertical-align: super;
  margin-right: 0.1rem;
}

.price-dollars {
  font-size: 2.8rem;
  line-height: 1;
}

.price-cents {
  font-size: 1.5rem;
  vertical-align: super;
  margin-left: 0.1rem;
}

.price-call {
  font-size: 2rem;
  color: #d32f2f;
  font-weight: bold;
}

.breadcrumbs {
  font-size: 0.9rem;
}

.breadcrumbs ol {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  font-size: 0.95rem;
  color: #666;
}

.breadcrumbs li {
  display: inline-flex;
  align-items: center;
}

.breadcrumbs li+li::before {
  content: "/";
  margin: 0 0.35rem;
  color: #999;
}

.breadcrumbs a {
  color: var(--primary-color);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumbs span[aria-current="page"] {
  color: var(--text-color);
  font-weight: bold;
}

.out-of-stock {
  color: #d32f2f;
  font-weight: bold;
  font-size: 1.4rem;
}

.out-of-stock-notice {
  background: #ffebee;
  padding: 1rem;
  border-radius: 6px;
  border: 1px solid #ef9a9a;
  text-align: center;
}

.toast-view-cart {
  display: inline-block;
  color: white;
  font-weight: 600;
  text-decoration: underline;
  font-size: 1rem;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  transition: background 0.2s;
}

.toast-view-cart:hover {
  background: rgba(255, 255, 255, 0.15);
}

.cart-toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #28a745;
  color: white;
  padding: 1.2rem 1.8rem;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  max-width: 380px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.4s ease;
  text-align: center;
  line-height: 1.5;
}

.cart-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-main {
  margin-bottom: 0.8rem;
  font-size: 1.05rem;
}

.subcategory-columns {
  max-width: 1200px;
  /* ← cap the total width so it doesn't stretch forever */
  margin: 0 auto;
  /* ← centers the block horizontally */
  padding-left: 1.5rem;
  /* ≈ half inch / 24px on most screens */
  padding-right: 1.5rem;
  /* symmetric right side */
}

.subcategory-list {
  column-count: 3;
  column-gap: 2.5rem;
  /* base gap – feels balanced */
  margin: 0;
  padding: 0;
  list-style: none;
  column-fill: balance;
  padding-top: 0 !important;
  /* keep your previous top-align fix */
}

/* Items get a bit more horizontal breathing room */
.subcategory-list li {
  margin: 0.7rem 0;
  padding-left: 0.5rem;
  /* tiny indent on each link for polish */
}

.subcategory-list li:first-child {
  margin-top: 0.6rem;
  /* or even 0 if you want dead-flush alignment */
}

.subcategory-list a {
  text-decoration: none;
  color: #0066cc;
  font-weight: 500;
  display: block;
}

.subcategory-list a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (min-width: 1200px) {
  .subcategory-columns {
    padding-left: 3rem;
    /* more indent on ultra-wide */
    padding-right: 3rem;
  }

  .subcategory-list {
    column-gap: 5rem;
    /* bigger gaps = more centered & airy feel */
  }
}

@media (min-width: 1600px) {
  .subcategory-columns {
    padding-left: 3rem;
    /* more indent on ultra-wide */
    padding-right: 3rem;
  }

  .subcategory-list {
    column-gap: 5rem;
    /* bigger gaps = more centered & airy feel */
  }
}

/* On medium screens keep it tight but still padded */
@media (max-width: 1100px) {
  .subcategory-columns {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .subcategory-list {
    column-count: 2;
    column-gap: 2rem;
  }
}

@media (max-width: 700px) {
  .subcategory-columns {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .subcategory-list {
    column-count: 1;
    column-gap: 0;
  }

  .subcategory-list li {
    margin: 1rem 0;
  }
}

/* ── Media Queries ──────────────────────────────────────── */

@media (max-width: 768px) {
  .container {
    margin: 0 3%;
    padding: 0 1rem;
  }

  .site-header .container {
    flex-direction: column;
    gap: 1rem;
  }

  .header-nav ul {
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
  }

  .header-right {
    flex-direction: column;
    width: 100%;
    gap: 1rem;
  }

  .search-form input[type="search"] {
    width: 100%;
  }

  .price-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .search-container {
    width: 100% !important;
    max-width: none !important;
  }

  .pagefind-ui__search-input {
    padding-left: 2.5rem !important;
  }

  .pagefind-ui__results-area {
    position: fixed !important;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 50vh;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
  }

  .pagefind-ui__message {
    font-size: 1rem !important;
    padding: 0.6rem 0;
  }

  .cart-toast {
    bottom: 90px;
    right: 15px;
    left: 15px;
    max-width: none;
    padding: 1rem 1.5rem;
  }
}

@media (min-width: 768px) {
  .product-layout {
    flex-direction: row;
  }

  .product-image {
    flex: 0 0 45%;
  }

  .product-info {
    flex: 1;
  }
}

@media (min-width: 600px) {
  .product-grid {
    row-gap: 3rem;
    /* force more vertical separation between rows if needed */
  }
}

@media (max-width: 1036px) and (min-width: 769px) {

  .header-right,
  .site-header .header-right {
    flex-wrap: nowrap !important;
    gap: 1rem;
  }

  .search-container {
    max-width: 280px !important;
    min-width: 180px !important;
  }

  .header-nav ul {
    gap: 1rem !important;
  }

  .cart-link {
    font-size: 0.95rem !important;
  }
}

@media (max-width: 600px) {
  .action-row {
    flex-direction: column;
    gap: 0.75rem;
  }

  .or-text {
    display: none;
  }
}

/* Pagefind heavy overrides – consolidated */
.search-container {
  flex: 1 1 auto;
  max-width: 320px;
  min-width: 180px;
  transition: max-width 0.3s ease;
}

#search {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
}

.pagefind-ui__search-input {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 0.7rem 2.8rem 0.7rem 2.5rem !important;
  font-size: 1rem !important;
  line-height: 1.5 !important;
  border: 1px solid #ccc !important;
  border-radius: 6px !important;
  transition: none !important;
}

.pagefind-ui__search-input::placeholder {
  padding-left: 1.5rem !important;
  color: #999 !important;
  opacity: 1 !important;
}

.pagefind-ui__search-input:focus,
.pagefind-ui__search-input:active,
.pagefind-ui__search-input:not(:placeholder-shown) {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  transform: none !important;
}

.pagefind-ui__search-input:focus {
  border-color: #0066cc !important;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1) !important;
  outline: none !important;
}

.pagefind-ui__clear-button {
  right: 0.8rem !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 20px !important;
  height: 20px !important;
  background: #eee !important;
  border-radius: 50% !important;
  color: #666 !important;
  font-size: 0.9rem !important;
  line-height: 20px !important;
  text-align: center !important;
}

.pagefind-ui__results-area {
  position: absolute !important;
  top: 100% !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1000 !important;
  margin-top: 0.5rem !important;
  background: white !important;
  background-color: #ffffff !important;
  border: 1px solid #ddd !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18) !important;
  max-height: 60vh !important;
  overflow-y: auto !important;
}

.pagefind-ui__results-area,
.pagefind-ui__results,
.pagefind-ui__result {
  background-color: white !important;
  color: #333 !important;
}

.pagefind-ui__results-area * {
  background-color: inherit !important;
}

.pagefind-ui__result {
  padding: 0.9rem 1.2rem !important;
  border-bottom: 1px solid #eee !important;
  margin: 0 !important;
}

.pagefind-ui__result:last-child {
  border-bottom: none;
}

.pagefind-ui__result:hover {
  background: #f8f9fa;
}

.pagefind-ui__result-title a {
  color: #0066cc;
  font-size: 1.05rem;
  text-decoration: none;
  font-weight: 500;
}

.pagefind-ui__result-title a:hover {
  text-decoration: underline;
}

.pagefind-ui__result-excerpt {
  color: #555 !important;
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  margin-top: 0.4rem;
}

.pagefind-ui__result-highlight {
  background-color: #fff3cd !important;
  color: #333 !important;
  padding: 0.05rem 0.15rem;
  border-radius: 3px;
}

.pagefind-ui__message,
.pagefind-ui__message * {
  text-align: center !important;
  display: block !important;
  width: 100% !important;
  margin: 1rem auto !important;
  font-weight: 500 !important;
  color: #444 !important;
  font-size: 1.05rem !important;
}

.pagefind-ui__message {
  padding: 0.75rem 0;
  background: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  margin-bottom: 1rem !important;
}

/* Footer navigation */
footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem 1rem;
}

.footer-nav {
  margin: 0;
}

.footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.5rem 2rem;
}

.footer-nav li {
  margin: 0;
}

.footer-nav a {
  color: #666;
  text-decoration: none;
  font-weight: 500;
  font-size: 1rem;
}

.footer-nav a:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

footer p {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
  color: #888;
  text-align: center;
}

/* Make header-right take full width on mobile if needed */
@media (max-width: 768px) {
  .site-header .container {
    flex-direction: column;
    align-items: stretch;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
    gap: 1rem;
  }

  .search-container {
    flex: 1;
  }
}

/* Hero */
.hero {
  background: linear-gradient(135deg, #f0f4ff 0%, #e6f0ff 100%);
  padding: 5rem 0 4rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.8rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.hero p {
  font-size: 1.25rem;
  max-width: 600px;
  margin: 0 auto 2rem;
  color: #444;
}

.hero-search {
  max-width: 500px;
  margin: 0 auto 2rem;
}

.hero .btn-primary {
  display: inline-block;
  background: var(--primary-color);
  color: white;
  padding: 1rem 2rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
}

.hero .btn-primary:hover {
  background: #0052a3;
}

/* Categories */
.categories-section {
  padding: 4rem 0;
  background: white;
}

.categories-section h2 {
  text-align: center;
  margin-bottom: 2.5rem;
  font-size: 2.2rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.5rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.5rem;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 12px;
  text-decoration: none;
  color: #333;
  transition: all 0.25s ease;
}

.category-card:hover,
.category-card:focus {
  transform: translateY(-6px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--primary-color);
}

.category-icon {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 1rem;
}

.category-card h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

/* Featured (placeholder) */
.featured {
  padding: 4rem 0;
  background: var(--light-bg);
  text-align: center;
}

.featured h2 {
  margin-bottom: 1.5rem;
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .hero h1 {
    font-size: 2.4rem;
  }

  .hero p {
    font-size: 1.1rem;
  }

  .category-grid {
    gap: 1.25rem;
  }
}

@media (max-width: 600px) {
  .hero {
    padding: 4rem 0 3rem;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .category-grid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
  }

  .category-icon {
    width: 70px;
    height: 70px;
  }
}

.subcategory-list {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.subcategory-list li:first-of-type,
.subcategory-list li:first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.subcategory-list a {
  display: block;
  margin-top: 0 !important;
  padding-top: 0 !important;
  line-height: 1.2;
  /* force tighter if line-height is the issue */
}

/* Extreme measure – collapse the first item's top margin completely */
.subcategory-columns>.subcategory-list:first-child li:first-child {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

/* WebKit-specific reset (Chrome/Safari) */
@supports (-webkit-margin-before: 0) {
  .subcategory-list {
    -webkit-margin-before: 0 !important;
    -webkit-margin-after: 0 !important;
  }
}