/*
 * Modern CSS Redesign for Back Pain Buddy
 * - Mobile-first approach
 * - Utilizes CSS Custom Properties, clamp(), aspect-ratio, and modern layout techniques.
 */

/* --- 1. Custom Properties (Variables) --- */
:root {
  /* Colors derived from the logo */
  --color-background: #F9F8F6; /* Soft, creamy off-white */
  --color-text: #2E5959;       /* Dark, calming teal */
  --color-text-light: #5a7d7d;
  --color-primary: #D88A4F;    /* Warm orange for accents & CTAs */
  --color-primary-dark: #b86e3a;
  --color-surface: #FFFFFF;    /* For cards and header background */
  --color-border: #EAE8E4;

  /* Typography */
  --font-family: 'Inter', sans-serif;
  --font-size-base: 16px;
  /* Fluid typography for the main heading */
  --font-size-h1: clamp(1.75rem, 5vw, 2.5rem); 

  /* Spacing & Borders */
  --spacing-unit: 8px;
  --border-radius: 12px;
  --shadow-subtle: 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-medium: 0 4px 12px rgba(46, 89, 89, 0.1);
  --shadow-hover: 0 6px 16px rgba(46, 89, 89, 0.15);
}

/* --- 2. Global Styles & Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--color-background);
  color: var(--color-text);
  margin: 0;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin-inline: auto; /* Modern equivalent of margin: 0 auto; */
  padding-inline: calc(var(--spacing-unit) * 3);
}

/* --- 3. Header & Navigation --- */
.site-header {
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding-block: calc(var(--spacing-unit) * 2);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-subtle);
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-unit);
  margin-bottom: var(--spacing-unit);
}

.logo {
  max-height: 50px;
}

h1 {
  font-size: var(--font-size-h1);
  margin: 0;
  line-height: 1.2;
}

.search-bar {
  width: 100%;
  max-width: 500px;
  padding: calc(var(--spacing-unit) * 1.5);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  font-size: 1rem;
  margin-bottom: calc(var(--spacing-unit) * 2);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.search-bar:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px hsla(28, 67%, 57%, 0.3);
}

.category-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-unit);
}

.category-nav a {
  color: var(--color-text-light);
  text-decoration: none;
  font-weight: 500;
  padding: var(--spacing-unit) calc(var(--spacing-unit) * 2);
  border-radius: 20px;
  background-color: var(--color-background);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.category-nav a:hover {
  background-color: var(--color-primary);
  color: white;
}


/* --- 4. Main Content & Product Grid --- */
main.container {
  padding-top: calc(var(--spacing-unit) * 4);
}

.masonry-grid {
  display: grid;
  gap: calc(var(--spacing-unit) * 3);
  /* Mobile: 1 column */
  grid-template-columns: 1fr; 
}

/* --- 5. Product Card --- */
.product-card {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-medium);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
}

.product-image-container {
  background-color: #f0f0f0;
  /* Modern CSS for aspect ratio */
  aspect-ratio: 1 / 1; 
}

.product-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  padding: calc(var(--spacing-unit) * 2);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 var(--spacing-unit) 0;
  min-height: 4.2em; /* Reserve space for ~3 lines of text */
}

.product-desc {
  font-size: 0.9rem;
  color: var(--color-text-light);
  margin-top: auto;
  padding-bottom: var(--spacing-unit);
}

.product-price {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--color-text);
  margin-bottom: calc(var(--spacing-unit) * 2);
}

.buy-button {
  display: block;
  width: 100%;
  padding: calc(var(--spacing-unit) * 1.5);
  background-color: var(--color-primary);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-weight: bold;
  border-radius: var(--border-radius);
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.buy-button:hover {
  background-color: var(--color-primary-dark);
}
.buy-button:active {
  transform: scale(0.98);
}


/* --- 6. Loader & Footer --- */
.loader { 
  text-align: center; 
  padding: calc(var(--spacing-unit) * 4); 
  font-size: 1.2em; 
  display: none; 
}

.site-footer {
  background: var(--color-text);
  color: var(--color-background);
  padding: calc(var(--spacing-unit) * 4);
  margin-top: calc(var(--spacing-unit) * 4);
  font-size: 0.9em;
  text-align: center;
}
.site-footer a { color: #fff; }

/* --- 7. Responsive Breakpoints (Mobile First) --- */

/* Tablet and up */
@media (min-width: 600px) {
  .masonry-grid {
    /* 2 columns for tablets */
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small Desktop and up */
@media (min-width: 900px) {
  .masonry-grid {
    /* 3 columns for small desktops */
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Large Desktop and up */
@media (min-width: 1200px) {
  .masonry-grid {
    /* 4 columns for large desktops */
    grid-template-columns: repeat(4, 1fr);
  }
}

