/* EasyCAS User Guide — stylesheet
   Offline-safe: no web fonts, no CDN, no external assets. */

:root {
  --paper:   #f6f6f3;
  --surface: #ffffff;
  --ink:     #1a242e;
  --muted:   #5a6672;
  --rule:    #d7dbdd;
  --rule-strong: #b8c0c4;
  --air:     #0f6fb4;
  --air-soft:#e7f1f8;
  --flag:    #a85f00;
  --flag-soft:#fbf3e4;
  --good:    #2e7050;
  --sans: "Segoe UI", system-ui, "Noto Sans", "DejaVu Sans", sans-serif;
  --serif: Georgia, "Noto Serif", "Liberation Serif", serif;
  --mono: Consolas, "DejaVu Sans Mono", "Courier New", monospace;
  --measure: 66ch;
  color-scheme: light;
}

html[data-theme="dark"] {
  --paper:   #141a1f;
  --surface: #1a2229;
  --ink:     #e3e7ea;
  --muted:   #9aa6b0;
  --rule:    #2c363f;
  --rule-strong: #3d4a54;
  --air:     #5aa9e6;
  --air-soft:#16303f;
  --flag:    #d79a4a;
  --flag-soft:#2a2316;
  --good:    #6fbf95;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--serif);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--air); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--air); outline-offset: 2px; }

h1, h2, h3, h4 { font-family: var(--sans); font-weight: 600; line-height: 1.25; }
h1 { font-size: 2rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; margin: 2.4rem 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.8rem 0 .4rem; }
p, ul, ol, table, figure, pre { max-width: var(--measure); }
p { margin: 0 0 1rem; }
li { margin: .3rem 0; }
code, kbd, samp { font-family: var(--mono); font-size: .9em; }
code { background: var(--air-soft); padding: .08em .35em; border-radius: 2px; }
kbd {
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-bottom-width: 2px; border-radius: 3px; padding: .05em .4em;
  font-size: .85em; white-space: nowrap;
}

/* ---------- header ---------- */

.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
}
.top .brand { font-weight: 600; letter-spacing: .01em; color: inherit; text-decoration: none; }
.top .brand span { color: var(--muted); font-weight: 400; }
.top .spacer { flex: 1; }
.top button {
  font: inherit; font-size: .85rem; color: var(--muted);
  background: none; border: 1px solid var(--rule); border-radius: 3px;
  padding: .25rem .6rem; cursor: pointer;
}
.top button:hover { color: var(--ink); border-color: var(--rule-strong); }

.search { position: relative; }
.search input {
  font: inherit; font-size: .9rem; width: 14rem;
  padding: .3rem .6rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 3px;
}
.search input::placeholder { color: var(--muted); }
.results {
  position: absolute; right: 0; top: calc(100% + .4rem); width: 26rem; max-width: 80vw;
  max-height: 60vh; overflow: auto; padding: .3rem;
  background: var(--surface); border: 1px solid var(--rule-strong);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.results:empty { display: none; }
.results a { display: block; padding: .45rem .55rem; text-decoration: none; color: inherit; }
.results a:hover, .results a.on { background: var(--air-soft); }
.results b { display: block; font-size: .9rem; }
.results small { color: var(--muted); font-family: var(--sans); font-size: .78rem; }

/* ---------- page frame ---------- */

.frame {
  display: grid; grid-template-columns: 16rem minmax(0, 1fr) 13rem;
  gap: 2.5rem; align-items: start;
  max-width: 78rem; margin: 0 auto; padding: 2rem 1.5rem 5rem;
}
.wide { max-width: 68rem; margin: 0 auto; padding: 0 1.5rem 5rem; }

nav.toc, aside.here { position: sticky; top: 4.2rem; font-family: var(--sans); font-size: .875rem; }
nav.toc { max-height: calc(100vh - 6rem); overflow: auto; }
nav.toc h2 {
  font-size: .72rem; letter-spacing: .06em; color: var(--muted);
  margin: 1.2rem 0 .35rem; font-weight: 600;
}
nav.toc h2:first-child { margin-top: 0; }
nav.toc ol { list-style: none; margin: 0; padding: 0; }
nav.toc li { margin: 0; }
nav.toc a {
  display: block; padding: .22rem .5rem .22rem .7rem;
  color: var(--muted); text-decoration: none;
  border-left: 2px solid var(--rule);
}
nav.toc a:hover { color: var(--ink); border-left-color: var(--rule-strong); }
nav.toc a[aria-current] { color: var(--ink); font-weight: 600; border-left-color: var(--air); background: var(--air-soft); }
nav.toc a.soon { color: var(--rule-strong); pointer-events: none; }

aside.here ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
aside.here a { display: block; padding: .2rem .7rem; color: var(--muted); text-decoration: none; }
aside.here a:hover { color: var(--ink); }
aside.here a.sub { padding-left: 1.4rem; font-size: .82rem; }
aside.here .lbl { font-size: .72rem; letter-spacing: .06em; color: var(--muted); margin: 0 0 .4rem .7rem; }

/* ---------- article ---------- */

article { min-width: 0; }
.eyebrow { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin: 0 0 .2rem; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: var(--measure); margin: 0 0 1.6rem; }

.meta {
  display: flex; flex-wrap: wrap; gap: .4rem 1.4rem;
  font-family: var(--sans); font-size: .85rem; color: var(--muted);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: .6rem 0; margin: 0 0 2rem; max-width: var(--measure);
}
.meta b { color: var(--ink); font-weight: 600; }

ol.steps { list-style: none; counter-reset: step; padding: 0; max-width: none; }
ol.steps > li { counter-increment: step; margin: 0 0 2.2rem; padding-left: 3rem; position: relative; }
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: .1rem;
  width: 2rem; height: 2rem; border: 1px solid var(--air); border-radius: 50%;
  color: var(--air); font: 600 .95rem/1.95rem var(--sans); text-align: center;
}
ol.steps > li > h2 { margin-top: 0; }

