/* Fursa UI v2 — /search (slice 3.1c). One calm column: title, the shared
   fx-searchbar + the filters card folded into one quiet line once a search
   has run, saved searches, then the results section — a one-row head (count
   + quiet actions + the inline save details), filter chips, an AI review
   strip reduced to underline tabs plus one live status line, the results
   list as the shared .fx-tcards card rows (face, sort strip and pager in
   components.css §21; this page owns only the grid template and per-cell
   placement), hairline disclosures, and the coverage note as a bottom
   fx-disclosure. Every selector is scoped to html[data-ui="v2"]
   under .fx-page--search and out-specifies the app.css rules it replaces
   (disclosure margins and the reference-table opt-outs that §21 doesn't
   cover). Colours, spacing and motion come from tokens only; hover/focus
   transitions stay ≤150ms and the global reduced-motion guard in shell.css
   collapses the rest. */

/* ---------------------------------------------------------------------------
   1. Frame — the results section is swapped wholesale by
      #apply-review-results, so it opts out of the page-level rise.
--------------------------------------------------------------------------- */

html[data-ui="v2"] .fx-page--search{
  display:grid; gap:var(--fx-space-6); align-content:start;
  max-inline-size:880px; margin-inline:auto; inline-size:100%;
}
html[data-ui="v2"] .fx-page--search > *{min-inline-size:0}
html[data-ui="v2"] .fx-page--search > .fx-results{animation:none}
html[data-ui="v2"] .fx-page--search .fx-search__form{margin-block-start:0}
html[data-ui="v2"] .fx-page--search .fx-search__help{
  margin:0; font-size:var(--fx-text-xs); color:var(--fx-text-subtle);
}
html[data-ui="v2"] .fx-page--search .fx-saved{margin-block-start:0}

/* ---------------------------------------------------------------------------
   2. Results head — one row: h2 + count baseline-aligned on the start side,
      export and the save details as quiet ghost controls on the end side;
      the actions wrap under the heading on narrow screens.
--------------------------------------------------------------------------- */

html[data-ui="v2"] .fx-page--search .fx-results{display:grid; gap:var(--fx-space-4); min-inline-size:0}
html[data-ui="v2"] .fx-page--search .fx-results > *{min-inline-size:0}
html[data-ui="v2"] .fx-page--search .fx-results__head{
  display:flex; flex-wrap:wrap; align-items:baseline; gap:8px 14px;
  padding-block-end:var(--fx-space-3); border-block-end:1px solid var(--fx-border);
}
html[data-ui="v2"] .fx-page--search .fx-results__lead{
  flex:1 1 auto; min-inline-size:0;
  display:flex; flex-wrap:wrap; align-items:baseline; gap:2px 12px;
}
html[data-ui="v2"] .fx-page--search .fx-results__h{
  margin:0; font-size:var(--fx-text-xl); font-weight:var(--fx-weight-bold);
  line-height:var(--fx-leading-tight); color:var(--fx-text);
}
html[data-ui="v2"] .fx-page--search .fx-results__count{
  margin:0; font-size:var(--fx-text-sm); color:var(--fx-text-muted);
  white-space:nowrap;
}
html[data-ui="v2"] .fx-page--search .export-pair{flex:none; align-self:center}

/* Save details — the summary looks like the other ghost button; the body
   expands inline as a full-width row under the head (no popover). */
