/* Discovery: the search field, the facet rail and the result rows.
   app/discovery.py. Tokens only, never a value, per S section 0. Nothing here
   touches a price surface: the cards are hub_pages.card and keep their own
   rules.

   One markup, two behaviours. Under 1024 the rail is a full-screen sheet
   reached by the #filters fragment and dismissed by the browser's own back;
   at 1024 and above it is the persistent 294 px column P section 6.1 asks
   for. `:target` is the whole mechanism, so a phone with JavaScript off gets
   the same filters a desktop gets. */

.disc { padding-block: var(--px-6) var(--px-12); }
.disc h1 { font-size: var(--px-t-h2); line-height: 1.12; font-weight: 800;
  letter-spacing: -.02em; }
.disc .trust { color: var(--px-dim); font-size: var(--px-t-ui);
  margin-top: var(--px-3); max-width: 62ch; }

/* ------------------------------------------------------------- the controls */
.dform { margin-top: var(--px-6); }
.dfield { display: flex; gap: var(--px-2); position: relative; }
.dfield input {
  flex: 1 1 auto; min-width: 0; height: 44px; padding-inline: var(--px-4);
  background: var(--px-ink-2); color: var(--px-chalk);
  border: var(--px-hair) solid var(--px-rule); border-radius: var(--px-r-chip);
  font: inherit; font-size: var(--px-t-ui);
}
.dfield input::placeholder { color: var(--px-dim); }
.dfield input:focus-visible, .dbar select:focus-visible, .pill:focus-visible,
.chip:focus-visible, .fbtn:focus-visible, .hit:focus-visible {
  outline: 2px solid var(--px-focus); outline-offset: 2px;
}
.dfield button, .dbar button {
  height: 44px; padding-inline: var(--px-5); border: 0; cursor: pointer;
  background: var(--px-signal); color: var(--px-signal-ink);
  border-radius: var(--px-r-chip); font: inherit; font-weight: 700;
  font-size: var(--px-t-ui);
}
.dbar { display: flex; align-items: center; gap: var(--px-2);
  margin-top: var(--px-3); flex-wrap: wrap; }
.dbar select {
  height: 44px; padding-inline: var(--px-3); background: var(--px-ink-2);
  color: var(--px-chalk); border: var(--px-hair) solid var(--px-rule);
  border-radius: var(--px-r-chip); font: inherit; font-size: var(--px-t-ui);
}
.dbar .count { color: var(--px-dim); font-size: var(--px-t-micro);
  margin-inline-start: auto; }
.fbtn {
  display: inline-flex; align-items: center; gap: var(--px-2); height: 44px;
  padding-inline: var(--px-4); border: var(--px-hair) solid var(--px-rule);
  border-radius: var(--px-r-chip); font-size: var(--px-t-ui);
}
.fbtn b { background: var(--px-signal); color: var(--px-signal-ink);
  border-radius: var(--px-r-pill); font-size: var(--px-t-micro);
  min-width: 18px; text-align: center; padding: 1px 5px; }

/* the typeahead list. Hidden until the script fills it, so JS off loses
   nothing: the same words submitted to the same query answer the same. */
.sug { position: absolute; inset-inline: 0; top: 48px; z-index: var(--px-z-sheet);
  margin: 0; padding: var(--px-1); list-style: none; background: var(--px-ink-2);
  border: var(--px-hair) solid var(--px-rule); border-radius: var(--px-r-card);
  max-height: 60vh; overflow-y: auto; }
.sug a { display: block; padding: var(--px-3) var(--px-4); border-radius: var(--px-r-chip); }
.sug a:hover, .sug a:focus-visible { background: var(--px-ink-3); }
.sug b { display: block; font-size: var(--px-t-ui); }
.sug i { display: block; font-style: normal; color: var(--px-dim);
  font-size: var(--px-t-micro); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }

/* ------------------------------------------------------------------- chips */
.applied { display: flex; flex-wrap: wrap; gap: var(--px-2);
  margin-bottom: var(--px-5); }
.chip { display: inline-flex; align-items: center; gap: var(--px-1);
  /* N4 finding 11. Measured 81x32 at 390; O section 1.1 is 44 x 44, no
     exception, and this chip is the only way to drop an applied filter. */
  min-height: 44px; padding-inline: var(--px-3); font-size: var(--px-t-micro);
  background: var(--px-ink-3); border-radius: var(--px-r-pill); }

/* -------------------------------------------------------------- the layout */
.dcols { margin-top: var(--px-6); }
.dres { min-width: 0; }
.none { color: var(--px-dim); padding-block: var(--px-10); }

/* A brand whose before and after pair is not built renders no figure at all
   (hub_pages.figure returns "" for an empty entry), so its card would be a
   short text block in a grid of tall ones. The plate holds the space the frame
   would hold. It is deliberately flat: a fake image is worse than none. */
