/* DESIGN-AUDIT (2026-11-26): table, layout and contrast fixes found by the site-wide audit
   (research_raw/design-audit-2026-11-26/). Loaded after style.css from base.html; every rule is scoped
   so it only touches what the audit found. Several old rules lost to `table.data td { white-space: nowrap }`
   (0,1,2) — .price-summary, .mcp-table td, .deal-past td — so the fixes below restate them with a
   stronger selector. */

/* 1. Data tables: on desktop, text cells wrap instead of pushing the table past its box.
      Names (first column, .name-cell) stay on one line. Auto table layout keeps every cell on one line while there is room, so tables that fit are unchanged.
      Phones keep one-line rows and scroll inside .table-wrap, as before. */
@media (min-width: 1024px) {
  table.data td.l:not(:first-child):not(:has(.name-cell)) { white-space: normal; }
}
table.data.mcp-table td.l.small { white-space: normal; }

/* 2. /pricing/ on desktop: the main table fits the page and "What you get" is a readable column, not a cut-off strip.
      Phones and tablets keep one-line rows that scroll inside the table box, as before. */
@media (min-width: 1024px) {
  table.price-table td.price-summary { white-space: normal; width: 30%; min-width: 15em; }
  table.price-table td.price-summary summary { overflow-wrap: anywhere; }
  table.price-table td:nth-child(4) { white-space: normal; width: 11em; min-width: 7em; }
  table.price-table td:first-child { white-space: normal; width: 14em; min-width: 11em; }
  table.price-table td:first-child .name-cell { min-width: 0; }
  table.price-table td:first-child .name-cell a { overflow-wrap: anywhere; }
}

/* 3. Dated lists in a card (/pricing/ "Recent price changes", /status/<agent>/ incidents):
      inner padding like other cards, the date column as wide as the date (the inline 18% / 22% left a gap) */
table.facts.card { border-collapse: separate; border-spacing: 0; overflow: hidden; }
table.facts.card th[scope="row"] { width: 1% !important; white-space: nowrap; padding: 11px 28px 11px 18px; }
table.facts.card td { padding: 11px 18px 11px 0; }
@media (max-width: 640px) {
  table.facts.card { table-layout: auto; }
  table.facts.card th[scope="row"] { padding: 10px 14px 10px 14px; }
  table.facts.card td { padding: 10px 14px 10px 0; }
}

/* 4. /deals/ "Ended recently": text columns left-aligned (table.data right-aligns numbers),
      the offer wraps, and on phones the table scrolls in its own box instead of being cut at the page edge */
