/**
 * Products Page - Optimized Layout
 * E-commerce best practices: sidebar + product grid
 *
 * Brand pass 2/3: reads only design tokens (design-tokens.css), through
 * the --product-* layer where a role exists. Ink carries text and
 * actions; amber is warmth; sage is a ground tint only.
 *
 * Literals that remain are layout geometry (sidebar width, image heights)
 * and media-query widths, which CSS cannot read from custom properties:
 * 1024px = --breakpoint-desktop, 768px = --breakpoint-tablet,
 * 480px sits between --breakpoint-mobile-lg and --breakpoint-tablet.
 *
 * Also loaded by search_results.pug, which reuses the sidebar + grid.
 */

/* =====================================================
   ACTIONS — the shared .btn is sage, which fails contrast
   with white. On these pages actions are ink. Scoped to
   .site-main so the cookie notice keeps its own buttons.
   ===================================================== */

.site-main .btn-primary {
  background-color: var(--product-action-bg);
  color: var(--product-action-text);
}

.site-main .btn-primary:hover {
  background-color: var(--product-action-hover);
  color: var(--product-action-text);
}

.site-main .btn-outline {
  border-color: var(--product-heading);
  color: var(--product-heading);
}

.site-main .btn-outline:hover {
  background-color: var(--product-action-bg);
  color: var(--product-action-text);
}

.site-main .affiliate-disclosure-footer__text a {
  color: var(--product-link);
  text-decoration: underline;
}

/* =====================================================
   LAYOUT FOUNDATION
   ===================================================== */

/* Mini Hero - Compact header */
.products-mini-hero {
  background: linear-gradient(135deg, var(--product-ground-warm) 0%, var(--color-wheat-linen) 55%, var(--color-sage-green) 100%);
  padding: var(--space-sm) 0;
  margin-bottom: 0;
}

.products-mini-hero .mini-headline {
  font-family: var(--font-serif);
  font-size: var(--text-h3);
  font-weight: var(--font-weight-semibold);
  margin: 0;
  color: var(--product-heading);
  line-height: var(--line-height-tight);
}

/* Graphite, not the muted slate: the hero ground is cream to sage. */
.products-mini-hero .breadcrumb {
  font-size: var(--text-small);
  color: var(--product-text);
  margin-top: var(--space-xs);
}

.products-mini-hero .breadcrumb a {
  color: var(--product-text);
  text-decoration: none;
}

.products-mini-hero .breadcrumb a:hover {
  color: var(--product-heading);
  text-decoration: underline;
}

/* Main Products Layout - Sidebar + Content */
.products-main-layout {
  display: flex;
  gap: var(--space-xl);
  align-items: flex-start;
  padding: var(--space-xl) 0;
}

/* =====================================================
   SIDEBAR (250px fixed width, sticky)
   ===================================================== */

.products-sidebar {
  width: 250px;
  flex-shrink: 0;
  position: sticky;
  top: var(--space-md);
  max-height: calc(100vh - var(--space-xl));
  overflow-y: auto;
  background: var(--product-ground);
  border: var(--border-width-thin) solid var(--product-rule);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}

/* Sidebar Banner (personalization) */
.sidebar-banner {
  background: var(--product-positive-tint);
  border: var(--border-width-thin) solid var(--product-positive);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  text-align: center;
}

.sidebar-banner span {
  display: block;
  font-weight: var(--font-weight-semibold);
  color: var(--product-positive);
  margin-bottom: var(--space-xs);
}

.sidebar-banner a {
  font-size: var(--text-small);
  color: var(--product-positive);
  text-decoration: underline;
}

/* Sidebar Navigation */
.sidebar-nav {
  margin-bottom: var(--space-lg);
}

/* Sidebar headings: h2 on /products, h3 on /search. */
.sidebar-nav h2,
.sidebar-nav h3,
.sidebar-section h2,
.sidebar-section h3 {
  font-family: var(--font-sans);
  font-size: var(--text-small);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  color: var(--product-muted);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.05em;
}

.sidebar-nav ul,
.shelf-filters {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li,
.shelf-filters li {
  margin-bottom: var(--space-xs);
}

.sidebar-nav a,
.shelf-filters a {
  display: block;
  padding: var(--space-sm) var(--space-md);
  color: var(--product-text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-nav a:hover,
.sidebar-nav a.active,
.shelf-filters a:hover,
.shelf-filters a.active {
  background: var(--product-tint);
  color: var(--product-heading);
}

.shelf-filters a.active {
  font-weight: var(--font-weight-semibold);
}

/* Sidebar Sections (filters) */
.sidebar-section {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-lg);
  border-bottom: var(--border-width-thin) solid var(--product-rule);
}

.sidebar-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Domain Filters (checkboxes) */
.domain-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.filter-checkbox:hover {
  background: var(--product-ground-soft);
}

.filter-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--product-action-bg);
}

.filter-checkbox span {
  font-size: var(--text-small);
  color: var(--product-text);
}

