/* feeless.money/exchange – mobile first, no external resources */
/* Colour tokens. Every text/background pair is checked in CI (tests/test_contrast.py):
   body and muted text >= 7:1 (WCAG AAA), everything else >= 4.5:1 (AA), borders >= 3:1.
   Colours are defined ONLY here; the rest of the file uses var(--...). */
:root {
  --bg: #fafaf7; --fg: #111214; --muted: #3b3e43; --line: #82868c; --card: #ffffff;
  --accent: #0a4796; --on-accent: #ffffff; --good: #0b5527; --good-bg: #e2f2e7;
  --warn: #5e3600; --warn-bg: #fff0d1; --bad: #8c1a13; --stale: #45484d; --nano: #0a6aa8;
  --focus: #0a4796;
  --radius: 10px; --gap: 12px;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* night: explicit choice ... */
:root[data-theme="dark"] {
  --bg: #0d0f12; --fg: #f3f3f1; --muted: #cdd1d6; --line: #7a8089; --card: #171a1f;
  --accent: #a6c8ff; --on-accent: #0d0f12; --good: #96e3ae; --good-bg: #0f2618;
  --warn: #ffd685; --warn-bg: #2b220e; --bad: #ffb0a8; --stale: #c2c6cc; --nano: #5cbcf5;
  --focus: #ffd685;
  color-scheme: dark;
}
/* ... or system setting when nothing was chosen (same values as above) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f12; --fg: #f3f3f1; --muted: #cdd1d6; --line: #7a8089; --card: #171a1f;
    --accent: #a6c8ff; --on-accent: #0d0f12; --good: #96e3ae; --good-bg: #0f2618;
    --warn: #ffd685; --warn-bg: #2b220e; --bad: #ffb0a8; --stale: #c2c6cc; --nano: #5cbcf5;
    --focus: #ffd685;
    color-scheme: dark;
  }
}
/* base font 18 px, five steps via the A-/A+ buttons (web/prefs.js) */
html { font-size: 18px; }
html[data-fs="1"] { font-size: 20px; }
html[data-fs="2"] { font-size: 22px; }
html[data-fs="3"] { font-size: 25px; }
html[data-fs="4"] { font-size: 28px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); line-height: 1.5; }
.xc { max-width: 1100px; margin: 0 auto; padding: 16px; overflow-wrap: anywhere; }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 6px; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 28px 0 8px; }
.xc-lead { margin: 0 0 6px; color: var(--muted); }
.xc-message { margin: 0 0 8px; font-weight: 600; }
.xc-lang { display: flex; gap: 10px; font-size: .9rem; }
.xc-lang a[aria-current="true"] { font-weight: 700; text-decoration: none; color: var(--fg); }

/* form */
.xc-form { display: grid; grid-template-columns: 1fr; gap: 8px var(--gap); align-items: end;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 14px 0; }
.xc-f { display: flex; flex-direction: column; gap: 3px; font-size: 0.9rem; color: var(--muted); min-width: 0; }
.xc-amount, .xc-f:has(#payout), .xc-go { grid-column: 1 / -1; }
.xc-form input, .xc-form select { font: inherit; font-size: 1rem; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0; }
.xc-swap { justify-self: center; font-size: 1.3rem; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg); color: var(--fg); cursor: pointer; }
.xc-go { font: inherit; font-weight: 600; padding: 11px; border: 0; border-radius: 8px; background: var(--accent); color: var(--on-accent); cursor: pointer; }
@media (min-width: 720px) {
  .xc-form { grid-template-columns: 1fr 1.2fr auto 1.2fr 1fr auto; }
  .xc-amount, .xc-f:has(#payout), .xc-go { grid-column: auto; }
}

/* notices */
.xc-nano { border-left: 4px solid var(--nano); background: var(--card); padding: 10px 14px; border-radius: 6px; margin: 12px 0; }
.xc-nano strong { display: block; margin-bottom: 4px; }
.xc-market { font-size: .9rem; color: var(--muted); margin: 8px 0; }
.xc-filters { border: 0; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .92rem; }
.xc-filters legend { font-weight: 600; float: left; margin-right: 8px; padding: 0; }
.xc-note, .xc-hint { font-size: 0.9rem; color: var(--muted); }
.xc-warn { background: var(--warn-bg); color: var(--warn); border-radius: 6px; padding: 4px 8px; font-size: 0.9rem; margin: 4px 0; }

/* sort bar is the mobile replacement for clickable headers */
.xc-sortbar { display: flex; gap: 8px; align-items: center; font-size: .9rem; margin: 6px 0 10px; flex-wrap: wrap; }
.xc-sortbar select { font: inherit; padding: 5px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--fg); max-width: 100%; }
.xc-btn-small, .xc-btn { font: inherit; font-size: 0.9rem; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); cursor: pointer; text-decoration: none; display: inline-block; }
.xc-btn-aff { border-color: var(--nano); }

