/*
 * Flit documentation.
 *
 * The same rules as the console, so the two read as one product: one neutral
 * ramp, one accent, hairlines and space instead of boxes and shadows, the
 * system's own type. Colour means something or is not used. The measure is
 * kept to what a line of prose can bear; code is allowed to be wider.
 */

:root {
  color-scheme: light;

  --surface: #ffffff;
  --plane: #f9f9f9;
  --code: #f6f6f6;
  --hover: #f4f4f4;

  --line: #e7e7e7;
  --line-strong: #d0d0d0;

  --ink: #191919;
  --ink-2: #5f5f5f;
  --ink-3: #8a8a8a;

  --accent: #1d6fd0;
  --accent-wash: #eef4fd;

  --good-ink: #00630f;      --good-wash: #e8f6ea;
  --warning-ink: #7a5200;   --warning-wash: #fff4d9;
  --critical-ink: #b3261e;  --critical-wash: #fdeceb;

  --button: #191919;
  --button-ink: #ffffff;

  --radius: 6px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --top: 52px;
  --side: 248px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --surface: #191919;
    --plane: #121212;
    --code: #212121;
    --hover: #232323;

    --line: #303030;
    --line-strong: #474747;

    --ink: #efefef;
    --ink-2: #a8a8a8;
    --ink-3: #7c7c7c;

    --accent: #6aabf1;
    --accent-wash: #1c2a3d;

    --good-ink: #6fd57c;      --good-wash: #15301a;
    --warning-ink: #f5c558;   --warning-wash: #3a2e10;
    --critical-ink: #f08a8a;  --critical-wash: #3d1c1c;

    --button: #efefef;
    --button-ink: #191919;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 20px); }
body { margin: 0; background: var(--surface); color: var(--ink); font: 15px/1.6 var(--sans); }
h1, h2, h3, p, ul, ol, dl, dd, figure, pre { margin: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
code, pre { font-family: var(--mono); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 30; background: var(--surface); padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); }

/* --- The bar across the top ------------------------------------------------ */

.top {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand b { font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.brand span { font-size: 13px; color: var(--ink-3); }
.top nav { display: flex; align-items: center; gap: 20px; font-size: 13.5px; }
.top nav a { color: var(--ink-2); }
.top nav a:hover { color: var(--ink); text-decoration: none; }
.top nav a.cta {
  color: var(--button-ink); background: var(--button); padding: 6px 12px; border-radius: var(--radius); font-weight: 500;
}

/* --- Three columns: where you are, the page, what is on it ----------------- */

.frame {
  display: grid; grid-template-columns: var(--side) minmax(0, 1fr) 200px;
  max-width: 1320px; margin: 0 auto;
}

.side {
  position: sticky; top: var(--top); align-self: start;
  height: calc(100vh - var(--top)); overflow-y: auto;
  padding: 24px 16px 40px 24px; border-right: 1px solid var(--line);
}
.side .group + .group { margin-top: 22px; }
.side h2 { font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 0 8px 6px; }
.side ul { list-style: none; }
.side a, .side .soon { display: block; padding: 5px 8px; border-radius: var(--radius); font-size: 14px; color: var(--ink-2); }
.side a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.side a[aria-current="page"] { background: var(--accent-wash); color: var(--accent); font-weight: 500; }
.side .soon { color: var(--ink-3); }
.side .soon small { font-size: 11px; margin-left: 4px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.side .out { font-size: 11px; color: var(--ink-3); }

main { min-width: 0; padding: 40px 48px 72px; }
article { max-width: 720px; }

.toc { position: sticky; top: var(--top); align-self: start; padding: 44px 24px 24px 0; font-size: 13px; }
.toc h2 { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; }
.toc ul { list-style: none; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 3px 0 3px 12px; color: var(--ink-2); }
.toc a:hover { color: var(--ink); text-decoration: none; }

/* --- Prose ----------------------------------------------------------------- */

article h1 { font-size: 30px; line-height: 1.2; font-weight: 650; letter-spacing: -0.02em; }
article .lead { font-size: 17px; line-height: 1.55; color: var(--ink-2); margin-top: 10px; }
article h2 { font-size: 20px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; margin-top: 44px; padding-top: 4px; }
article h3 { font-size: 15.5px; font-weight: 650; margin-top: 28px; }
article p, article ul, article ol, article table, article .callout, article dl { margin-top: 14px; }
article ul, article ol { padding-left: 22px; }
article li + li { margin-top: 6px; }
article strong { font-weight: 600; }
article :not(pre) > code {
  font-size: 0.88em; background: var(--code); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere;
}

article table { width: 100%; border-collapse: collapse; font-size: 14px; }
article th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-2); padding: 8px 12px 8px 0; border-bottom: 1px solid var(--line-strong); }
article td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
article td:first-child { white-space: nowrap; }
.scroll { overflow-x: auto; }

.callout { padding: 12px 14px; border-radius: var(--radius); background: var(--plane); border: 1px solid var(--line); font-size: 14px; }
.callout b { font-weight: 600; }
.callout.warning { background: var(--warning-wash); border-color: transparent; color: var(--warning-ink); }
.callout.warning a { color: inherit; text-decoration: underline; }

/* A numbered path: the page's own table of what to do, in order. */
.path { list-style: none; padding: 0; margin-top: 20px; border-top: 1px solid var(--line); counter-reset: step; }
.path li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: 0 12px; padding: 14px 0; border-bottom: 1px solid var(--line); margin: 0; }
.path li::before { content: counter(step); font: 600 13px/22px var(--sans); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.path a, .path .title { font-weight: 600; color: var(--ink); }
.path a:hover { color: var(--accent); text-decoration: none; }
.path p { grid-column: 2; margin-top: 2px; color: var(--ink-2); font-size: 14px; }
.path .soon { font-size: 11px; font-weight: 400; color: var(--ink-3); margin-left: 4px; padding: 1px 6px; border: 1px solid var(--line); border-radius: 999px; vertical-align: 1px; }
.path .title { color: var(--ink-2); }

/* What to do with each answer: the word, then the instruction. */
.verdicts { margin-top: 18px; border-top: 1px solid var(--line); }
.verdicts > div { display: grid; grid-template-columns: 150px 1fr; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.verdicts dt { font: 500 13px/1.6 var(--mono); }
.verdicts dd { color: var(--ink-2); font-size: 14.5px; }
.verdicts dd b { color: var(--ink); font-weight: 600; }
.tag { display: inline-block; font: 500 12px/1 var(--sans); padding: 4px 7px; border-radius: 4px; }
.tag.block { background: var(--critical-wash); color: var(--critical-ink); }
.tag.hold { background: var(--warning-wash); color: var(--warning-ink); }
.tag.allow { background: var(--good-wash); color: var(--good-ink); }

/* --- A request and its answer ---------------------------------------------- */

.example { margin-top: 20px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.example figcaption { padding: 9px 14px; font: 12.5px/1.4 var(--mono); border-bottom: 1px solid var(--line); background: var(--plane); overflow-wrap: anywhere; }
.example .verb { font-weight: 600; margin-right: 6px; }
.example .route { color: var(--ink-2); }

.tabs { display: flex; gap: 2px; padding: 6px 8px 0; border-bottom: 1px solid var(--line); }
.tabs button {
  appearance: none; border: 0; background: none; cursor: pointer; color: var(--ink-2);
  font: 500 13px/1 var(--sans); padding: 8px 10px 9px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

pre { position: relative; font-size: 13px; line-height: 1.55; padding: 14px 16px; overflow-x: auto; background: var(--surface); tab-size: 2; }
article > pre { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--code); }
.copy {
  position: absolute; top: 8px; right: 8px; cursor: pointer;
  font: 500 12px/1 var(--sans); color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 5px; padding: 5px 8px;
}
.copy:hover { color: var(--ink); background: var(--hover); }

.response { border-top: 1px solid var(--line); }
.response .bar { padding: 8px 14px; font-size: 12.5px; color: var(--ink-2); background: var(--plane); border-bottom: 1px solid var(--line); }
.response .status { font: 600 12px/1 var(--mono); color: var(--good-ink); background: var(--good-wash); padding: 3px 6px; border-radius: 4px; margin-right: 6px; }
.response .note { color: var(--ink-3); margin-left: 6px; }
.response .note::before { content: "· "; }
.response pre { background: var(--code); }
.whole { border-top: 1px solid var(--line); }
.whole summary { cursor: pointer; padding: 8px 14px; font-size: 12.5px; color: var(--ink-2); background: var(--plane); }
.whole summary:hover { color: var(--ink); }
.whole pre { max-height: 420px; border-top: 1px solid var(--line); }

/* --- Before and after ------------------------------------------------------ */

.pager { max-width: 720px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-weight: 500; }
.pager a:hover { border-color: var(--line-strong); text-decoration: none; }
.pager small { display: block; font-size: 12px; font-weight: 400; color: var(--ink-3); }
.pager .next { text-align: right; }

/* --- Narrow screens -------------------------------------------------------- */

@media (max-width: 1120px) {
  .frame { grid-template-columns: var(--side) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 760px) {
  .top { padding: 0 16px; }
  .top nav a:not(.cta) { display: none; }
  .frame { display: block; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; }
  .side .group { display: inline-block; vertical-align: top; margin: 0 20px 8px 0; }
  .side .group + .group { margin-top: 0; }
  main { padding: 28px 16px 56px; }
  article h1 { font-size: 26px; }
  .verdicts > div { grid-template-columns: 1fr; gap: 2px; }
  article td:first-child { white-space: normal; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}

@media print {
  .top, .side, .toc, .pager, .copy, .tabs { display: none; }
  .frame { display: block; }
  [role="tabpanel"][hidden] { display: none; }
}

/* The catalogue of findings: three columns do not fit a phone without
   breaking a code in the middle, so each finding stacks there instead. */
.findings td:first-child code { white-space: nowrap; }
@media (max-width: 640px) {
  .findings thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .findings, .findings tbody, .findings tr, .findings td { display: block; }
  .findings tr { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .findings td { padding: 0; border: 0; }
  .findings td + td { margin-top: 4px; }
  .findings td:last-child { color: var(--ink-3); font-size: 13px; }
}
