@import url("fonts/fonts.css");

/* Layout: one centered column; sections are "nodes" chained by a pointer rail on the left. */
:root {
  --paper: #F5F7FA;
  --card: #FFFFFF;
  --ink: #131A27;
  --muted: #5A6377;
  --line: #DCE1EA;
  --accent: #2346B8;
  --accent-ink: #FFFFFF;
  --ptr: #B9640A;
  --soft: #E8EDF8;

  --f-display: "Unbounded", "Arial Black", system-ui, sans-serif;
  --f-body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --wrap: 68rem;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0D1118;
    --card: #141A25;
    --ink: #E5E9F1;
    --muted: #9AA3B6;
    --line: #253046;
    --accent: #8DA7FF;
    --accent-ink: #0D1118;
    --ptr: #F0A54C;
    --soft: #1A2338;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}
img { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
code, .mono { font-family: var(--f-mono); font-size: 0.92em; }

.wrap {
  width: 100%;
  max-width: calc(var(--wrap) + var(--gutter) + var(--gutter-r));
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter-r);
}

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 10;
}
.skip:focus { left: var(--gutter); top: 8px; }

/* ---------- header: navigation as a linked list ---------- */
.site-head { padding-block: 22px; border-bottom: 1px solid var(--line); }
.chain {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 0;
  margin: 0; padding: 0; list-style: none;
  font-family: var(--f-mono); font-size: 0.875rem;
}
.chain li { display: flex; align-items: center; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.head-row > nav:first-child { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.lang-switch {
  flex: none;
  display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden;
  font-family: var(--f-mono); font-size: 0.8125rem; font-weight: 600;
}
.lang-switch > * { padding: 5px 12px; text-decoration: none; }
.lang-switch [aria-current] { background: var(--accent); color: var(--accent-ink); }
.lang-switch a { color: var(--muted); }
.lang-switch a:hover { color: var(--accent); }
.chain li + li::before {
  content: "→"; color: var(--ptr); padding: 0 0.6em; font-weight: 600;
}
.chain a { color: var(--ink); text-decoration: none; padding: 4px 2px; }
.chain a:hover { color: var(--accent); }
.chain .head { color: var(--accent); font-weight: 600; }
.chain .none { color: var(--muted); }

/* ---------- hero ---------- */
.hero { padding-block: clamp(48px, 9vw, 104px) clamp(40px, 7vw, 80px); }
.eyebrow {
  font-family: var(--f-mono); font-size: 0.8125rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ptr); margin: 0 0 18px; font-weight: 600;
}
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; text-wrap: balance; margin: 0; }
h1 {
  font-size: clamp(2.4rem, 7.4vw, 5.2rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
}
h1 .line2 { display: block; color: var(--accent); }
.lead { font-size: clamp(1.125rem, 2.1vw, 1.375rem); max-width: 38em; margin: 26px 0 0; color: var(--ink); }
.lead .muted { color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 13px 22px; border-radius: 999px;
  font-weight: 600; text-decoration: none; font-size: 1rem;
  border: 1.5px solid var(--accent);
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { color: var(--accent); background: transparent; }
.btn:hover { transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } .btn:hover { transform: none; } }

/* node diagram */
.nodes {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 0;
  margin-top: 56px; font-family: var(--f-mono); font-size: 0.9375rem;
}
.node { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--card); }
.node span { padding: 8px 14px; }
.node .nx { border-left: 1.5px solid var(--ink); display: grid; place-items: center; padding: 8px 12px; }
.node .nx::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ptr); }
.node.last .nx::before { width: auto; height: auto; background: none; content: "∅"; color: var(--muted); }
.arrow { width: 34px; height: 2px; background: var(--ptr); position: relative; margin: 0 4px 0 2px; flex: none; }
.arrow::after {
  content: ""; position: absolute; right: -2px; top: 50%; transform: translateY(-50%);
  border-left: 8px solid var(--ptr); border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.nodes .link { display: inline-flex; align-items: center; }

/* ---------- sections as chained nodes ---------- */
main { padding-bottom: 40px; }
.section { position: relative; padding-block: clamp(40px, 6vw, 72px); border-top: 1px solid var(--line); }
.section-label {
  font-family: var(--f-mono); font-size: 0.8125rem; color: var(--muted);
  margin: 0 0 14px; display: flex; align-items: center; gap: 10px;
}
.section-label b { color: var(--ptr); font-weight: 600; }
h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); line-height: 1.15; }
.prose { max-width: 40em; }
.prose p { margin: 18px 0 0; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 64px); align-items: start; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.principles { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.principles li {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 18px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start;
}
.principles .k { font-family: var(--f-mono); color: var(--ptr); font-weight: 600; font-size: 0.875rem; padding-top: 2px; }
.principles strong { display: block; font-weight: 600; }
.principles span.t { color: var(--muted); font-size: 0.975rem; }

/* course */
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; padding: 0; list-style: none; }
.meta li {
  font-family: var(--f-mono); font-size: 0.8125rem; padding: 6px 12px; border-radius: 999px;
  background: var(--soft); color: var(--ink);
}
.program { counter-reset: lec; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .program { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .program { grid-template-columns: minmax(0, 1fr); } }
.program li {
  counter-increment: lec;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.program li::before {
  content: "лекция " counter(lec);
  font-family: var(--f-mono); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ptr); font-weight: 600;
}
.program strong { font-weight: 600; line-height: 1.3; }
.program span { color: var(--muted); font-size: 0.9375rem; line-height: 1.45; }
.course-format {
  margin-top: 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px 32px; align-items: center;
  background: var(--soft); border-radius: 16px; padding: 24px 26px;
}
.course-format p { margin: 0; max-width: 46em; }
.course-format p + p { margin-top: 10px; color: var(--muted); font-size: 0.975rem; }

/* channel */
.rubrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
@media (max-width: 560px) { .rubrics { grid-template-columns: minmax(0, 1fr); } }
.rubrics li { border-left: 3px solid var(--ptr); padding: 4px 0 4px 14px; }
.rubrics strong { display: block; font-weight: 600; }
.rubrics span { color: var(--muted); font-size: 0.9375rem; }

/* footer */
.site-foot { border-top: 1px solid var(--line); padding-block: 28px 36px; color: var(--muted); font-size: 0.9375rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.site-foot .mono { color: var(--muted); }

/* ---------- nav: current page ---------- */
.chain a[aria-current="page"] { color: var(--accent); }

/* ---------- inner pages ---------- */
.hero-sm { padding-block: clamp(40px, 6vw, 72px) clamp(24px, 4vw, 40px); }
.page-title { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 1.08; letter-spacing: -0.015em; }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }

/* home: materials teaser */
.more-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 28px; }
@media (max-width: 720px) { .more-grid { grid-template-columns: minmax(0, 1fr); } }
.more-card {
  display: flex; flex-direction: column; gap: 8px; padding: 22px 24px; border-radius: 16px;
  background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  transition: border-color 0.15s ease;
}
.more-card:hover { border-color: var(--accent); }
.more-card strong { font-family: var(--f-display); font-size: 1.25rem; font-weight: 700; }
.more-card span { color: var(--muted); }
.more-card .go { color: var(--accent); font-weight: 600; margin-top: 4px; }

