/* Screenery reading pages: docs.html, guide.html, changelog.html and t/<slug>/.
   Loaded after gallery.css, which supplies the tokens, header and footer.
   1. Header on reading pages   2. Page frame and "On this page"   3. Prose
   4. Code and prompts   5. Tables   6. Template pages   7. Responsive */

/* 1. Header ------------------------------------------------------------- */
.doc .top__nav a[aria-current='page'] { font-weight: 600; }
.doc .top__nav a[aria-current='page']::after { transform: scaleX(1); }
.doc .skip:focus { top: 1rem; }
.doc .foot { padding-bottom: 2.5rem; }

/* 2. Page frame ---------------------------------------------------------- */
.doc main { display: block; }
.page {
  max-width: 76rem; margin: 0 auto;
  padding: clamp(2.5rem, 6vw, 5rem) var(--gutter) clamp(3.5rem, 8vw, 6.5rem);
}
.page__head { max-width: 46rem; }
.page__head h1 {
  font-size: clamp(2.3rem, 5vw, 3.9rem);
  font-weight: 600; line-height: 1.02; letter-spacing: -0.04em;
  text-wrap: balance;
}
.page__lede { margin-top: 1.25rem; font-size: clamp(1.1rem, 1.4vw, 1.25rem); line-height: 1.5; color: var(--ink-2); text-wrap: pretty; }
.page__meta { margin-top: 1.1rem; font: 400 0.8125rem/1.4 var(--mono); color: var(--ink-2); }

.page__body {
  display: grid;
  grid-template-columns: minmax(0, 41rem) minmax(0, 15rem);
  justify-content: space-between;
  gap: 2rem clamp(2rem, 6vw, 6rem);
  margin-top: clamp(2.5rem, 5vw, 4rem);
  padding-top: clamp(2rem, 4vw, 3rem);
  border-top: 1px solid var(--ink);
  align-items: start;
}
.page__body--single { grid-template-columns: minmax(0, 41rem); justify-content: start; }

.toc { position: sticky; top: 5.5rem; grid-column: 2; grid-row: 1; max-height: calc(100vh - 7rem); overflow-y: auto; font-size: 0.9375rem; scrollbar-width: thin; }
.toc h2 { font-size: 0.9375rem; font-weight: 600; letter-spacing: 0; line-height: 1.4; }
.toc ol { margin-top: 0.6rem; }
.toc a {
  display: grid; grid-template-columns: 0.9rem 1fr; align-items: baseline;
  padding: 0.32rem 0; color: var(--ink-2); text-decoration: none; line-height: 1.35;
  transition: color 0.2s;
}
.toc a::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-ink); transform: translateY(-0.15em) scale(0); transition: transform 0.35s var(--ease); }
.toc a:hover { color: var(--ink); }
.toc a[aria-current='true'] { color: var(--ink); font-weight: 500; }
.toc__toggle[hidden] { display: none; }
.toc a[aria-current='true']::before { transform: translateY(-0.15em) scale(1); }

/* 3. Prose ---------------------------------------------------------------- */
.prose { grid-column: 1; grid-row: 1; min-width: 0; font-size: 1.0625rem; line-height: 1.65; }
.prose > section + section { margin-top: clamp(3rem, 6vw, 4.5rem); }
.prose section { scroll-margin-top: 5.5rem; }
.prose h2 { font-size: clamp(1.55rem, 2.4vw, 1.95rem); letter-spacing: -0.03em; line-height: 1.12; }
.prose h3 { margin-top: 2.25rem; font-size: 1.1875rem; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.prose p, .prose ul, .prose ol, .prose dl, .prose .codeblock, .prose .table-wrap { margin-top: 1rem; }
.prose h2 + p { margin-top: 1.1rem; }
.prose p { text-wrap: pretty; }
.prose a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent-ink); text-decoration-thickness: 1.5px; text-underline-offset: 0.22em; transition: color 0.2s; }
.prose a:hover { color: var(--accent-ink); }
.prose ul { list-style: disc; padding-left: 1.2rem; }
.prose ol { list-style: decimal; padding-left: 1.35rem; }
.prose li + li { margin-top: 0.4rem; }
.prose li::marker { color: var(--ink-2); }
.prose strong { font-weight: 600; }
.prose code { overflow-wrap: anywhere; }
.prose .note { color: var(--ink-2); font-size: 0.9875rem; }