.dres .card .cardl > .cbody:first-child::before {
  content: ""; display: block; aspect-ratio: 4 / 5; margin-bottom: var(--px-4);
  background: var(--px-ink-2); border-radius: var(--px-r-card);
}
.none a { text-decoration: underline; }

/* ---------------------------------------------------------------- the rail */
.rail {
  position: fixed; inset: 0; z-index: var(--px-z-sheet);
  background: var(--px-ink);
  /* the bottom padding clears the sticky Show results button, so the last
     facet row is scrollable out from under it rather than pinned behind it */
  padding: var(--px-4) var(--px-4) calc(var(--px-16) + 48px);
  overflow-y: auto; overscroll-behavior: contain;
  /* Off screen rather than display:none, so the fragment can bring it back
     and a screen reader does not lose it mid-gesture. */
  visibility: hidden; transform: translateY(100%);
  transition: transform var(--px-t-enter) var(--px-e-enter), visibility 0s linear var(--px-t-enter);
}
.rail:target { visibility: visible; transform: none; transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }
.railhead { display: flex; align-items: center; gap: var(--px-4);
  padding-bottom: var(--px-4); border-bottom: var(--px-hair) solid var(--px-rule); }
.railhead h2 { font-size: var(--px-t-h3); font-weight: 800; margin-inline-end: auto; }
.railhead .clear, .railhead .close { font-size: var(--px-t-ui); color: var(--px-dim);
  min-height: 44px; display: inline-flex; align-items: center; }
.railhead .close { color: var(--px-chalk); font-weight: 700; }
.fgroup { padding-block: var(--px-5);
  border-bottom: var(--px-hair) solid var(--px-rule); }
.fgroup h3 { font-size: var(--px-t-micro); text-transform: uppercase;
  letter-spacing: .08em; color: var(--px-dim); margin-bottom: var(--px-3); }
.pills { display: flex; flex-wrap: wrap; gap: var(--px-2); }
.pill { display: inline-flex; align-items: center; gap: var(--px-2);
  min-height: 44px; padding-inline: var(--px-4);
  border: var(--px-hair) solid var(--px-rule); border-radius: var(--px-r-pill);
  font-size: var(--px-t-ui); }
.pill b { font-weight: 400; color: var(--px-dim); font-size: var(--px-t-micro); }
.pill.on { background: var(--px-chalk); color: var(--px-ink); border-color: var(--px-chalk); }
.pill.on b { color: var(--px-ink); }
/* zero rows stay, greyed. A facet that vanishes when you filter is a facet
   that cannot be reasoned about (P section 6.3). */
/* N4 finding 8. opacity:.45 multiplied BOTH layers against the ink ground:
   the label measured 4.23:1 and the count 2.41:1, and a facet you cannot read
   is a facet you cannot reason about either. Colour, not opacity, so the two
   are dimmed independently and both stay over 4.5:1 (label 6.28, count 4.72).
   The zero count is text, so the state was never colour alone. */
.pill.off { color: color-mix(in srgb, var(--px-chalk) 58%, var(--px-ink)); }
.pill.off b { color: color-mix(in srgb, var(--px-dim) 76%, var(--px-ink)); }
.rail .apply { position: sticky; bottom: 0; display: block; margin-top: var(--px-6);
  height: 48px; line-height: 48px; text-align: center; font-weight: 700;
  background: var(--px-signal); color: var(--px-signal-ink);
  border-radius: var(--px-r-chip); }

/* ----------------------------------------------------- preset and collection hits */
.rhead { font-size: var(--px-t-h3); font-weight: 800; margin-top: var(--px-12);
  margin-bottom: var(--px-4); }
.hits { list-style: none; margin: 0; padding: 0;
  border-top: var(--px-hair) solid var(--px-rule); }
.hit { display: grid; gap: 2px var(--px-4); padding-block: var(--px-3);
  border-bottom: var(--px-hair) solid var(--px-rule); min-height: 44px;
  align-content: center; }
.hit:hover { background: var(--px-ink-2); }
.hname { font-size: var(--px-t-ui); font-weight: 700; }
.hsub, .hbrand { color: var(--px-dim); font-size: var(--px-t-micro); }
.hsub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------- 1024 and up */
@media (min-width: 1024px) {
  .disc h1 { font-size: var(--px-t-display); line-height: var(--px-lh-display); }
  .dform { max-width: 640px; }
  .fbtn { display: none; }                 /* the rail is always there */
  .dcols { display: grid; grid-template-columns: 294px 1fr; gap: var(--px-6); }
  .rail {
    position: sticky; top: 88px; inset: auto; z-index: var(--px-z-rail);
    visibility: visible; transform: none; transition: none;
    max-height: calc(100vh - 112px); padding: 0 var(--px-4) 0 0;
    background: transparent; border-inline-end: var(--px-hair) solid var(--px-rule);
  }
  .railhead .close, .rail .apply { display: none; }
  .hit { grid-template-columns: 22ch 1fr 16ch; align-items: baseline; }
}
