/* Shell of the legal pages: static HTML served from /_afk/legal/, beside the
 * injected extension.
 *
 * Two themes, because the visitor arrives here from the application and must
 * not feel they left it. `prefs.js` sets `data-theme` from `?dark`/`?light`,
 * then the stored choice (`afk.theme`), then the operating system. The light
 * values mirror `web/ext/styles/chooser.css` so the two surfaces match; the
 * media query repeats the decision when JavaScript is off. Light values live
 * once, in the `--light-*` constants, so a future tweak cannot drift.
 *
 * The four pages carry both languages in the markup: French is the no-JS
 * fallback, `prefs.js` sets `<html lang>` before the first paint, and the rules
 * below hide the other language. Translation pairs are marked with `lang`, not
 * with a class, so a screen reader gets the right pronunciation too.
 */

:root {
  /* Light palette, copied from the chooser's `[data-theme="light"]`. The link
   * green is deepened: #1fa66a does not reach text contrast on a pale
   * surface. */
  --light-glow: #f2fbf3;
  --light-top: #f2fbf3;
  --light-mid: #e7f5e9;
  --light-bottom: #dbeee0;
  --light-text: #1e2a22;
  --light-muted: #4b5a50;
  --light-body: #3c4b41;
  --light-border: rgba(30, 42, 34, 0.14);
  --light-surface: rgba(255, 255, 255, 0.72);
  --light-code: rgba(30, 42, 34, 0.08);
  --light-link: #006b3c;
  --light-link-hover: #004d2b;
  --light-footer: #6c7d72;
  --light-footer-link: #4b5a50;

  /* Roles. Dark is the brand default, and what a browser without JavaScript
   * gets: the application is dark until told otherwise. */
  color-scheme: dark;
  --bg-glow: #22324a;
  --bg-top: #0b1220;
  --bg-mid: #0b1220;
  --bg-bottom: #070b12;
  --text: #e7edf6;
  --muted: #9fb0c6;
  --body-text: #c9d5e4;
  --border: rgba(255, 255, 255, 0.1);
  --surface: rgba(255, 255, 255, 0.04);
  --code-bg: rgba(255, 255, 255, 0.08);
  --link: #1fa66a;
  --link-hover: #34d399;
  --footer: #71809a;
  --footer-link: #9fb0c6;
  --accent: #008000;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-glow: var(--light-glow);
  --bg-top: var(--light-top);
  --bg-mid: var(--light-mid);
  --bg-bottom: var(--light-bottom);
  --text: var(--light-text);
  --muted: var(--light-muted);
  --body-text: var(--light-body);
  --border: var(--light-border);
  --surface: var(--light-surface);
  --code-bg: var(--light-code);
  --link: var(--light-link);
  --link-hover: var(--light-link-hover);
  --footer: var(--light-footer);
  --footer-link: var(--light-footer-link);
}

/* No JavaScript: follow the operating system. `prefs.js` always sets
 * `data-theme`, so this only covers a browser with scripting disabled. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg-glow: var(--light-glow);
    --bg-top: var(--light-top);
    --bg-mid: var(--light-mid);
    --bg-bottom: var(--light-bottom);
    --text: var(--light-text);
    --muted: var(--light-muted);
    --body-text: var(--light-body);
    --border: var(--light-border);
    --surface: var(--light-surface);
    --code-bg: var(--light-code);
    --link: var(--light-link);
    --link-hover: var(--light-link-hover);
    --footer: var(--light-footer);
    --footer-link: var(--light-footer-link);
  }
}

/* Both languages are in the DOM; only the selected one is rendered. */
html[lang="fr"] [lang="en"],
html[lang="en"] [lang="fr"] {
  display: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  background-color: var(--bg-top);
  background-image: radial-gradient(
    1000px 600px at 10% -10%,
    var(--bg-glow) 0%,
    var(--bg-mid) 55%,
    var(--bg-bottom) 100%
  );
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 48px) clamp(20px, 5vw, 40px) 0;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.brand span {
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0;
  /* The markup keeps a real space (screen readers and copy-paste need it) and
   * the wordmark's tracking trails its last letter: no extra margin needed.
   * check-ui.mjs asserts the credit stays tight against the wordmark. */
  margin-left: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.back {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.back:hover {
  color: var(--text);
}

/* The same FR/EN segmented control as the application's home screen. */
.lang-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.lang-switch a {
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-decoration: none;
}

.lang-switch a[aria-current="true"] {
  background: var(--accent);
  color: #fff;
}

.lang-switch a:not([aria-current="true"]):hover {
  color: var(--text);
}

main {
  padding: 28px 0 52px;
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.15;
}

.lead {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 17px;
}

h2 {
  margin: 32px 0 8px;
  font-size: 18px;
}

p,
li {
  color: var(--body-text);
}

ul {
  padding-left: 20px;
}

code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--code-bg);
  font-size: 0.9em;
}

.todo {
  color: #fbbf24;
  border-bottom: 1px dashed currentColor;
}

.draft {
  margin: 0 0 24px;
  padding: 10px 14px;
  border: 1px solid #b45309;
  border-radius: 10px;
  background: rgba(180, 83, 9, 0.15);
  color: #fcd34d;
  font-size: 13px;
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 20px 0 32px;
  border-top: 1px solid var(--border);
  color: var(--footer);
  font-size: 12px;
}

footer a {
  color: var(--footer-link);
  text-decoration: none;
}

footer a:hover {
  color: var(--text);
}

/* ---- Contact channels --------------------------------------------------- */

.channels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.channels a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.channels a:hover,
.channels a:focus-visible {
  border-color: var(--accent);
  color: var(--text);
}

.channels svg {
  flex: none;
  width: 22px;
  height: 22px;
}

.channels span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channels small {
  color: var(--muted);
  font-size: 12px;
}
