/* Lab Match: page shell + results components (owner: shell).
   Builds on css/warm-lab.css. Every class here is lm- prefixed and every color is a design token,
   so the light and dark themes both work with no extra rules. Breakpoints mirror warm-lab.css. */

/* ------------------------------------------------------------------ page rhythm */
/* Room for the sticky header (nav + preview strip) when the page scrolls a section into view,
   like warm-lab.css's .anchor { scroll-margin-top: 140px }. Header: ~130px desktop, ~116px at
   <= 900px, ~142px at <= 600px (two rows + strip); the extra keeps a little air above the heading. */
:root { --lm-head-clear: 148px; }
.lm-page-head { padding-bottom: 40px; }
.lm-section { padding: 24px 0 120px; scroll-margin-top: var(--lm-head-clear); }
#lm-results { scroll-margin-top: calc(var(--lm-head-clear) - 40px); }
.lm-section:focus { outline: none; }
.lm-section:focus-visible { outline: 2px solid var(--teal); outline-offset: 8px; }
.lm-block { padding: 56px 0 0; scroll-margin-top: var(--lm-head-clear); }
.lm-block[hidden], .lm-excluded[hidden] { display: none; }
.lm-block:focus { outline: none; }
.lm-chart { min-height: 0; }
.lm-loading { font-family: var(--mono); font-size: 14px; color: var(--faint); margin: 24px 0; }

/* Section headings: mono .label used as a heading, and the big results title */
.lm-label-h { font-weight: 400; line-height: 1.4; }
.lm-h2 { margin: 0 0 14px; max-width: 22ch; }
.lm-sub { font-size: 17px; line-height: 1.65; color: var(--muted); max-width: 64ch; margin: 0 0 32px; }
#lm-results-title { margin: 0; max-width: 22ch; }
#lm-results-title:focus { outline: none; }
#lm-results-title:focus-visible { outline: 2px solid var(--teal); outline-offset: 6px; }

/* "Your answers are saved in this browser" + "Clear my saved answers" */
.lm-draft-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin: 0 0 24px;
  font-size: 14px; line-height: 1.5; color: var(--faint); }
.lm-draft-line[hidden] { display: none; }

/* Buttons that look like the site's mono links / ghost buttons (44px targets) */
.lm-linkbtn { background: none; border: 0; border-bottom: 1px solid var(--rule-dark); padding: 6px 0; min-height: 44px;
  cursor: pointer; font: inherit; font-family: var(--mono); font-size: 13px; color: var(--muted); border-radius: 0; }
.lm-linkbtn.teal { color: var(--teal); border-bottom-color: var(--teal-line); }
.lm-linkbtn:hover { color: var(--coral); border-bottom-color: var(--coral); }
.lm-linkbtn[hidden] { display: none; }
.lm-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 12px 22px;
  font-family: var(--sans); font-size: 15px; font-weight: 700; color: var(--ink); background: var(--bg);
  border: 1px solid var(--rule-dark); border-radius: 999px; cursor: pointer; white-space: nowrap; }
.lm-ghost:hover { color: var(--coral); border-color: var(--coral); }
.lm-ghost[hidden] { display: none; }
/* "Sending…" / "Sent": aria-disabled (not disabled) so keyboard focus stays on the button */
.lm-ghost[aria-disabled="true"], .lm-ghost[aria-disabled="true"]:hover { color: var(--faint); border-color: var(--line); cursor: default; }

/* ------------------------------------------------------------------ results head + status line */
.lm-results-head { padding-top: 32px; }
.lm-results-head .label { margin-bottom: 18px; }
.lm-status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 20px; min-height: 24px; }
.lm-status { margin: 0; font-size: 15px; line-height: 1.55; color: var(--faint); max-width: 72ch; }
.lm-status:empty { display: none; }
.lm-status.is-busy { color: var(--muted); }
.lm-status.is-busy::before { content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 10px; border-radius: 50%;
  background: var(--teal); vertical-align: 1px; animation: lm-pulse 1.2s ease-in-out infinite; }