/* articles list */
.article-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.article-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 18px; align-items: baseline;
  padding: 22px 24px; border-radius: 16px; background: var(--card); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; transition: border-color 0.15s ease;
}
.article-card:hover { border-color: var(--accent); }
.article-card .k { grid-row: span 3; font-family: var(--f-mono); color: var(--ptr); font-weight: 600; }
.article-card strong { font-family: var(--f-display); font-size: 1.3rem; font-weight: 700; line-height: 1.25; }
.article-card .t { color: var(--muted); }
.article-card .m { font-family: var(--f-mono); font-size: 0.8125rem; color: var(--muted); }

/* article page */
.article-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 16rem; gap: 0 56px;
  grid-template-areas: "head head" "body toc";
  padding-block: clamp(36px, 5vw, 64px) 24px;
}
.article-head { grid-area: head; margin-bottom: 36px; max-width: 46rem; }
.article-title { font-size: clamp(1.9rem, 4.6vw, 3rem); line-height: 1.1; letter-spacing: -0.015em; }
.article-head .lead { font-size: 1.125rem; color: var(--muted); margin-top: 16px; }
.article-toc { grid-area: toc; position: sticky; top: 24px; align-self: start; font-size: 0.9375rem; }
.article-toc ol { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 8px; }
.article-toc a { color: var(--muted); text-decoration: none; }
.article-toc a:hover { color: var(--accent); }
.toc-title { font-family: var(--f-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ptr); font-weight: 600; margin: 0 0 12px; }
.article-body { grid-area: body; min-width: 0; max-width: 46rem; }
@media (max-width: 960px) {
  .article-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "toc" "body"; }
  .article-toc { position: static; margin-bottom: 32px; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
  .article-toc ol { border-left: 0; padding-left: 0; }
}

