/*
 * Project catalog styles.
 *
 * Bootstrap 5.3 provides the grid and components. This file sets the palette and
 * type through CSS variables, restyles the Bootstrap pieces the catalog uses
 * (buttons, form controls, links, cards), and adds what Bootstrap does not provide.
 * There are no inline styles, so the page keeps working under a strict CSP.
 */

/* ---------- Tokens ---------- */

:root {
  --cat-ground: #f6f4ef;       /* warm paper background */
  --cat-surface: #ffffff;      /* cards and inputs */
  --cat-ink: #1d2320;          /* headings and body text */
  --cat-muted: #596058;        /* secondary text, about 6:1 on the ground */
  --cat-line: #e3dfd4;         /* hairlines and borders */
  --cat-accent: #0f766e;       /* the one accent: primary action, active filter, icon tiles */
  --cat-accent-hover: #0b5f58;
  --cat-accent-wash: #e2f0ec;  /* icon tile background */

  /* Bootstrap variables, so its defaults follow the palette above. */
  --bs-body-font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bs-body-color: var(--cat-ink);
  --bs-body-bg: var(--cat-ground);
  --bs-secondary-color: var(--cat-muted);
  --bs-border-color: var(--cat-line);
  --bs-border-radius: 0.75rem;
  --bs-link-color: var(--cat-accent);
  --bs-link-color-rgb: 15, 118, 110;
}

/* ---------- Browser surfaces ---------- */

html {
  scrollbar-color: #c4bfb1 var(--cat-ground);
}

::selection {
  background: #bfe3dc;
  color: var(--cat-ink);
}

input {
  caret-color: var(--cat-accent);
}

a {
  text-underline-offset: 0.2em;
}

a:focus-visible {
  outline: 2px solid var(--cat-accent);
  outline-offset: 3px;
  border-radius: 0.25rem;
}

/* ---------- Bootstrap components, restyled ---------- */

.btn-primary {
  --bs-btn-bg: var(--cat-accent);
  --bs-btn-border-color: var(--cat-accent);
  --bs-btn-hover-bg: var(--cat-accent-hover);
  --bs-btn-hover-border-color: var(--cat-accent-hover);
  --bs-btn-active-bg: var(--cat-accent-hover);
  --bs-btn-active-border-color: var(--cat-accent-hover);
  --bs-btn-disabled-bg: var(--cat-accent);
  --bs-btn-disabled-border-color: var(--cat-accent);
  --bs-btn-focus-shadow-rgb: 15, 118, 110;
}

.btn-outline-primary {
  --bs-btn-color: var(--cat-accent);
  --bs-btn-border-color: var(--cat-accent);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-bg: var(--cat-accent);
  --bs-btn-hover-border-color: var(--cat-accent);
  --bs-btn-active-color: #ffffff;
  --bs-btn-active-bg: var(--cat-accent-hover);
  --bs-btn-active-border-color: var(--cat-accent-hover);
  --bs-btn-focus-shadow-rgb: 15, 118, 110;
}

.btn {
  font-weight: 600;
}

.form-control,
.input-group-text {
  background-color: var(--cat-surface);
  border-color: var(--cat-line);
  color: var(--cat-ink);
}

.input-group-text {
  color: var(--cat-muted);
}

.form-control::placeholder {
  color: var(--cat-muted);
  opacity: 1;
}

.form-control:focus {
  border-color: var(--cat-accent);
  box-shadow: 0 0 0 0.25rem rgba(15, 118, 110, 0.2);
}

/* ---------- Hero ---------- */

.catalog-hero {
  position: relative;
  overflow: hidden;
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--cat-line);
}

/* A faint dot grid that fades out towards the content. CSS only. */
.catalog-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(15, 118, 110, 0.16) 1px, transparent 1.3px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, transparent 90%);
  mask-image: linear-gradient(to bottom, #000 0%, transparent 90%);
  pointer-events: none;
}

.catalog-hero > .container {
  position: relative;
}

.catalog-hero h1 {
  font-size: clamp(2rem, 1.4rem + 2.2vw, 2.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

.catalog-lead {
  max-width: 40rem;
  font-size: 1.125rem;
  color: var(--cat-muted);
  margin-bottom: 1rem;
}

.catalog-hero-count {
  font-weight: 600;
  color: var(--cat-accent);
}

/* ---------- Toolbar ---------- */

.search-box {
  width: min(100%, 24rem);
}

#category-filters .btn {
  font-size: 0.9rem;
}

.catalog-empty {
  padding: 3rem 1rem;
  color: var(--cat-muted);
}

/* ---------- Icon tiles ---------- */

.catalog-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: var(--cat-accent-wash);
  color: var(--cat-accent);
}

.catalog-icon i {
  line-height: 1;
}

.catalog-icon-sm {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.65rem;
}

.catalog-icon-sm i {
  font-size: 1.05rem;
}

.catalog-icon-md {
  width: 2.75rem;
  height: 2.75rem;
}

