/* ============================================================
   Nerdstorm – Products
   Everything rendered from the product catalog: the home page's
   product index, the /products card grid and /products/:slug.

   Products carry their colours as data (src/products/entries/*.js).
   Each product's root element receives them as custom properties —
   --brand-base, --brand-light, --brand-text and --brand-spark — and
   the generic brand hooks below read them, so a new product needs
   no CSS. Only --brand-text is used for text; the catalog tests hold
   it to WCAG AA (4.5:1) on the page background.
   ============================================================ */

/* ── Brand hooks ─────────────────────────────────────────── */
.brand-text { color: var(--brand-text, var(--color-text)); }

.brand-accent,
.product-card::before {
  background: linear-gradient(90deg,
    var(--brand-base, var(--color-text)),
    var(--brand-light, var(--color-text)) 60%,
    var(--brand-spark, var(--brand-light, var(--color-text))));
}

.product-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 2px;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand-chip {
  color: var(--brand-text, var(--color-text));
  background: rgba(var(--rgb-white), 0.15);
  border: 1px solid color-mix(in srgb, var(--brand-text, var(--color-text)) 28%, transparent);
}

/* ── Icons and labels ────────────────────────────────────── */
.product-icon { display: block; flex-shrink: 0; object-fit: contain; }
/* Icons that carry their own background square (e.g. the Tars logo). */
.product-icon--tile { object-fit: cover; border-radius: 18%; }

.product-kind,
.product-index-number,
.product-index-tag,
.product-index-kind {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

/* Title and intro on the left, the section's action on the right. */
.product-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

.product-section-header .btn-primary,
.product-section-header .text-link { flex-shrink: 0; }

/* ── Product index: one numbered row per product ─────────── */
.product-index {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.product-index li + li { border-top: 1px solid var(--color-border); }

.product-index-row {
  display: grid;
  grid-template-columns: 2rem 44px minmax(0, 1fr) minmax(0, 11rem) 7.5rem 1.25rem;
  gap: 1.25rem;
  align-items: center;
  padding: 1.1rem 0.75rem;
  color: var(--color-text);
  text-decoration: none;
  transition: background-color var(--transition);
}

.product-index-row .product-icon { width: 44px; height: 44px; }
.product-index-main { min-width: 0; }

.product-index-name {
  display: block;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.2;
  transition: color var(--transition);
}

.product-index-line {
  display: block;
  margin-top: 0.3rem;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.product-index-tag { color: var(--brand-text, var(--color-muted)); }
.product-index-arrow { justify-self: end; transition: transform var(--transition); }

.product-index-row:hover { background: var(--color-surface); }
.product-index-row:hover .product-index-name { color: var(--color-primary); }
.product-index-row:hover .product-index-arrow { transform: translateX(4px); }
.product-index-row:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }

/* ── Product grid: cards wrap across, and stack on narrow screens ── */
.product-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 1.5rem;
}

.product-grid > li { display: flex; }

.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 2rem 1.75rem 1.75rem;
  border: 1px solid var(--color-border);
  border-radius: 2px;
  color: var(--color-text);
  text-decoration: none;
  transition: border-color var(--transition);
}

.product-card::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: 3px;
}

.product-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.product-card .product-icon { width: 56px; height: 56px; }

.product-card-name {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.4rem;
  transition: color var(--transition);
}

.product-card-tagline {
  color: var(--brand-text, var(--color-text));
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.product-card-summary {
  color: var(--color-muted);
  font-size: 0.93rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.product-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

/* margin-top: auto pins the link to the bottom, so it lines up across a row. */
.product-card-cta {
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0 0.35rem;
  border-bottom: 1px solid var(--color-text);
  font-size: 0.88rem;
  font-weight: 700;
}

.product-card-cta span { transition: transform var(--transition); }

.product-card:hover { border-color: var(--color-text); }
.product-card:hover .product-card-name { color: var(--color-primary); }
.product-card:hover .product-card-cta span { transform: translateX(4px); }
.product-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }

/* ── /products hero ──────────────────────────────────────── */
.product-hero {
  padding: 140px 0 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.product-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 300px;
  background: radial-gradient(ellipse, rgba(var(--rgb-primary), 0.08) 0%, transparent 70%);
  pointer-events: none;
}

/* ── /products/:slug ─────────────────────────────────────── */
.product-detail { padding: 128px 0 96px; }

.product-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 2.5rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.product-breadcrumb a {
  color: var(--color-text);
  text-decoration: none;
  border-bottom: 1px solid var(--color-text);
}

.product-breadcrumb a:hover { color: var(--color-primary); border-color: var(--color-primary); }

.product-detail .product-icon { width: 96px; height: 96px; }

.product-detail kbd {
  font-family: 'DM Mono', monospace;
  font-size: 0.85em;
  padding: 0.05em 0.4em;
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #fff;
  color: var(--color-text);
  white-space: nowrap;
}

.product-detail-card { position: relative; overflow: hidden; }

.product-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.product-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 36px;
}

.product-feature-item {
  background: rgba(var(--rgb-white), 0.025);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 20px;
  transition: border-color var(--transition), background var(--transition);
}

.product-feature-item:hover {
  border-color: rgba(var(--rgb-primary), 0.3);
  background: rgba(var(--rgb-primary), 0.03);
}

.product-feature-item .fi-icon {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.product-feature-item h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

.product-feature-item p {
  color: var(--color-muted);
  font-size: 0.85rem;
  line-height: 1.65;
}

/* Other products, at the foot of a product page. */
.product-more { padding: 80px 0 96px; }

.product-more-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--color-text);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .product-index-row { grid-template-columns: 2rem 44px minmax(0, 1fr) 7.5rem 1.25rem; }
  .product-index-tag { display: none; }
}

@media (max-width: 768px) {
  .product-section-header { flex-direction: column; align-items: flex-start; gap: 1.5rem; }
  .product-feature-grid { grid-template-columns: 1fr; }
  .product-detail { padding: 108px 0 72px; }
}

@media (max-width: 640px) {
  .product-index-row {
    grid-template-columns: 1.5rem 40px minmax(0, 1fr) 1rem;
    gap: 0.9rem;
    padding: 1rem 0.25rem;
  }
  .product-index-row .product-icon { width: 40px; height: 40px; }
  .product-index-kind { display: none; }
  .product-card { padding: 1.75rem 1.25rem 1.5rem; }
}
