/* Guide page: the paper side of the design (see DESIGN.md). Reading first, no decoration that does not carry meaning. */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bone); color: var(--ink); font: 400 var(--t-15)/1.5 var(--font-ui); color-scheme: light; -webkit-font-smoothing: antialiased; }
h1, h2, h3, p, ol, ul, dl, dd, figure, pre { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: var(--radius); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: var(--s-4); top: -60px; z-index: 30; padding: var(--s-2) var(--s-3); background: var(--bone); color: var(--ink); border: 1px solid var(--ink); }
.skip:focus { top: var(--s-2); }
code { font: 0.875em ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--paper-shade); padding: 1px 5px; border-radius: var(--radius); }
.stamp { font-style: normal; font-size: var(--t-12); color: var(--ink-soft); border: 1px dashed currentColor; padding: 0 5px; border-radius: var(--radius); white-space: nowrap; }

/* top bar: the same instrument strip as the app */
.g-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-4); min-height: 56px; padding: 0 var(--s-5); background: var(--lampblack); color: var(--bone); }
.g-bar :focus-visible { outline-color: var(--film); }
.g-home { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; text-decoration: none; font: 500 var(--t-18)/1.2 var(--font-read); }
.g-mark { width: 28px; height: 28px; color: var(--film); flex: none; }
.g-here { margin-right: auto; padding-left: var(--s-4); border-left: 1px solid var(--rule); font-size: var(--t-13); color: var(--ash); }
.g-btn { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s-4); border: 1px solid var(--ash); border-radius: var(--radius); font: 600 var(--t-13)/1 var(--font-ui); text-decoration: none; white-space: nowrap; transition: background-color var(--d-hover) var(--ease-out), color var(--d-hover) var(--ease-out), transform var(--d-press) var(--ease-out); }
.g-btn:active { transform: scale(.97); }
.tb-langs { display: flex; align-items: center; }
.tb-lang { min-width: 36px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; font: 600 var(--t-12)/1 var(--font-ui); letter-spacing: .04em; color: var(--ash); }
.tb-lang + .tb-lang { border-left: 1px solid var(--rule); }
.tb-lang[aria-pressed="true"] { color: var(--bone); text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; }
html.i18n-wait body { visibility: hidden; }
.g-btn-ink { min-height: 48px; padding: 0 var(--s-5); background: var(--ink); color: var(--bone); border-color: var(--ink); font-size: var(--t-15); }
.g-btn-line { min-height: 48px; padding: 0 var(--s-5); border-color: var(--ink); font-size: var(--t-15); }
@media (hover: hover) { .g-bar .g-btn:hover { background: var(--bone); color: var(--ink); } .g-btn-ink:hover { background: #000; } .g-btn-line:hover { background: var(--paper-shade); } }

/* layout */
.g-wrap { display: grid; grid-template-columns: 216px minmax(0, 880px); gap: 72px; max-width: 1232px; margin: 0 auto; padding: 0 var(--s-6); }
.g-main { padding-bottom: 120px; }
.g-toc { position: sticky; top: 56px; align-self: start; max-height: calc(100vh - 56px); overflow-y: auto; padding: 76px 0 var(--s-6); }
.g-toc summary { display: none; }
.g-toc ol { border-left: 1px solid var(--paper-rule); }
.g-toc a { display: block; margin-left: -1px; padding: 7px 0 7px var(--s-4); border-left: 2px solid transparent; color: var(--ink-soft); font-size: var(--t-13); line-height: 1.35; text-decoration: none; transition: color var(--d-hover) var(--ease-out); }
.g-toc a[aria-current] { color: var(--ink); font-weight: 600; border-left-color: var(--ink); }
@media (hover: hover) { .g-toc a:hover { color: var(--ink); } }

/* hero */
.g-hero { padding-top: 64px; }
.stars7 { display: block; width: 132px; height: auto; margin-bottom: var(--s-5); color: var(--ink); }
.g-hero h1 { max-width: 17ch; font: 500 clamp(2.125rem, 4.6vw, 3.5rem)/1.04 var(--font-read); letter-spacing: -.022em; text-wrap: balance; }
.g-lead { max-width: 58ch; margin-top: var(--s-5); font: 400 1.25rem/1.5 var(--font-read); text-wrap: pretty; }
.g-note { max-width: 74ch; margin-top: var(--s-5); font-size: var(--t-13); color: var(--ink-soft); }
.g-note strong, .g-end strong { color: var(--ink); }
.orn { height: 14px; margin-top: var(--s-7); background: var(--ink-soft); }

/* sections */
section { padding-top: 72px; }
section h2 { font: 500 2rem/1.12 var(--font-read); letter-spacing: -.015em; margin-bottom: var(--s-4); }
section h3 { font: 600 1.0625rem/1.3 var(--font-ui); margin: 44px 0 var(--s-2); }
section > p { max-width: 66ch; font: 400 1.0625rem/1.62 var(--font-read); text-wrap: pretty; }
section > p + p { margin-top: var(--s-4); }
.g-small { font: 400 var(--t-13)/1.5 var(--font-ui) !important; color: var(--ink-soft); }

.g-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-5); margin: var(--s-6) 0; padding: var(--s-5) 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.g-facts dt { font: 500 2rem/1.1 var(--font-ui); font-stretch: 112%; letter-spacing: -.01em; }
.g-facts dd { margin-top: var(--s-2); font-size: var(--t-15); line-height: 1.4; }
.g-facts cite { display: block; margin-top: 4px; font-style: normal; font-size: var(--t-12); color: var(--ink-soft); }

.g-scroll { margin-top: var(--s-4); overflow-x: auto; }
.g-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; line-height: 1.45; }
.g-table th { text-align: left; font-weight: 600; }
.g-table thead th { padding: 0 var(--s-4) var(--s-2) 0; font-size: var(--t-12); color: var(--ink-soft); border-bottom: 1px solid var(--ink); white-space: nowrap; }
.g-table td, .g-table tbody th { padding: var(--s-3) var(--s-4) var(--s-3) 0; vertical-align: top; border-bottom: 1px solid var(--paper-rule); }
.g-table tbody th { width: 24%; }
.g-table td:last-child, .g-table th:last-child { padding-right: 0; }
.g-table small { display: block; color: var(--ink-soft); font-size: var(--t-12); }
.g-rules td { width: 19%; }
.g-rules .stamp { display: inline-block; margin-top: 4px; }
.g-rules a { display: block; overflow-wrap: anywhere; }
.g-rules a + a { margin-top: 4px; }

