/* Tools directory (/tools/) — a normal Brief page (header + footer + our
   tokens/components) whose content uses a category-rail + card-grid layout.
   Reuses global tokens + .container + .skip-link / .sr-only.
   Mobile-first: filters are a horizontal scroll rail on top, then a left rail
   from 768px up. Built to scale 1 -> 8 cards with no layout change. */

.tools-directory {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-3xl);
}

.tools-directory-head {
  margin-bottom: var(--space-2xl);
}

.tools-directory-head h1 {
  margin: 0 0 var(--space-sm);
}

.tools-lede {
  margin: 0;
  max-width: 60ch;
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
}

/* ---- Two-column layout ---------------------------------------------------- */

.tools-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
}

/* Grid/flex items default to min-width:auto, which lets wide content (the filter
   rail, long card text) blow the track past the viewport and side-scroll the
   whole page. Pin tracks to 0 so they never exceed their column. */
.tools-layout > * {
  min-width: 0;
}

/* ---- Sidebar / filter rail ------------------------------------------------ */

.tools-sidebar {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-md);
}

.tools-sidebar-label {
  margin: 0 0 var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* Mobile: filters wrap onto multiple rows (no side-scroll). Desktop turns this
   into a vertical rail (see the min-width media query below). */
.tools-filter-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.tools-filter {
  appearance: none;
  white-space: nowrap;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
  font-family: inherit;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tools-filter:hover {
  background: var(--color-background-muted);
  color: var(--color-text);
}

.tools-filter.is-active {
  background: var(--color-primary);
  color: var(--color-primary-text);
  font-weight: 600;
}

.tools-filter:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

/* ---- Card grid ------------------------------------------------------------ */

.tools-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: 1fr;
}

.tools-card-item {
  display: flex;
}

/* display:flex above outranks the UA [hidden] rule, so the JS filter's
   item.hidden = true wouldn't take effect without this. */
.tools-card-item[hidden] {
  display: none;
}

.tools-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: clamp(20px, 3vw, 32px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-subtle);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.tools-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
  border-color: var(--color-text-muted);
}

/* Lift the keyboard focus ring to the whole card; the title link is stretched
   across it (see .tools-card-link::after). */
.tools-card:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.tools-card-category {
  margin: 0 0 var(--space-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.tools-card-title {
  margin: 0 0 var(--space-sm);
  font-size: var(--font-size-2xl);
  line-height: 1.25;
}

.tools-card-link {
  color: var(--color-text);
  text-decoration: none;
}

.tools-card-link:hover {
  color: var(--color-accent-dark);
}

/* Stretched link: the title anchor is the single real click target, but its
   hit area covers the whole card. One link, fully keyboard-accessible. */
.tools-card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
}

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

.tools-card-desc {
  margin: 0 0 var(--space-lg);
  color: var(--color-text-secondary);
  /* push the CTA to a consistent baseline across cards of differing length */
  flex-grow: 1;
}

.tools-card-cta {
  font-weight: 600;
  color: var(--color-accent-dark);
  transition: transform 0.2s ease;
  pointer-events: none;
}

.tools-card:hover .tools-card-cta {
  transform: translateX(2px);
}

.tools-empty {
  margin: 0;
  color: var(--color-text-secondary);
}

/* ---- Placeholder ("coming soon") cards — demo only, delete before launch --- */

.tools-card--soon {
  border-style: dashed;
  background: var(--color-background-subtle);
  box-shadow: none;
}

.tools-card--soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--color-border);
}

.tools-card--soon .tools-card-title {
  color: var(--color-text-secondary);
}

.tools-card-badge {
  align-self: flex-start;
  padding: 2px var(--space-sm);
  border-radius: 999px;
  background: var(--color-background-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}

/* ---- Two-column from tablet up -------------------------------------------- */

@media (min-width: 768px) {
  .tools-layout {
    grid-template-columns: 220px 1fr;
    gap: var(--space-2xl);
    align-items: start;
  }

  .tools-sidebar {
    position: sticky;
    top: var(--space-xl);
    border-right: 1px solid var(--color-border);
    border-bottom: none;
    padding: 0 var(--space-lg) 0 0;
  }

  .tools-filter-list {
    flex-direction: column;
    gap: var(--space-xs);
    overflow-x: visible;
  }

  .tools-filter {
    width: 100%;
    text-align: left;
  }

  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}