.article-body h2 { font-size: 1.6rem; line-height: 1.2; margin: 48px 0 0; scroll-margin-top: 16px; }
.article-body h3 { font-family: var(--f-body); font-weight: 600; font-size: 1.2rem; margin: 32px 0 0; }
.article-body h4 { font-size: 1.05rem; margin: 24px 0 0; font-family: var(--f-body); font-weight: 600; }
.article-body p, .article-body ul, .article-body ol { margin: 14px 0 0; }
.article-body li + li { margin-top: 6px; }
.article-body img { display: block; margin: 24px auto 0; border-radius: 12px; background: #fff; height: auto; }
.article-body :not(pre) > code { background: var(--soft); padding: 0.1em 0.35em; border-radius: 5px; overflow-wrap: anywhere; }
.article-body pre {
  margin: 16px 0 0; padding: 16px 18px; border-radius: 12px; overflow-x: auto;
  background: var(--card); border: 1px solid var(--line);
  font-size: 0.875rem; line-height: 1.55; tab-size: 4;
}
.article-body pre code { font-size: inherit; }
.article-body blockquote { margin: 16px 0 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--line); color: var(--muted); }

.table-wrap { margin-top: 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.article-body table { border-collapse: collapse; width: 100%; font-size: 0.9375rem; font-variant-numeric: tabular-nums; }
.article-body th, .article-body td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.article-body tr:last-child td { border-bottom: 0; }
.article-body th { background: var(--soft); font-weight: 600; }

.note { margin: 20px 0 0; padding: 16px 20px; border-radius: 12px; background: var(--soft); border-left: 3px solid var(--ptr); }
.note > :first-child { margin-top: 0; }
.note-label { font-family: var(--f-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ptr); font-weight: 600; margin: 0 0 6px !important; }
.note p { margin-top: 6px; }

/* code tabs */
.tabs { margin-top: 16px; }
.tab-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: -1px; }
.tab-list button {
  font: 600 0.8125rem var(--f-mono); color: var(--muted); background: transparent; cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px 10px 0 0; padding: 7px 14px;
}
.tab-list button[aria-selected="true"] { color: var(--accent); background: var(--card); border-bottom-color: var(--card); }
.tab-list button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tab-label { font-family: var(--f-mono); font-size: 0.8125rem; color: var(--ptr); font-weight: 600; margin: 16px 0 0 !important; }
.tabs-ready .tab-label { display: none; }
.tabs-ready .tab-panel > pre:first-of-type { margin-top: 0; border-top-left-radius: 0; }

.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 56px; }
.pager a {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: 12px;
  border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 600;
}
.pager a:hover { border-color: var(--accent); }
.pager a span { font-family: var(--f-mono); font-size: 0.75rem; color: var(--muted); font-weight: 400; }
.pager .next { text-align: right; }
@media (max-width: 560px) { .pager { grid-template-columns: minmax(0, 1fr); } .pager .next { text-align: left; } }

/* talks */
.talks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 960px) { .talks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .talks { grid-template-columns: minmax(0, 1fr); } }
.talk { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.talk-player, .talk-frame { display: block; width: 100%; max-width: 100%; aspect-ratio: 16 / 9; border: 0; }
.talk-player { position: relative; padding: 0; cursor: pointer; background: var(--soft); color: var(--ink); }
.talk-cover {
  position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 16px 18px;
  background:
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(0deg, var(--line) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--soft);
}
.talk-cover-title { font-family: var(--f-display); font-weight: 700; font-size: 1.15rem; text-align: left; }
.talk-play {
  position: absolute; left: 50%; top: 45%; width: 58px; height: 58px; transform: translate(-50%, -50%);
  border-radius: 50%; background: var(--accent); transition: transform 0.15s ease;
}
.talk-play::after {
  content: ""; position: absolute; left: 23px; top: 18px;
  border-left: 18px solid var(--accent-ink); border-top: 11px solid transparent; border-bottom: 11px solid transparent;
}
.talk-player:hover .talk-play { transform: translate(-50%, -50%) scale(1.06); }
.talk-player:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) { .talk-play { transition: none; } }
.talk-info { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.talk-info h2 { font-family: var(--f-body); font-weight: 600; font-size: 1.1rem; line-height: 1.35; }
.talk-info p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.talk-info a { margin-top: auto; font-weight: 600; font-size: 0.9375rem; }
.privacy-note { margin: 20px 0 0; color: var(--muted); font-size: 0.875rem; }