.g-points > li { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-6); align-items: center; padding: var(--s-5) 0; border-top: 1px solid var(--paper-rule); }
.g-points > li:last-child { border-bottom: 1px solid var(--paper-rule); }
.g-points h3 { margin: 0 0 var(--s-2); }
.g-points p { max-width: 52ch; font: 400 1rem/1.58 var(--font-read); text-wrap: pretty; }
.g-points img { display: block; width: 100%; height: auto; border: 1px solid var(--ink); border-radius: var(--radius); background: var(--lampblack); }

.g-fig { margin: var(--s-6) 0 0; }
.g-fig figcaption { margin-top: var(--s-3); max-width: 70ch; font-size: var(--t-13); color: var(--ink-soft); }
#diagram svg { display: block; width: 100%; height: auto; font-family: var(--font-ui); }
#diagram .d-tall { display: none; max-width: 340px; margin: 0 auto; }
.d-box { fill: var(--bone); stroke: var(--ink); stroke-width: 1.2; }
.d-core { fill: var(--ink); stroke: var(--ink); }
.d-chip { fill: var(--bone); }
.d-far { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 2 3; }
.d-frame { fill: none; stroke: var(--ink-soft); stroke-width: 1; stroke-dasharray: 5 5; }
.d-arrow { fill: none; stroke: var(--ink); stroke-width: 1.3; }
.d-t { font-size: 14px; font-weight: 600; fill: var(--ink); }
.d-s { font-size: 11.5px; fill: var(--ink-soft); }
html[lang="ru"] #diagram .d-wide .d-t { font-size: 11.5px !important; }   /* Russian box titles are longer */
.d-core-t { fill: var(--bone); }
.d-core-s { fill: var(--ash); }
.d-frame-t { font-size: 12px; font-weight: 600; fill: var(--ink-soft); }

.g-defs { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--s-6); margin-top: var(--s-3); }
.g-defs > div { padding: var(--s-4) 0; border-top: 1px solid var(--paper-rule); }
.g-defs dt { font-weight: 600; }
.g-defs dd { margin-top: 4px; font-size: var(--t-15); line-height: 1.5; }

.g-src > li { padding: var(--s-3) 0; border-top: 1px solid var(--paper-rule); }
.g-src > li:last-child { border-bottom: 1px solid var(--paper-rule); }
.g-src a, .g-src-t { display: block; font-weight: 600; }
.g-src span:last-child { display: block; margin-top: 2px; max-width: 70ch; color: var(--ink-soft); }

