/* The public resources index.
 *
 * This file holds only what the board has no equivalent for: the grid of sources and the filter
 * field. Colour, type, radius, elevation, cards, chips, pills, tiles and the top nav all come
 * from tokens.css, app.css and public.css, which is why nothing here declares a colour value.
 * Adding one would fork the design system rather than use it. See DESIGN.md.
 */

/* ---------- Page head ---------- */

/* The hero is the full width of the board here, with nothing beside it, so the copy and the
   filter share the row rather than leaving half the panel empty. */
.hero-main.lead {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
}

.lead-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

/* ---------- The filter field ---------- */

.find {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 400px;
}

.find-icon {
  position: absolute;
  left: 14px;
  color: var(--faint);
  pointer-events: none;
}

.find input {
  padding-left: 40px;
  padding-right: 40px;
  border-radius: var(--r-pill);
  background: var(--canvas-2);
  border-color: var(--line-3);
  font-weight: 600;
}

.find input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* The keyboard hint sits inside the field, so it disappears once the field has focus rather
   than telling you how to reach somewhere you already are. */
.find-key {
  position: absolute;
  right: 12px;
  font-size: var(--fs-10-5);
  font-weight: 600;
  color: var(--faint);
  background: var(--surface);
  border: 1px solid var(--line-3);
  border-radius: var(--r-6);
  padding: 2px 7px;
  pointer-events: none;
}

.find input:focus ~ .find-key {
  opacity: 0;
}

/* ---------- Category card head ---------- */

.cat-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cat-id .card-sub {
  max-width: 62ch;
}

/* Scroll-margin, not padding: the top nav is sticky, so an anchor jump would otherwise land
   the heading underneath it. */
.cat {
  scroll-margin-top: 84px;
}

/* ---------- The source grid ---------- */

.src-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 10px;
}

/* An inner block inside an 18px card, so 14px, matching .row in app.css. */
.src {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-2);
  border-radius: var(--r-14);
  background: var(--canvas-3);
  padding: 13px 14px 11px 14px;
  gap: 9px;
  transition:
    border-color var(--speed) ease-out,
    background var(--speed) ease-out;
}

.src:hover {
  border-color: var(--brand-line);
  background: var(--surface);
}

.src:focus-within {
  border-color: var(--brand);
}

/* The whole tile is the link, but the GitHub mark is a second destination and cannot be nested
   inside the first. So the anchor is stretched over the tile and the footer is lifted above it. */
.src-hit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
  min-width: 0;
}

.src-hit::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-14);
}

.src-hit:hover {
  text-decoration: none;
}

.src-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* The disc is white in both themes, not var(--surface). These are other people's marks and
   several of them are near-black line art that vanishes on a dark ground. Same remedy, and the
   same reason, as the level 4 skill chip in app.css. */
.src-ico {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: var(--r-8);
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--line-2);
  padding: 3px;
}

.src-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-11-5);
  font-weight: 800;
  color: var(--brand);
  background: var(--brand-tint);
  border-color: var(--brand-line);
  padding: 0;
}

.src-id {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.src-name {
  font-size: var(--fs-12-5);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.src:hover .src-name {
  color: var(--brand);
}

.src-host {
  font-size: var(--fs-10-5);
  font-weight: 500;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.src-why {
  font-size: var(--fs-11-5);
  font-weight: 500;
  color: var(--muted);
  line-height: 1.6;
}

.src-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 2px;
}

.src-gh {
  display: flex;
  align-items: center;
  color: var(--faint-3);
  transition: color var(--speed) ease-out;
}

.src-gh svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.src-gh:hover {
  color: var(--ink);
}

/* The hidden attribute is how the filter takes something off the page, and the browser's own
   rule for it is display:none at the weakest possible specificity. Both of these set
   display:flex, which beats it, so without this pair the filter would hide nothing at all. */
.src[hidden],
.cat[hidden] {
  display: none;
}

/* ---------- Empty state ---------- */

.no-hits {
  display: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-18);
  padding: 22px 24px;
  font-size: var(--fs-13);
  font-weight: 600;
  color: var(--muted);
}

.no-hits.is-on {
  display: block;
}

/* ---------- Ranked-search controls ---------- */

.resource-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 14px;
}

.resource-control {
  display: grid;
  gap: 6px;
  min-width: 180px;
  font-size: var(--fs-11-5);
  font-weight: 700;
  color: var(--muted);
}

.resource-control select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-12);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.resource-code-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-12);
  color: var(--ink);
  background: var(--surface);
  font-size: var(--fs-12);
  font-weight: 700;
}

.resource-code-control input {
  width: 18px;
  height: 18px;
}

.resource-clear {
  min-height: 42px;
}

.resource-clear:disabled {
  opacity: 0.45;
  cursor: default;
}

.resource-result-count {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: var(--fs-12);
  font-weight: 700;
}

.resource-unverified {
  color: var(--warning, var(--muted));
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .tiles {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .hero-main.lead {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-main.lead .find {
    flex: none;
  }
}

@media (max-width: 640px) {
  .tiles {
    grid-template-columns: 1fr;
  }
  .src-grid {
    grid-template-columns: 1fr;
  }
  .cat-id .icon-wrap {
    display: none;
  }
  .resource-controls,
  .resource-control,
  .resource-clear {
    width: 100%;
  }
  .resource-control select,
  .resource-code-control {
    width: 100%;
  }
}
