/* Shared catalog styles for both before and after demos */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #888;
  --font: system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  padding-top: 40px; /* demo-nav height */
}

/* ─── Render time banner ─────────────────────────────────────── */
.render-banner {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.78rem;
  font-family: var(--mono);
}

.render-banner .label { color: var(--muted); }

#render-time {
  font-weight: 700;
  color: var(--muted);
  transition: color 0.3s;
}

#render-time.fast { color: #52c07a; }
#render-time.ok   { color: #f0a04a; }
#render-time.slow { color: #e05252; }

/* ─── Page header ────────────────────────────────────────────── */
.catalog-header {
  padding: 1.5rem 1.5rem 0;
}

.catalog-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

/* ─── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.filter-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.filter-btn:hover {
  color: var(--text);
  border-color: #555;
}

.filter-btn.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* ─── Product grid ───────────────────────────────────────────── */
#grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

/* ─── Product card ───────────────────────────────────────────── */
.product-card {
  background: var(--surface);
  position: relative;
  overflow: hidden;
  transition: background 0.15s;

  /* Multiple layered box-shadows: expensive to paint.
     This is intentional — it makes the rendering cost visible
     and mirrors real-world CSS patterns found in production apps. */
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.04),
    0 1px 2px  rgba(0,0,0,0.3),
    0 2px 4px  rgba(0,0,0,0.25),
    0 4px 8px  rgba(0,0,0,0.2),
    0 8px 16px rgba(0,0,0,0.15);
}

.product-card:hover { background: #222; }

/* Subtle gradient overlay — adds to paint complexity */
.product-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(255,255,255,0.025) 0%,
    transparent 40%,
    rgba(0,0,0,0.04) 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Category color accent bar at bottom of each card */
.product-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cat-color), transparent);
}

/* ─── Product thumbnail ──────────────────────────────────────── */
.product-thumbnail {
  height: 170px;
  background: linear-gradient(135deg, var(--cat-dark) 0%, color-mix(in srgb, var(--cat-color) 40%, var(--cat-dark)) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Radial glare — adds to paint complexity */
.product-thumbnail::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 35%, rgba(255,255,255,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 75% 80%, rgba(0,0,0,0.25) 0%, transparent 45%);
}

/* Bottom fade for depth */
.product-thumbnail::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 48px;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent);
}

.product-emoji {
  font-size: 3.5rem;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
  line-height: 1;
}

/* ─── Product body ───────────────────────────────────────────── */
.product-body {
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.product-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  align-self: flex-start;
}

.badge-sale        { background: #3a1a1a; color: #e05252; border: 1px solid #5a2a2a; }
.badge-new         { background: #1a2a3a; color: #6ab4f7; border: 1px solid #2a4a6a; }
.badge-best-seller { background: #1a3a28; color: #52c07a; border: 1px solid #2a5a3a; }

.product-name {
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  margin-top: 0.1rem;
}

.product-category {
  font-size: 0.7rem;
  color: var(--cat-color, var(--muted));
  font-weight: 500;
  letter-spacing: 0.03em;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.15rem;
}

.stars {
  color: #f7d76a;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.review-count {
  font-size: 0.68rem;
  color: var(--muted);
}

.product-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.product-price {
  font-size: 1rem;
  font-weight: 700;
  color: #52c07a;
  font-family: var(--mono);
}

.add-to-cart {
  padding: 0.35rem 0.75rem;
  background: #7c6af7;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.15s;
}

.add-to-cart:hover { background: #6a58e0; }

/* ─── Light theme ────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f8f8f8;
    --surface: #ffffff;
    --border: #e2e2e2;
    --text: #111111;
    --muted: #777777;
  }

  :root:not([data-theme="dark"]) .product-card:hover { background: #f5f5f5; }

  :root:not([data-theme="dark"]) .filter-btn:hover { border-color: #bbb; }

  :root:not([data-theme="dark"]) .badge-sale        { background: #fde8e8; border-color: #f5b8b8; }
  :root:not([data-theme="dark"]) .badge-new         { background: #e8f2fd; border-color: #b8d4f5; }
  :root:not([data-theme="dark"]) .badge-best-seller { background: #e8f5ee; border-color: #b8e5c8; }

  :root:not([data-theme="dark"]) .product-card {
    box-shadow:
      inset 0 0 0 1px rgba(0,0,0,0.04),
      0 1px 2px  rgba(0,0,0,0.06),
      0 2px 4px  rgba(0,0,0,0.05),
      0 4px 8px  rgba(0,0,0,0.04),
      0 8px 16px rgba(0,0,0,0.03);
  }
}

:root[data-theme="light"] {
  --bg: #f8f8f8;
  --surface: #ffffff;
  --border: #e2e2e2;
  --text: #111111;
  --muted: #777777;
}

html[data-theme="light"] .product-card:hover { background: #f5f5f5; }
html[data-theme="light"] .filter-btn:hover { border-color: #bbb; }
html[data-theme="light"] .badge-sale        { background: #fde8e8; border-color: #f5b8b8; }
html[data-theme="light"] .badge-new         { background: #e8f2fd; border-color: #b8d4f5; }
html[data-theme="light"] .badge-best-seller { background: #e8f5ee; border-color: #b8e5c8; }

html[data-theme="light"] .product-card {
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,0.04),
    0 1px 2px  rgba(0,0,0,0.06),
    0 2px 4px  rgba(0,0,0,0.05),
    0 4px 8px  rgba(0,0,0,0.04),
    0 8px 16px rgba(0,0,0,0.03);
}
