/* Browse & search dialog — a full-screen faceted browser over every clip in
   every library. Matches the app's light "paper" aesthetic (see style.css). */

.browse-open {
  width: 100%;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 13px;
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.12s, filter 0.2s;
}
.browse-open:hover { filter: brightness(1.05); }
.browse-open:active { transform: scale(0.98); }

.browse-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(30, 40, 55, 0.42);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3.5vh 3vw;
  animation: browse-fade 0.18s ease;
}
.browse-scrim[hidden] { display: none; }
@keyframes browse-fade { from { opacity: 0; } to { opacity: 1; } }

.browse {
  width: min(1180px, 96vw);
  height: min(880px, 94vh);
  background: #f4f8fc;
  border-radius: 26px;
  box-shadow: 0 40px 120px rgba(20, 30, 50, 0.4);
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: 264px 1fr;
  grid-template-areas: "head head" "chips chips" "facets results";
  overflow: hidden;
}

/* header */
.browse-head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.browse-head h2 { font-size: 1.15rem; font-weight: 900; white-space: nowrap; }
.browse-head .sub { font-size: 0.72rem; font-weight: 800; color: var(--ink-soft); }
.browse-search {
  flex: 1;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 11px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.browse-search:focus { border-color: var(--accent); }
.browse-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--line);
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
  flex: none;
}
.browse-close:hover { background: rgba(51, 50, 61, 0.14); }

/* active-filter chip bar */
.browse-active {
  grid-area: chips;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  min-height: 0;
}
.browse-active:empty { display: none; }
.browse-active .lead { font-size: 0.7rem; font-weight: 800; color: var(--ink-soft); margin-right: 2px; }
.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}
.active-chip .x { opacity: 0.8; font-weight: 900; }
.active-chip:hover { filter: brightness(1.06); }
.active-clear {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
  margin-left: 4px;
}

/* facet sidebar */
.browse-facets {
  grid-area: facets;
  overflow-y: auto;
  padding: 8px 10px 24px 22px;
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: rgba(51, 50, 61, 0.18) transparent;
}
.facet-group { margin-top: 14px; }
.facet-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.facet-values { display: flex; flex-wrap: wrap; gap: 6px; }
.facet-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.facet-chip:hover { border-color: var(--accent); }
.facet-chip .n { font-size: 0.66rem; font-weight: 800; color: var(--ink-soft); }
.facet-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.facet-chip.on .n { color: rgba(255, 255, 255, 0.85); }
.facet-chip.off { opacity: 0.4; cursor: default; }
.facet-chip.off:hover { border-color: var(--line); }

/* results */
.browse-results {
  grid-area: results;
  overflow-y: auto;
  padding: 14px 20px 28px;
  scrollbar-width: thin;
  scrollbar-color: rgba(51, 50, 61, 0.18) transparent;
}
.browse-resultbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  position: sticky;
  top: -14px;
  background: #f4f8fc;
  padding: 6px 0;
  z-index: 1;
}
.browse-resultbar .count { font-size: 0.82rem; font-weight: 900; }
.browse-resultbar .hint { font-size: 0.7rem; font-weight: 700; color: var(--ink-soft); }
.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.result-card {
  text-align: left;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 15px;
  padding: 11px 12px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}
.result-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 12px 26px rgba(60, 70, 90, 0.14);
}
.result-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.result-card .rc-top { display: flex; align-items: flex-start; gap: 8px; }
.result-card .rc-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; margin-top: 4px; }
.result-card .rc-label {
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.25;
  /* full description — no truncation, so nothing is hidden */
  overflow-wrap: anywhere;
}
.result-card .rc-label mark,
.rc-tag.match { background: var(--accent); color: #fff; border-radius: 4px; padding: 0 2px; }
.result-card .rc-src { font-size: 0.63rem; font-weight: 800; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.02em; }

/* every tag, grouped under its family heading */
.result-card .rc-tags { display: flex; flex-direction: column; gap: 5px; }
.rc-fam { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.rc-fam-k {
  font-size: 0.58rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  opacity: 0.7;
  min-width: 46px;
}
.rc-tag {
  font-size: 0.64rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--line);
  border-radius: 6px;
  padding: 2px 6px;
}
.rc-tag.flag { background: color-mix(in srgb, var(--accent) 16%, transparent); color: color-mix(in srgb, var(--accent) 78%, var(--ink)); }
.rc-tag.match { color: #fff; }
.browse-empty { text-align: center; color: var(--ink-soft); font-weight: 800; padding: 60px 20px; }
.browse-loading { text-align: center; color: var(--ink-soft); font-weight: 800; padding: 60px 20px; }

/* mobile / narrow: facets become a collapsible drawer above the results */
@media (max-width: 720px) {
  .browse {
    grid-template-columns: 1fr;
    grid-template-areas: "head" "chips" "facets" "results";
    grid-template-rows: auto auto auto 1fr;
    height: 94vh;
  }
  .browse-facets {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 34vh;
    padding: 8px 16px 14px;
  }
  .browse-head { flex-wrap: wrap; }
}