.filter-note {
  font-size: var(--text-small);
  color: var(--product-muted);
  line-height: var(--line-height-normal);
}

/* Price Range Select */
#price-filter {
  width: 100%;
  padding: var(--space-sm);
  border: var(--border-width-thin) solid var(--product-rule-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  background: var(--product-ground);
  cursor: pointer;
}

/* Sidebar CTA */
.sidebar-cta {
  background: var(--product-ground-soft);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.sidebar-cta p {
  font-size: var(--text-small);
  color: var(--product-muted);
  margin-bottom: var(--space-sm);
}

.sidebar-cta .btn-sm {
  width: 100%;
  font-size: var(--text-small);
  padding: var(--space-sm) var(--space-md);
}

/* =====================================================
   MAIN CONTENT AREA
   ===================================================== */

.products-content {
  flex: 1;
  min-width: 0; /* Prevent flex overflow */
}

/* Personalization Banner (top of content) */
.personalization-banner {
  background: linear-gradient(135deg, var(--product-tint) 0%, var(--product-ground-warm) 100%);
  border: var(--border-width-medium) solid var(--color-sage-green);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.personalization-banner .banner-icon {
  font-size: var(--icon-lg);
}

.personalization-banner .banner-text {
  flex: 1;
}

.personalization-banner .banner-text strong {
  display: block;
  font-size: var(--text-cta);
  color: var(--product-heading);
  margin-bottom: var(--space-xs);
}

.personalization-banner .banner-text p {
  margin: 0;
  font-size: var(--text-small);
  color: var(--product-text);
}

.personalization-banner .banner-link {
  color: var(--product-link);
  font-weight: var(--font-weight-semibold);
  text-decoration: underline;
  white-space: nowrap;
}

/* Products Toolbar (sort/filter bar) */
.products-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: var(--product-ground-soft);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
}

.toolbar-left .product-count {
  font-size: var(--text-small);
  color: var(--product-muted);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.toolbar-right label {
  font-size: var(--text-small);
  color: var(--product-muted);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

.toolbar-right select {
  padding: var(--space-sm) var(--space-xl) var(--space-sm) var(--space-md);
  border: var(--border-width-thin) solid var(--product-rule-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-small);
  color: var(--product-text);
  background: var(--product-ground);
  cursor: pointer;
}

.view-toggle {
  display: flex;
  gap: var(--space-sm);
}

.view-btn {
  padding: var(--space-sm) var(--space-md);
  border: var(--border-width-thin) solid var(--product-rule-strong);
  background: var(--product-ground);
  color: var(--product-text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-small);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.view-btn:hover {
  background: var(--product-ground-soft);
}

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

/* =====================================================
   PRODUCT GRID (3 columns, responsive)
   ===================================================== */

.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-top: 0; /* guard: products-domain.css adds a top margin */
  margin-bottom: var(--space-2xl);
}

/* Product Card Enhanced */
.product-card {
  background: var(--product-ground);
  border: var(--border-width-thin) solid var(--product-rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  position: relative;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--product-accent);
}

.product-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Product Image */
.product-image {
  width: 100%;
  height: 220px;
  background: var(--product-ground-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

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

.product-placeholder {
  font-size: var(--icon-xl);
  color: var(--color-text-light);
}

/* Product Badge (gap-filling %) */
.product-badge {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--product-accent);
  color: var(--product-accent-text);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  box-shadow: var(--shadow-sm);
}

/* Product Content */
.product-content {
  padding: var(--space-md);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-title {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--font-weight-semibold);
  color: var(--product-heading);
  margin: 0 0 var(--space-sm) 0;
  line-height: var(--line-height-normal);
  min-height: calc(2em * var(--line-height-normal)); /* 2 lines */
}

.product-tagline {
  font-size: var(--text-small);
  color: var(--product-muted);
  line-height: var(--line-height-normal);
}

.product-price {
  font-size: var(--text-cta);
  font-weight: var(--font-weight-bold);
  color: var(--product-price);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-sm);
}

/* Capability Tags */
.product-capability {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.capability-tag {
  background: var(--product-tint);
  color: var(--product-heading);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

/* Product CTA */
.product-cta {
  margin-top: auto;
  padding-top: var(--space-sm);
  border-top: var(--border-width-thin) solid var(--product-rule);
}

.cta-text {
  color: var(--product-link);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-small);
  display: inline-block;
  transition: color var(--transition-fast);
}

.product-card:hover .cta-text {
  text-decoration: underline;
}

/* =====================================================
   EDUCATIONAL SECTIONS (below products)
   ===================================================== */

.products-educational {
  margin-top: var(--space-3xl);
  padding-top: var(--space-2xl);
  border-top: var(--border-width-medium) solid var(--product-rule);
}

.products-educational h2 {
  font-family: var(--font-serif);
  font-weight: var(--font-weight-semibold);
  color: var(--product-heading);
}

/* Quick Scenarios Grid */
.quick-scenarios {
  margin-bottom: var(--space-2xl);
}

.quick-scenarios h2 {
  text-align: center;
  font-size: var(--text-h3);
  margin-bottom: var(--space-lg);
}

.scenario-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.scenario-quick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: var(--product-ground-soft);
  border: var(--border-width-thin) solid var(--product-rule);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  width: 100%;
}

.scenario-quick-card:hover {
  background: var(--product-ground);
  border-color: var(--product-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.scenario-quick-card:active {
  transform: translateY(0);
}

.scenario-quick-card .icon {
  font-size: var(--icon-lg);
}

.scenario-quick-card .label {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-small);
  color: var(--product-heading);
  text-align: center;
}

/* Condensed Capability Explainer */
.capability-explainer-condensed {
  background: var(--product-ground-soft);
  padding: var(--space-2xl) 0;
  margin-bottom: var(--space-2xl);
}

.capability-explainer-condensed h2 {
  text-align: center;
  font-size: var(--text-h3);
  margin-bottom: var(--space-xl);
}

.capability-principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
}

.capability-principle {
  display: block; /* guard: products-domain.css lays this out as a flex row */
  margin-bottom: 0;
  text-align: center;
}

.capability-principle .icon {
  font-size: var(--icon-xl);
  margin-bottom: var(--space-md);
  display: block;
}

.capability-principle h3 {
  font-family: var(--font-sans);
  font-size: var(--text-cta);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-sm);
  color: var(--product-heading);
}

.capability-principle p {
  font-size: var(--text-small);
  color: var(--product-muted);
  line-height: var(--line-height-normal);
}

/* Condensed Quality Philosophy */
.quality-philosophy-condensed {
  background: var(--product-ground);
  padding: var(--space-2xl) 0;
  text-align: center;
}

.quality-philosophy-condensed h2 {
  font-size: var(--text-h3);
  margin-bottom: var(--space-lg);
}

.quality-philosophy-condensed p {
  font-family: var(--font-body);
  font-size: var(--text-body);
  color: var(--product-muted);
  max-width: var(--container-md);
  margin: 0 auto var(--space-lg);
  line-height: var(--line-height-relaxed);
}

.quality-philosophy-condensed .btn {
  margin-top: var(--space-md);
}

/* =====================================================
   RESPONSIVE DESIGN
   ===================================================== */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .scenario-quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .capability-principles {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
  .products-main-layout {
    flex-direction: column;
  }

  .products-sidebar {
    width: 100%;
    position: static;
    max-height: none;
    margin-bottom: var(--space-xl);
  }

  .product-grid {
    grid-template-columns: 1fr;
  }

  .products-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .toolbar-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right select {
    width: 100%;
  }

  .view-toggle {
    width: 100%;
  }

  .view-btn {
    flex: 1;
  }

  .scenario-quick-grid {
    grid-template-columns: 1fr;
  }

  .personalization-banner {
    flex-direction: column;
    text-align: center;
  }

  .personalization-banner .banner-link {
    display: block;
    margin-top: var(--space-sm);
  }
}

/* Small Mobile (< 480px) */
@media (max-width: 480px) {
  .product-title {
    min-height: auto;
  }
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* =====================================================
   SEARCH RESULTS PAGE
   (search_results.pug reuses the sidebar + grid layout)
   ===================================================== */

.search-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: var(--border-width-thin) solid var(--product-rule-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  font-family: var(--font-sans);
  color: var(--product-text);
  background: var(--product-ground);
}

.search-input:focus {
  outline: none;
  border-color: var(--product-heading);
  box-shadow: 0 0 0 var(--focus-ring-width) color-mix(in srgb, var(--focus-ring-color) 35%, transparent);
}

/* Simple concept cards (partials/product_card.pug) inside the search grid */
.product-grid--search .product-card > a {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  color: inherit;
  text-decoration: none;
}

.product-grid--search .product-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--product-ground-warm);
}

.product-grid--search .product-card h3 {
  font-size: var(--text-body);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-normal);
  color: var(--product-heading);
  margin: 0;
}

.product-grid--search .product-card p {
  margin: 0;
  font-size: var(--text-small);
  color: var(--product-muted);
  line-height: var(--line-height-normal);
}

/* price line */
.product-grid--search .product-card > a > p:last-of-type {
  margin-top: auto;
  padding-top: var(--space-sm);
  font-size: var(--text-body);
  font-weight: var(--font-weight-bold);
  color: var(--product-price);
}

/* badge list -> warm chips */
.product-grid--search .product-card ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: 0;
  margin: 0;
}

.product-grid--search .product-card ul li {
  background: var(--product-ground-warm);
  color: var(--product-heading);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  margin: 0;
  white-space: nowrap;
}

.product-grid--search .product-card__actions {
  padding: 0 var(--space-md) var(--space-md);
  margin-top: auto;
}

.product-grid--search .product-card__actions .btn {
  font-size: var(--text-small);
  padding: var(--space-sm) var(--space-md);
}

.empty-state {
  padding: var(--space-2xl) var(--space-md);
  text-align: center;
  color: var(--product-muted);
}
