/*
  The guides of fruitback.com (docs/_layouts/docs.html), after the board « Fruitback Docs » of FRU-417.
  The colours are the board's: ink #1c1917 on #faf9f5, body #44403c, muted #736c67, lines #e7e5e4, and
  code on #1c1917. Each text colour holds 4.5:1 at least on the surface it sits on, the Rouge palette of
  the code blocks included (docs-site.test.ts computes each one).

  Text wraps the way the landing does (widget.md, FRU-350): content wraps anywhere, so a selector or an
  address stays in its box; a code block scrolls in its own box instead.
*/
:root {
  --page: #faf9f5;
  --surface: #ffffff;
  --inset: #fafaf9;
  --chip: #f5f5f4;
  --line: #e7e5e4;
  --edge: #8f8883;
  --ink: #1c1917;
  --body: #44403c;
  --muted: #736c67;
  --accent: #dd2c27;
  --link: #b91c1c;
  --code-surface: #1c1917;
  --code-text: #e7e5e4;
  --code-line: #44403c;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

/* A link to another guide fades from one page to the next, where the browser can (FRU-440). */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  @view-transition {
    navigation: none;
  }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font:
    16px/1.6 -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

img {
  max-width: 100%;
  height: auto;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
  z-index: 10;
}

.skip:focus {
  top: 12px;
}

/* The header. */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  min-height: 64px;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  display: block;
}

.pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--body);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 360px;
}

.top-nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--body);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.top-nav a:hover,
.top-nav a[aria-current] {
  background: var(--chip);
  color: var(--ink);
}

.top-nav a[aria-current] {
  font-weight: 600;
}

