/* Pixel Lab developer docs: board 03, "Field notebook" (the tokens of
   app/Sources/PixelLab/Theme/Theme.swift), day and night. Sora for headings,
   Silkscreen only for short uppercase labels, the system face for text and
   controls, a monospace face for code. Nothing animates. */

:root {
  color-scheme: light;
  --page: #f4ede0;
  --hero: #eadfc8;
  --sidebar: #efe6d6;
  --card: #e9dcc6;
  --ink: #2e2418;
  --ink-muted: #5c4b39;
  --border: rgba(90, 62, 43, 0.16);
  --grid: rgba(90, 62, 43, 0.12);
  --accent: #3f6b45;
  --on-accent: #f4ede0;
  --gold: #d8b66a;
  --selection: rgba(63, 107, 69, 0.16);
  --shadow: 0 8px 28px rgba(46, 36, 24, 0.16);

  --font-head: 'Sora', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-text: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-label: 'Silkscreen', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-code: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;

  --topbar: 56px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #1c1712;
    --hero: #262019;
    --sidebar: #211b15;
    --card: #2d251c;
    --ink: #f1e8d8;
    --ink-muted: #c8b9a1;
    --border: rgba(241, 232, 216, 0.16);
    --grid: rgba(241, 232, 216, 0.07);
    --accent: #8cbc86;
    --on-accent: #1c1712;
    --selection: rgba(140, 188, 134, 0.18);
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #1c1712;
  --hero: #262019;
  --sidebar: #211b15;
  --card: #2d251c;
  --ink: #f1e8d8;
  --ink-muted: #c8b9a1;
  --border: rgba(241, 232, 216, 0.16);
  --grid: rgba(241, 232, 216, 0.07);
  --accent: #8cbc86;
  --on-accent: #1c1712;
  --selection: rgba(140, 188, 134, 0.18);
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar) + 16px);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.6 var(--font-text);
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

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

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

::selection {
  background: var(--selection);
}

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

.skip {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 30;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 6px;
}

.skip:focus {
  top: 8px;
}

.label {
  font: 400 11px/1.4 var(--font-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 8px;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar);
  padding: 0 var(--gutter);
  background: var(--hero);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font: 600 16px/1 var(--font-head);
  white-space: nowrap;
  min-height: 44px;
  flex-shrink: 0;
}

.brand img {
  image-rendering: pixelated;
  border-radius: 6px;
}

.brand-sub {
  color: var(--ink-muted);
  font-weight: 400;
}

.search {
  position: relative;
  flex: 0 1 320px;
  margin-left: auto;
  min-width: 0;
}

.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: 14px var(--font-text);
}

.search input::placeholder {
  color: var(--ink-muted);
}

#search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(440px, calc(100vw - 2 * var(--gutter)));
  max-height: 60vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

#search-results li a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
}

#search-results li a small {
  display: block;
  color: var(--ink-muted);
  font-size: 12px;
}

#search-results li[aria-selected="true"] a,
#search-results li a:hover {
  background: var(--selection);
}

#search-results .empty {
  padding: 8px 10px;
  color: var(--ink-muted);
}

.menu-button,
.theme-button,
.copy-button {
  font: 500 13px var(--font-text);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.menu-button,
.theme-button {
  flex-shrink: 0;
  min-height: 36px;
  min-width: 44px;
  padding: 0 12px;
  white-space: nowrap;
}

.menu-button {
  display: none;
}

.theme-button {
  min-width: 64px;
}

/* ---------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 224px;
  align-items: start;
  max-width: 1440px;
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: var(--topbar);
  height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding: 24px 16px 40px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

.sidebar section + section {
  margin-top: 22px;
}

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar a {
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.35;
}

.sidebar a:hover {
  background: var(--selection);
}

.sidebar a[aria-current="page"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.sidebar .group + .group {
  margin-top: 10px;
}

.sidebar .group-name {
  display: block;
  padding: 4px 10px 2px;
  font: 12px var(--font-code);
  color: var(--ink-muted);
}

.sidebar .group ul a {
  padding-left: 20px;
}

.content {
  min-width: 0;
  padding: 32px 48px 64px;
  outline: none;
}

.doc {
  max-width: 780px;
}

.toc {
  position: sticky;
  top: var(--topbar);
  max-height: calc(100vh - var(--topbar));
  overflow-y: auto;
  padding: 32px 16px 40px 8px;
  font-size: 13px;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc a {
  display: block;
  padding: 4px 0 4px 12px;
  color: var(--ink-muted);
  text-decoration: none;
  line-height: 1.35;
}

.toc a:hover {
  color: var(--ink);
}

.toc .l3 a {
  padding-left: 24px;
}

.page-foot {
  max-width: 780px;
  margin-top: 56px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 13px;
}

/* ---------------------------------------------------------------- the doc */

.doc h1,
.doc h2,
.doc h3,
.doc h4,
.doc h5,
.doc h6 {
  font-family: var(--font-head);
  line-height: 1.25;
  margin: 2em 0 0.6em;
}

.doc h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-top: 0;
}

.doc h2 {
  font-size: 1.45rem;
  font-weight: 600;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.doc h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.doc h4 {
  font-size: 1rem;
  font-weight: 600;
}

.doc .anchor {
  margin-left: 0.35em;
  color: var(--ink-muted);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
}

.doc :is(h1, h2, h3, h4, h5, h6):hover .anchor,
.doc .anchor:focus-visible {
  opacity: 1;
}

.doc p,
.doc ul,
.doc ol,
.doc blockquote,
.doc pre,
.doc .table-wrap {
  margin: 0 0 1em;
}

.doc ul,
.doc ol {
  padding-left: 1.5em;
}

.doc li + li {
  margin-top: 0.25em;
}

.doc li > ul,
.doc li > ol,
.doc li > p {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
}

.doc li.task {
  list-style: none;
  margin-left: -1.3em;
}

.doc li.task input {
  margin: 0 0.4em 0 0;
  accent-color: var(--accent);
}

.doc blockquote {
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--gold);
  color: var(--ink-muted);
}

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

.doc hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.doc img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.doc code {
  font: 0.88em/1.5 var(--font-code);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}

.doc pre {
  position: relative;
  overflow-x: auto;
  padding: 14px 16px;
  background: var(--hero);
  border: 1px solid var(--border);
  border-radius: 10px;
  line-height: 1.5;
}

.doc pre code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  white-space: pre;
}

.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  opacity: 0;
}

.doc pre:hover .copy-button,
.copy-button:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .copy-button {
    opacity: 1;
  }
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.doc table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
  line-height: 1.45;
}

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

.doc th {
  background: var(--card);
  font-weight: 600;
}

.doc tbody tr:last-child td {
  border-bottom: 0;
}

.doc td code,
.doc th code {
  white-space: nowrap;
}

.crumb {
  margin-bottom: 12px;
}

/* ---------------------------------------------------------------- narrow */

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .menu-button {
    display: inline-block;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: var(--topbar) 0 0 0;
    z-index: 15;
    width: 100%;
    height: auto;
    border-right: 0;
  }

  .sidebar.open {
    display: block;
  }

  .content {
    padding: 24px var(--gutter) 48px;
  }

  .doc td code,
  .doc th code {
    white-space: normal;
  }
}

@media (max-width: 600px) {
  .topbar {
    gap: 8px;
  }

  .brand-sub {
    display: none;
  }

  .theme-button {
    min-width: 56px;
    padding: 0 8px;
  }
}

@media (max-width: 420px) {
  .brand span {
    display: none;
  }

  .doc h1 {
    font-size: 1.6rem;
  }
}