@keyframes lm-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* "See your lab matches": skips the two charts for someone who came for the list */
.lm-jump { margin: 20px 0 0; }
.lm-jump[hidden] { display: none; }

/* Chart mount points: the viz modules own what is inside; this only covers the fail-soft note */
.lm-chart-error { font-size: 15px; line-height: 1.6; color: var(--faint); margin: 0; padding: 20px 24px;
  border: 1px dashed var(--rule-dark); border-radius: 8px; max-width: 72ch; }

/* ------------------------------------------------------------------ lab cards */
/* Built to be scanned: name + fit, one sentence, three quick facts, three small meters. Everything else
   sits behind "How to reach out and more". Body text is --ink or --muted (>= 7:1); --faint is not used. */
.lm-cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.lm-card-item[hidden] { display: none; }
.lm-card.card { position: relative; padding: 24px 28px; border-color: var(--rule-dark);
  scroll-margin-top: calc(var(--lm-head-clear) + 16px); transition: border-color .2s, box-shadow .2s; }
.lm-card:focus { outline: none; }
.lm-card:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.lm-card.card.glow { border-color: var(--teal); box-shadow: 0 0 0 3px var(--glow); }
.lm-card.lm-flash, .lm-excl-name.lm-flash { border-color: var(--teal); box-shadow: 0 0 0 4px var(--glow), 0 0 0 1px var(--teal); }

.lm-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 24px; }
.lm-card-title { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; align-items: center; min-width: 0; }
.card .lm-rank { grid-row: span 2; align-self: start; margin: 0; width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; background: var(--ink); color: var(--bg);
  font-size: 17px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.card h3.lm-card-name { margin: 0; font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.card .lm-card-who { grid-column: 2; margin: 4px 0 0; font-size: 15px; line-height: 1.45; color: var(--muted); }
.lm-fit { flex: none; text-align: right; }
.card .lm-fit-line { margin: 0; line-height: 1; color: var(--ink); white-space: nowrap; }
.lm-fit-num { font-size: 34px; font-weight: 800; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }
.lm-fit-word { font-size: 15px; font-weight: 600; color: var(--muted); }

.card .lm-focus { margin: 16px 0 0; font-size: 17px; line-height: 1.55; color: var(--ink); max-width: 76ch; overflow-wrap: break-word; }

/* quick facts: plain words, one line each on a phone, one row on a desktop */
.lm-quick { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 24px;
  font-size: 15px; line-height: 1.5; color: var(--ink); }
.lm-quick-label { color: var(--muted); }
.lm-quick .tag { min-height: 28px; font-family: var(--sans); font-size: 13px; letter-spacing: 0; }

/* Facet meters, three across: name | track | value */
.lm-meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 28px; margin: 16px 0 0; max-width: 760px; }
.lm-meter { display: grid; grid-template-columns: auto minmax(40px, 1fr) auto; align-items: center; gap: 10px; }
.lm-meter-name { font-size: 14px; font-weight: 600; color: var(--muted); }
.lm-meter-track { position: relative; height: 8px; border-radius: 999px; background: var(--panel2);
  box-shadow: inset 0 0 0 1px var(--rule-dark); overflow: hidden; }
.lm-meter-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: var(--teal); }
.lm-meter-val { font-size: 14px; font-weight: 700; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; }
.lm-meter.is-na .lm-meter-val { color: var(--muted); font-weight: 400; }

/* "How to reach out and more" + the lab's links */
.lm-card-foot { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 28px; margin-top: 14px; }
.lm-details { flex: 1 1 100%; order: 2; min-width: 0; }
.lm-details:not([open]) { flex: 0 1 auto; order: 0; }
.lm-details-sum { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; list-style: none;
  font-size: 15px; font-weight: 700; color: var(--teal); }