.defs { display: grid; gap: 0; }
.defs > div { display: grid; grid-template-columns: minmax(8rem, 13rem) 1fr; gap: 0.25rem 1.5rem; padding: 0.85rem 0; border-top: 1px solid var(--line); }
.defs > div:last-child { border-bottom: 1px solid var(--line); }
.defs dt { font-weight: 600; }
.defs dd { color: var(--ink-2); }

/* 4. Code and prompts ------------------------------------------------------ */
.codeblock { position: relative; border-radius: var(--radius); background: var(--ink); color: #e6e9ec; }
.codeblock pre { margin: 0; padding: 1.15rem 1.25rem; padding-right: 5.5rem; overflow-x: auto; font: 400 0.875rem/1.7 var(--mono); tab-size: 2; scrollbar-color: #5b626b transparent; }
.codeblock code { background: none; padding: 0; font-size: inherit; border-radius: 0; overflow-wrap: normal; }
.codeblock .c { color: #9aa3ad; }
.codeblock::selection, .codeblock ::selection { background: var(--paper); color: var(--ink); }
.codeblock--prompt { background: #f8f9fa; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.codeblock--prompt pre { white-space: pre-wrap; overflow-wrap: anywhere; padding-top: 3.4rem; padding-right: 1.25rem; font-size: 0.875rem; }
.codeblock--prompt ::selection { background: var(--ink); color: var(--paper); }
.codeblock__label { position: absolute; top: 0.95rem; left: 1.25rem; font: 500 0.8125rem/1.6 var(--mono); color: var(--ink-2); }

.copy {
  position: absolute; top: 0.6rem; right: 0.6rem;
  min-height: 2.25rem; min-width: 4.4rem; padding: 0 0.8rem;
  font: 500 0.8125rem/1 var(--sans); color: #e6e9ec;
  background: #1d2125; border: 1px solid #5b626b; border-radius: 999px; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.copy:hover { background: #e6e9ec; border-color: #e6e9ec; color: var(--ink); }
.copy:focus-visible { outline-color: var(--accent); }
.codeblock--prompt .copy { color: var(--ink); background: transparent; border-color: var(--ink); }
.codeblock--prompt .copy:hover { background: var(--ink); color: var(--paper); }
.codeblock--prompt .copy:focus-visible { outline-color: var(--accent-ink); }
.copy.is-done, .copy.is-done:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }

/* 5. Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.45; }
.table-wrap th, .table-wrap td { text-align: left; vertical-align: top; padding: 0.7rem 1.25rem 0.7rem 0; }
.table-wrap th:last-child, .table-wrap td:last-child { padding-right: 0; }
.table-wrap thead th { font-weight: 600; font-size: 0.875rem; white-space: nowrap; }
.table-wrap tbody tr { border-top: 1px solid var(--line); }
.table-wrap tbody th { font-weight: 600; white-space: nowrap; }
.table-wrap td { color: var(--ink-2); }
.table-wrap td code { white-space: nowrap; }
.table-wrap .num { font-family: var(--mono); font-size: 0.875rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap--wide table { min-width: 34rem; }
.table-wrap--params tbody th { width: 44%; white-space: normal; }
.table-wrap--params th code { white-space: normal; overflow-wrap: anywhere; }

/* 6. Template pages ------------------------------------------------------------ */
.crumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; font-size: 0.9375rem; color: var(--ink-2); }
.crumbs a { color: var(--ink-2); text-underline-offset: 0.22em; }
.crumbs a:hover { color: var(--ink); }
.crumbs li + li::before { content: '/'; margin-right: 0.5rem; color: var(--ink-2); }
.crumbs [aria-current] { color: var(--ink); }

.tpl__head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1.5rem 3rem; margin-top: 1.5rem; }
.tpl__head h1 { font-size: clamp(2.4rem, 6vw, 4.6rem); font-weight: 600; line-height: 1; letter-spacing: -0.04em; text-wrap: balance; }
.tpl__type { margin-top: 0.8rem; font: 400 0.9375rem/1.4 var(--mono); color: var(--ink-2); }
.tpl__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tpl__shot {
  display: block; margin-top: clamp(1.75rem, 4vw, 3rem);
  aspect-ratio: 16 / 10; overflow: hidden;
  border-radius: var(--radius); background: var(--paper-2);
  box-shadow: 0 0 0 1px var(--line), 0 26px 44px -28px rgb(16 18 20 / 0.5);
}
.tpl__shot img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform 0.9s var(--ease); }
.tpl__shot:hover img { transform: scale(1.015); }

.tpl__body {
  display: grid; grid-template-columns: minmax(0, 42rem) minmax(0, 20rem);
  justify-content: space-between; align-items: start;
  gap: 3rem clamp(2rem, 6vw, 6rem);
  margin-top: clamp(2.5rem, 5vw, 4rem);
}
.tpl__body .prose { grid-column: auto; grid-row: auto; }
.tpl__world { font-size: clamp(1.2rem, 1.7vw, 1.4rem); line-height: 1.4; letter-spacing: -0.015em; font-weight: 500; text-wrap: pretty; }
.tpl__facts { display: grid; gap: 2rem; font-size: 0.9375rem; }
.tpl__facts h2 { font-size: 0.9375rem; font-weight: 600; letter-spacing: 0; line-height: 1.4; padding-bottom: 0.6rem; border-bottom: 1px solid var(--ink); }
.tpl__facts ul { margin-top: 0.2rem; }
.tpl__facts li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.tpl__facts li span:first-child { color: var(--ink); }
.tpl__facts .num { font: 400 0.8125rem/1.6 var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tpl__facts .chips li { justify-content: flex-start; align-items: center; gap: 0.75rem; }
.chip { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0 1.5rem; margin-top: 1rem; }
.checks > div { padding: 0.8rem 0; border-top: 1px solid var(--line); }
.checks dt { font-size: 0.875rem; color: var(--ink-2); }
.checks dd { margin-top: 0.15rem; font: 500 1rem/1.4 var(--mono); font-variant-numeric: tabular-nums; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: clamp(3rem, 7vw, 5.5rem); padding-top: 1.5rem; border-top: 1px solid var(--ink); }
.pager a { display: block; text-decoration: none; }
.pager a:last-child { text-align: right; }
.pager span { display: block; font-size: 0.875rem; color: var(--ink-2); }
.pager strong { display: block; margin-top: 0.2rem; font-size: clamp(1.15rem, 2vw, 1.5rem); font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 0.2em; transition: text-decoration-color 0.25s; }
.pager a:hover strong { text-decoration-color: var(--accent-ink); }
.back { margin-top: 2rem; font-size: 0.9375rem; }

/* Changelog */
.release__date { font: 400 0.875rem/1.4 var(--mono); color: var(--ink-2); margin-top: 0.5rem; }
.names { columns: 2; column-gap: 2rem; list-style: none !important; padding-left: 0 !important; }
.names li { break-inside: avoid; }
.names li + li { margin-top: 0.3rem; }
.names span { color: var(--ink-2); }

/* 7. Responsive ------------------------------------------------------------------ */
@media (max-width: 64rem) {
  .page__body { grid-template-columns: minmax(0, 41rem); justify-content: start; }
  .toc { position: static; grid-column: 1; grid-row: auto; max-height: none; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
  .toc { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 1rem; padding-bottom: 1rem; }
  .toc ol { flex: 1 1 100%; columns: 2; column-gap: 2rem; }
  .toc__toggle { min-height: 2.75rem; padding: 0 1rem; font: 500 0.9rem/1 var(--sans); color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
  .toc__toggle:hover { border-color: var(--ink); }
  .toc li { break-inside: avoid; }
  .toc a::before { display: none; }
  .toc a { display: block; padding: 0.5rem 0; }
  .prose { grid-row: auto; }
  .tpl__body { grid-template-columns: minmax(0, 41rem); justify-content: start; }
}
@media (max-width: 48rem) {
  .doc .top__nav a:nth-child(n) { display: block; }
  .doc .foot__cols { grid-template-columns: 1fr 1fr; }
  .doc .foot__about { grid-column: 1 / -1; }
  .doc .top__nav { gap: 1rem; font-size: 0.9rem; }
  .doc .top { gap: 0.75rem; }
  .defs > div { grid-template-columns: 1fr; }
  .tpl__actions .btn { flex: 1 1 100%; }
}
@media (max-width: 30rem) {
  .doc .mark span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .toc ol, .names { columns: 1; }
  .codeblock pre { font-size: 0.8125rem; }
  .pager { grid-template-columns: 1fr; }
  .pager a:last-child { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .tpl__shot:hover img { transform: none; }
}
@media print {
  .top, .toc, .copy, .foot { display: none; }
  .codeblock { background: none; color: #000; box-shadow: inset 0 0 0 1px #999; }
}
