/* One search field (v3 Wall): chips in the field, the suggestion panel, the result line, the Looser rows, the phone sheet. Tokens only (tokens.css).
   Ported from project/03-design/v3/wall/search.css. Page-local sizes that tokens.css does not have, justified:
   --t-11 (the Geist Mono key hints), --chip-h 28 (= s-5 + s-1), --thumb-r 24 (brand thumbs in rows), --cancel-w 64 (the phone sheet's Cancel). */
:root { --t-11: 11px; --chip-h: calc(var(--s-5) + var(--s-1)); --thumb-r: 24px; --cancel-w: 64px; }

/* ---------- result line (under the scope row, only when the wall is filtered) ---------- */
.lede:has(> .result-line) { padding: var(--s-5) var(--gutter) var(--s-4); }
.result-line { margin: 0; font-size: var(--t-20); font-weight: var(--w-medium); line-height: 1.3; letter-spacing: var(--track-display); color: var(--text-2); }
.result-line .n, .result-line .q { color: var(--text-1); font-variant-numeric: tabular-nums; }

/* ---------- the field ---------- */
.sfield { position: relative; width: 100%; height: 100%; display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-1) 0 var(--s-4);
  background: var(--surface-2); border-radius: var(--r-control); transition: background var(--dur-hover) linear; }
.sfield:hover { background: var(--surface-3); }
.sfield:has(input:focus) { outline: var(--focus-w) solid var(--focus); outline-offset: var(--focus-gap); background: var(--surface-2); }
.sf-ic { width: var(--icon-s); height: var(--icon-s); flex: none; color: var(--text-3); }
.sf-scroll { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; }
.sf-scroll::-webkit-scrollbar { display: none; }
/* edge fades on the chip row when it overflows (set by search.js from the scroll position) */
.sf-scroll[data-fade~="end"] { -webkit-mask-image: linear-gradient(to right, var(--mask) calc(100% - var(--s-6)), transparent); mask-image: linear-gradient(to right, var(--mask) calc(100% - var(--s-6)), transparent); }
.sf-scroll[data-fade~="start"] { -webkit-mask-image: linear-gradient(to left, var(--mask) calc(100% - var(--s-6)), transparent); mask-image: linear-gradient(to left, var(--mask) calc(100% - var(--s-6)), transparent); }
.sf-scroll[data-fade~="start"][data-fade~="end"] { -webkit-mask-image: linear-gradient(to right, transparent, var(--mask) var(--s-6), var(--mask) calc(100% - var(--s-6)), transparent); mask-image: linear-gradient(to right, transparent, var(--mask) var(--s-6), var(--mask) calc(100% - var(--s-6)), transparent); }
.sf-scroll input { flex: 1 0 var(--s-9); width: auto; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text-1); font: var(--w-regular) var(--t-14)/1 var(--font); }
.sf-scroll input::placeholder { color: var(--text-3); opacity: 1; }
.sfield kbd { font: var(--w-medium) var(--t-12)/1 var(--mono); color: var(--text-3); padding: var(--s-1) var(--s-2); border-radius: var(--s-1); background: var(--surface-3); margin-right: var(--s-1); }
.sfield:has(input:focus) kbd, .sfield[data-has] kbd { display: none; }
.sf-hue { flex: none; width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: var(--r-control); color: var(--text-2); }
.sf-hue:hover { color: var(--text-1); }
.sf-hic { width: var(--icon); height: var(--icon); }
.sf-hue:focus-visible { outline-offset: calc(var(--s-1) * -1); }

.sf-chips { display: flex; align-items: center; gap: var(--s-1); flex: none; }
.sf-chip { flex: none; height: var(--chip-h); display: inline-flex; align-items: center; gap: var(--s-2); padding: 0 0 0 var(--s-2); border-radius: var(--s-2);
  background: var(--surface-3); color: var(--text-1); font-size: var(--t-13); font-weight: var(--w-medium); white-space: nowrap; }