.lm-details-sum::-webkit-details-marker { display: none; }
.lm-details-sum::before { content: ''; flex: none; width: 8px; height: 8px; border: solid currentColor; border-width: 0 2px 2px 0;
  transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
details[open] > .lm-details-sum::before { transform: rotate(45deg); }
.lm-details-sum:hover { color: var(--coral); }
.lm-details-sum:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 4px; }
.lm-details-body { padding: 4px 0 6px; max-width: 76ch; }
.card .lm-fact { margin: 10px 0 0; font-size: 16px; line-height: 1.6; color: var(--muted); overflow-wrap: anywhere; }
.lm-fact strong { color: var(--ink); font-weight: 700; }
.lm-card-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; order: 1; }
.lm-card-links .mono-link { min-height: 44px; font-family: var(--sans); font-size: 15px; font-weight: 600; color: var(--teal);
  border-bottom-color: var(--teal-line); }
.lm-card-links .mono-link:hover { color: var(--coral); border-bottom-color: var(--coral); }
.card .lm-card-note { margin: 14px 0 0; font-size: 14px; line-height: 1.5; color: var(--muted); }

/* Show 5 more matches */
.lm-more-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 24px; }
.lm-more { min-height: 52px; padding: 14px 28px; font-size: 16px; color: var(--bg); background: var(--ink); border-color: var(--ink); }
.lm-more:hover { color: var(--bg); background: var(--teal); border-color: var(--teal); }
.lm-more-count { margin: 0; font-size: 15px; color: var(--muted); }

/* ------------------------------------------------------------------ left-out labs */
.lm-excluded { margin-top: 28px; padding: 6px 24px; border: 1px solid var(--rule-dark); border-radius: 8px; max-width: 88ch; }
.lm-excl-details > .lm-details-sum { color: var(--ink); font-weight: 600; }
.lm-excl-body { padding: 2px 0 14px; }
.lm-excl-line { margin: 0; font-size: 15px; line-height: 1.65; color: var(--muted); }
.lm-excl-line + .lm-excl-line { margin-top: 10px; }
.lm-excl-name { color: var(--ink); font-weight: 600; border-radius: 4px; transition: box-shadow .2s; }
.lm-excl-name:focus { outline: none; }

/* ------------------------------------------------------------------ from what you wrote */
.lm-topics { list-style: none; margin: 0 0 24px; padding: 0; }
.lm-quote { margin: 0 0 20px; padding: 4px 0 4px 20px; border-left: 3px solid var(--teal-line); max-width: 72ch; }
.lm-quote p { margin: 0; font-size: 18px; line-height: 1.6; color: var(--ink); font-style: italic; }
.lm-quote p::before { content: '“'; } .lm-quote p::after { content: '”'; }
.lm-reading { margin: 0; font-size: 16px; line-height: 1.6; color: var(--muted); max-width: 72ch; }

/* ------------------------------------------------------------------ how this works */
.lm-faq { max-width: 880px; }
.lm-faq details > *:not(summary) { max-width: 70ch; }
.lm-faq-list { margin: 0 0 18px; padding-left: 20px; font-size: 16px; line-height: 1.6; color: var(--muted); }
.lm-faq-list li + li { margin-top: 6px; }
.lm-faq-list strong { color: var(--ink); }

/* ------------------------------------------------------------------ actions band */
.lm-actions { margin-top: 72px; }
.lm-actions .headline { margin: 0; }
.lm-actions .sub { margin: 6px 0 0; }
.lm-actions-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* ------------------------------------------------------------------ email my matches (under the cards) */
.lm-email-row { margin: 40px 0 0; max-width: 720px; }
.lm-email-label { display: block; margin: 0 0 8px; font-weight: 700; font-size: 16px; color: var(--ink); }
.lm-email-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.lm-email-inline .lm-input { flex: 1 1 240px; min-width: 0; max-width: 420px; }
.lm-email-row .lm-email-note { margin: 10px 0 0; }   /* empty = hidden, via .lm-status */
.lm-email-optin { margin-top: 12px; }

