/* The search box and its panel (gopher/search_box.html, js/search/panel.js; docs/gopher-network/search-plan.md 4.5),
   loaded after shell.css on a site that turns the box on (gopher/layout.html, `gopher_search`).

   From lg up the box sits in the navbar and its panel hangs from the navbar's lower edge, as wide as the window.
   Below lg the box is behind the navbar's magnifier, which opens it and the panel full screen in a <dialog>.
   Built on Bootstrap's variables, so both color modes follow data-bs-theme with no rule of their own, but for the
   grade fills. Class names keep the shell's lg- prefix: lg-ss is the box's shell, lg-sp what the panel shows. */

/* ---- Tokens ---------------------------------------------------------------------------------------------------- */

/* The grade fills of a listing card. table.css holds the same tokens for the tables (it loads after this sheet and
   wins where both are on a page); a page without a table has only these. gopher_core/tests/test_web.py holds the
   two sheets to the same values. */
:root {
  --lg-great-bg: #63d863;
  --lg-good-bg: #a0e7a0;
  --lg-fair-bg: #fcf4a3;
  --lg-bad-bg: #ff6961;
  --lg-grade-fg: #1a1d1a;
}
[data-bs-theme="dark"] {
  --lg-great-bg: #3fae5a;
  --lg-good-bg: #7cc98a;
  --lg-fair-bg: #d9cc6a;
  --lg-bad-bg: #e0605a;
  --lg-grade-fg: #0b0f0c;
}

/* ---- The box ---------------------------------------------------------------------------------------------------- */

.lg-ss-form { position: relative; display: flex; align-items: center; gap: .75rem; margin: 0; }
/* The magnifier inside the field (the sprite's #i-search). */
.lg-ss-glass {
  position: absolute; left: .625rem; top: 50%; width: .875rem; height: .875rem; transform: translateY(-50%);
  color: var(--bs-secondary-color); pointer-events: none;
}
.lg-ss-input { flex: 1 1 auto; min-width: 0; padding-left: 2rem; }
.lg-ss-cancel { flex: none; padding-inline: .25rem; text-decoration: none; }
.lg-ss-cancel[hidden] { display: none; }

/* In the navbar, from lg up: between the site's menus and the right-hand group, which it pushes to the edge. It
   gives way before the navbar wraps or the page scrolls sideways: on LabGopher it is 186px wide at 992px and its
   full 18rem from 1100px, and the small minimum is for a development build, whose site menu takes another 90px. */
@media (min-width: 992px) {
  .lg-navbar .lg-ss { flex: 0 1 18rem; min-width: 5rem; margin: 0 auto 0 .75rem; }
  .lg-navbar .lg-ss + .navbar-nav { margin-left: 1rem; }
}
/* Below lg the magnifier is the way in: the box isn't an entry of the collapsed menu. */
@media (max-width: 991.98px) {
  .lg-navbar .navbar-collapse .lg-ss { display: none; }
}

/* ---- The panel -------------------------------------------------------------------------------------------------- */

/* It hangs from the sticky navbar's lower edge (the navbar is its containing block), as wide as the window. */
.lg-ss-panel {
  position: absolute; z-index: 1035; top: 100%; left: 0; right: 0;
  max-height: min(80vh, 44rem); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bs-body-bg); color: var(--bs-body-color);
  border-radius: 0 0 var(--bs-border-radius-lg) var(--bs-border-radius-lg);
  box-shadow: 0 0 0 1px rgba(var(--bs-body-color-rgb), .12), 0 .5rem 1.5rem rgba(0, 0, 0, .18);
}
.lg-ss-panel[hidden] { display: none; }
/* Its content lines up with the page's (the navbar's container). */
.lg-sp { max-width: var(--lg-max-width); margin-inline: auto; padding: .75rem .75rem 1rem; }
.lg-sp a { color: inherit; text-decoration: none; }
.lg-sp ul { margin: 0; padding: 0; list-style: none; }
.lg-sp-none { margin: 0 0 .75rem; line-height: 1.4; }
.lg-sp-top { margin-bottom: .875rem; }
.lg-sp-cols {
  display: grid; grid-template-columns: minmax(13rem, 17rem) minmax(0, 1fr); gap: 1rem 2rem; align-items: start;
}
/* Without cards the list has the room: "Look up eBay item 235288143925" is never cut short. */
.lg-sp-cols.lg-sp-solo { grid-template-columns: minmax(0, 28rem); }
.lg-sp-head { margin: 0 0 .375rem; font-size: .8125rem; font-weight: 600; color: var(--bs-secondary-color); }
.lg-sp-side .lg-sp-group + .lg-sp-group {
  margin-top: .75rem; padding-top: .625rem; border-top: var(--bs-border-width) solid var(--bs-border-color);
}
.lg-sp-main .lg-sp-group + .lg-sp-group { margin-top: 1rem; }

