/* Search (D-030): a quiet field on the wall, tags as chips, filters folded
   away on a phone, results in the home page's grid. */

/* The header's magnifying glass: a round icon button beside the menu. */
.nav-search {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
}
.nav-search:hover, .nav-search[aria-current="page"] { background: var(--hover); text-decoration: none; }
.nav-search .icon { width: 1.3rem; height: 1.3rem; }
/* On a phone the tab bar keeps its three places (home, upload, menu); the
   magnifying glass sits at the top, beside the name of the place. */
.nav-search-top { display: none; }
@media (max-width: 40rem) {
  .site-nav .nav-search { display: none; }
  .nav-search-top { display: grid; margin-left: auto; }
}

.search-page { padding-top: 1.5rem; }
.search-page > h1 { margin-bottom: 1.25rem; }
@media (min-width: 100rem) { .search-page { max-width: 84rem; } }

form.search-form {
  max-width: none;
  padding: 0;
  margin: 0 0 2rem;
  background: none;
  border: 0;
  border-radius: 0;
  gap: 1rem;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 44rem;
  padding: 0.3rem 0.3rem 0.3rem 1rem;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 1px 2px #0000000a;
}
.search-box:focus-within { border-color: var(--ink); }
.search-box-icon { display: grid; color: var(--muted); }
.search-box input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.55rem 0.25rem;
  border: 0;
  background: transparent;
  font-size: 1.05rem;
}
.search-box input:focus { outline: none; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.search-box button { flex: none; min-height: 2.75rem; padding: 0.55rem 1.2rem; }

fieldset.search-tags { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.search-tags legend, .search-filters summary {
  padding: 0;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.tag-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
label.tag-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.18s, border-color 0.18s, color 0.18s;
}
label.tag-chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
label.tag-chip:hover { border-color: var(--faint); }
label.tag-chip:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
label.tag-chip:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 3px; }

.search-filters { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.search-filters summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  margin: 0;
  cursor: pointer;
  list-style: none;
}
.search-filters summary::-webkit-details-marker { display: none; }
.search-filters summary .icon { width: 1.1rem; height: 1.1rem; }
.search-filters[open] summary { color: var(--ink); }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  gap: 0.9rem 1rem;
  margin: 0.5rem 0 1rem;
}
.search-filters > button { justify-self: start; }

.search-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}
.search-summary a { display: inline-flex; align-items: center; gap: 0.3rem; min-height: 2.75rem; color: var(--ink); }
.search-summary a .icon { width: 1rem; height: 1rem; }

ul.search-grid { list-style: none; margin: 0; padding: 0; }
.search-item { break-inside: avoid; position: relative; }
.search-item .tile { margin-bottom: 2.25rem; }
.search-item .label time { display: block; margin-top: 0.15rem; font-size: 0.8rem; color: var(--faint); }
.search-item.is-hidden .mat { opacity: 0.42; box-shadow: none; }
.search-item.is-hidden .label { opacity: 0.7; }
.search-item .badge { position: absolute; top: 0.5rem; left: 0.5rem; }
.search-more { display: flex; justify-content: center; margin: 1rem 0 0; }
.search-more .button { min-width: 12rem; }
.search-try { font-family: var(--sans); font-style: normal; font-size: 1rem; }
.search-try a { text-decoration: underline; text-underline-offset: 0.2em; color: var(--ink); }

@media (max-width: 40rem) {
  /* The tags scroll sideways in one row instead of filling the screen. */
  .tag-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(var(--gutter) * -1); padding: 0.1rem var(--gutter) 0.4rem; scrollbar-width: none; overscroll-behavior-x: contain; }
  .tag-chips::-webkit-scrollbar { display: none; }
  label.tag-chip { flex: none; }
  .search-item .tile { margin-bottom: 1.5rem; }
  .search-box { padding-left: 0.8rem; }
  .search-box button { padding: 0.55rem 0.95rem; }
}
@media (max-width: 22rem) {
  .search-box-icon { display: none; }
}
