/*
 * v9 result cards.
 *
 * ai-match.css builds the whole card system out of custom properties, and
 * declares them on `.mffc`. The v9 wrapper is `.mffc9`, so inside it every
 * `var(--…)` resolved to nothing: the factor bars lost their background and
 * disappeared, the hairlines went, and every grey fell back to inherited
 * text. Patching the affected classes one by one was the wrong fix and broke
 * more than it mended — it forced dark text onto the dark work-tile covers
 * and mono-uppercased labels the design sets in sentence case.
 *
 * So: restate the token set for a light ground, once, and let the existing
 * card CSS do its job. Values are the design's own
 * ("MatchFast Find a Company v9.dc.html"):
 *   ink #12131C  muted #565B6E  dim #6A6F80  violet #4F4CE6
 *   good #0E8A5F  warn #B07813  bad #C04040  surface #FFFFFF  rail #F5F5FA
 *
 * Scoped to .mffc9 throughout. The site is dark; only this page is light.
 */

.mffc9 {
  --ground: #EDEDF2;
  --inset: #F5F5FA;
  --panel: #FFFFFF;
  --hair: rgba(16, 17, 28, 0.06);
  --cline: rgba(16, 17, 28, 0.1);
  --line: rgba(16, 17, 28, 0.12);
  --line2: rgba(16, 17, 28, 0.16);
  --line3: rgba(16, 17, 28, 0.24);
  --track: rgba(16, 17, 28, 0.08);
  --rtrack: rgba(16, 17, 28, 0.1);

  --text: #12131C;
  --bright: #12131C;
  --ink: #2A2D3A;
  --soft: #454A5C;
  --dim: #565B6E;
  --dimmer: #6A6F80;

  /* The accent carries the score bars and the primary button, so it is the
     design's violet, not the dark theme's green. */
  --accent: #4F4CE6;
  --accent-h: #5B57F2;
  --accent-lift: #413BD6;
  --accent-ink: #FFFFFF;
  --accent-bg: #EFEEFD;
  --accent-line: #0E8A5F;

  --warn: #B07813;
  --tagbg: #EFEEFD;
  --bad: #C04040;

  /*
   * The type tokens, which the first pass forgot. Without them every rule in
   * ai-match.css that sets `font:600 11px/1 var(--mono)` resolved to nothing
   * and the browser fell back to the theme's Inter and DM Sans — so the mono
   * labels rendered at 16.32px proportional, "MATCH SCORE" wrapped onto two
   * lines under the ring, and the score in the ring came out the same size
   * as body text.
   */
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  color-scheme: light;
}

/*
 * The attribute the script toggles. The theme's display rules beat it, which
 * left the "Read as" row on screen before any search had run.
 */