html[data-ui="v2"] .fx-page--search details.fx-save{
  display:flex; flex-wrap:wrap; align-items:center; gap:8px 14px;
  flex:none; align-self:center;
}
html[data-ui="v2"] .fx-page--search .fx-save__toggle{
  list-style:none; display:inline-flex; align-items:center; gap:6px;
  min-block-size:var(--fx-control-h-sm); padding-inline:var(--fx-space-3);
  border:1px solid transparent; border-radius:var(--fx-radius-sm);
  color:var(--fx-text-muted);
  font-size:var(--fx-text-sm); font-weight:var(--fx-weight-semibold);
  cursor:pointer; user-select:none; white-space:nowrap;
  transition:background-color var(--fx-dur-fast) var(--fx-ease-out),
    color var(--fx-dur-fast) var(--fx-ease-out);
}
html[data-ui="v2"] .fx-page--search .fx-save__toggle::-webkit-details-marker{display:none}
html[data-ui="v2"] .fx-page--search .fx-save__toggle::after{
  content:""; flex:none; inline-size:10px; block-size:10px; background:currentColor;
  -webkit-mask:url('/static/icons/chevron-down.svg?v=ui2-1') center/contain no-repeat;
  mask:url('/static/icons/chevron-down.svg?v=ui2-1') center/contain no-repeat;
}
html[data-ui="v2"] .fx-page--search .fx-save[open] .fx-save__toggle::after{transform:rotate(180deg)}
html[data-ui="v2"] .fx-page--search .fx-save__toggle:hover{
  background:var(--fx-surface-sunken); color:var(--fx-text);
}
html[data-ui="v2"] .fx-page--search .fx-save__toggle:focus-visible{outline:none; box-shadow:var(--fx-ring)}
html[data-ui="v2"] .fx-page--search .fx-save[open]{flex-basis:100%}
html[data-ui="v2"] .fx-page--search .fx-save__form{
  flex:1 1 320px; display:flex; flex-wrap:wrap; align-items:center;
  gap:8px 12px; margin:0; padding-block-start:2px;
}
html[data-ui="v2"] .fx-page--search .fx-save__form .fx-input{inline-size:min(280px,100%)}
html[data-ui="v2"] .fx-page--search .fx-save__alert{
  display:inline-flex; align-items:center; gap:7px; cursor:pointer;
  font-size:var(--fx-text-sm); color:var(--fx-text-muted);
}
html[data-ui="v2"] .fx-page--search .fx-save__alert input{accent-color:var(--fx-primary)}
@media (prefers-reduced-motion:no-preference){
  html[data-ui="v2"] .fx-page--search .fx-save[open] .fx-save__form{
    animation:fx-save-in 180ms var(--fx-ease-out) both;
  }
}
@keyframes fx-save-in{from{opacity:0; transform:translateY(6px)}}

/* Saved confirmation + capped note — quiet one-liners. */
html[data-ui="v2"] .fx-page--search .fx-results__saved{
  margin:0; font-size:var(--fx-text-sm);
}
html[data-ui="v2"] .fx-page--search .fx-results__saved.good{color:var(--fx-success)}
html[data-ui="v2"] .fx-page--search .fx-results__saved.warn{color:var(--fx-warning)}
html[data-ui="v2"] .fx-page--search .fx-results__capped{
  margin:0; font-size:var(--fx-text-sm); color:var(--fx-text-muted);
}
html[data-ui="v2"] .fx-page--search .fx-results__chips{margin:0}

/* ---------------------------------------------------------------------------
   3. AI review strip — underline text tabs over a hairline, then one muted
      status line holding the live progress, processing note, failed count,
      the apply-results link and the start-review form.
--------------------------------------------------------------------------- */

