/*
 * /directory — the cross-feed site index.
 *
 * Every colour is a token from the inline :root in src/pages.js. Nothing here is a literal
 * colour, so the page inherits the brand and contrast decisions made in one place.
 *
 * Layout: one column of cards on a phone, two on a tablet, three on a desktop. The cards are
 * equal-height in a row (the grid row stretches them) so the traffic line sits on a common
 * baseline instead of jumping with the summary length.
 */

.dir {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.dir-hero { max-width: 760px; }
.dir-hero h1 { margin: 0 0 12px; color: var(--foreground); }
.dir-lead { margin: 0; color: var(--foreground-secondary); }
.dir-updated { margin: 8px 0 0; color: var(--muted-foreground); font-size: var(--fs-sm); }

/* ---- search ------------------------------------------------------------------------ */

.dir-search {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 24px 0 16px;
}

.dir-search input[type="search"] {
  flex: 1 1 280px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
  font: inherit;
  font-size: var(--fs-lg);
}

.dir-search input[type="search"]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
}

.dir-clear {
  color: var(--primary);
  font-size: var(--fs-base);
  font-weight: 600;
}

/* ---- tabs and toolbar -------------------------------------------------------------- */

/* base.css styles every bare `nav` as the site header (space-between across the
 * viewport, 16px margin on each link). These tabs are a left-aligned cluster, so each
 * property that rule sets is stated here rather than inherited. */
.dir-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.dir-tabs a { margin-left: 0; }

.dir-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground-secondary);
  font-size: var(--fs-base);
  font-weight: 600;
  text-decoration: none;
}

.dir-tab:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

.dir-tab.is-active {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--foreground);
}

.dir-tab-count {
  color: var(--muted-foreground);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

.dir-tab.is-active .dir-tab-count { color: var(--foreground-secondary); }

.dir-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.dir-count { margin: 0; color: var(--foreground-secondary); font-size: var(--fs-base); }

.dir-sort { display: flex; gap: 12px; margin: 0; font-size: var(--fs-base); }
.dir-sort a { color: var(--foreground-secondary); text-decoration: none; }
.dir-sort a:hover { color: var(--primary); text-decoration: underline; }
.dir-sort a.is-active { color: var(--primary); font-weight: 700; }

/* ---- cards ------------------------------------------------------------------------- */

.dir-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.dir-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  /* A card is a column of text of unknown width; nothing inside it may paint over the card
     beside it. The wrap rules below do the real work — this is the backstop. */
  overflow: hidden;
}

.dir-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.dir-card-title {
  margin: 0;
  color: var(--foreground);
  font-size: var(--fs-lg);
  line-height: 1.35;
  /* Two lines, then ellipsis: a feed title can be a whole sentence and one card must not
     set the height of its row. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.dir-card-title a { color: var(--foreground); text-decoration: none; }
.dir-card-title a:hover { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }

.dir-badge {
  flex: none;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--background-secondary);
  color: var(--foreground-secondary);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}

.dir-badge.is-launches {
  border-color: var(--domain-available);
  background: var(--domain-available-surface);
  color: var(--domain-available);
}

.dir-badge.is-hosted {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
}

.dir-badge.is-checkouts {
  border-color: var(--domain-pending);
  background: var(--domain-pending-surface);
  color: var(--domain-pending);
}

.dir-domain {
  margin: -4px 0 0;
  color: var(--muted-foreground);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.dir-summary {
  margin: 0;
  color: var(--foreground-secondary);
  font-size: var(--fs-base);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.dir-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.dir-chip {
  padding: 2px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--background-secondary);
  color: var(--foreground-secondary);
  font-size: var(--fs-xs);
  /* The feed's category is a taxonomy path like
     `Computers_Electronics_and_Technology-Computers_Electronics-...` — one unbroken token
     60 characters long. A flex item sizes to its longest word, so without these two lines the
     chip was 54 px wider than the card and painted over the neighbour. */
  max-width: 100%;
  overflow-wrap: anywhere;
}

.dir-kws {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
  font-size: var(--fs-xs);
}

.dir-kw {
  color: var(--primary);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.dir-kw:hover { text-decoration: underline; text-underline-offset: 3px; }

.dir-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px 12px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-sm);
}

.dir-traffic { color: var(--foreground-secondary); }
.dir-visits-num { color: var(--foreground); font-variant-numeric: tabular-nums; }
.dir-muted { color: var(--muted-foreground); }
.dir-feed-link { color: var(--primary); text-decoration: none; }
.dir-feed-link:hover { text-decoration: underline; }

/* ---- pager and empty state --------------------------------------------------------- */

.dir-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 28px;
}
.dir-pager a { margin-left: 0; }

.dir-page-btn {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground);
  font-size: var(--fs-base);
  font-weight: 600;
  text-decoration: none;
}

.dir-page-btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.dir-page-count { color: var(--muted-foreground); font-size: var(--fs-sm); }

.dir-empty {
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--background-secondary);
  text-align: center;
}

.dir-empty-title { margin: 0 0 8px; color: var(--foreground); font-size: var(--fs-lg); font-weight: 700; }
.dir-empty p { margin: 0; }

@media (max-width: 640px) {
  .dir { padding: 24px 16px 48px; }
  .dir-results { grid-template-columns: 1fr; }
  .dir-search input[type="search"] { flex-basis: 100%; }
  .dir-toolbar { flex-direction: column; align-items: flex-start; }
}