.sf-chip.is-new { animation: chip-in 150ms linear; }
@keyframes chip-in { from { opacity: 0; } to { opacity: 1; } }
.sf-chip .c-thumb { width: var(--icon-s); height: var(--icon-s); border-radius: var(--s-1); object-fit: cover; }
.sf-chip .c-sw { width: var(--icon-s); height: var(--icon-s); border-radius: 50%; box-shadow: inset 0 0 0 1px var(--hover-ring); }
.sf-chip .c-ico { width: var(--icon-s); height: var(--icon-s); color: var(--text-2); }
.sf-chip .c-med { width: var(--icon-s); height: var(--icon-s); flex: none; color: var(--text-2); }
.sf-chip[data-t="text"] .c-label { padding-left: var(--s-1); }
.sf-chip .c-x { position: relative; width: var(--chip-h); height: var(--chip-h); display: grid; place-items: center; color: var(--text-2); border-radius: var(--s-2); }
.sf-chip .c-x:hover { color: var(--text-1); }
.sf-chip .c-xi { width: var(--icon-s); height: var(--icon-s); }

/* ---------- scrim: the wall dims at most 40% ---------- */
.sf-scrim { position: fixed; inset: 0; z-index: 20; background: var(--ground); opacity: 0; pointer-events: none; transition: opacity 150ms linear; }
.sf-scrim[data-on] { opacity: .4; pointer-events: auto; }
/* while the panel is up the bar stays put even if the wall is scrolled */
html[data-search] .top .bar::before, html[data-search] .top .bar-in, html[data-search] .top .scope { transform: none; }

/* ---------- panel ---------- */
.sp { position: absolute; z-index: 5; top: calc(100% + var(--s-2)); left: 0; right: 0; background: var(--pop-bg); border-radius: var(--r-pop);
  box-shadow: var(--pop-shadow); max-height: calc(100dvh - var(--bar-h) - var(--s-5)); display: flex; flex-direction: column; overflow: hidden; }
.sp[hidden] { display: none; }
.sp-body { overflow-y: auto; padding: var(--s-2); overscroll-behavior: contain; scrollbar-width: none; }
.sp-body::-webkit-scrollbar { display: none; }
.g + .g { margin-top: var(--s-2); }
.g-h { margin: 0; padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--t-12); font-weight: var(--w-medium); letter-spacing: .02em; color: var(--text-3); }
.r { position: relative; display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); padding: var(--s-1) var(--s-3); border-radius: var(--r-control);
  font-size: var(--t-14); color: var(--text-1); cursor: pointer; }
.r.is-active { background: var(--surface-3); }
.r-t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-t b { font-weight: var(--w-semibold); }
.r-n { flex: none; font-size: var(--t-13); color: var(--text-3); font-variant-numeric: tabular-nums; }
.r.is-active .r-n { color: var(--text-2); }                     /* text-3 is not used on surface-3 */
.r-i { width: var(--icon-s); height: var(--icon-s); color: var(--text-3); flex: none; margin-inline: var(--s-1); }
.r.is-active .r-i { color: var(--text-2); }
.r-dot { width: var(--icon-s); height: var(--icon-s); border-radius: 50%; flex: none; margin-inline: var(--s-1); box-shadow: inset 0 0 0 1px var(--hover-ring); }
.r-th { width: var(--thumb-r); height: var(--thumb-r); border-radius: var(--s-1); object-fit: cover; flex: none; background: var(--surface-3); }
.r-k { display: none; flex: none; font: var(--w-medium) var(--t-11)/1 var(--mono); color: var(--text-2); }
.r.is-active .r-k { display: block; }
.r.is-active.is-sw .r-k { display: none; }
.is-col { min-height: calc(var(--s-6) + var(--s-3)); }
.mz { flex: none; width: var(--s-6); height: var(--s-6); display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 1px; border-radius: var(--s-1); overflow: hidden; background: var(--surface-3); }
.mz i { display: block; overflow: hidden; }
.mz i:first-child { grid-row: span 2; }
.mz img { width: 100%; height: 100%; object-fit: cover; }
.r.is-sw { flex-wrap: wrap; gap: 0; padding: 0 var(--s-1); }
.sf-sw { width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: 50%; }
.sf-sw i { width: var(--s-5); height: var(--s-5); border-radius: 50%; box-shadow: inset 0 0 0 1px var(--hover-ring); transition: transform var(--dur-hover) linear; }
.sf-sw:hover i { transform: scale(1.12); }
.sf-sw.is-on { outline: var(--focus-w) solid var(--focus); outline-offset: calc(var(--focus-w) * -1); }
.r.is-sw.is-active { background: none; }

