/* MacroFinance site-wide search - the header box and its dialog, on every page
   outside the Flow shell (inc/custom/32-site-search.php).

   flow.css already carries these rules, but it also paints the page dark
   (body{background-color:...!important}) and sizes .mfd as a page surface, so
   it cannot be loaded site-wide. The dialog rules below are a deliberate copy
   of flow.css's `:is(.mfd,.mfd-scope) .mfd-search-modal` block, re-scoped to
   .mfs-scope: CHANGE THE TWO TOGETHER. The button rules are new - the one in
   the launch strip is .mfd-search and styled there. */

/* ---------- the header button ----------
   Literal colours, not tokens: this button sits in the site header, outside
   .mfs-scope, where none of the custom properties are declared. The values
   match .mfd-search in flow.css and the auth pills in custom-login-menu. */
.mfs-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;
  background:#131922;border:1px solid #2a313c;border-radius:4px;
  padding:5px 12px;min-height:30px;max-width:300px;box-sizing:border-box;
  color:#9aa7b4;font:400 13px/1 system-ui,-apple-system,"Segoe UI",sans-serif;
  cursor:pointer;vertical-align:middle;
  transition:border-color .12s ease,color .12s ease}
.mfs-btn svg{flex:none}
.mfs-btn span{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.mfs-btn:hover,.mfs-btn:focus{background:#131922 !important;border-color:#3ee0c8 !important;color:#e6edf3 !important}
.mfs-btn:focus-visible{outline:2px solid #3ee0c8;outline-offset:2px}

/* One label at a time. The full prompt where the header row has room for it,
   "Search" where it does not - a box that ellipsises mid-word reads as broken.
   1200px is where the primary nav and the auth pills start competing for the
   same row. */
.mfs-btn .mfs-s{display:none}
@media (max-width:1200px){
  .mfs-btn .mfs-l{display:none}
  .mfs-btn .mfs-s{display:inline}
}

/* Phone top bar: a 40px square beside the bell and the account icon, which is
   what .mf-mbar sizes everything in. */
.mfs-btn-sq{width:40px;height:40px;padding:0;background:#101820;
  border-color:#3ee0c8;color:#3ee0c8}
.mfs-btn-sq:hover{background:rgba(62,224,200,.12);color:#3ee0c8}

@media (prefers-reduced-motion:reduce){ .mfs-btn{transition:none} }

/* ---------- the dialog ---------- */
.mfs-scope{
  --bg:#0d1117; --panel:#131922; --card:#161b22; --sunk:#0d1520;
  --line:#2a313c; --text:#e6edf3; --mut:#9aa7b4; --dim:#6b7684;
  --accent:#3ee0c8;
  font:400 14px/1.45 system-ui,-apple-system,"Segoe UI",sans-serif;
}
.mfs-scope *,.mfs-scope *::before,.mfs-scope *::after{box-sizing:border-box}
.mfs-scope .mfd-sheet{display:none}

/* NOTE the `inset` and `margin:0`: the UA stylesheet styles a modal <dialog>
   as `inset:0; margin:auto`. Setting only top/left leaves right:0 and bottom:0
   in force, which over-constrains the box and lets the auto margins absorb the
   slack - the dialog then lands bottom-right instead of centred. */
.mfs-scope .mfd-search-modal[open]{display:block;position:fixed;
  inset:50% auto auto 50%;margin:0;
  transform:translate(-50%,-50%);width:min(900px,94vw);max-height:80vh;overflow-y:auto;
  z-index:99999;background:var(--card);color:var(--text);border:1px solid var(--line);
  border-radius:14px;padding:18px}
.mfs-scope .mfd-search-modal::backdrop{background:rgba(0,0,0,.6)}
.mfs-scope .mfd-search-modal input:focus{outline:2px solid var(--accent);outline-offset:1px}

/* facets */
.mfs-scope .mfd-facets{display:flex;gap:6px;flex-wrap:wrap;margin-top:14px}
.mfs-scope .mfd-facet{display:inline-flex;align-items:center;gap:6px;padding:5px 12px;
  border:1px solid var(--line);border-radius:14px;background:var(--panel);
  color:#c7cdd6;font-family:inherit;font-weight:500;font-size:12px;line-height:1.35;
  cursor:pointer;white-space:nowrap;transition:border-color .12s ease,color .12s ease}
.mfs-scope .mfd-facet:hover{border-color:#3a434f}
.mfs-scope .mfd-facet[aria-pressed="true"]{border-color:var(--accent);color:var(--accent);font-weight:600}
.mfs-scope .mfd-facet:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.mfs-scope .mfd-facet-dot{width:6px;height:6px;border-radius:50%;flex:none}

/* result rows: title+meta on the left, the section tag pinned right */
.mfs-scope .mfd-sheet-h{font:700 11px/1 inherit;letter-spacing:.07em;
  color:var(--dim);text-transform:uppercase;margin:16px 0 4px}
.mfs-scope .mfd-rr{display:flex;justify-content:space-between;align-items:center;gap:8px;
  padding:8px 0;border-bottom:1px solid rgba(255,255,255,.06);font-size:13px;
  text-decoration:none}
.mfs-scope .mfd-rr:last-child{border-bottom:0}
.mfs-scope .mfd-rr:hover .mfd-sym{color:var(--accent)}
.mfs-scope .mfd-sym{font-weight:600;color:var(--text)}
.mfs-scope .mfd-mut{color:var(--mut)}
.mfs-scope .mfd-sr{display:flex;align-items:center;gap:12px}
.mfs-scope .mfd-sr-txt{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}
.mfs-scope .mfd-srtag{flex:none;padding:2px 9px;border-radius:10px;border:1px solid currentColor;
  font-family:inherit;font-weight:700;font-size:10.5px;line-height:1.5;
  white-space:nowrap;opacity:.9}
.mfs-scope .mfd-sr-more{padding:8px 0 2px}
.mfs-scope .mfd-sr-more a{font-size:12px;color:var(--accent);text-decoration:none}
/* "View more" is a button - it expands the group in place - styled as the link
   it replaced. Mirrors the same rules in flow.css. */
.mfs-scope .mfd-sr-more button{appearance:none;background:none;border:0;padding:0;
  font:inherit;font-size:12px;color:var(--accent);cursor:pointer}
.mfs-scope .mfd-sr-more button:hover{text-decoration:underline}
.mfs-scope .mfd-sr-more button:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.mfs-scope .mfd-sr-more button[disabled]{opacity:.6;cursor:default;text-decoration:none}
.mfs-scope .mfd-empty{padding:28px 20px;text-align:center;color:var(--mut);font-size:13.5px}

/* browse footer */
.mfs-scope .mfd-browse{margin-top:22px;padding-top:14px;border-top:1px solid var(--line);
  display:flex;gap:18px;flex-wrap:wrap;align-items:center;font-size:12.5px}
.mfs-scope .mfd-browse-lbl{color:var(--dim)}
.mfs-scope .mfd-browse a{color:var(--accent);text-decoration:none}
.mfs-scope .mfd-browse a:hover{text-decoration:underline}

/* dismiss: sized to its label and pushed right, where a dismiss belongs */
.mfs-scope .mfd-sheet-done{display:block;width:auto;margin:16px 0 0 auto;
  padding:9px 18px;min-height:38px;border:1px solid var(--line);border-radius:8px;
  background:var(--sunk);color:var(--mut);font:500 13px/1 inherit;cursor:pointer;
  transition:border-color .12s,color .12s}
.mfs-scope .mfd-sheet-done:hover{border-color:var(--accent);color:var(--text)}
.mfs-scope .mfd-sheet-done:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

@media (max-width:780px){
  /* The tag wraps under the text rather than squeezing the title on a phone. */
  .mfs-scope .mfd-sr{flex-wrap:wrap;gap:6px}
  .mfs-scope .mfd-srtag{order:-1}
}
@media (prefers-reduced-motion:reduce){
  .mfs-scope .mfd-facet,.mfs-scope .mfd-sheet-done{transition:none}
}