html[data-ui="v2"] .fx-page--search .fx-review{
  display:flex; flex-wrap:wrap; align-items:baseline; gap:6px 14px;
  min-inline-size:0;
}
html[data-ui="v2"] .fx-page--search .fx-review__tabs{
  flex:1 0 100%;
  display:flex; align-items:baseline; gap:4px 18px;
  min-inline-size:0; overflow-x:auto; scrollbar-width:none;
  border-block-end:1px solid var(--fx-border);
}
html[data-ui="v2"] .fx-page--search .fx-review__tabs::-webkit-scrollbar{display:none}
html[data-ui="v2"] .fx-page--search .fx-review__tabs a{
  flex:none; position:relative; padding-block:5px;
  color:var(--fx-text-muted);
  font-size:var(--fx-text-sm); font-weight:var(--fx-weight-medium);
  text-decoration:none; white-space:nowrap;
  transition:color var(--fx-dur-fast) var(--fx-ease-out);
}
html[data-ui="v2"] .fx-page--search .fx-review__tabs a:hover{color:var(--fx-text)}
html[data-ui="v2"] .fx-page--search .fx-review__tabs a:focus-visible{outline:none; box-shadow:var(--fx-ring)}
html[data-ui="v2"] .fx-page--search .fx-review__tabs a::after{
  content:""; position:absolute; inset-inline:0; inset-block-end:-1px;
  block-size:2px; border-radius:2px; background:transparent;
  transition:background-color var(--fx-dur-fast) var(--fx-ease-out);
}
html[data-ui="v2"] .fx-page--search .fx-review__tabs a[aria-current="page"]{
  color:var(--fx-text); font-weight:var(--fx-weight-semibold);
}
html[data-ui="v2"] .fx-page--search .fx-review__tabs a[aria-current="page"]::after{
  background:var(--fx-primary);
}
html[data-ui="v2"] .fx-page--search .fx-review__status{
  flex:0 1 auto; min-inline-size:0;
  display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 14px;
  margin:0; font-size:var(--fx-text-xs); color:var(--fx-text-muted);
}
html[data-ui="v2"] .fx-page--search .fx-review__status #review-processing:empty{display:none}
html[data-ui="v2"] .fx-page--search .fx-review__failed{color:var(--fx-warning)}
html[data-ui="v2"] .fx-page--search .fx-review__status a{
  color:var(--fx-link); text-decoration:none; border-radius:0;
}
html[data-ui="v2"] .fx-page--search .fx-review__status a:hover{
  color:var(--fx-link-hover); text-decoration:underline; text-underline-offset:3px;
}
html[data-ui="v2"] .fx-page--search .fx-review__status a:focus-visible{
  outline:none; box-shadow:var(--fx-ring);
}
html[data-ui="v2"] .fx-page--search #apply-review-results[hidden]{display:none}
html[data-ui="v2"] .fx-page--search .fx-review__start{display:inline; margin:0}
html[data-ui="v2"] .fx-page--search .fx-review__start .fx-link-btn{color:var(--fx-link)}

/* ---------------------------------------------------------------------------
   3.5 Filters fold — after a search the whole filters card collapses into
      one quiet line under the search bar: «الفلاتر: N نشطة … تعديل ▾».
      The line is no card; the partial inside keeps its home look.
--------------------------------------------------------------------------- */

html[data-ui="v2"] .fx-page--search details.fx-filters-fold{margin:0}
html[data-ui="v2"] .fx-page--search .fx-filters-fold__line{
  list-style:none; display:flex; align-items:center; gap:10px;
  min-block-size:40px; padding:0; border-radius:var(--fx-radius-sm);
  color:var(--fx-text-muted);
  font-size:var(--fx-text-sm); font-weight:var(--fx-weight-medium);
  cursor:pointer; user-select:none;
  transition:color var(--fx-dur-fast) var(--fx-ease-out);
}
html[data-ui="v2"] .fx-page--search .fx-filters-fold__line::-webkit-details-marker{display:none}
html[data-ui="v2"] .fx-page--search .fx-filters-fold__line:hover{color:var(--fx-text)}
html[data-ui="v2"] .fx-page--search .fx-filters-fold__line:focus-visible{outline:none; box-shadow:var(--fx-ring)}
html[data-ui="v2"] .fx-page--search .fx-filters-fold__edit{
  margin-inline-start:auto;
  display:inline-flex; align-items:center; gap:6px;
  color:var(--fx-text-subtle);
  font-size:var(--fx-text-xs); font-weight:var(--fx-weight-semibold);
}
html[data-ui="v2"] .fx-page--search .fx-filters-fold__edit::after{
  content:""; flex:none; inline-size:10px; block-size:10px; background:currentColor;
  -webkit-mask:url('/static/icons/chevron-down.svg?v=ui2-1') center/contain no-repeat;
  mask:url('/static/icons/chevron-down.svg?v=ui2-1') center/contain no-repeat;
  transition:transform var(--fx-dur-fast) var(--fx-ease-out);
}
html[data-ui="v2"] .fx-page--search .fx-filters-fold[open] .fx-filters-fold__edit::after{transform:rotate(180deg)}
html[data-ui="v2"] .fx-page--search .fx-filters-fold > .fx-filters{margin-block-start:2px}

