/* Guides: static, readable article pages in the app's palette and type */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin-wght.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  ascent-override: 90.2%;
  descent-override: 22.48%;
  line-gap-override: 0%;
  size-adjust: 107.4%;
}

:root {
  color-scheme: dark;
  --page: #07090d;
  --surface: #0e1117;
  --surface-2: #151a22;
  --line: #1f2631;
  --line-strong: #2b3441;
  --ink: #eef2f7;
  --ink-2: #b6c0cc;
  --ink-3: #8794a4;
  --accent: #5b9dff;
  --link: #8cbcff;
  --primary-bg: #2563eb;
  --primary-bg-hover: #1d4ed8;
  --primary-border: #3b7bff;
  --primary-ink: #ffffff;
  --good: #0ca30c;
}

* {
  box-sizing: border-box;
}

/* Keeps focused controls and anchors clear of the sticky header (WCAG 2.4.11) */
html {
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: 'Inter', 'Inter Fallback', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11', 'ss03';
  line-height: 1.7;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--link);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

::selection {
  background: rgb(91 157 255 / 35%);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  background: var(--primary-bg);
  color: var(--primary-ink);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 20;
}

.skip-link:focus {
  top: 12px;
}

/* Sticky glass header, same as the app's */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgb(7 9 13);
  border-bottom: 1px solid var(--line);
}

.site-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand img {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 9px;
}

.site-header nav {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(14 17 23 / 80%);
  line-height: 1.4;
}

.site-header nav a {
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  padding: 8px 18px;
  border-radius: 9px;
  white-space: nowrap;
}

.site-header nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.site-header nav a[aria-current] {
  color: var(--ink);
  background: #14284a;
  font-weight: 600;
}

.header-cta {
  font-size: 14px;
  padding: 7px 14px;
}

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

.btn.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
}

.btn-icon[hidden] {
  display: none;
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.btn-icon[aria-pressed='true'] svg {
  fill: currentColor;
}

@media (max-width: 560px) {
  .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .btn.btn-icon {
    padding: 8px;
  }
}

/* Night mode, shared with the app: everything in dim reds so it doesn't spoil dark adaptation */
:root.night {
  --page: #000;
  --surface: #0e0000;
  --surface-2: #160000;
  --line: #2a0000;
  --line-strong: #3a0000;
  --ink: #ff7070;
  --ink-2: #e05a5a;
  --ink-3: #d44c4c;
  --accent: #ff3b3b;
  --link: #ff7070;
  --primary-bg: #3a0000;
  --primary-bg-hover: #4a0606;
  --primary-border: #c83030;
  --primary-ink: #ff6a6a;
  --good: #e86060;
}

:root.night body {
  background: var(--page);
}

:root.night .site-header {
  background: rgb(0 0 0);
}

:root.night .site-header nav {
  background: var(--surface);
}

:root.night .site-header nav a[aria-current] {
  background: var(--primary-bg);
}

:root.night .btn-primary {
  box-shadow: none;
}

:root.night ::selection {
  background: var(--line-strong);
}

:root.night main img,
:root.night .brand img {
  filter: grayscale(1) sepia(1) hue-rotate(-50deg) saturate(5) brightness(0.55);
}

@media (max-width: 760px) {
  .site-header nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .site-header nav a {
    flex: 1;
    text-align: center;
    padding-inline: 4px;
    font-size: 14px;
  }

  .brand {
    font-size: 20px;
  }

  .brand img {
    width: 36px;
    height: 36px;
  }
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

h1 {
  font-size: clamp(32px, 5vw, 46px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-wrap: balance;
  margin: 8px 0 8px;
}

h2 {
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 36px 0 8px;
  line-height: 1.25;
}

h3 {
  font-size: 19px;
  margin: 24px 0 6px;
}

p,
ul,
ol {
  color: var(--ink-2);
}

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

code {
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 15px;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--ink);
}

td {
  color: var(--ink-2);
}

blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
}

blockquote p {
  margin: 0;
}

.breadcrumbs {
  font-size: 14px;
  color: var(--ink-3);
}

.breadcrumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--ink-3);
}