table.data.deal-past th, table.data.deal-past td { text-align: left; }
table.data.deal-past td { white-space: normal; }
table.data.deal-past td:nth-child(2) { min-width: 14em; }
table.data.deal-past td:nth-child(3) { white-space: nowrap; }
@media (max-width: 720px) {
  table.data.deal-past { display: block; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
  table.data.deal-past td:nth-child(2) { min-width: 12em; }
}

/* 5. Fact tables: long numbers ("118,387 in 30 days · 1,217,110 in a year") wrap on tablets too;
      on phones a row label with an inline width (16%) no longer squeezes "Homebrew" into 46 px */
.facts td.num { white-space: normal; }
@media (max-width: 640px) {
  .facts th[scope="row"][style*="width"] { width: 34% !important; }
  .facts th { hyphens: auto; -webkit-hyphens: auto; }
}

/* 6. KPI tiles (agent pages): no lone fifth tile on tablets, two per row on phones */
@media (min-width: 641px) and (max-width: 1100px) {
  .kpis:has(> .kpi:nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpis .kpi { padding: 12px 14px; }
  .kpis .kpi .value { font-size: 1.3rem; }
}

/* 7. Contrast (WCAG AA 4.5:1 for small text) */
:root { --da-pill-green: #0d7f0d; --da-flag-amber: #8f5d12; }
/* green "Promo" / "Hot now" pills and the amber "price changed" flag: white text was 3.35:1 and 3.64:1 */
.promo-pill, .dl-flame { background: var(--da-pill-green); }
.home-deals .dl-flame { background: linear-gradient(120deg, var(--accent), #8b5cf6); }
.cr-price-ch { background: var(--da-flag-amber); }
/* /deals/ big green numbers (2.74:1) and the amber "showcase" label (4.02:1) in the light theme */
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) :is(.dc-usage_boost, .dc-free_access) .dc-big { color: var(--da-pill-green); } }
:root[data-theme="light"] :is(.dc-usage_boost, .dc-free_access) .dc-big { color: var(--da-pill-green); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) :is(.dc-student, .dc-open_source) .dc-big { color: #157a55; } }
:root[data-theme="light"] :is(.dc-student, .dc-open_source) .dc-big { color: #157a55; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .uc-kicker .t-showcase { color: #9a5c00; } }
:root[data-theme="light"] .uc-kicker .t-showcase { color: #9a5c00; }
:root dd.ar-reuse-conditions { color: #9a5c00 !important; }
/* skill pages used var(--muted, #6b7280): --muted does not exist, so the grey fallback was 3.3–4.0:1 in the dark theme */
:root .sc-src, :root .ed-box h4 { color: var(--meta); }

/* dark theme: white text on the accent fill was 3.64:1; filled buttons and badges get a deeper blue (5.0:1),
   links and accent text keep the lighter accent */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --da-fill: #2a6fc4; }
  :root:not([data-theme="light"]) :is(.signup-btn, .gh-search button, .gh-pick a, .gh-track a, .tl-search button, .tl-apply, .tl-btn, .ap-search button, .ap-apply, .ap-btn, .ar-search button, .ar-apply,
    .picker-row .btn.primary, .picker .btn.primary, .match-actions .btn.primary, .btn.big, .btn-out, .lp-btn.primary, .au-submit, .dx-run, .news-pin, .mv.new,
    .gf-kicker .new, .uc-kicker .new, .ch-kicker .new, .st-new) { background-color: var(--da-fill); border-color: var(--da-fill); }
  :root:not([data-theme="light"]) .status-pill.s-major { color: #f2a25c; }
  :root:not([data-theme="light"]) .news-kind.k-discussion { color: #ef8a45; }
  :root:not([data-theme="light"]) .status-pill.s-none { color: #3cc13c; }
}
:root[data-theme="dark"] { --da-fill: #2a6fc4; }
:root[data-theme="dark"] :is(.signup-btn, .gh-search button, .gh-pick a, .gh-track a, .tl-search button, .tl-apply, .tl-btn, .ap-search button, .ap-apply, .ap-btn, .ar-search button, .ar-apply,
  .picker-row .btn.primary, .picker .btn.primary, .match-actions .btn.primary, .btn.big, .btn-out, .lp-btn.primary, .au-submit, .dx-run, .news-pin, .mv.new,
  .gf-kicker .new, .uc-kicker .new, .ch-kicker .new, .st-new) { background-color: var(--da-fill); border-color: var(--da-fill); }
:root[data-theme="dark"] .status-pill.s-major { color: #f2a25c; }
:root[data-theme="dark"] .news-kind.k-discussion { color: #ef8a45; }
:root[data-theme="dark"] .status-pill.s-none { color: #3cc13c; }

/* 8. Skill pages, the "Skills in <pack>" list (table.sc-t inside .table-wrap): overflow-wrap:anywhere (SKILLCARD-MOBILE)
      let the browser shrink columns to one letter, so names and headers broke mid-word ("acade/my-guide", "Cha/nges").
      break-word still wraps long words when it must, but sizes columns by whole words. Other sc-t tables keep anywhere
      (their long paths need it). On phones the list becomes one card per skill. */
:root .table-wrap > table.sc-t th, :root .table-wrap > table.sc-t td { overflow-wrap: break-word; }
:root .table-wrap > table.sc-t td code { overflow-wrap: anywhere; }
@media (max-width: 719px) {
  :root .table-wrap > table.sc-t, :root .table-wrap > table.sc-t tbody, :root .table-wrap > table.sc-t tr, :root .table-wrap > table.sc-t td { display: block; }
  :root .table-wrap > table.sc-t tr:first-child:has(th) { display: none; }
  :root .table-wrap > table.sc-t tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  :root .table-wrap > table.sc-t tr:last-child { border-bottom: 0; }
  :root .table-wrap > table.sc-t td { border: 0; padding: 2px 0; }
  :root .table-wrap > table.sc-t td.sc-k-plain { color: var(--ink); }
  :root .table-wrap > table.sc-t td.sc-k-changes { color: var(--meta); font-size: 13px; }
  :root .table-wrap > table.sc-t td.sc-k-changes::before { content: "Changes files: "; }
  :root .table-wrap > table.sc-t td.sc-k-desc { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
}
/* SKILL-PACK-TABLE: "Show all N skills" under a pack list folded to 5 rows (quiet button, like other section buttons) */
.sc-fold-btn { display: block; margin: 10px 0 0; padding: 9px 16px; min-height: 44px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--link); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.sc-fold-btn:hover { background: var(--surface-2); }
.sc-fold-btn[hidden] { display: none; }
:root .table-wrap > table.sc-t td.sc-k-name b { font-weight: 650; }

/* Other sc-t tables on skill pages ("May I use it like this?", "Which one to pick"): headers and short cells
   ("Answer", "conditions") broke mid-word on phones; the last column keeps anywhere for long paths. */
:root table.sc-t th, :root table.sc-t td:not(:last-child) { overflow-wrap: break-word; }
:root .table-wrap > table.sc-t tr[hidden] { display: none; }

/* 9. TOOLS-AVATAR: project icons in the /tools/ hub (templates/_tools_hub.html). card_icon() brings a 40 px inline-styled
      <img>, so the sizes here need !important; rows without a cached icon get a same-size initials tile. */
.tl-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px; vertical-align: -6px; flex: none; }
.tl-ico img.card-icon { width: 22px !important; height: 22px !important; margin: 0 !important; vertical-align: 0 !important; border-radius: 6px !important; }
.tl-ico-l { border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 9px; font-weight: 700; color: var(--ink-2); line-height: 1; }
.tl-logo.tl-logo-img { background: none; border: 0; overflow: hidden; }
.tl-logo.tl-logo-img img.card-icon { width: 34px !important; height: 34px !important; margin: 0 !important; vertical-align: 0 !important; border-radius: 9px !important; }
.tp-bars th .tl-nm { display: inline-flex; align-items: flex-start; gap: 7px; }
.tp-bars th .tl-nm .tl-ico { margin: 0; vertical-align: 0; width: 20px; height: 20px; }
.tp-bars th .tl-nm .tl-ico img.card-icon { width: 20px !important; height: 20px !important; }
.th-race .tp-bars th:has(.tl-nm) { width: 54%; }

/* 10. ASSETS-AVATAR: icon next to each source name in the /assets/ tables (templates/assets.html). Fixed 28 px for the
       image and the letter tile alike, so rows do not shift while icons load (SEO thread: no CLS). */
.as-nm { display: flex; align-items: flex-start; gap: 10px; }
.as-nm-t { min-width: 0; }
.as-ico { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-top: 1px; }
.as-ico img.card-icon { width: 28px !important; height: 28px !important; margin: 0 !important; vertical-align: 0 !important; border-radius: 7px !important; }
.as-ico-l { border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--ink-2); }
/* APIS-AVATAR: the /apis/ hub card tile shows the project icon when we have one (same 40 px box as the initials) */
.ap-logo.ap-logo-img { background: none; border: 0; overflow: hidden; }
.ap-logo.ap-logo-img img.card-icon { width: 40px !important; height: 40px !important; margin: 0 !important; vertical-align: 0 !important; border-radius: 10px !important; }

/* 11. IMPECCABLE-PASS (2026-11-27): findings of the Impeccable detector on 12 key pages at 1280 and 390 px. */
/* functional text under 11 px: tools list metric labels, home table headers, badges and pills */
:root .tl-m dt { font-size: 11.5px; letter-spacing: .2px; }
:root .gh-thead, :root .gh-lhead { font-size: 11px; }
:root .gh-edate small { font-size: 11px; }
:root .promo-pill, :root .cr-flag { font-size: 11px; }
:root .new-badge, :root .news-hot, :root .news-pin, :root .case-type { font-size: 11px; }
/* placeholders: the browser grey #757575 was 4.49:1 on the page surface; --meta is 5.3:1 (light) / 7.6:1 (dark) */
:root input::placeholder, :root textarea::placeholder { color: var(--meta); opacity: 1; }
/* reading measure: paragraphs in .prose (76ch box ≈ 105 characters a line) stay near 70 characters; tables and figures keep the full width */
:root .prose > p, :root .prose > ul, :root .prose > ol, :root .prose > blockquote, :root .faq details > p { max-width: 68ch; }
/* no lone last word in paragraphs, balanced multi-line headings (deal card titles, section heads); browsers without support ignore it */
:root main :is(p, li, dd, figcaption) { text-wrap-style: pretty; }  /* longhand: the text-wrap shorthand would also reset nowrap */
:root main :is(h1, h2, h3, .dc-title) { text-wrap-style: balance; }
/* skill cards: sub-headings sat 1 px under the block above and 16 px over their own content */
:root .sc-h4 { margin-top: 24px; }