/* ------------------------------------------------------------------ error card */
.lm-error { max-width: 72ch; }
.lm-error .h3 { margin: 0 0 6px; }
.lm-cmd { margin: 14px 0 6px; padding: 14px 18px; border-radius: 6px; background: var(--panel2); border: 1px solid var(--line);
  overflow-x: auto; font-family: var(--mono); font-size: 14px; line-height: 1.6; color: var(--ink); }
.card .lm-error-detail, .lm-error-detail { font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--faint);
  margin: 14px 0 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ dev panel (?dev=1) */
.lm-dev { margin: 0 0 120px; padding: 24px 28px; border: 1px dashed var(--rule-dark); border-radius: 8px; background: var(--panel2); }
.lm-dev[hidden] { display: none; }
.lm-dev .label { margin-bottom: 12px; }
.lm-dev-note, .lm-dev-msg { margin: 0 0 14px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.lm-dev-msg:empty { display: none; }
.lm-dev-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.lm-dev-row .fchip { background: var(--bg); }
.lm-dev-details summary { cursor: pointer; min-height: 44px; display: flex; align-items: center;
  font-family: var(--mono); font-size: 13px; color: var(--teal); }
.lm-dev-pre { max-height: 320px; overflow: auto; margin: 8px 0 16px; padding: 12px 14px; border-radius: 6px; background: var(--bg);
  border: 1px solid var(--line); font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--ink); }
.lm-dev-scroll { overflow-x: auto; }
.lm-dev-table { border-collapse: collapse; font-family: var(--mono); font-size: 12px; color: var(--ink); min-width: 100%; }
.lm-dev-table th, .lm-dev-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.lm-dev-table th { color: var(--faint); font-weight: 600; }
.lm-dev-table td.lm-dev-name, .lm-dev-table th:nth-child(2) { text-align: left; white-space: normal; min-width: 180px; }

/* ------------------------------------------------------------------ breakpoints (mirror warm-lab.css) */
@media (max-width: 900px) {
  :root { --lm-head-clear: 132px; }
  .lm-section { padding-bottom: 96px; }
  .lm-block { padding-top: 48px; }
  .lm-meters { grid-template-columns: minmax(0, 1fr); max-width: 420px; }
  .lm-meter { grid-template-columns: 84px minmax(0, 1fr) 44px; }
  .lm-actions { margin-top: 56px; }
}
@media (max-width: 600px) {
  :root { --lm-head-clear: 156px; }
  /* header: keep the live site's mobile look (brand row + one links row) but with the extra
     "Lab match" link it must not wrap onto two lines */
  .nav-links { gap: 12px; }
  .nav-links a { white-space: nowrap; }
  .lm-page-head { padding-bottom: 24px; }
  .lm-section { padding-bottom: 80px; }
  .lm-block { padding-top: 40px; }
  .lm-card.card { padding: 20px 18px; }
  .lm-card-head { gap: 12px; }
  .lm-fit-num { font-size: 28px; }
  .card .lm-rank { width: 30px; height: 30px; font-size: 15px; }
  .card h3.lm-card-name { font-size: 19px; }
  .lm-quick { flex-direction: column; align-items: flex-start; gap: 4px; }
  .lm-meter { grid-template-columns: 76px minmax(0, 1fr) 40px; gap: 10px; }
  .lm-excluded { padding: 4px 18px; }
  .lm-more { width: 100%; }
  .lm-actions-row { width: 100%; }
  .lm-actions-row > * { flex: 1 1 100%; }
  .lm-dev { padding: 18px 16px; }
}