.sp-foot { flex: none; border-top: 1px solid var(--line); }
.sp-keys { display: flex; gap: var(--s-5); align-items: center; padding: var(--s-3) var(--s-4); font-size: var(--t-12); color: var(--text-3); }
.sp-keys span { display: inline-flex; align-items: center; gap: var(--s-2); }
.sp-keys .kb { font-weight: var(--w-medium); font-family: var(--mono); font-size: var(--t-11); line-height: 1; color: var(--text-2); }
.sp-show { display: none; }

/* ---------- Looser rows under the wall, and the notice when nothing matches ---------- */
.looser { padding: var(--s-7) 0 var(--s-9); max-width: var(--field-max); }
#notice .looser { padding: var(--s-5) var(--gutter) var(--s-9); }
.looser-label { margin: 0 0 var(--s-2); font-size: var(--t-12); font-weight: var(--w-medium); letter-spacing: .02em; color: var(--text-3); }
.looser-list { list-style: none; margin: 0; padding: 0; }
.looser-list a { display: flex; gap: var(--s-3); min-height: var(--tap); align-items: center; padding: var(--s-1) 0; border-top: 1px solid var(--line);
  font-size: var(--t-16); font-weight: var(--w-medium); border-radius: 0; text-decoration: none; }
.looser-list li:last-child a { border-bottom: 1px solid var(--line); }
.l-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-w { flex: 1; font-size: var(--t-13); font-weight: var(--w-regular); color: var(--text-3); white-space: nowrap; }
.l-n { margin-left: auto; font-size: var(--t-13); color: var(--text-3); font-variant-numeric: tabular-nums; }
.looser-list a:hover .l-t { text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: var(--s-1); }
.looser-note { margin: var(--s-4) 0 0; font-size: var(--t-13); color: var(--text-3); }
.looser-note a { text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: var(--s-1); }
.looser-note a:hover { color: var(--text-1); }

/* ---------- phone: tapping the field opens a full-screen sheet; the chip row scrolls sideways with edge fades ---------- */
.sf-sheet-bg { position: fixed; inset: 0; z-index: 40; background: var(--ground); }
.sf-sheet-bg[hidden], .sf-cancel[hidden] { display: none; }
.sf-cancel { position: fixed; z-index: 51; top: var(--s-3); right: var(--gutter); width: var(--cancel-w); height: var(--field-h); display: grid; place-items: center;
  font-size: var(--t-14); font-weight: var(--w-medium); color: var(--text-2); border-radius: var(--r-control); }
.show { width: 100%; text-align: center; height: var(--field-h); border-radius: var(--r-pill); background: var(--primary-bg); color: var(--primary-text); font-weight: var(--w-semibold); font-size: var(--t-14); }
@media (max-width: 699px) {
  .lede:has(> .result-line) { padding-top: var(--s-4); }
  html[data-sheet] { overflow: hidden; }
  html[data-sheet] .top { z-index: 50; }
  html[data-sheet] .bar-mark, html[data-sheet] .bar-nav, html[data-sheet] .scope, html[data-sheet] .medium { display: none; }
  html[data-sheet] .bar-in { transition: none; transform: none; }
  html[data-sheet] .sfield { position: fixed; z-index: 45; top: var(--s-3); left: var(--gutter); right: calc(var(--gutter) + var(--cancel-w)); width: auto; height: var(--field-h); }
  html[data-sheet] .sf-scroll input { font-size: var(--t-16); }
  html[data-sheet] .sf-hue { display: none; }
  html[data-sheet] .sp { position: absolute; top: calc(100% + var(--s-3)); left: calc(var(--gutter) * -1); right: calc((var(--gutter) + var(--cancel-w)) * -1);
    border-radius: 0; box-shadow: none; background: var(--ground); max-height: none; height: calc(100dvh - var(--field-h) - var(--s-3) * 3); }
  html[data-sheet] .sp-body { flex: 1; padding-inline: var(--gutter); padding-bottom: calc(var(--s-9) + env(safe-area-inset-bottom, 0px)); }
  html[data-sheet] .sp-keys { display: none; }
  html[data-sheet] .sp-show { display: block; position: absolute; left: var(--gutter); right: var(--gutter); bottom: calc(var(--s-4) + env(safe-area-inset-bottom, 0px)); border: 0; }
  html[data-sheet] .r { min-height: var(--tap); }
  html[data-sheet] .g-top .r { background: var(--surface-2); }
  .sfield { padding-left: var(--s-3); }
  .sfield kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sf-chip.is-new { animation: none; } .sf-scrim { transition: none; } .sf-sw i { transition: none; } }