.mffc9 [hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ card */

.mffc9 .mffc-card {
  background: #FFFFFF;
  border: 1px solid rgba(16, 17, 28, 0.1);
  border-radius: 20px;
  box-shadow: inset 0 1px 0 rgba(16, 17, 28, 0.04), 0 18px 40px -30px rgba(16, 17, 28, 0.18);
}

@media (hover: hover) and (pointer: fine) {
  .mffc9 .mffc-card:hover {
    border-color: rgba(79, 76, 230, 0.35);
  }
}

/*
 * The score bars. is-full/is-mid read as "met" and "partly met", so they are
 * the design's green and amber rather than the accent, and only the track
 * needed restating for a light ground.
 */
.mffc9 .mffc-f-fill.is-full { background: #0E8A5F; }
.mffc9 .mffc-f-fill.is-mid { background: #4F4CE6; }
.mffc9 .mffc-f-fill.is-low { background: #B07813; }

/*
 * Work-tile covers are a dark colour block, in the design as much as here,
 * so their text stays light. This is what the blanket rule got wrong: it
 * painted the client name #12131C onto a dark green cover, and forcing the
 * sans family onto the mono label made it wrap inside a fixed-height header
 * and collide with the line below.
 */
.mffc9 .mffc-tile-client { color: rgba(255, 255, 255, 0.82); }
.mffc9 .mffc-tile-metric { color: #FFFFFF; }
.mffc9 .mffc-tile-metric.is-text { color: rgba(255, 255, 255, 0.94); }

.mffc9 .mffc-tile,
.mffc9 .mffc-tile-empty {
  background: #FFFFFF;
}

/* ------------------------------------------------------- band: unscored */

/*
 * A score of 0 means the profile carried nothing to score, not that the
 * company is a poor fit — so it is grey and named for what it is, rather
 * than wearing the lowest fit band.
 */
.mffc9 .mffc-is-unscored .mffc-score-band,
.mffc9 .mffc-is-unscored .mffc-ring-num {
  color: #6A6F80;
}

/* ---------------------------------------------------------- buttons/links */

.mffc9 .mffc-btn {
  /* No double-tap zoom here, so the tap fires without the browser first
     spending 300ms deciding whether a second tap is coming. */
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.mffc9 .mffc-btn-primary {
  background: linear-gradient(180deg, #5B57F2, #413BD6);
  border: 0;
  color: #FFFFFF;
  /* The label was overflowing its pill: the dark theme sizes this button
     tighter than IBM Plex Sans renders at this weight. */
  padding: 0 18px;
  white-space: nowrap;
}

.mffc9 .mffc-btn-ghost {
  background: transparent;
  border: 1px solid rgba(16, 17, 28, 0.14);
  color: #12131C;
}

.mffc9 .mffc-btn-on {
  background: #EFEEFD;
  border-color: rgba(79, 76, 230, 0.45);
  color: #413BD6;
}

@media (hover: hover) and (pointer: fine) {
  .mffc9 .mffc-btn-ghost:hover { border-color: #4F4CE6; }
}

/* Press feedback for touch, where :hover never fires at all. */
.mffc9 .mffc-btn:active { transform: scale(0.98); }

.mffc9 .mffc-lnk,
.mffc9 .mffc-why-go {
  color: #4F4CE6;
}

/* --------------------------------------------------------------- touch */

/*
 * Found by auditing the live page at 390px: every control measured between
 * 23px and 40px tall. The design draws 38px controls, which is right for a
 * mouse and small for a thumb, so the floor is raised on coarse pointers
 * only and the desktop design is left exactly as drawn.
 */
@media (pointer: coarse) {
  .mffc9 button,
  .mffc9 .mffc-btn,
  .mffc9 .mffc-rate-btn,
  .mffc9 select {
    min-height: 44px;
  }

  /* Inline links sit in running text, so they get the hit area without the
     box growing — padding would push the lines apart. */
  .mffc9 .mffc-lnk,
  .mffc9 .mffc-why-go {
    display: inline-block;
    padding: 10px 0;
  }
}

/* -------------------------------------------------------------- phone */

@media (max-width: 860px) {
  /*
   * The work tiles become a horizontal carousel here — that is deliberate,
   * and an audit measuring element width against the viewport reads it as
   * overflow when it is not; the page itself never scrolls sideways. What
   * the carousel did need was being told who owns which axis: without pan-y
   * the browser guesses whether a swipe is the page or the track, and the
   * guess shows up as the page juddering while the tiles move.
   */
  .mffc9 .mffc-tiles {
    touch-action: pan-y;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
  }

  .mffc9 .mffc-tile,
  .mffc9 .mffc-tile-empty {
    scroll-snap-align: start;
  }

  .mffc9 .mffc-name,
  .mffc9 .mffc-facts,
  .mffc9 .mffc-tile-desc {
    overflow-wrap: anywhere;
  }

  /*
   * The shortlist rail was rendering after all eight cards — 13,911px down a
   * 17,007px page, which is the same as not being there.
   */
  .mffc9 [data-mffc-aside] {
    position: static !important;
    order: -1;
    margin-bottom: 18px;
  }

  /* 16px side gutter, and never a sideways scroll. */
  .mffc9 section {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

/* ----------------------------------------------------------------- inputs */

/*
 * 16px minimum. Under it, iOS Safari zooms the page on focus and does not
 * zoom back out — on a lead-capture page that leaves the visitor looking at
 * a cropped layout for the rest of the session.
 */
.mffc9 input,
.mffc9 textarea,
.mffc9 select {
  font-size: 16px;
}

/*
 * The honeypot is parked off-screen, which is what it is for. Keeping it out
 * of the layout box stops it widening the document on small screens.
 */
.mffc9 .mffc-hp {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ------------------------------------------------- theme overrides */

/*
 * The site's own button styling reaches into the card and paints a #CC3366
 * border on anything that is a <button> or an <a> with a button class. On
 * the dark page it never showed; on white it put a pink outline around
 * "Show the reasoning" and "Request an introduction".
 */
/*
 * Only the two link-like buttons. Resetting every button in the card was
 * too broad: `.mffc9 .mffc-card button` out-specifies `.mffc9 .mffc-rate-btn`
 * and `.mffc-btn-ghost`, so it stripped the borders off "Shortlist" and the
 * Good fit / Not a fit pills as well.
 */
.mffc9 .mffc-why-go,
.mffc9 .mffc-lnk {
  border: 0;
  background: transparent;
  padding: 0;
}

/* The company name is the card's heading, and the theme was painting it
   near-white in DM Sans. */
.mffc9 .mffc-name,
.mffc9 .mffc-name a {
  color: #12131C;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* "MATCH SCORE" is a two-word label above the ring; it was wrapping and
   colliding with it. */
.mffc9 .mffc-score-lab {
  white-space: nowrap;
}

/* Restated after the token rewrite: these inherited the dark theme's
   near-white ink and a near-invisible white border. */
.mffc9 .mffc-rate-btn {
  color: #12131C;
  border: 1px solid rgba(16, 17, 28, 0.16);
  background: #FFFFFF;
}

@media (hover: hover) and (pointer: fine) {
  .mffc9 .mffc-rate-btn:hover {
    border-color: #4F4CE6;
    color: #413BD6;
  }
}

.mffc9 .mffc-rate-q {
  color: #565B6E;
}

/*
 * The work-tile header is a fixed 88px box. "DIFFERENT INDUSTRY" wrapped to
 * two lines inside it and pushed the project name past the cover's bottom
 * edge, so the name was clipped mid-letter.
 */
.mffc9 .mffc-tile-client {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/*
 * A factor the company published nothing for is left out of the score, so it
 * gets a flat grey track and a grey label — not the amber "nearly missed"
 * treatment, which would read as a check the company failed rather than one
 * it was never measured on.
 */
.mffc9 .mffc-f-fill.is-unknown { background: rgba(16, 17, 28, 0.22); }
.mffc9 .mffc-f-v.is-unknown { color: #6A6F80; font-style: normal; }

/*
 * The refine step when it leads rather than follows: it is the first thing
 * on a weak shortlist, so it reads as a prompt, not as an afterthought.
 */
.mffc9 .mffc-refine-first {
  background: #EFEEFD;
  border: 1px solid rgba(79, 76, 230, 0.22);
  border-radius: 20px;
  padding: 20px 22px;
  margin-bottom: 20px;
}

/* ===================================================================
 * Hero, themed to match the homepage
 * ===================================================================
 *
 * The site's hero is dark and the finder's was the one light hero on it.
 * Values read from the live homepage rather than eyeballed:
 *   section background #0B0D18
 *   heading           #FFFFFF
 *   serif accent      #CFCBFF  (Instrument Serif italic)
 *   composer card     #FFFFFF, 22px radius,
 *                     0 30px 80px -30px rgba(10,8,40,0.9)
 *                     plus a 1px rgba(255,255,255,0.1) ring
 *
 * The results below stay light. That is the homepage's own pattern — dark
 * hero, light body — and it gives the page a seam where the search ends and
 * the answers begin.
 *
 * Everything in this section carries inline styles from the design, and an
 * element style beats a stylesheet, so the colour overrides need !important.
 * They are confined to the hero: `:not(.mffc-out)` keeps them off the
 * results section.
 *
 * The typeface stays IBM Plex. The homepage sets DM Sans here, but the rest
 * of this page is Plex and changing family halfway down reads worse than one
 * hero that does not match the homepage's lettering exactly.
 */

.mffc9 > section:not(.mffc-out) {
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(91, 87, 242, 0.28), transparent 70%),
    #0B0D18;
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

/* -- headline and lede -- */

.mffc9 > section:not(.mffc-out) h1 {
  color: #FFFFFF !important;
}

.mffc9 > section:not(.mffc-out) h1 em {
  color: #CFCBFF !important;
}

/* The lede. .mffc-err is also a <p> in here and keeps its own colour. */
.mffc9 > section:not(.mffc-out) > div > div > p:not(.mffc-err) {
  color: rgba(248, 250, 255, 0.72) !important;
}

.mffc9 > section:not(.mffc-out) .mffc-err {
  color: #FF9B9B !important;
}

/* -- the "new ranking" pill above the headline -- */

.mffc9 > section:not(.mffc-out) > div > div > div:first-child > a {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.14) !important;
  color: rgba(248, 250, 255, 0.92) !important;
}

/* -- links, try chips, and the "read as" row -- */

.mffc9 > section:not(.mffc-out) a {
  color: #CFCBFF !important;
}

.mffc9 > section:not(.mffc-out) span,
.mffc9 > section:not(.mffc-out) .mffc-try {
  color: rgba(248, 250, 255, 0.64) !important;
}

.mffc9 > section:not(.mffc-out) .mffc-try {
  border-bottom-color: rgba(255, 255, 255, 0.28) !important;
}

@media (hover: hover) and (pointer: fine) {
  .mffc9 > section:not(.mffc-out) .mffc-try:hover {
    color: #FFFFFF !important;
    border-bottom-color: rgba(255, 255, 255, 0.6) !important;
  }
}

.mffc9 > section:not(.mffc-out) .mffc-readrow {
  color: rgba(248, 250, 255, 0.64) !important;
}

/*
 * The composer stays a white card on the dark ground, exactly as the
 * homepage does it — so everything inside it keeps its dark ink and is put
 * back after the sweeping rules above.
 */
.mffc9 .mffc-form {
  border-radius: 22px !important;
  border: 0 !important;
  box-shadow:
    0 30px 80px -30px rgba(10, 8, 40, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.1) !important;
}

.mffc9 .mffc-form,
.mffc9 .mffc-form span,
.mffc9 .mffc-form label,
.mffc9 .mffc-form button:not(.mffc-btn-primary),
.mffc9 .mffc-form textarea {
  color: #12131C !important;
}

.mffc9 .mffc-form textarea::placeholder {
  color: #6A6F80 !important;
}

.mffc9 .mffc-form button[type="submit"] {
  color: #FFFFFF !important;
}

/* -- "Read as" chips on the dark hero -- */

/*
 * The chips are <span>s, so the sweeping hero rule above painted their text
 * the same near-white as the ground they sit on and they rendered as blank
 * grey blocks. On a dark hero they want a dark surface anyway, not the
 * white pill the light design gives them.
 */
.mffc9 > section:not(.mffc-out) .mffc-chip {
  background: rgba(255, 255, 255, 0.07) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
  color: rgba(248, 250, 255, 0.92) !important;
}

.mffc9 > section:not(.mffc-out) .mffc-chip span {
  color: rgba(248, 250, 255, 0.92) !important;
}

.mffc9 > section:not(.mffc-out) .mffc-chip .mffc-chip-k {
  color: rgba(248, 250, 255, 0.55) !important;
}

.mffc9 > section:not(.mffc-out) .mffc-chip.is-missing {
  color: #F2C98B !important;
  border-style: dashed !important;
}

/* -- the RFP panel, which the attach button reveals -- */

.mffc9 > section:not(.mffc-out) .mffc-rfp {
  margin-top: 14px;
  padding: 16px 18px;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  display: grid;
  gap: 6px;
}

.mffc9 > section:not(.mffc-out) .mffc-rfp-t {
  color: #FFFFFF !important;
  font-weight: 600;
}

.mffc9 > section:not(.mffc-out) .mffc-rfp-d {
  color: rgba(248, 250, 255, 0.64) !important;
  font-size: 14px;
  line-height: 1.55;
}

/* The picker comes from matchfast-leads and is styled for the dark site, so
   it needs no repainting here — only room to breathe. */
.mffc9 > section:not(.mffc-out) .mffc-rfp > *:last-child {
  margin-top: 6px;
}

/* ===================================================================
 * Mobile
 * ===================================================================
 * Measured with content-plan/finder/audit-mobile.mjs at 375 / 390 / 412.
 * Two things that looked like problems and were not, so they are left
 * alone: the compare control (the INPUT is 18x18 but the LABEL wrapping it
 * is 157x48, which is what a thumb hits) and the work-tile carousel
 * (deliberate horizontal scroll; the page never scrolls sideways).
 */

@media (max-width: 640px) {
  /*
   * The hero was giving up 88px of a 375px screen to side padding — 23% of
   * the width — because its inner wrapper adds 28px on top of the 16px
   * gutter the section already provides. The results column was always
   * correct at 16px; this brings the hero in line with it.
   */
  .mffc9 > section:not(.mffc-out) > div {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .mffc9 > section:not(.mffc-out) > div > div {
    padding-top: 22px !important;
    padding-bottom: 28px !important;
  }

  .mffc9 .mffc-form {
    padding: 16px 14px 14px !important;
  }

  /*
   * The example briefs were three stacked 44px rows, ~150px of a 667px
   * screen before a single result. One scrolling row instead, which is the
   * same pattern the work tiles already use — and pan-y so the browser
   * keeps the vertical axis and the page does not judder on a sideways
   * swipe.
   */
  .mffc9 .mffc-tries {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    justify-content: flex-start !important;
    touch-action: pan-y;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .mffc9 .mffc-tries::-webkit-scrollbar { display: none; }

  .mffc9 .mffc-try {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }

  /*
   * Hero links were 23-24px tall. They are navigation, not running prose,
   * so they get a real hit area — through padding on an inline-block, which
   * grows the target without pushing the lines apart.
   */
  .mffc9 > section:not(.mffc-out) a:not([href*="listicles/top-"]),
  .mffc9 [data-mffc-edit] {
    display: inline-block;
    padding: 10px 2px;
    min-height: 44px;
    box-sizing: border-box;
  }

  /* 10px is below what a phone renders legibly; 11px is the floor. */
  .mffc9 .mffc-ring-over,
  .mffc9 .mffc-tile-src,
  .mffc9 .mffc-score-lab {
    font-size: 11px !important;
  }
}

/* -- card density on phones -------------------------------------------
 *
 * Measured with scratch-v9/card-anatomy.mjs at 375px. A card was 1,236px —
 * close to two screens each, eight of them. Where it went:
 *   b-mid 505 (why 326 + work 153) · b-top 263 · b-act 183 · rate 121
 *
 * Everything below is density. Nothing is hidden: the five factor rows and
 * their bars are the proof the page exists to show, and collapsing them
 * would make the card shorter by making it worth less.
 */

@media (max-width: 640px) {
  /* Tightened by measurement, not assumption: a first pass that shrank the
     row gap and added a track margin made the block 11px TALLER, because
     what separates rows is .mffc-why's own gap, not anything on the row. */
  .mffc9 .mffc-f-row { gap: 3px; }
  .mffc9 .mffc-f-note { margin: 1px 0 2px; }
  .mffc9 .mffc-why { padding: 12px 12px 10px; gap: 7px; }
  .mffc9 .mffc-why-go { margin-top: 6px; }

  /*
   * The summary line is boilerplate on most profiles ("… profile for X.
   * Compare listed services, team details, rates …"). Two lines is enough
   * to tell a real summary from the generic one, and the whole thing is on
   * the company's own page.
   */
  .mffc9 .mffc-pitch {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /*
   * The rating row stacked its question above two buttons. One row: the
   * question takes the space it needs and the buttons sit at the end.
   */
  .mffc9 .mffc-rate {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .mffc9 .mffc-rate-q { flex: 1 1 100%; }
  .mffc9 .mffc-rate-btn { flex: 1 1 0; }

  /* Shortlist and Compare share a row; the primary and the introduction
     link keep their own, because those are the two real decisions. */
  .mffc9 .mffc-b-act { gap: 8px; }
}

/*
 * The theme prints a page-header block above the content holding an
 * <h1 class="entry-title"> that this page already has its own heading for.
 * The h1 renders at 0x0, but the wrapper keeps its padding, so the page
 * opened with an empty light band between the site header and the dark
 * hero. Hidden on this page only.
 */
body.mffc9-page .page-header {
  display: none;
}

/*
 * The theme also puts 56px of top padding on <main>. With the page-header
 * hidden that padding became a bare strip of body background — the light
 * ground of the results area — sitting between the dark site header and the
 * dark hero. The hero is full-bleed by design and should meet the header.
 */
body.mffc9-page main.site-main {
  padding-top: 0 !important;
}

/* The attach button is a toggle now, so it should look like one. */
.mffc9 [data-mffc-attach][aria-expanded="true"] {
  background: #EFEEFD !important;
  border-color: rgba(79, 76, 230, 0.45) !important;
  color: #413BD6 !important;
}
