/* LibreHU site: one stylesheet, light / dark from the system, no build step. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #15171c;
  --text-dim: #5b6170;
  --line: #dde1e8;
  --accent: #1a66d9;
  --accent-text: #ffffff;
  --accent-soft: #e3edfc;
  --ok: #1e8e3e;
  --warn: #b26a00;
  --bad: #c5221f;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0f;
    --surface: #17191e;
    --surface-2: #202329;
    --text: #e8eaed;
    --text-dim: #9aa0a6;
    --line: #2c3038;
    --accent: #8ab4f8;
    --accent-text: #0b1b33;
    --accent-soft: #1b2a42;
    --ok: #81c995;
    --warn: #fdd663;
    --bad: #f28b82;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0c0f;
  --surface: #17191e;
  --surface-2: #202329;
  --text: #e8eaed;
  --text-dim: #9aa0a6;
  --line: #2c3038;
  --accent: #8ab4f8;
  --accent-text: #0b1b33;
  --accent-soft: #1b2a42;
  --ok: #81c995;
  --warn: #fdd663;
  --bad: #f28b82;
  --shadow: none;
  color-scheme: dark;
}

/* Language: both texts are in the page, only the chosen one shows (English without JavaScript). */
html:not([data-lang="fr"]) [lang="fr"]:not(html),
html[data-lang="fr"] [lang="en"]:not(html) {
  display: none !important;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 72px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); text-underline-offset: 2px; }
code { font: .9em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
img { max-width: 100%; height: auto; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand svg { width: 28px; height: 28px; }
.bar nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.bar nav::-webkit-scrollbar { display: none; }
.bar nav a { color: var(--text-dim); text-decoration: none; padding: 6px 8px; border-radius: 999px; white-space: nowrap; font-size: 15px; }
.bar nav a:hover, .bar nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex: none; }
.lang button { border: 0; background: transparent; color: var(--text-dim); font: inherit; font-size: 13px; font-weight: 600; padding: 4px 10px; cursor: pointer; }
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }

/* Hero */
.hero { padding: 64px 0 40px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.1; margin: 0 0 16px; letter-spacing: -.02em; }
.hero p.lead { font-size: clamp(17px, 2.2vw, 20px); color: var(--text-dim); max-width: 760px; margin: 0 0 28px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; text-decoration: none;
  background: var(--accent); color: var(--accent-text); border: 1px solid var(--accent);
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 40px; }
.shots figure { margin: 0; }
.shots img { border-radius: 14px; border: 1px solid var(--line); display: block; }
.shots figcaption { font-size: 13px; color: var(--text-dim); margin-top: 6px; }
@media (max-width: 760px) { .shots { grid-template-columns: 1fr; } }

/* Sections */
section { padding: 48px 0; border-top: 1px solid var(--line); }
section h2 { font-size: clamp(24px, 3.5vw, 32px); margin: 0 0 8px; letter-spacing: -.01em; }
section > .wrap > p.sub { color: var(--text-dim); margin: 0 0 28px; max-width: 780px; }
h3 { margin: 0 0 6px; font-size: 18px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card p { margin: 0; color: var(--text-dim); font-size: 15px; }
.card .tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; margin-bottom: 8px; }

/* Tables */
.table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .dl { display: flex; flex-wrap: wrap; gap: 6px; }
.muted { color: var(--text-dim); }
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.nowrap { white-space: nowrap; }

