/* =========================================
   CATEGORY FILTER BAR + TOOL GRID
   Single source of truth — no conflicts
========================================= */

/* ── TOOLS SECTION WRAPPER ─────────────── */
.tools-section {
  background: #ffffff;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 30px 20px 60px;
  box-sizing: border-box;
}

/* ══════════════════════════════════════════
   FILTER BAR
   - overflow-x:auto so buttons scroll on mobile
   - flex-wrap:nowrap so buttons stay on one line
   - NO negative margins (they cause overflow)
══════════════════════════════════════════ */
.tools-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 4px 0 6px;

  /* scroll, never overflow */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;

  /* one line only */
  flex-wrap: nowrap;

  /* never wider than parent */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}
.tools-filter-bar::-webkit-scrollbar { display: none; }

/* ── FILTER BUTTONS ─────────────────────── */
.itz-fb {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid #e5e7eb;
  background: #f9fafb;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s, transform .15s;
  outline: none;
}

.itz-fb:hover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37,99,235,.12);
}

.itz-fb.active,
.itz-fb[aria-selected="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37,99,235,.28);
}

.itz-fb:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* ══════════════════════════════════════════
   TOOL GRID
══════════════════════════════════════════ */
#toolsContainer,
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

/* ── TOOL CARD ──────────────────────────── */
.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  background: #ffffff;
  border: 1px solid #f0f0f0;
  border-radius: 14px;
  box-shadow: 0 4px 15px rgba(0,0,0,.05);
  text-decoration: none;
  color: #111827;
  overflow: hidden;
  box-sizing: border-box;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  animation: itzCardIn .35s ease both;
  will-change: transform;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(0,0,0,.1);
  border-color: var(--icon-color, #2563eb);
}

/* ── CARD TOP ───────────────────────────── */
.tool-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tool-icon-wrap {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--icon-color, #2563eb) 12%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s ease;
}
.tool-card:hover .tool-icon-wrap {
  background: color-mix(in srgb, var(--icon-color, #2563eb) 20%, transparent);
}
.tool-icon-wrap svg,
.tool-icon-wrap img {
  width: 26px;
  height: 26px;
  display: block;
}

.tool-meta { flex: 1; min-width: 0; }

.tool-meta h3 {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tool-meta p {
  font-size: 12px;
  color: #9ca3af;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clam: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── CARD BOTTOM ────────────────────────── */
.tool-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
  margin-top: auto;
}

/* ── CATEGORY BADGE ─────────────────────── */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: capitalize;
  letter-spacing: .02em;
  background: color-mix(in srgb, var(--icon-color, #2563eb) 10%, transparent);
  color: var(--icon-color, #2563eb);
}

/* per-category overrides */
.tool-card[data-category="image"]    { --icon-color: #0369a1; }
.tool-card[data-category="pdf"]      { --icon-color: #b91c1c; }
.tool-card[data-category="text"]     { --icon-color: #15803d; }
.tool-card[data-category="dev"]      { --icon-color: #7e22ce; }
.tool-card[data-category="security"] { --icon-color: #c2410c; }
.tool-card[data-category="seo"]      { --icon-color: #065f46; }
.tool-card[data-category="ai"]       { --icon-color: #86198f; }
.tool-card[data-category="utilities"]{ --icon-color: #475569; }

.rating {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

/* ── HIDDEN ─────────────────────────────── */
.tool-card.itz-hidden,
.itz-hidden { display: none !important; }

/* ── EMPTY STATE ────────────────────────── */
.itz-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: #9ca3af;
  font-size: 15px;
}

/* ── ANIMATION ───────────────────────────── */
@keyframes itzCardIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */

@media (max-width: 900px) {
  .tools-section { padding: 24px 16px 48px; }
  #toolsContainer,
  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
}

@media (max-width: 640px) {
  .tools-section { padding: 20px 12px 40px; }

  /* filter bar on mobile: just scroll, nothing more */
  .tools-filter-bar {
    gap: 6px;
    padding: 4px 0 8px;
    /* NO margin tricks, NO width tricks */
  }
  .itz-fb {
    padding: 7px 13px;
    font-size: 12.5px;
  }

  #toolsContainer,
  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .tool-card { padding: 14px; }
  .tool-icon-wrap { width: 40px; height: 40px; min-width: 40px; border-radius: 10px; }
  .tool-icon-wrap svg, .tool-icon-wrap img { width: 22px; height: 22px; }
  .tool-meta p { display: none; }
}

@media (max-width: 380px) {
  .tools-section { padding: 16px 10px 32px; }
  #toolsContainer,
  .tools-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tool-card { padding: 12px 10px; }
}