.note, .warn {
  border-left: 3px solid var(--air); background: var(--air-soft);
  padding: .8rem 1rem; margin: 1.2rem 0; max-width: var(--measure);
  font-size: .97rem;
}
.warn { border-left-color: var(--flag); background: var(--flag-soft); }
.note > :last-child, .warn > :last-child { margin-bottom: 0; }
.note b, .warn b { font-family: var(--sans); font-size: .9rem; }

.check {
  border: 1px solid var(--rule); border-left: 3px solid var(--good);
  background: var(--surface); padding: .8rem 1rem; margin: 1.2rem 0;
  max-width: var(--measure); font-size: .97rem;
}
.check p:first-child { font-family: var(--sans); font-size: .9rem; font-weight: 600; margin-bottom: .3rem; }
.check > :last-child { margin-bottom: 0; }

table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .9rem; margin: 1.2rem 0; }
th, td { text-align: left; vertical-align: top; padding: .45rem .7rem; border-bottom: 1px solid var(--rule); }
th { background: var(--surface); font-weight: 600; border-bottom-color: var(--rule-strong); }
td code { background: none; padding: 0; }

/* таблицы «что ввести» и «что должно получиться»: число и единица выровнены,
   строки, которые читатель вводит сам, - зелёная полоса, как в таблице Item */
table.vals { width: auto; min-width: 22rem; }
table.vals td.v { font-family: var(--mono); text-align: right; white-space: nowrap; }
table.vals td.u { color: var(--muted); white-space: nowrap; }
table.vals tr.in td:first-child { border-left: 3px solid var(--good); }
table.vals tr.res td:first-child { border-left: 3px solid var(--air); }
table.vals td.c { color: var(--muted); font-size: .85rem; }

/* ---------- figures and screenshot placeholders ---------- */

figure.shot { margin: 1.6rem 0; max-width: none; }
figure.shot a.shot-link { display: inline-block; max-width: 100%; line-height: 0; }
figure.shot img {
  display: block;
  width: auto; height: auto;          /* 1:1, как снято */
  max-width: 100%;                    /* но не шире колонки */
  border: 1px solid var(--rule-strong); background: var(--surface);
}
figure.shot.fill  img { width: 100%; }        /* мелкий кадр растянуть на колонку */
figure.shot.small img { max-width: min(26rem, 100%); }   /* фрагмент: уже колонки */
figure.shot.tall  img { max-height: 34rem; }  /* длинное окно: можно ужать по высоте */
figure.shot figcaption { font-family: var(--sans); font-size: .85rem; color: var(--muted); margin-top: .45rem; max-width: var(--measure); }
figure.shot .fig-no { color: var(--ink); font-weight: 600; }

.shot-todo {
  border: 1px dashed var(--rule-strong); background: var(--surface);
  padding: 1rem 1.1rem; font-family: var(--sans); font-size: .85rem; color: var(--muted);
}
.shot-todo .file { display: block; font-family: var(--mono); font-size: .8rem; color: var(--flag); margin-bottom: .4rem; }
.shot-todo .brief { color: var(--ink); }

/* ---------- CHM cross references ---------- */