.g-steps { counter-reset: step; margin-top: var(--s-5); }
.g-steps > li { position: relative; counter-increment: step; max-width: 68ch; padding: var(--s-3) 0 var(--s-3) 52px; font: 400 1rem/1.58 var(--font-read); border-top: 1px solid var(--paper-rule); }
.g-steps > li::before { content: counter(step); position: absolute; left: 0; top: 13px; display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--ink); border-radius: var(--radius); font: 600 var(--t-13)/1 var(--font-ui); }
.g-steps b { font-family: var(--font-ui); font-weight: 600; }
.g-cta { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-5) !important; }

.g-pre { margin: var(--s-5) 0; padding: var(--s-4) var(--s-5); background: var(--ink); color: var(--bone); border-radius: var(--radius); overflow-x: auto; font: 0.8125rem/1.7 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color-scheme: dark; }
.g-pre:focus-visible { outline-offset: 3px; }
.g-pre code { font: inherit; background: none; padding: 0; }
.g-pre b { color: var(--calm); font-weight: 600; }
.g-pre span:empty { display: none; }

.g-list { margin-top: var(--s-2); }
.g-list > li { position: relative; max-width: 68ch; padding: var(--s-2) 0 var(--s-2) var(--s-5); font: 400 1rem/1.58 var(--font-read); }
.g-list > li::before { content: ""; position: absolute; left: 2px; top: 1.05em; width: 7px; height: 7px; background: var(--ink); }
.g-end { margin-top: var(--s-5) !important; font: 400 var(--t-13)/1.5 var(--font-ui) !important; color: var(--ink-soft); }

@media (max-width: 960px) {
  html { scroll-padding-top: 68px; }
  .g-wrap { display: block; padding: 0 var(--s-5); }
  .g-toc { position: static; max-height: none; padding: var(--s-4) 0 0; }
  .g-toc summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 var(--s-4); border: 1px solid var(--ink); border-radius: var(--radius); font-weight: 600; cursor: pointer; list-style: none; }
  .g-toc summary::-webkit-details-marker { display: none; }
  .g-toc summary::after { content: ""; width: 8px; height: 8px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); rotate: 45deg; translate: 0 -2px; }
  .g-toc details[open] summary::after { rotate: -135deg; translate: 0 2px; }
  .g-toc ol { margin-top: var(--s-2); }
  .g-toc a { padding: 11px 0 11px var(--s-4); font-size: var(--t-15); }
  .g-hero { padding-top: var(--s-6); }
  section { padding-top: 56px; }
}
@media (max-width: 720px) {
  .g-wrap { padding: 0 var(--s-4); }
  .g-bar { padding: 0 var(--s-4); gap: var(--s-3); }
  .g-home span { display: none; }
  html[lang="ru"] .g-bar { gap: var(--s-2); }
  html[lang="ru"] .g-bar .g-btn { padding: 0 var(--s-2); }
  html[lang="ru"] .tb-lang { min-width: 32px; }
  .g-here { padding-left: 0; border-left: 0; font-size: var(--t-15); color: var(--bone); font-weight: 600; }
  .g-lead { font-size: 1.125rem; }
  section h2 { font-size: 1.625rem; }
  .g-facts { grid-template-columns: 1fr; gap: var(--s-4); }
  .g-points > li { grid-template-columns: 1fr; gap: var(--s-4); }
  .g-defs { grid-template-columns: 1fr; }
  #diagram .d-wide { display: none; }
  #diagram .d-tall { display: block; }
  /* tables become stacked records */
  .g-table, .g-table tbody, .g-table tr, .g-table td, .g-table tbody th { display: block; width: auto; }
  .g-table thead { display: none; }
  .g-table tr { padding: var(--s-3) 0; border-bottom: 1px solid var(--ink); }
  .g-table td, .g-table tbody th { padding: 3px 0; border: 0; }
  .g-table tbody th { font-size: 1rem; margin-bottom: 4px; }
  .g-table td[data-l]::before { content: attr(data-l); display: block; margin-top: 6px; font-size: var(--t-12); font-weight: 600; color: var(--ink-soft); }
  .g-cta .g-btn { flex: 1 1 auto; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media print {
  .g-bar, .g-toc { display: none; }
  .g-wrap { display: block; }
}