/* ------------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  .lm-card, .lm-excl-name, .lm-details-sum::before { transition: none; }
  .lm-status.is-busy::before { animation: none; opacity: 1; }
}

/* -------------------------------------------- feedback buttons: 👍 / 👎 / I'm gonna apply! (a card's footer) */
.card .lm-fit-personal { margin: 6px 0 0; font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--gold-text); }
.lm-rate { margin: 14px 0 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--rule-dark); min-width: 0; scroll-margin-bottom: 160px; }
.lm-rate-q { padding: 0; margin: 0 0 8px; font-size: 15px; font-weight: 700; color: var(--ink); }
.lm-rate-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.lm-votes { display: inline-flex; gap: 8px; }
.lm-vote { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; cursor: pointer;
  font: 600 15px/1 var(--sans); color: var(--ink); background: transparent; border: 1px solid var(--rule-dark);
  border-radius: 999px; transition: background-color .15s, border-color .15s, color .15s; }
.lm-vote-icon { flex: none; width: 18px; height: 18px; }
.lm-vote:hover { border-color: var(--teal); color: var(--ink); }
.lm-vote:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.lm-vote-up[aria-pressed="true"] { color: var(--teal); border-color: var(--teal); background: var(--glow); }
.lm-vote-down[aria-pressed="true"] { color: var(--coral); border-color: var(--coral); }
.lm-vote-apply { color: var(--teal); border-color: var(--teal-line); }
.lm-vote-apply[aria-pressed="true"] { color: var(--on-teal); background: var(--teal); border-color: var(--teal); }
@media (prefers-reduced-motion: reduce) { .lm-vote { transition: none; } }
.lm-rate-note { font-size: 14px; color: var(--muted); }
/* "Why not? (optional)": shown only while "Not for me" is pressed; fixed choices, no free text */
.lm-why { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; }
.lm-why[hidden] { display: none; }
.lm-why-q { flex: 1 1 100%; font-size: 14px; font-weight: 600; color: var(--muted); }
.lm-reason { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; cursor: pointer;
  font: 600 14px/1 var(--sans); color: var(--ink); background: transparent; border: 1px dashed var(--rule-dark);
  border-radius: 999px; }
.lm-reason:hover { border-color: var(--coral); }
.lm-reason:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.lm-reason[aria-pressed="true"] { color: var(--coral); border: 1px solid var(--coral); }

/* the share question, under the first card a student rates (once per page) */
.lm-ask { margin: 14px 0 0; padding: 14px 16px; background: var(--panel2); border: 1px solid var(--teal-line);
  border-radius: 8px; }
.lm-ask .lm-ask-lead { margin: 0 0 10px; font-size: 15px; font-weight: 700; line-height: 1.5; color: var(--ink); }
.lm-ask-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.lm-ask .lm-ghost { padding: 10px 18px; }
.lm-ask-more { margin: 12px 0 0; font-size: 14px; line-height: 1.6; color: var(--muted); }
.lm-ask-more[hidden] { display: none; }
.lm-ask .lm-ask-more p { margin: 0 0 8px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.lm-ask .lm-ask-more p:last-child { margin: 0; }

/* the bar that applies / shares ratings: sticks to the bottom while the cards scroll past */
.lm-rate-bar { position: sticky; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  margin-top: 20px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--teal-line); border-radius: 8px;
  box-shadow: 0 -4px 16px var(--glow); }
.lm-rate-bar[hidden], .lm-rate-bar .pill[hidden] { display: none; }   /* .pill sets display: inline-flex */
.lm-rate-count:focus { outline: none; }
.lm-rate-count { margin: 0; font-size: 15px; color: var(--ink); flex: 1 1 220px; }
.lm-rate-hint { margin: 0; flex: 1 1 100%; font-size: 14px; color: var(--muted); }
.lm-rate-hint[hidden], .lm-share-state[hidden], .lm-share-state [hidden] { display: none; }
/* "Sharing is on · Turn off · Delete what I shared" */
.lm-share-state { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; margin: 0; flex: 1 1 100%;
  font-size: 14px; color: var(--ink); }
.lm-share-state > span { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0 10px; }
.lm-share-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--teal); }
.lm-share-note { margin: 0; flex: 1 1 100%; font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--faint); }
@media (max-width: 600px) {
  .lm-rate-bar { padding: 10px 12px; }
  .lm-vote { padding: 0 12px; }
}