.chm {
  display: inline-block; font-family: var(--sans); font-size: .82rem;
  padding: .05em .45em; border: 1px solid var(--rule-strong); border-radius: 3px;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.chm::before { content: "F1 "; color: var(--air); font-weight: 600; }
a.chm:hover { color: var(--ink); border-color: var(--air); }
.seealso { font-family: var(--sans); font-size: .9rem; color: var(--muted); margin-top: 2.5rem; }
.seealso .chm { margin-right: .3rem; }

/* ---------- prev / next ---------- */

.updown { display: flex; gap: 1rem; justify-content: space-between; border-top: 1px solid var(--rule); margin-top: 3rem; padding-top: 1rem; font-family: var(--sans); font-size: .9rem; }
.updown a { text-decoration: none; }
.updown small { display: block; color: var(--muted); font-size: .78rem; }
.updown .next { text-align: right; margin-left: auto; }

/* ---------- home ---------- */

.hero { padding: 2.5rem 0 1rem; }
.hero h1 { font-size: 2.6rem; max-width: 20ch; }
.hero .lede { font-size: 1.2rem; max-width: 60ch; }
.circuit { width: 100%; height: auto; margin: 2rem 0 .5rem; }
.circuit .wire { fill: none; stroke: var(--rule-strong); stroke-width: 2; }
.circuit .sym { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.circuit .fillsym { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; }
.circuit .cap { font: 600 12px var(--sans); fill: var(--muted); }
.circuit .num { font: 600 11px var(--mono); fill: var(--rule-strong); }
.circuit a { text-decoration: none; }
.circuit a:hover .sym, .circuit a:focus .sym { stroke: var(--air); }
.circuit a:hover .fillsym, .circuit a:focus .fillsym { stroke: var(--air); }
.circuit a:hover .cap, .circuit a:focus .cap { fill: var(--air); }
.circuit a:hover .hit, .circuit a:focus .hit { fill: var(--air-soft); }
.circuit .hit { fill: transparent; }

.lesson-list { max-width: 56rem; width: 100%; }
.lesson-list td.n { font-family: var(--mono); color: var(--muted); width: 2.5rem; }
.lesson-list td.t a { font-weight: 600; text-decoration: none; }
.lesson-list td.t a:hover { text-decoration: underline; }
.lesson-list td.t .soon { color: var(--muted); font-weight: 600; }
.lesson-list td.d { color: var(--muted); }
.lesson-list td.m { font-family: var(--mono); font-size: .82rem; color: var(--muted); white-space: nowrap; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 2rem; max-width: 56rem; }
.cols h2 { margin-top: 0; }
.cols p, .cols ul { max-width: none; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .frame { grid-template-columns: 15rem minmax(0, 1fr); }
  aside.here { display: none; }
}
@media (max-width: 800px) {
  .frame { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-top: 1rem; }
  nav.toc { position: static; max-height: none; border-bottom: 1px solid var(--rule); padding-bottom: 1rem; }
  .top { padding: .5rem .9rem; }
  .top .brand span { display: none; }
  .search input { width: 9rem; }
  .hero h1 { font-size: 1.9rem; }
  body { font-size: 1rem; }
}

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

/* ---------- print ---------- */

@media print {
  :root { --paper: #fff; --surface: #fff; --ink: #000; --muted: #444; --rule: #bbb; --air: #000; --air-soft: #f2f2f2; }
  .top, nav.toc, aside.here, .updown, .search { display: none !important; }
  .frame { display: block; max-width: none; padding: 0; }
  body { font-size: 11pt; }
  p, ul, ol, table, figure { max-width: none; }
  h2, h3 { break-after: avoid; }
  figure.shot, .note, .warn, .check, table { break-inside: avoid; }
  figure.shot img { max-height: 11cm; }
  .chm::before { content: "Help: "; }
  a { color: #000; text-decoration: none; }
}

/* ---------- toolbar icons from the program (img/ic/NN.png, 24x24) ---------- */
img.ic { width: 1.25em; height: 1.25em; vertical-align: -.28em; margin-right: .15em; image-rendering: auto; }
html[data-theme="dark"] img.ic { background: #e3e7ea; border-radius: 3px; padding: 1px; }

/* ---------- footer ---------- */
.foot { max-width: 72rem; margin: 3rem auto 1.5rem; padding: 1rem 1.5rem 0; border-top: 1px solid var(--rule);
        font-family: var(--sans); font-size: .8rem; color: var(--muted); }
@media print { .foot { display: none; } }

/* ---------- draft: values not yet confirmed in the program (class="tbd") ----------
   Подсветка работает, пока в nav.js draft: true. Что проверить — в shots/check.md. */
.tbd { border-bottom: 1px dashed var(--flag); background: var(--flag-soft); cursor: help; }
.tbd::after { content: "?"; font: 600 .7em var(--sans); color: var(--flag); vertical-align: super; margin-left: .1em; }
td .tbd { padding: 0 .15em; }

/* ---------- code blocks: what the reader types into the Text tab ---------- */
pre { background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--good);
      padding: .6rem .9rem; overflow-x: auto; margin: .8rem 0 1.2rem; line-height: 1.45; }
pre code { background: none; padding: 0; font-size: .88rem; }

/* ---------- small scheme drawings inside lessons (inline SVG) ---------- */
svg.scheme { display: block; width: 100%; max-width: 40rem; height: auto; margin: 1rem 0 1.6rem; }
svg.scheme .ln { fill: none; stroke: var(--muted); stroke-width: 2; }
svg.scheme .ln .rev { stroke: var(--flag); stroke-dasharray: 6 4; }
svg.scheme .bx * { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
svg.scheme .tx text { font: 600 13px var(--sans); fill: var(--ink); }
svg.scheme .tx text.sm { font: 400 11px var(--sans); fill: var(--muted); }

/* ---------- glossary ---------- */
dl.gloss { max-width: var(--measure); margin: 0 0 1rem; }
dl.gloss dt { font-family: var(--sans); font-weight: 600; margin-top: 1rem; }
dl.gloss dd { margin: .15rem 0 0 1.2rem; }

/* ---------- narrow screens: wide tables scroll inside themselves, not the page ---------- */
@media (max-width: 800px) {
  table.vals { min-width: 0; }
  article table { display: block; overflow-x: auto; }
}