.top-end {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-link {
  color: var(--body);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.top-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.button-outline {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

/* The sidebar, the page and « On this page ». */
.frame {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
}

.side {
  flex: 0 0 280px;
  border-right: 1px solid var(--line);
}

.side nav {
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  padding: 28px 16px 40px 24px;
}

.side-group + .side-group {
  margin-top: 22px;
}

.side-title {
  margin: 0;
  padding: 0 10px 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.side ul,
.side-small ul,
.toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.side li a,
.side-small li a {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--body);
  font-size: 14px;
  line-height: 1.35;
  text-decoration: none;
}

.side li a:hover,
.side-small li a:hover {
  color: var(--ink);
  background: var(--chip);
}

.side li a[aria-current='page'],
.side-small li a[aria-current='page'] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  box-shadow:
    0 0 0 1px var(--line),
    0 1px 2px rgba(28, 25, 23, 0.06);
}

.out {
  color: var(--muted);
}

.main {
  display: flex;
  flex: 1 1 auto;
  gap: 40px;
  min-width: 0;
  padding: 40px 32px 80px;
}

.side-small {
  display: none;
}

.page {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 760px;
}

.toc {
  flex: 0 0 220px;
  align-self: flex-start;
  position: sticky;
  top: 24px;
}

.toc .side-title {
  padding-left: 12px;
}

.toc li a {
  display: block;
  padding: 5px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-decoration: none;
}

.toc li a:hover {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
}

.toc ul {
  margin-bottom: 10px;
}

.improve {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 14px 12px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.improve a {
  color: var(--body);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.improve a:hover {
  text-decoration: underline;
}

.crumbs {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
}

.crumbs a {
  color: var(--muted);
}

.crumb-here {
  color: var(--ink);
  font-weight: 600;
}

/* The page itself: what the markdown becomes. */
.prose {
  color: var(--body);
  font-size: 15px;
  line-height: 1.7;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  color: var(--ink);
  letter-spacing: -0.02em;
}

.prose h1 {
  margin: 0 0 16px;
  font-size: clamp(32px, 4vw, 44px);
  line-height: 1.08;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.prose h1 + p {
  font-size: 19px;
  line-height: 1.55;
}

.prose h2 {
  margin: 48px 0 14px;
  font-size: 26px;
  line-height: 1.2;
  font-weight: 700;
}

.prose h3 {
  margin: 32px 0 10px;
  font-size: 19px;
  line-height: 1.3;
  font-weight: 700;
}

.prose h4 {
  margin: 24px 0 8px;
  font-size: 16px;
}

.prose p,
.prose ul,
.prose ol,
.prose table,
.prose blockquote,
.prose .highlighter-rouge,
.prose pre {
  margin: 0 0 16px;
}

.prose li + li {
  margin-top: 4px;
}

.prose strong {
  color: var(--ink);
}

.prose hr {
  margin: 40px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.prose code {
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--chip);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.87em;
}

/* A code block: dark, with its own scroll, and « Copy » in its corner when the script ran. */
.prose .highlighter-rouge,
.prose .code-box {
  position: relative;
  margin: 0 0 16px;
}

.prose pre {
  overflow-x: auto;
  padding: 14px 18px;
  border-radius: 14px;
  background: var(--code-surface);
  color: var(--code-text);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: normal;
  white-space: pre;
}

.prose .highlighter-rouge pre,
.prose .code-box pre {
  margin: 0;
}

/* The button covers no text: a block that has one keeps room for it on its first line. */
.prose .copy + pre,
.prose .copy + .highlight pre {
  padding-right: 88px;
}

.prose pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 12px;
  border: 1px solid #78716c;
  border-radius: 999px;
  background: var(--code-surface);
  color: var(--code-text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.copy:hover {
  border-color: var(--code-text);
}

/*
  The Rouge palette on #1c1917: comments #a8a29e 6.9:1, strings #a5d6a7 10.6:1, keywords #f9a8a8 9.3:1,
  names #fcd38d 12.4:1, numbers and builtins #93c5fd 9.7:1, tags #86efac 12.5:1.
*/
.highlight .c,
.highlight .c1,
.highlight .cm,
.highlight .cp,
.highlight .cs,
.highlight .cd,
.highlight .gh,
.highlight .gu {
  color: #a8a29e;
}
.highlight .nb,
.highlight .bp,
.highlight .na,
.highlight .no,
.highlight .ss,
.highlight .m,
.highlight .mi,
.highlight .mf,
.highlight .mh,
.highlight .mo,
.highlight .il {
  color: #93c5fd;
}
.highlight .nv,
.highlight .vc,
.highlight .vg,
.highlight .vi,
.highlight .nn,
.highlight .nc,
.highlight .nf,
.highlight .ne {
  color: #fcd38d;
}
.highlight .s,
.highlight .s1,
.highlight .s2,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr {
  color: #a5d6a7;
}
.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt,
.highlight .o,
.highlight .ow {
  color: #f9a8a8;
}
.highlight .nt {
  color: #86efac;
}
.highlight .err {
  color: inherit;
  background: none;
}

/* A table scrolls in its own box rather than pushing the page sideways. */
.prose table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}

.prose th,
.prose td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--inset);
  color: var(--ink);
  font-weight: 650;
}

.prose td {
  background: var(--surface);
}

.prose td code,
.prose th code {
  overflow-wrap: normal;
}

/* A quote is a callout, the « Note » of the board. */
.prose blockquote {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--inset);
  color: var(--body);
  font-size: 14px;
  line-height: 1.55;
}

.prose blockquote > :last-child {
  margin-bottom: 0;
}

.prose img {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
}

/* « Previous » and « Next ». */
.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.pager a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-decoration: none;
}

.pager a:hover {
  border-color: var(--edge);
}

.pager-next {
  align-items: flex-end;
  text-align: right;
  grid-column: 2;
}

.pager-word {
  color: var(--muted);
  font-size: 12px;
}

.pager-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
}

/* The home of the docs (docs.md). */
.home-paths,
.home-sections,
.home-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.prose .home-paths li,
.prose .home-sections li,
.prose .home-modes li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.5;
}

.home-who,
.home-num {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.home-title {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.home-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.home-tags span {
  padding: 2px 9px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.home-cta {
  margin-top: auto;
  font-weight: 600;
}

.prose .home-sections ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.prose .home-sections ul li {
  padding: 0;
  border: 0;
  background: none;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.foot p {
  margin: 0;
}

.foot a {
  margin-left: 16px;
  color: var(--body);
}

/* « On this page » leaves first, then the sidebar becomes a list that opens. */
@media (max-width: 1180px) {
  .toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .side {
    display: none;
  }

  .main {
    flex-direction: column;
    gap: 16px;
    padding: 20px 16px 56px;
  }

  .side-small {
    display: block;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
  }

  .side-small summary {
    padding: 12px 16px;
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
  }

  .side-small nav {
    padding: 0 8px 16px;
  }

  .side-small .side-group + .side-group {
    margin-top: 16px;
  }

  .top {
    padding: 10px 16px;
  }

  .top-nav {
    order: 3;
    flex-basis: 100%;
  }

  .top-end {
    margin-left: auto;
  }

  .top-link {
    display: none;
  }

  .pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .pager-next {
    grid-column: 1;
  }

  .foot a {
    margin: 0 16px 0 0;
  }
}