.breadcrumbs li + li::before {
  content: '›';
  margin-right: 6px;
}

.post-meta {
  color: var(--ink-3);
  font-size: 14px;
}

.lead {
  font-size: 19px;
}

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  background: var(--surface-2);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  transition: background-color 0.15s;
}

.btn:hover {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--primary-bg);
  border-color: var(--primary-border);
  color: var(--primary-ink);
}

.btn-primary:hover {
  background: var(--primary-bg-hover);
  border-color: var(--primary-border);
}

.rig-card {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 24px 0;
}

.rig-card-label {
  margin: 0;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.rig-card h3 {
  margin: 2px 0 10px;
}

.rig-card dl {
  margin: 0 0 12px;
  display: grid;
  gap: 4px;
}

.rig-card dl div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  font-size: 15px;
}

.rig-card dt {
  color: var(--ink-3);
}

.rig-card dd {
  margin: 0;
  color: var(--ink);
}

.rig-card-note {
  font-size: 15px;
}

.cta {
  margin-top: 40px;
  background: var(--surface);
  border-radius: 14px;
  padding: 24px;
}

.cta h2 {
  margin-top: 0;
}

.related ul,
.post-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 12px;
}

.related li {
  background: var(--surface);
  border-radius: 10px;
  padding: 14px 16px;
}

.related p {
  margin: 4px 0 0;
  font-size: 15px;
}

.post-list > li {
  background: var(--surface);
  border-radius: 12px;
  transition: background-color 0.15s;
}

.post-list > li:hover {
  background: var(--surface-2);
}

.post-list > li > a {
  display: block;
  padding: 16px 18px;
  text-decoration: none;
}

.post-list h4 {
  margin: 0 0 4px;
  font-size: 19px;
  color: var(--ink);
}

.post-list p {
  margin: 0 0 6px;
}

.site-footer {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
  gap: 32px;
  max-width: 1240px;
  margin: 72px auto 0;
  padding: 40px 24px 48px;
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.5;
}

.site-footer p {
  color: var(--ink-3);
  margin: 0;
  max-width: 34ch;
}

.site-footer .footer-name {
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}

.site-footer h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 12px;
}

.site-footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.site-footer a {
  color: var(--ink-3);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.site-footer .footer-note {
  grid-column: 1 / -1;
  max-width: none;
  font-size: 13px;
}

@media (max-width: 800px) {
  .site-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

main.wide {
  max-width: 1100px;
}

/* --- Guides home --- */
.guides-home {
  max-width: 820px;
  margin: 0 auto;
}

.guides-hero {
  padding: 24px 0 8px;
}

.guide-search {
  position: relative;
}

.guide-search input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}

.guide-search input:focus {
  border-color: var(--accent);
  outline: none;
}

.guide-search.big input {
  font-size: 18px;
  padding: 14px 44px 14px 16px;
  border-radius: 12px;
}

.guide-search kbd {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font: 13px/1 ui-monospace, monospace;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 6px;
}

.guide-search input:focus + kbd,
.guide-search input:not(:placeholder-shown) + kbd {
  display: none;
}

.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.topic-chips button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
}

.topic-chips button[aria-pressed='true'] {
  color: var(--primary-ink);
  background: var(--primary-bg);
  border-color: var(--primary-border);
}

/* The chips only work with the script */
html:not(.js) .topic-chips,
html:not(.js) .guide-search kbd {
  display: none;
}

.search-status {
  min-height: 1.6em;
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--ink-3);
}

.topic-group h3 {
  margin-top: 28px;
  margin-bottom: 0;
  font-size: 20px;
}

/* Guides home: Tutorials and Guides */
.part-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 4px 0 0;
  font-size: 15px;
}

.guide-part {
  margin-top: 48px;
}

.part-head {
  padding: 18px 20px;
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--surface);
}

.part-head h2 {
  margin: 0;
}

.part-head p {
  margin: 4px 0 0;
  color: var(--ink-2);
}