/* ---------------------------------------------------------------------------
   4. Results list — the shared .fx-tcards card rows (components.css §21) on
      the real <table>: the wrapper chrome, sortbar strip, card face,
      entrance + replay guards, cell reset, inline .dt dates and the pager
      all live there. Kept here are only this page's column template and
      per-cell placement — the hidden type column / mixed scope token, the
      «·» meta separators, the shared end column and the ≤768px ordering.
--------------------------------------------------------------------------- */

/* Cards — the shared tr.fx-card-row face is in components.css §21; this is
   only the column template, tightened for 100 per page: title on line 1;
   [scope ·] agency · reference · published as one phrase flowing from the
   start edge on line 2 (agency capped at 55% and wrapping inside its
   column, the published cell's 1fr track eats the slack); the deadline
   cell (open rows) or status pill (closed rows) in the reading-end column
   spanning both lines. */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody tr.fx-card-row{
  grid-template-columns:fit-content(55%) max-content max-content minmax(0,1fr) 11rem;
  grid-template-areas:
    "title  title title title end"
    "agency ref   pub   .     end";
  column-gap:var(--fx-space-4);
}
/* Mixed-scope searches add the scope token as the first meta cell. */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table.is-mixed tbody tr.fx-card-row{
  grid-template-columns:max-content fit-content(50%) max-content max-content minmax(0,1fr) 11rem;
  grid-template-areas:
    "title title  title title title end"
    "scope agency ref   pub   .     end";
}
/* The type column stays in the DOM for screen readers (the deadline cell
   and status pill already carry the state); a mixed-scope search shows it
   as the first quiet meta token — plain muted text, no chip. */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-type{
  position:absolute; inset-inline-start:auto; top:auto; z-index:auto;
  inline-size:1px; block-size:1px; margin:-1px; padding:0;
  overflow:hidden; clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap;
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table.is-mixed tbody td.col-type{
  position:static; inline-size:auto; block-size:auto; margin:0; padding:0;
  overflow:visible; clip:auto; clip-path:none;
  grid-area:scope; align-self:baseline; white-space:nowrap;
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table .fx-scope-token{
  display:inline-flex; align-items:center; white-space:nowrap;
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table .fx-scope-token.is-open::before{
  content:""; flex:none; inline-size:6px; block-size:6px; border-radius:50%;
  background:var(--fx-success); margin-inline-end:6px;
}
/* «·» after the token — the same separator the other meta cells carry. */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table .fx-scope-token::after{
  content:"·" / ""; margin-inline-start:8px; color:var(--fx-text-subtle);
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-title{
  grid-area:title;
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-agency{
  grid-area:agency; min-inline-size:0; overflow-wrap:anywhere;
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-ref{
  grid-area:ref; white-space:nowrap; color:var(--fx-text-subtle);
  font-variant-numeric:tabular-nums;
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-date:nth-of-type(5){
  grid-area:pub; justify-self:start; white-space:nowrap; font-variant-numeric:tabular-nums;
}
/* Quiet «·» separators between the meta cells. */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody :is(td.col-ref, td.col-date:nth-of-type(5))::before{
  content:"·" / ""; margin-inline-end:8px; color:var(--fx-text-subtle);
}
/* The deadline cell and the status cell share the end column (never both
   non-empty): the inbox's deadline-column look — ~11rem track, hairline at
   its start edge, spanning both card lines, content vertically centred.
   Both cells paint the same identical column so whichever is filled shows
   it. */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-date:nth-of-type(6){
  grid-area:end; align-self:stretch; justify-self:stretch;
  display:flex; flex-direction:column; justify-content:center; align-items:flex-start; gap:3px;
  padding-inline-start:var(--fx-space-4); border-inline-start:1px solid var(--fx-border);
  white-space:nowrap; font-variant-numeric:tabular-nums; color:var(--fx-text);
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-date:nth-of-type(6):empty{
  display:none;
}
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-status{
  grid-area:end; align-self:stretch; justify-self:stretch;
  display:flex; align-items:center;
  padding-inline-start:var(--fx-space-4); border-inline-start:1px solid var(--fx-border);
}
/* The published cell is the date only; the deadline cell keeps its time.
   (The inline .dt layout itself is shared in components.css §21.) */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-date:nth-of-type(5) .dt-time{
  display:none;
}
/* Open rows carry their state in the deadline cell; the «open» pill stays
   in the DOM for screen readers. */
html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-status .pill.open{
  position:absolute; inline-size:1px; block-size:1px; margin:-1px; padding:0;
  overflow:hidden; clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap;
}
/* app.css's ≤1279px reference-table opt-outs (sticky first column,
   min-inline-size, the sortbar nowrap) moved to components.css §21; here
   only the wrapping meta cells keep white-space:normal. */
@media (max-width:1279px){
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-agency,
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-title{
    min-inline-size:0; white-space:normal;
  }
}

/* ≤768px — three stacked lines: title, agency, then one meta line with
   «[scope ·] reference · نُشرت date» at the start and the deadline/status
   cell flush at the line's end (no column border on phones). The slack
   lives in the published cell's end margin, so an end cell pushed to a
   wrapped line lands start-aligned and no «·» ever opens a line. */
@media (max-width:768px){
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody tr.fx-card-row{
    display:flex; flex-wrap:wrap; align-items:baseline;
    column-gap:8px; row-gap:2px;
  }
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-title{order:1; flex-basis:100%}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-agency{order:2; flex-basis:100%}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-ref{order:3}
  /* A plain td.col-ref::before loses to the :is() separator rule above on
     specificity — nth-of-type(4) ties it, so content:none actually wins. */
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-ref:nth-of-type(4)::before{content:none}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-date:nth-of-type(5){order:4; margin-inline-end:auto}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-date:nth-of-type(5)::before{margin-inline-end:6px}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-date:nth-of-type(6){order:5}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody td.col-status{order:6}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table tbody :is(td.col-date:nth-of-type(6), td.col-status){
    padding-inline-start:0; border-inline-start:0;
  }
  /* Mixed scope: the token joins the meta line before the reference —
     «open · ref · نُشرت date» (its own ::after carries the separator). */
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table.is-mixed tbody td.col-type{order:3}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table.is-mixed tbody td.col-ref{order:4}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table.is-mixed tbody td.col-date:nth-of-type(5){order:5}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table.is-mixed tbody td.col-date:nth-of-type(6){order:6}
  html[data-ui="v2"] .fx-page--search .fx-results__list .fx-results__table.is-mixed tbody td.col-status{order:7}
}

/* ---------------------------------------------------------------------------
   5. Disclosures — v1's .disclosure boxes become quiet fx-disclosure rows;
      the inner tables take the §20.6 fx-table chrome. Coverage sits at the
      bottom of the page on the same quiet pattern.
--------------------------------------------------------------------------- */

html[data-ui="v2"] .fx-page--search details.fx-disclosure{
  margin:0; padding:0; border:0; border-radius:0; background:none;
}
html[data-ui="v2"] .fx-page--search details.fx-disclosure > summary{
  padding-block:10px; padding-inline:0; min-height:0;
}
html[data-ui="v2"] .fx-page--search details.fx-disclosure > summary .hint{
  margin-inline-start:8px;
  font-size:var(--fx-text-xs); font-weight:var(--fx-weight-regular);
  color:var(--fx-text-subtle);
}
html[data-ui="v2"] .fx-page--search details.fx-disclosure[open] > summary{border-block-end:0}
html[data-ui="v2"] .fx-page--search details.fx-disclosure > .disclosure-body{padding:0}
html[data-ui="v2"] .fx-page--search .fx-coverage__caption{
  margin:0 0 var(--fx-space-3); font-size:var(--fx-text-sm); color:var(--fx-text-muted);
}
html[data-ui="v2"] .fx-page--search .fx-coverage__note{margin:0}
html[data-ui="v2"] .fx-page--search .fx-coverage__actions{
  display:flex; flex-wrap:wrap; align-items:center; gap:var(--fx-space-2);
  margin-block:var(--fx-space-3) 0;
}

/* «4,598 results · Page 1 of 46» is wider than a 320px screen in English. */
@media (max-width: 420px){
  html[data-ui="v2"] .fx-page--search .fx-results__count{white-space:normal}
}
