/* The filter dialog in the family design (docs/design/FAMILY.md). views/filter.js arranges the markup; the sheet,
   its head and its foot wear the shared cf- classes of views/create.css. What is this dialog's own, prefix fl-:
   a row per section (the name on the left, the options on the right, a small count of what is chosen beside the
   name), chips with a plus that becomes a check and a soft tint when on, two segments with a raised piece that
   slides under the chosen option, a search field and a quiet "Show all" where a list is long, and the primary
   action "Show n updates" whose number rolls as the choices change. Tokens only; dark and light follow the theme. */

:is(#modalFilter, #filtersScreen) > .cf-sheet.fl-sheet, #filtersScreen > .cf-sheet.fl-sheet { width: min(780px, 100%); max-width: 780px; height: auto; max-height: min(840px, calc(100dvh - 32px)); }
.fl-sheet .cf-kind.fl-kind { background: var(--brand-grad); color: var(--color-primary-foreground); box-shadow: inset 0 1px 0 color-mix(in srgb, var(--color-card) 30%, transparent), 0 10px 20px -12px var(--color-brand); }
.fl-names { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.fl-sheet .cf-name { white-space: normal; }
.fl-sub { margin: 0; font-size: 13.5px; line-height: 1.4; color: var(--color-muted-foreground); }
.fl-sheet .cf-head { grid-template-columns: minmax(0, 1fr) auto; padding-bottom: 8px; }
.fl-sheet:focus { outline: none; }

/* the body: rows with hairlines in one surface */
.cf-sheet .fl-body { display: flex; flex-direction: column; padding: 4px 32px 16px; }
.fl-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: start; gap: 12px 20px; padding: 18px 0; border-top: 1px solid var(--color-border); }
.fl-row:first-child { border-top: 0; }
.fl-row[hidden] { display: none; }
.fl-sheet.is-in .fl-row { animation: fl-row-in .5s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 50ms + 60ms); }
@keyframes fl-row-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fl-row__label { display: flex; align-items: center; gap: 8px; min-width: 0; padding-top: 8px; }
.fl-row__name { margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.3; color: var(--color-foreground); }
.fl-row__mark { display: grid; min-width: 20px; height: 20px; flex: none; place-items: center; padding: 0 6px; border-radius: 999px; background: var(--color-brand); color: var(--color-primary-foreground); font-size: 11.5px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.fl-row__opts { display: flex; min-width: 0; flex-direction: column; gap: 10px; }

/* chips: a plus that becomes a check, a soft tint when on */
.fl-chips { display: flex; flex-wrap: wrap; gap: 8px; }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog { display: inline-flex; height: 38px; align-items: center; gap: 6px; margin: 0; padding: 0 15px 0 12px; border: 1px solid var(--frost-line); border-radius: 999px; background: var(--color-card); box-shadow: var(--frost-rim); font-size: 14px; font-weight: 500; color: var(--oryn-text-2); transition: border-color .18s var(--ease-out), background-color .18s var(--ease-out), color .18s var(--ease-out), scale .16s var(--ease-out); }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog .fl-chip__ic { font-size: 13px; color: var(--color-muted-foreground); transition: color .18s var(--ease-out); }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog:hover { border-color: var(--oryn-border-hover); color: var(--color-foreground); }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog:active { scale: .95; }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog.is-on { border-color: var(--color-brand); background: var(--brand-soft); color: var(--color-brand-ink); font-weight: 600; }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog.is-on .fl-chip__ic { color: var(--color-brand); }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog.filt-hid { display: none; }

/* segments: one raised piece slides under the chosen option */
.fl-seg { position: relative; display: inline-flex; max-width: 100%; flex-wrap: wrap; gap: 2px; padding: 4px; border: 1px solid var(--frost-line); border-radius: 999px; background: var(--frost-well); }
.fl-seg__ind { position: absolute; top: 4px; left: 4px; width: 0; height: 36px; border-radius: 999px; background: var(--color-card); box-shadow: var(--frost-rim), var(--frost-shadow); opacity: 0; transition: left .34s var(--ease-out), top .34s var(--ease-out), width .34s var(--ease-out), height .34s var(--ease-out), opacity .2s var(--ease-out); pointer-events: none; }
:is(#modalFilter, #filtersScreen) .fl-seg > button { position: relative; z-index: 1; display: inline-flex; flex: 0 0 auto; height: 36px; align-items: center; margin: 0; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; box-shadow: none; font-size: 14px; font-weight: 500; color: var(--color-muted-foreground); transition: color .2s var(--ease-out); }
:is(#modalFilter, #filtersScreen) .fl-seg > button:hover { background: transparent; color: var(--color-foreground); }
:is(#modalFilter, #filtersScreen) .fl-seg > button.seg-on, :is(#modalFilter, #filtersScreen) .fl-seg > button.is-on { background: transparent; color: var(--color-foreground); font-weight: 600; }

/* a search where a list is long, and the quiet way to the whole list */
.fl-search { position: relative; margin: 0; }
:is(#modalFilter, #filtersScreen) .fl-search input.fld { height: 42px; padding-left: 2.5rem; border: 1px solid var(--frost-line); border-radius: 12px; background: var(--color-card); box-shadow: var(--frost-rim); font-size: 14.5px; color: var(--color-foreground); transition: border-color .22s var(--ease-out), box-shadow .32s var(--ease-out); }
:is(#modalFilter, #filtersScreen) .fl-search input.fld:focus { border-color: color-mix(in srgb, var(--color-brand) 70%, transparent); box-shadow: var(--frost-rim), 0 0 0 4px var(--brand-soft); }
.fl-search__ic { position: absolute; top: 50%; left: 14px; font-size: 15px; color: var(--color-muted-foreground); translate: 0 -50%; pointer-events: none; }
:is(#modalFilter, #filtersScreen) .fl-more { display: inline-flex; height: 32px; align-self: flex-start; align-items: center; gap: 6px; margin: -2px 0 0 -10px; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; font-size: 13.5px; font-weight: 500; color: var(--color-brand-ink); transition: background-color .16s var(--ease-out); }
:is(#modalFilter, #filtersScreen) .fl-more:hover { background: var(--brand-soft); }
:is(#modalFilter, #filtersScreen) .fl-more i { font-size: 13px; }

/* the foot */
.cf-sheet .fl-foot { justify-content: space-between; border-top: 1px solid var(--color-border); }
:is(#modalFilter, #filtersScreen) .cf-foot .fl-clear { border: 1px solid var(--frost-line); background: var(--frost-strong); box-shadow: var(--frost-rim); text-decoration: none; }
:is(#modalFilter, #filtersScreen) .cf-foot .fl-clear:hover { border-color: var(--oryn-border-hover); }
:is(#modalFilter, #filtersScreen) .cf-foot .fl-show { font-variant-numeric: tabular-nums; }
:is(#modalFilter, #filtersScreen) .cf-foot .fl-show #filtCount { display: inline-block; }
:is(#modalFilter, #filtersScreen) .cf-foot .fl-show.is-changed { box-shadow: inset 0 1px 0 color-mix(in srgb, var(--color-card) 30%, transparent), 0 0 0 6px var(--brand-soft), 0 12px 24px -10px var(--color-brand); }

@media (max-width: 1023.98px) {
  .cf-sheet .fl-body { padding: 0 20px 16px; }
  .fl-row { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 16px 0; }
  .fl-row__label { padding-top: 0; }
  /* a narrow screen: the options share the width, two or three to a line, and the piece follows the one chosen */
  .fl-seg { display: flex; width: 100%; }
  :is(#modalFilter, #filtersScreen) .fl-seg > button { flex: 1 1 30%; justify-content: center; padding: 0 10px; }
  :is(#modalFilter, #filtersScreen) #filtPub > button { flex-basis: 45%; }
}
@media (prefers-reduced-motion: reduce) {
  .fl-sheet.is-in .fl-row { animation: none; }
  .fl-seg__ind, :is(#modalFilter, #filtersScreen) .fl-chips .chiptog { transition-duration: 0s; }
}

/* 44 px to the finger (the phone audit of 3 October, carried to this dialog when the two lines of that day were
   joined): on a touch screen the choices of a row and "Show more" take a 44 px press and look as they did */
@media (pointer: coarse) {
  :is(#modalFilter, #filtersScreen) .fl-seg > button::after, :is(#modalFilter, #filtersScreen) .fl-more::after { content: ''; position: absolute; }
  :is(#modalFilter, #filtersScreen) .fl-seg > button::after { inset: -4px 0; }
  :is(#modalFilter, #filtersScreen) .fl-more { position: relative; }
  :is(#modalFilter, #filtersScreen) .fl-more::after { inset: -6px 0; }
}

/* ── the count beside each choice (20 October 2026): how many posts of the last month it would keep ── */
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog .fl-chip__n { margin-left: 2px; font-size: 11.5px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--color-muted-foreground); }
:is(#modalFilter, #filtersScreen) .fl-chips .chiptog.is-on .fl-chip__n { color: var(--color-brand-ink); }
:is(#modalFilter, #filtersScreen) .fl-none { font-size: 13px; color: var(--color-muted-foreground); }

/* related research (21 October 2026): asked only when a specialty is chosen; the reviewer says which studies touch it
   without being about it */

/* C1.11 (26 October 2026): the same sheet as a screen of Home: the page's width, no ceiling, the rows at rest from the start */
#filtersScreen > .cf-sheet.fl-sheet { width: 100%; max-width: none; max-height: none; margin: 0 auto; }
#filtersScreen > .fl-sheet .cf-body { max-height: none; }

/* ── format, condition, topic and Related came to this sheet from Home's bar (10 November 2026). Related is a switch: a track
   with a knob that slides, and the words beside it. ── */
:is(#modalFilter, #filtersScreen) .fl-switch { display: inline-flex; min-height: 44px; align-items: center; align-self: flex-start; gap: 12px; margin: 0; padding: 0 4px 0 0; border: 0; border-radius: 999px; background: transparent; font: inherit; font-size: 15px; color: var(--color-foreground); cursor: pointer; }
.fl-switch__sw { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--color-border); transition: background-color .2s var(--ease-out); }
.fl-switch__sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--color-card); box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: translate .22s var(--ease-out); }
.fl-switch[aria-checked="true"] .fl-switch__sw { background: var(--color-brand); }
.fl-switch[aria-checked="true"] .fl-switch__sw::after { translate: 18px 0; }
@media (prefers-reduced-motion: reduce) { .fl-switch__sw, .fl-switch__sw::after { transition-duration: 0s; } }

/* ── 10 November 2026: the screen made simple (the owner could not scroll it, and found it too much at once) ──
   1. The scroll. The sheet's middle kept the dialog's "scroll inside" rule (overflow auto, overscroll-behavior: contain) but on
   the screen it has no height of its own, so it never scrolled, and the contain rule kept every wheel and every finger from
   reaching the page: nothing moved. On the screen the middle is plain flow, the page scrolls, and the foot stays in sight at the
   bottom of the window. On a phone the foot takes the place of the tab bar while the screen is open. */
html #filtersScreen > .cf-sheet.fl-sheet > .fl-body { overflow: visible; overscroll-behavior: auto; -webkit-mask-image: none; mask-image: none; max-height: none; }
html #filtersScreen > .cf-sheet.fl-sheet > .fl-foot { position: sticky; bottom: 0; z-index: 3; border-radius: 0 0 23px 23px; background: var(--cl-surface, var(--color-card)); }
@media (max-width: 1023.98px) {
  html:has([data-viewpanel="filters"]:not(.hidden)) .mnav { display: none; }
  html:has([data-viewpanel="filters"]:not(.hidden)) #appShell { padding-bottom: 16px; }
  html #filtersScreen > .cf-sheet.fl-sheet > .fl-foot { gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  html #filtersScreen > .cf-sheet.fl-sheet > .fl-foot .fl-show { flex: 1 1 auto; justify-content: center; }
}

/* 2. One line under the title says what is chosen, with Clear all beside it once something is */
html :is(#filtersScreen, #modalFilter) .fl-sum { display: flex; min-width: 0; align-items: center; gap: 2px 12px; margin-top: 6px; }
html :is(#filtersScreen, #modalFilter) .fl-sum__w { min-width: 0; margin: 0; overflow: hidden; font-size: 15px; line-height: 1.45; color: var(--cl-ink-3, var(--color-muted-foreground)); white-space: nowrap; text-overflow: ellipsis; }
html :is(#filtersScreen, #modalFilter) .fl-sum__v { color: var(--cl-ink, var(--color-foreground)); }
html :is(#filtersScreen, #modalFilter) .fl-sum__clear { display: inline-flex; flex: none; height: 32px; align-items: center; gap: 6px; margin: 0; padding: 0 10px; border: 0; border-radius: 999px; background: transparent; font-size: 14.5px; color: var(--cl-ink-2, var(--oryn-text-2)); cursor: pointer; transition: background-color .16s var(--ease-out), color .16s var(--ease-out); }
html :is(#filtersScreen, #modalFilter) .fl-sum__clear:hover { background: var(--cl-hover, var(--oryn-surface-hover)); color: var(--cl-ink, var(--color-foreground)); }
html :is(#filtersScreen, #modalFilter) .fl-sum__clear i { font-size: 14px; }

/* 3. The lists: only options with posts, six in view, "More ..." for the rest; an option a choice elsewhere left empty greys */
html :is(#filtersScreen, #modalFilter) .fl-chips .chiptog.fl-hide { display: none; }
html :is(#filtersScreen, #modalFilter) .fl-chips .chiptog.fl-dim { opacity: .45; }
html :is(#filtersScreen, #modalFilter) .fl-row.fl-row--empty { display: none; }
html :is(#filtersScreen, #modalFilter) .fl-row .fl-more--list { position: relative; height: 34px; margin: 0 0 0 -10px; padding: 0 10px; font-size: 15px; font-weight: 400; color: var(--cl-ink-2, var(--oryn-text-2)); }
html :is(#filtersScreen, #modalFilter) .fl-row .fl-more--list:hover { background: var(--cl-hover, var(--oryn-surface-hover)); color: var(--cl-ink, var(--color-foreground)); }
html :is(#filtersScreen, #modalFilter) .fl-row .fl-more--list i { transition: rotate .3s var(--ease-out); }
html :is(#filtersScreen, #modalFilter) .fl-row .fl-more--list[aria-expanded="true"] i { rotate: 180deg; }

/* 4. More options: one row, closed by default, opening in place */
html :is(#filtersScreen, #modalFilter) .fl-fold { border-top: 1px solid var(--cl-line, var(--color-border)); }
html :is(#filtersScreen, #modalFilter) .fl-fold__btn { display: flex; width: 100%; min-height: 60px; align-items: center; gap: 12px; margin: 0; padding: 0; border: 0; background: transparent; font: inherit; font-size: 15.5px; line-height: 1.3; color: var(--cl-ink, var(--color-foreground)); text-align: left; cursor: pointer; }
html :is(#filtersScreen, #modalFilter) .fl-fold__btn:focus-visible { outline: 2px solid var(--color-ring); outline-offset: 2px; border-radius: 8px; }
html :is(#filtersScreen, #modalFilter) .fl-fold__n { padding: 3px 10px; border-radius: 999px; background: var(--cl-surface-2, var(--frost-well)); font-size: 14px; color: var(--cl-ink-2, var(--oryn-text-2)); font-variant-numeric: tabular-nums; }
html :is(#filtersScreen, #modalFilter) .fl-fold__btn > i { display: grid; width: 36px; height: 36px; margin-left: auto; place-items: center; border-radius: 50%; font-size: 16px; color: var(--cl-ink-3, var(--color-muted-foreground)); transition: rotate .36s var(--ease-out), background-color .16s var(--ease-out); }
html :is(#filtersScreen, #modalFilter) .fl-fold__btn:hover > i { background: var(--cl-hover, var(--oryn-surface-hover)); }
html :is(#filtersScreen, #modalFilter) .fl-fold.is-open .fl-fold__btn > i { rotate: 180deg; }
html :is(#filtersScreen, #modalFilter) .fl-fold__panel { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .42s var(--ease-out), opacity .32s var(--ease-out); }
html :is(#filtersScreen, #modalFilter) .fl-fold.is-open .fl-fold__panel { grid-template-rows: 1fr; opacity: 1; }
html :is(#filtersScreen, #modalFilter) .fl-fold__inner { min-height: 0; overflow: hidden; margin: 0 -6px; padding: 0 6px; }
html :is(#filtersScreen, #modalFilter) .fl-fold__inner > .fl-row:first-child, html :is(#filtersScreen, #modalFilter) .fl-fold__inner > .fl-row[hidden] + .fl-row { border-top: 0; }
html :is(#filtersScreen, #modalFilter) .fl-fold__inner > .fl-row:last-child { padding-bottom: 18px; }
@media (prefers-reduced-motion: reduce) {
  html :is(#filtersScreen, #modalFilter) :is(.fl-fold__panel, .fl-fold__btn > i, .fl-more--list i) { transition: none; }
}

/* 5. Room to breathe: rows a little apart, labels at 15.5 px, the chips at 15 px */
html :is(#filtersScreen, #modalFilter) .fl-sheet .fl-row { padding-top: 16px; padding-bottom: 16px; }
html :is(#filtersScreen, #modalFilter) .fl-sheet .fl-chips .chiptog { height: 40px; font-size: 15px; }
html :is(#filtersScreen, #modalFilter) .fl-sheet .fl-chips .chiptog .fl-chip__n { font-size: 13.5px; }
/* the four ways to show on one line on a phone */
@media (max-width: 1023.98px) {
  html :is(#filtersScreen, #modalFilter) #filtKind { flex-wrap: nowrap; }
  html :is(#filtersScreen, #modalFilter) #filtKind > button { flex: 1 1 0; min-width: 0; padding: 0 6px; }
}