/* Tutorial pages: previous and next in the series */
.series {
  margin-top: 40px;
}

.series-count {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink-3);
}

.series-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 12px;
}

.series-links a {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
  text-decoration: none;
  color: var(--ink);
  transition: background-color 0.15s;
}

.series-links a:hover {
  background: var(--surface-2);
}

.series-links a[rel='next'] {
  text-align: right;
}

.series-links span {
  display: block;
  font-size: 13px;
  color: var(--ink-3);
}

.topic-blurb {
  margin: 2px 0 0;
  font-size: 15px;
}

.card-sections {
  display: none;
  list-style: none;
  margin: -8px 0 0;
  padding: 0 18px 14px;
  font-size: 14px;
}

.card-sections.show {
  display: grid;
  gap: 2px;
}

.card-sections a::before {
  content: '§ ';
  color: var(--ink-3);
}

/* --- Guide pages: menu beside the article --- */
.doc {
  display: grid;
  grid-template-columns: 250px minmax(0, 760px);
  gap: 40px;
  justify-content: center;
}

.guide-menu {
  position: sticky;
  top: 76px;
  align-self: start;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  padding: 8px 4px 16px 0;
  font-size: 14.5px;
  line-height: 1.45;
}

.guide-menu-toggle {
  display: none;
}

.menu-home {
  display: block;
  margin: 12px 0 4px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.menu-topic {
  margin: 16px 0 4px;
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 600;
}

.guide-menu-list,
.menu-sections {
  list-style: none;
  margin: 0;
  padding: 0;
}

.guide-menu-list a {
  display: block;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--ink-2);
  text-decoration: none;
}

.guide-menu-list a:hover {
  color: var(--ink);
  background: var(--surface);
}

.guide-menu-list a[aria-current='page'] {
  color: var(--ink);
  background: var(--surface-2);
  font-weight: 600;
}

.menu-sections {
  margin: 2px 0 6px 10px;
}

.menu-sections a {
  font-size: 13.5px;
  padding: 3px 10px;
  color: var(--ink-3);
}

/* Running text keeps a readable measure; tables and rig cards still use the full column */
.post > p,
.post > ul,
.post > ol,
.post > blockquote {
  max-width: 68ch;
}

/* Clear the sticky header when jumping to a section */
.post h2[id],
.post h3[id] {
  scroll-margin-top: 84px;
}

@media (max-width: 999px) {
  .doc {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .guide-menu {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0 0 8px;
  }

  .js .guide-menu-toggle {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
  }

  .js .guide-menu:not(.open) .guide-menu-body {
    display: none;
  }

  .js .guide-menu.open .guide-menu-body {
    margin-top: 8px;
    padding: 12px;
    background: var(--surface);
    border-radius: 10px;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 16px;
  }

  .rig-card dl div {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
}

.post-list > li,
.related li {
  transition: border-color 0.2s, transform 0.2s;
}

.post-list > li:hover {
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* --- Open-source licences page --- */
.licence {
  margin-top: 40px;
}

.licence h2 {
  font-size: 20px;
  margin-top: 20px;
}

.licence h2 .post-meta {
  font-weight: 400;
  margin-left: 6px;
}

.licence pre {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  max-height: 260px;
  overflow: auto;
}

/* Back to top (to-top.js), once you're a couple of screens down a long page */
.to-top {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 6px 20px rgb(0 0 0 / 40%);
}

.to-top[hidden] {
  display: none;
}

.to-top:hover {
  border-color: var(--accent);
}

.to-top svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* iOS zooms the page into any focused field with text under 16px, and stays zoomed. :root
   outranks the per-form sizes in the other stylesheets */
@media (max-width: 760px) {
  :root input:not([type='checkbox'], [type='radio']),
  :root select,
  :root textarea {
    font-size: 16px;
  }
}

/* ™ after the name in the header and footer: small, raised, not bold */
.tm {
  font-size: 0.5em;
  font-weight: 500;
  vertical-align: super;
  line-height: 0;
  margin-left: 1px;
}