/* Steps */
ol.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
ol.steps > li { counter-increment: s; position: relative; padding: 16px 18px 16px 62px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
ol.steps > li::before { content: counter(s); position: absolute; left: 18px; top: 14px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-weight: 700; display: grid; place-items: center; }

.note { border-left: 4px solid var(--warn); background: var(--surface); border-radius: 0 12px 12px 0; padding: 12px 16px; margin: 20px 0 0; }
.note.info { border-left-color: var(--accent); }

details { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 10px; }
details summary { cursor: pointer; font-weight: 600; }
details p { color: var(--text-dim); margin: 8px 0 0; }

footer { padding: 32px 0 48px; color: var(--text-dim); font-size: 14px; border-top: 1px solid var(--line); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* Long pages (docs, developers): contents on the left, text on the right. */
.doc { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; padding-top: 32px; padding-bottom: 48px; }
.toc { position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 92px); overflow-y: auto; font-size: 14px; }
.toc details { padding: 0; border: 0; background: transparent; margin: 0; }
.toc summary { font-weight: 700; padding: 4px 0 8px; list-style: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 3px 10px; border-left: 2px solid var(--line); color: var(--text-dim); text-decoration: none; }
.toc a:hover { color: var(--text); border-left-color: var(--accent); }
.toc ol ol a { padding-left: 22px; font-size: 13px; }
.doc article { min-width: 0; }
.doc article > h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.1; margin: 0 0 12px; letter-spacing: -.02em; }
.doc article > p.lead { font-size: 18px; color: var(--text-dim); margin: 0 0 24px; }
.doc article h2 { font-size: 26px; margin: 48px 0 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.doc article h3 { font-size: 19px; margin: 28px 0 8px; }
.doc article h4 { font-size: 16px; margin: 20px 0 6px; }
.doc article p, .doc article li { max-width: 820px; }
.doc article ul, .doc article ol:not(.steps) { padding-left: 22px; }
.doc article .table { margin: 12px 0 18px; }
.doc article table { font-size: 14px; }
.doc article td code, .doc article th code { white-space: nowrap; }
pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; overflow-x: auto; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 12px 0 18px; }
pre code { background: none; padding: 0; font-size: inherit; }
.diagram { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; overflow-x: auto; margin: 12px 0 18px; }
.diagram svg { display: block; min-width: 720px; width: 100%; height: auto; }
.status { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.status.done { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.status.wip { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.status.plan { background: var(--surface-2); color: var(--text-dim); }
/* Progress bars of the roadmap (CAN compatibility). */
.progress { margin: 14px 0 6px; }
.progress .label { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; margin-bottom: 6px; }
.progress .label strong { color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress .bar { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.progress .bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.progress .bar.ok > span { background: var(--ok); }
@media (max-width: 900px) {
  .doc { grid-template-columns: 1fr; gap: 16px; }
  .toc { position: static; max-height: none; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
  .toc summary { cursor: pointer; padding: 2px 0; }
  .toc details:not([open]) ol { display: none; }
}

/* Discord and Liberapay links, mobile menu, screen-reader text */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.discord-link { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #5865F2; flex: none; }
.discord-link:hover { background: var(--surface-2); }
/* Liberapay: its yellow square with the dark "lp" cut out, as the official logo */
.liberapay-link { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #1A171B; flex: none; }
.liberapay-link svg { background: #F6C915; border-radius: 4px; }
.liberapay-link:hover { background: var(--surface-2); }
.menu { display: none; border: 0; background: transparent; color: var(--text); width: 40px; height: 40px; border-radius: 10px; padding: 8px; cursor: pointer; flex: none; }
.menu:hover { background: var(--surface-2); }
@media (max-width: 1119px) {
  .bar .wrap { gap: 8px; }
  .bar nav {
    display: none; position: absolute; left: 0; right: 0; top: 60px; margin: 0;
    flex-direction: column; gap: 2px; padding: 8px 16px 16px; overflow: visible;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: 0 12px 24px rgba(0,0,0,.18);
  }
  .bar nav.open { display: flex; }
  .bar nav a { padding: 10px 12px; border-radius: 10px; font-size: 16px; }
  .liberapay-link { margin-left: auto; }
  .lang { margin-left: 0; }
  .menu { display: block; }
}
.community { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.community svg { width: 56px; height: 56px; color: #5865F2; flex: none; }
.community .txt { flex: 1 1 260px; min-width: 0; }
.community h3 { margin: 0 0 4px; }
.community p { margin: 0; color: var(--text-dim); }
.community .count { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.btn.discord { background: #5865F2; border-color: #5865F2; color: #fff; }
.community + .community { margin-top: 16px; }
.community.support svg { color: #1A171B; background: #F6C915; border-radius: 10px; }
.btn.liberapay { background: #F6C915; border-color: #F6C915; color: #1A171B; }
.community .badge { display: block; margin-top: 8px; height: 20px; width: auto; }
/* Small screens: tighter hero and tables */
@media (max-width: 600px) {
  .hero { padding: 36px 0 24px; }
  section { padding: 36px 0; }
  th, td { padding: 8px 10px; }
  .doc article h2 { font-size: 22px; }
  .card { padding: 14px; }
}

/* Screenshot gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 16px; }
.gallery figure { margin: 0; }
.gallery img, .shot-card img { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line); background: #000; }
.gallery figcaption { font-size: 14px; color: var(--text-dim); margin-top: 6px; }
.shot-card { display: block; text-decoration: none; color: inherit; }
.shot-card h3 { margin: 12px 0 4px; }
.shot-card:hover { border-color: var(--accent); }
/* Long identifiers (fingerprints, URIs) wrap in running text instead of widening the page. */
.doc article p code, .doc article li code, .doc article h2 code, .doc article h3 code { overflow-wrap: anywhere; }
.doc article p, .doc article li { overflow-wrap: break-word; }

/* Versions in the download tables (read from GitHub every hour), zips by category. */
.ver { display: block; font-size: 12px; font-weight: 400; color: var(--text-dim); text-decoration: none; margin-top: 2px; font-variant-numeric: tabular-nums; }
a.ver:hover { color: var(--accent); text-decoration: underline; }
#download h3 { margin-top: 32px; }
table.zips tr.cat th { padding-top: 18px; font-size: 13px; letter-spacing: .02em; color: var(--text-dim); background: none; }
.btn small { font-weight: 400; opacity: .75; margin-left: 2px; }

/* Changelog: filter, months, days, one line a change. */
.log-filter { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.log-filter select { font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); max-width: 100%; }
.log details.month { border-top: 1px solid var(--line); }
.log details.month > summary { cursor: pointer; font-weight: 700; font-size: 18px; padding: 14px 0; }
.log .count { color: var(--text-dim); font-weight: 400; font-size: 14px; margin-left: 4px; }
.log h3.day { font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 14px 0 4px; }
.log ul { list-style: none; margin: 0 0 8px; padding: 0; }
.log li { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log .tag { flex: none; width: 8.5em; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim); white-space: nowrap; text-align: center; }
.log a.m { color: var(--text); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.log a.m:hover { text-decoration: underline; }
.log .br { flex: none; color: var(--text-dim); font-size: 12px; }
.log li.rel .tag { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.log li.rel a.m { color: var(--ok); }
@media (max-width: 600px) {
  .log li { flex-wrap: wrap; gap: 4px 8px; }
  .log .tag { width: auto; }
  .log a.m { flex-basis: 100%; }
}

/* Cars decoded with a CAN box (docs.html#can-cars). */
table.cars tr.cat th { padding-top: 18px; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); background: none; white-space: normal; }
table.cars .what { display: block; font-weight: 400; font-size: 13px; color: var(--text-dim); margin-top: 2px; }
table.cars td.since { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.cars td.since small { white-space: normal; color: var(--text-dim); }
table.cars .ok { color: var(--ok); font-weight: 700; }