/* Chips: the popular models. */
.lg-sp-chips .lg-sp-items { display: flex; flex-wrap: wrap; gap: .5rem; }
.lg-sp-chip {
  display: block; padding: .3125rem .875rem; border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: 50rem; background: var(--bs-body-bg); font-size: .875rem; white-space: nowrap;
}
.lg-sp-chip:hover { background: var(--bs-tertiary-bg); }

/* Rows: models with their listings in aligned figures, pages, and what the text can do on this page. They are the
   list's options: the arrow keys move through them, and the one they are on is outlined. */
.lg-sp-row {
  display: flex; align-items: baseline; gap: .5rem; padding: .3125rem .5rem; margin-inline: -.5rem;
  border-radius: var(--bs-border-radius); white-space: nowrap;
}
.lg-sp-row:hover { background: var(--bs-tertiary-bg); }
.lg-sp-row .lg-sp-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lg-sp-row b { font-weight: 700; }
.lg-sp-row .lg-sp-count { font-variant-numeric: tabular-nums; color: var(--bs-secondary-color); }
.lg-sp-row.lg-sp-empty .lg-sp-name, .lg-sp-row.lg-sp-empty .lg-sp-count { color: var(--lg-menu-empty-color); }
.lg-sp-icon { flex: none; align-self: center; width: 1rem; height: 1rem; color: var(--bs-secondary-color); }
.lg-sp-row[aria-selected="true"] { outline: 2px solid var(--lg-focus-color); outline-offset: -2px; }

/* Cards: a listing as the table words it. */
.lg-sp-cards .lg-sp-items { display: grid; grid-template-columns: repeat(4, minmax(0, 14.5rem)); gap: .75rem; }
.lg-sp-cards .lg-sp-items > li { display: flex; }
.lg-sp-card {
  display: flex; flex: 1 1 auto; flex-direction: column; gap: .1875rem; min-width: 0; line-height: 1.3;
  padding: .5rem; border: var(--bs-border-width) solid var(--bs-border-color);
  border-radius: var(--bs-border-radius); background: var(--bs-body-bg);
}
.lg-sp-card:hover { border-color: var(--bs-secondary-color); }
.lg-sp-photo {
  display: block; aspect-ratio: 3 / 2; margin-bottom: .375rem; overflow: hidden;
  border-radius: calc(var(--bs-border-radius) - 2px); background: var(--bs-tertiary-bg);
}
.lg-sp-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lg-sp-card-title { font-weight: 600; color: var(--bs-link-color); }
.lg-sp-card-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .375rem; }
.lg-sp-card-price { font-size: 1.0625rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.lg-sp-card-note, .lg-sp-card-specs, .lg-sp-card-checked { font-size: .8125rem; color: var(--bs-secondary-color); }
/* Each spec stays whole ("E5-2680 v4" never breaks at its hyphen); a line breaks between specs. */
.lg-sp-card-specs > span {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: bottom;
}
.lg-sp-card .lg-grade {
  margin-left: auto; padding: 0 .4375rem; border-radius: .25rem; font-size: .8125rem; font-weight: 600;
  color: var(--lg-grade-fg); background: var(--lg-grade-bg);
}
.lg-sp-card .lg-grade-great { --lg-grade-bg: var(--lg-great-bg); }
.lg-sp-card .lg-grade-good { --lg-grade-bg: var(--lg-good-bg); }
.lg-sp-card .lg-grade-fair { --lg-grade-bg: var(--lg-fair-bg); }
.lg-sp-card .lg-grade-bad { --lg-grade-bg: var(--lg-bad-bg); }

@media (max-width: 1199.98px) {
  .lg-sp-cols { grid-template-columns: minmax(11rem, 14rem) minmax(0, 1fr); gap: 1rem 1.25rem; }
}

/* ---- The dialog: the box and the panel full screen, below lg --------------------------------------------------- */

.lg-ss-dialog {
  inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: .5rem .75rem 0;
  overflow-y: auto; border: 0; background: var(--bs-body-bg); color: var(--bs-body-color);
}
.lg-ss-dialog::backdrop { background: rgba(0, 0, 0, .4); }
html:has(.lg-ss-dialog[open]) { overflow: hidden; }
.lg-ss-dialog .lg-ss-glass { left: .875rem; width: 1rem; height: 1rem; }
/* iOS zooms into a field under 16px. */
.lg-ss-dialog .lg-ss-input { font-size: 1rem; padding: .5rem .75rem .5rem 2.5rem; }
.lg-ss-dialog .lg-ss-panel {
  position: static; max-height: none; overflow: visible; box-shadow: none; border-radius: 0;
}
.lg-ss-dialog .lg-sp { padding: .75rem 0 1.5rem; }
.lg-ss-dialog .lg-sp-cols { display: flex; flex-direction: column; align-items: stretch; gap: 1rem; }
/* At rest a phone shows the deals before the list of pages. */
.lg-ss-dialog .lg-sp-rest .lg-sp-main { order: -1; }
.lg-ss-dialog .lg-sp-cards .lg-sp-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lg-ss-dialog .lg-sp-row { padding-block: .5rem; }