/* route table: cards on phones, table from 720 px */
.xc-table { width: 100%; border-collapse: collapse; }
.xc-table caption { text-align: left; font-size: 0.9rem; color: var(--muted); padding-bottom: 4px; }
.xc-table thead { display: none; }
.xc-table tr.xc-row { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 10px 12px; }
.xc-table td { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border: 0; text-align: right; }
.xc-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.9rem; text-align: left; flex: 0 0 auto; }
.xc-table td.c-route { display: block; text-align: left; }
.xc-table td.c-route::before { content: none; }
.xc-table td.c-final { font-size: 1.15rem; font-weight: 700; }
.xc-row.is-stale { border-style: dashed; }
.xc-row.is-stale td.c-final { color: var(--stale); }
@media (min-width: 720px) {
  .xc-sortbar { display: none; }
  .xc-table thead { display: table-header-group; }
  .xc-table tr.xc-row { display: table-row; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: none; }
  .xc-table td, .xc-table th { display: table-cell; padding: 8px 6px; vertical-align: top; text-align: right; }
  .xc-table td::before { content: none; }
  .xc-table th { font-size: 0.9rem; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 2px solid var(--line); }
  .xc-table th.c-route, .xc-table td.c-route { text-align: left; }
  .xc-table td.c-final { font-size: 1rem; }
  .xc-table th button { all: unset; cursor: pointer; }
  .xc-table th button:focus-visible { outline: 2px solid var(--accent); }
  .xc-table th[aria-sort="ascending"] button::after { content: " ▲"; }
  .xc-table th[aria-sort="descending"] button::after { content: " ▼"; }
}
.c-route .xc-short { font-weight: 600; }
.xc-gain { color: var(--good); background: var(--good-bg); border-radius: 4px; padding: 0 5px; font-weight: 600; }
.xc-small { font-size: 0.9rem; color: var(--muted); }
.xc-badge { display: inline-block; font-size: 0.9rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; margin: 1px 2px; white-space: nowrap; color: var(--muted); }
.xc-badge.k-executable { border-color: var(--good); color: var(--good); }
.xc-badge.k-manual { border-color: var(--warn); color: var(--warn); }
.xc-badge.f-stale, .xc-badge.f-manual_old, .xc-badge.f-unverified { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.xc-badge.f-expired, .xc-badge.f-nodata { background: none; color: var(--bad); border-color: var(--bad); }
.xc-actions { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }

/* step details */
.xc-steps summary { cursor: pointer; font-size: 0.9rem; color: var(--accent); margin-top: 4px; }
.xc-steps ol { margin: 6px 0 0; padding-left: 20px; font-size: 0.9rem; }
.xc-steps li { margin-bottom: 8px; }
.xc-steps dl { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; margin: 2px 0; }
.xc-steps dt { color: var(--muted); }
.xc-steps dd { margin: 0; }

/* simple tables (buy, sources, intermediates) -> stacked on phones */
.xc-simple { width: 100%; border-collapse: collapse; font-size: .9rem; }
.xc-simple th, .xc-simple td { padding: 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.xc-simple th { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
@media (max-width: 719px) {
  .xc-simple thead { display: none; }
  .xc-simple tr { display: block; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 6px 10px; background: var(--card); }
  .xc-simple td { display: flex; justify-content: space-between; gap: 10px; border: 0; padding: 2px 0; text-align: right; }
  .xc-simple td::before { content: attr(data-label); color: var(--muted); text-align: left; }
}

.xc-unranked { margin-top: 10px; }
.xc-unranked summary { cursor: pointer; font-weight: 600; }
.xc-unranked .xc-table tr.xc-row { border-style: dashed; }

/* ads */
.xc-ad { margin: 16px 0; }
.xc-ad:empty { display: none; }
.xc-ad-box { border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px; text-align: center; font-size: .9rem; color: var(--muted); }
.xc-ad-box img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.xc-ad-label { font-size: 0.9rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.xc-faq details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.xc-faq summary { cursor: pointer; font-weight: 600; }
.xc-foot { margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.9rem; color: var(--muted); }
.xc-error { color: var(--bad); font-weight: 600; }
.xc-spend-group ul { padding-left: 18px; }
.xc-spend-group li { margin-bottom: 6px; }
.xc-center { justify-content: center; }
/* stats viewer */
.xc-form-stats { grid-template-columns: 1fr; }
.xc-wide { grid-column: 1 / -1; }
.xc-scroll { overflow-x: auto; }
.xc-stats td, .xc-stats th { white-space: nowrap; }
.xc-keys code { word-break: break-all; }
.xc-stats { border-collapse: collapse; font-size: 0.9rem; }
.xc-stats th, .xc-stats td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.xc-stats th[scope="row"] { text-align: left; color: var(--muted); font-weight: 600; }
.xc-chain { font-size: 0.9rem; color: var(--muted); margin-top: 2px; }
.xc-missing { font-size: 0.9rem; color: var(--warn); margin-top: 2px; }

/* day/night + font size toolbar */
.xc-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 4px; }
.xc-tools button { font: inherit; font-size: 1rem; font-weight: 600; min-height: 44px; min-width: 44px; padding: 6px 14px;
  border-radius: 8px; border: 2px solid var(--fg); background: var(--card); color: var(--fg); cursor: pointer; }
.xc-tools button:disabled { border-style: dashed; cursor: default; }
.xc-tools .xc-theme { border-color: var(--accent); color: var(--accent); }
input[type="checkbox"] { width: 1.25em; height: 1.25em; accent-color: var(--accent); vertical-align: -0.2em; }

/* Embedded in NanoTracker (?embed=1): theme comes from the parent page, so no own theme button */
:root[data-embed="1"] .xc-tools .xc-theme { display: none; }