.catalog-icon-md i {
  font-size: 1.3rem;
}

.catalog-icon-lg {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 1.1rem;
}

.catalog-icon-lg i {
  font-size: 2.15rem;
}

/* ---------- Status pills ---------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.status-active {
  background: #e3f2e9;
  color: #17603c;
}

.status-prototype {
  background: #fbefd3;
  color: #7a4a00;
}

.status-template {
  background: #e2ecfb;
  color: #1d4f91;
}

.status-review {
  background: #ece9f6;
  color: #4b3f85;
}

.status-unknown {
  background: var(--cat-surface);
  color: var(--cat-muted);
  box-shadow: inset 0 0 0 1px var(--cat-line);
}

/* ---------- Cards ---------- */

.catalog-card {
  border: 1px solid var(--cat-line);
  border-radius: 0.875rem;
  background: var(--cat-surface);
  box-shadow: 0 1px 2px rgba(29, 35, 32, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.catalog-card:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 12px 24px -14px rgba(29, 35, 32, 0.3);
}

/* The keyboard focus ring goes on the whole card, not only the title text. */
.catalog-card:has(:focus-visible) {
  outline: 2px solid var(--cat-accent);
  outline-offset: 3px;
}

.catalog-card .stretched-link:focus-visible {
  outline: none;
}

.catalog-card .card-body {
  padding: 1.375rem 1.375rem 1rem;
}

.card-type {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--cat-muted);
  white-space: nowrap;
}

.card-category {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--cat-muted);
}

.card-title {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-title a {
  color: var(--cat-ink);
  text-decoration: none;
}

.catalog-card:hover .card-title a {
  color: var(--cat-accent);
}

.card-summary {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--cat-muted);
}

/* Sits above the stretched link, so it can be clicked on its own. */
.card-open {
  position: relative;
  z-index: 2;
  display: inline-block;
  margin-top: 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.card-open:hover {
  color: var(--cat-accent-hover);
}

.catalog-card .card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.375rem;
  background: transparent;
  border-top: 1px solid var(--cat-line);
}

.card-more {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--cat-accent);
  white-space: nowrap;
}

.card-arrow {
  transition: transform 0.2s ease;
}

.catalog-card:hover .card-arrow,
.catalog-card:has(:focus-visible) .card-arrow {
  transform: translateX(3px);
}

/* ---------- Details page ---------- */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.75rem;
  font-weight: 600;
  color: var(--cat-accent);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

.detail-header h1 {
  margin-bottom: 0.6rem;
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  font-size: 0.95rem;
  color: var(--cat-muted);
}

.detail-note {
  font-size: 0.95rem;
  color: var(--cat-muted);
}

.detail-lead {
  max-width: 65ch;
  font-size: 1.1rem;
  line-height: 1.65;
}

.detail-text {
  max-width: 65ch;
  line-height: 1.6;
}

.backend-name {
  margin-bottom: 0.4rem;
  font-weight: 600;
}

.detail-section + .detail-section {
  margin-top: 2.5rem;
}

.detail-section h2 {
  margin-bottom: 0.9rem;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.tech-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tech-chip {
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--cat-line);
  border-radius: 999px;
  background: var(--cat-surface);
  font-size: 0.88rem;
  font-weight: 500;
}

.related-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  height: 100%;
  padding: 1rem;
  border: 1px solid var(--cat-line);
  border-radius: 0.875rem;
  background: var(--cat-surface);
  color: var(--cat-ink);
  text-decoration: none;
  transition: border-color 0.2s ease;
}

.related-card:hover {
  border-color: rgba(15, 118, 110, 0.45);
}

.related-text {
  display: flex;
  flex-direction: column;
}

.related-name {
  font-weight: 700;
  line-height: 1.25;
}

.related-type {
  font-size: 0.82rem;
  color: var(--cat-muted);
}

/* "At a glance" is a plain definition list in one panel. */
.glance {
  margin: 0;
  padding: 0.25rem 1.5rem;
  border: 1px solid var(--cat-line);
  border-radius: 0.875rem;
  background: var(--cat-surface);
}

.glance > div {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.75rem;
  padding: 0.85rem 0;
}

.glance > div + div {
  border-top: 1px solid var(--cat-line);
}

.glance dt {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--cat-muted);
}

.glance dd {
  margin: 0;
  font-weight: 600;
}

/* ---------- Motion preference ---------- */

@media (prefers-reduced-motion: reduce) {
  .catalog-card,
  .card-arrow,
  .related-card {
    transition: none;
  }

  .catalog-card:hover,
  .catalog-card:has(:focus-visible) .card-arrow,
  .catalog-card:hover .card-arrow {
    transform: none;
  }
}

/* ---------- Small screens ---------- */

@media (max-width: 575.98px) {
  .catalog-hero {
    padding: 2.5rem 0 2rem;
  }

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

  .glance > div {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }
}
