/* Нико — архив материалов и заметок.
   Single stylesheet, no framework, no external requests.
   Self-hosted fonts only; system stack as fallback.

   v2 "paper cinema": editorial Prata display, warm oklch paper,
   scroll-driven article scenes (sticky chapter panel), quiet figures.
   All motion is progressive: content is fully readable with JS off. */

@font-face {
  font-family: 'Prata';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/prata-cyrillic-400-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Prata';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/prata-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122, U+2191, U+2193, U+2212;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/manrope-cyrillic-400-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/manrope-cyrillic-600-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/manrope-cyrillic-700-normal.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/manrope-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122, U+2191, U+2193, U+2212;
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/manrope-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2122, U+2191, U+2193, U+2212;
}

:root {
  --bg: oklch(0.976 0.006 85);
  --bg-raised: oklch(0.988 0.004 85);
  --bg-deep: oklch(0.94 0.012 78);
  --ink: oklch(0.23 0.016 50);
  --ink-soft: oklch(0.46 0.014 50);
  --accent: oklch(0.52 0.1 42);
  --accent-deep: oklch(0.44 0.11 42);
  --rule: oklch(0.9 0.012 82);
  --serif: 'Prata', Georgia, 'Times New Roman', serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --measure: 34rem;
  --measure-narrow: 29rem;
  --wide: 68rem;
}

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

html {
  background-color: #f8f5f1;
  background-color: var(--bg);
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  font: 400 1.02rem/1.7 var(--sans);
  color: var(--ink);
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

img, svg { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(2.4rem, 1.6rem + 3.4vw, 4.4rem); letter-spacing: -.01em; line-height: 1.08; }
h2 { font-size: clamp(1.25rem, 1.1rem + .7vw, 1.55rem); margin-top: 2.4em; }
h3 { font-size: 1.1rem; margin-top: 1.8em; }
p, ul, ol, blockquote, figure { margin: 0 0 1.2em; }
li { margin: .3em 0; }

.wrap { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: 1.4rem; }
.prose { max-width: var(--measure); }

/* ---- masthead ---- */
.masthead {
  border-bottom: 1px solid var(--rule);
  background-color: var(--bg-raised);
  padding-block: 1.05rem;
}
.masthead .wrap { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: baseline; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand-name { font-family: var(--serif); font-size: 1.35rem; letter-spacing: .01em; }

.nav ul { display: flex; flex-wrap: wrap; gap: .35rem 1.4rem; margin: 0; padding: 0; list-style: none; }
.nav a { color: var(--ink-soft); text-decoration: none; font-size: .92rem; }
.nav a:hover { color: var(--accent); text-decoration: underline; }
.nav a[aria-current='page'] { color: var(--accent); text-decoration: underline; text-underline-offset: .3em; }

/* ---- hero ---- */
.hero { padding-block: clamp(3rem, 7vw, 6rem) 2.5rem; border-bottom: 1px solid var(--rule); }
.hero .kicker {
  display: block;
  font: 600 .72rem/1 var(--sans);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.4rem;
}
.hero h1 { max-width: 18ch; }
.hero p.lede { font-size: 1.12rem; line-height: 1.65; color: var(--ink-soft); max-width: 44ch; margin-bottom: 0; }

main { padding-block: 2.5rem 4rem; }

section + section { margin-top: 4rem; }

.section-head {
  display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline;
  justify-content: space-between; border-bottom: 1px solid var(--rule);
  padding-bottom: .6rem; margin-bottom: 1.6rem;
}
.section-head h2 { margin: 0; font-size: 1.3rem; }
.section-head .kicker { display: block; font: 600 .72rem/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem; }

/* ---- article index (library) ---- */
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { border-bottom: 1px solid var(--rule); padding-block: 1.15rem; margin: 0; display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); column-gap: 1.4rem; }
.entries li:last-child { border-bottom: 0; }
.entries .entry-index { font-family: var(--serif); font-size: 1.1rem; color: var(--accent); }
.entries h3 { margin: 0 0 .25rem; font-size: 1.35rem; font-family: var(--serif); }
.entries h3 a { color: var(--ink); text-decoration: none; }
.entries h3 a:hover { color: var(--accent); text-decoration: underline; }
.entries time { font: 400 .82rem/1 var(--mono); color: var(--ink-soft); letter-spacing: .04em; }
.entries .abstract { margin: .45rem 0 0; color: var(--ink-soft); font-size: .97rem; line-height: 1.6; max-width: 46ch; }

/* ---- single article ---- */
.article-head { border-bottom: 1px solid var(--rule); padding-bottom: 1.3rem; margin-bottom: 2.6rem; }
.article-head time { font: 400 .85rem/1 var(--mono); color: var(--ink-soft); letter-spacing: .05em; }
.article-body > p:first-of-type { font-size: 1.08rem; }

/* ---- article scene: sticky chapter panel + flowing prose ---- */
.article-scene { margin-inline: auto; }

.scene-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.2rem; }
.scene-panel { display: none; }
html.js .scene-panel { display: block; }

@media (min-width: 56rem) {
  .scene-layout { grid-template-columns: 14rem minmax(0, var(--measure-narrow)); gap: 3.5rem; justify-content: center; }
  html.js .scene-panel {
    position: sticky;
    top: 3.5rem;
    align-self: start;
  }
}

.scene-panel {
  padding-top: .5rem;
}
.scene-panel .scene-num {
  display: block;
  font-family: var(--serif);
  font-size: clamp(3.2rem, 8vw, 5.5rem);
  line-height: .95;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  opacity: .9;
}
.scene-panel .scene-title {
  display: block;
  margin-top: 1rem;
  font-family: var(--serif);
  font-size: 1.12rem;
  line-height: 1.4;
  color: var(--ink);
  min-height: 2.8em;
  transition: opacity .22s ease, transform .22s ease;
}
.scene-panel .scene-title.is-swap { opacity: 0; transform: translateY(.4rem); }

/* quiet per-theme figures (CSS only, no images) */
.scene-figure {
  display: block;
  width: 8.5rem;
  height: 8.5rem;
  margin-top: 1.8rem;
  border-radius: 50%;
  position: relative;
  opacity: .8;
}
.scene-figure::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px oklch(0.86 0.04 45);
}

/* theme-silence: concentric attention rings, slow breathing */
.theme-silence .scene-figure { background: oklch(0.95 0.02 88); }
@supports (background: none) {
  .theme-silence .scene-figure {
    background:
      radial-gradient(circle at 50% 50%, transparent 0 28%, var(--bg) 29% 30%, transparent 31% 47%, var(--bg) 48% 49%, transparent 50% 66%, var(--bg) 67% 68%, transparent 69%),
      linear-gradient(oklch(0.935 0.02 86), oklch(0.945 0.025 86));
  }
}
@media (prefers-reduced-motion: no-preference) {
  .theme-silence .scene-figure { animation: silence-breathe 7s ease-in-out infinite; }
}
@keyframes silence-breathe {
  0%, 100% { transform: scale(1); opacity: .65; }
  50% { transform: scale(1.07); opacity: .95; }
}

/* theme-paper: stacked edges like a ream of sheets */
.theme-paper .scene-figure {
  border-radius: 18% 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 4px, oklch(0.9 0.02 82) 5px 6px),
    linear-gradient(oklch(0.96 0.02 88), oklch(0.93 0.025 84));
  box-shadow: inset 0 0 0 1px oklch(0.84 0.03 70);
}
.theme-paper .scene-figure::after { border-radius: 18% 0; box-shadow: inset 0 0 0 1px oklch(0.8 0.04 70); }

/* theme-hands: three grip strokes */
.theme-hands .scene-figure {
  border-radius: 0;
  height: 3.4rem;
  width: 10rem;
  background:
    linear-gradient(transparent 0 27%, oklch(0.72 0.05 46) 27% 29%, transparent 29% 38%, oklch(0.72 0.05 46) 38% 40%, transparent 40% 49%, oklch(0.72 0.05 46) 49% 51%, transparent 51%);
}
.theme-hands .scene-figure::after { display: none; }

/* theme-reading: measure ruler — tick marks along a hairline */
.theme-reading .scene-figure {
  border-radius: 0;
  width: 10rem;
  height: 8.5rem;
  background:
    repeating-linear-gradient(90deg, transparent 0 1.4rem, oklch(0.8 0.03 60) 1.4rem 1.6rem),
    linear-gradient(180deg, transparent 0 96%, oklch(0.78 0.03 50) 96%);
}
.theme-reading .scene-figure::after { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .theme-reading .scene-figure { animation: ruler-drift 3.2s ease-in-out infinite; }
}
@keyframes ruler-drift {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-.35rem); }
}

blockquote {
  margin-inline: 0;
  padding-left: 1.1rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}
figcaption { font-size: .85rem; color: var(--ink-soft); margin-top: .5rem; }

hr { border: 0; border-top: 1px solid var(--rule); margin-block: 2.5rem; }

.backlink { font-size: .92rem; }

/* ---- prose details ---- */
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li::marker { color: var(--ink-soft); }
.prose code { font: 400 .88em/1.5 var(--mono); background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 3px; padding: .05em .3em; }

.note { background: var(--bg-raised); border: 1px solid var(--rule); border-radius: 6px; padding: 1rem 1.15rem; font-size: .95rem; }
.note p:last-child { margin-bottom: 0; }

.defs { margin: 0; }
.defs dt { font-weight: 600; margin-top: 1rem; }
.defs dd { margin: .25rem 0 0; color: var(--ink-soft); }

/* ---- contact form ---- */
.contact-form { max-width: var(--measure-narrow); }
.field { margin-bottom: 1.2rem; }
.field label { display: block; font-size: .9rem; margin-bottom: .35rem; color: var(--ink-soft); }
.field input, .field textarea {
  width: 100%;
  font: 400 1rem/1.5 var(--sans);
  color: var(--ink);
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .6rem .75rem;
}
.field textarea { min-height: 9rem; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field .hint { display: block; font-size: .82rem; color: var(--ink-soft); margin-top: .3rem; }

.button {
  display: inline-block;
  font: 600 .95rem/1 var(--sans);
  color: var(--bg-raised);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: .75rem 1.5rem;
  cursor: pointer;
}
.button:hover { background: var(--accent-deep); }
.button:disabled { opacity: .7; cursor: not-allowed; }

.form-notice {
  margin-top: 1rem;
  padding: .7rem .9rem;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: .95rem;
}

/* ---- footer ---- */
.footer { border-top: 1px solid var(--rule); background: var(--bg-raised); padding-block: 1.6rem; font-size: .88rem; color: var(--ink-soft); }
.footer ul { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; }
.footer p { margin: 0; max-width: 60ch; }

.skip {
  position: absolute; left: -9999px;
  background: var(--bg-raised); color: var(--ink);
  padding: .6rem 1rem; border: 1px solid var(--rule); border-radius: 4px; z-index: 10;
}
.skip:focus { left: .75rem; top: .75rem; }

@media (max-width: 34rem) {
  body { font-size: 1rem; }
  .hero { padding-block: 2.4rem 1.9rem; }
  main { padding-block: 1.9rem 3rem; }
  .masthead .wrap { gap: .7rem; }
}

/* ================================================================
   Scroll layer: reading progress, gentle reveals, chapters, rail,
   article scenes. Local only — no external requests, no third-party
   scripts. Nothing here hides content when JS is absent.
   ================================================================ */

.progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 30;
  pointer-events: none;
}

/* Reveal is applied by scroll.js only for below-the-fold blocks. */
html.js .will-reveal {
  opacity: 0;
  transform: translateY(.6rem);
  transition: opacity .55s ease, transform .55s cubic-bezier(.2, .7, .3, 1);
}
html.js .will-reveal.is-in {
  opacity: 1;
  transform: none;
}

/* ---- hero scroll cue ---- */
.scroll-cue {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin: 2.75rem 0 0;
  font: 400 .74rem/1 var(--sans);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.cue-line {
  display: block;
  width: 1px;
  height: 2.5rem;
  background: linear-gradient(to bottom, var(--accent), transparent);
  transform-origin: top center;
  animation: cue 2.6s ease-in-out infinite;
}
@keyframes cue {
  0%, 100% { transform: scaleY(.35); opacity: .45; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* ---- chapters: sticky numeral column + scrolling steps ---- */
.chapters { display: grid; grid-template-columns: minmax(0, 1fr); }
.chapters-visual { display: none; }

@media (min-width: 60rem) {
  .chapters { grid-template-columns: 15rem minmax(0, 1fr); column-gap: 3rem; }
  html.js .chapters-visual {
    display: block;
    position: sticky;
    top: 3.5rem;
    align-self: start;
    padding-top: .4rem;
  }
}

.ghost-num {
  display: block;
  font-family: var(--serif);
  font-size: clamp(3.5rem, 7vw, 6rem);
  line-height: .95;
  font-variant-numeric: tabular-nums;
  color: oklch(0.88 0.055 44);
  transition: opacity .28s ease, transform .28s ease;
}
.ghost-title {
  display: block;
  margin-top: .85rem;
  max-width: 14ch;
  font: 600 .74rem/1.5 var(--sans);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  transition: opacity .28s ease, transform .28s ease;
}
.ghost.is-swap .ghost-num,
.ghost.is-swap .ghost-title {
  opacity: 0;
  transform: translateY(.45rem);
}

.chapter-steps { list-style: none; margin: 0; padding: 0; }
.chapter-steps li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 1.1rem;
  border-bottom: 1px solid var(--rule);
  padding-block: 1.35rem;
  margin: 0;
}
.chapter-steps li:first-child { padding-top: 0; }
.chapter-steps li:last-child { border-bottom: 0; }
.step-body { min-width: 0; }
.step-num { font: 400 .8rem/1.9 var(--mono); letter-spacing: .06em; color: var(--accent); }
.chapter-steps h3 { margin: 0 0 .3rem; font-size: 1.4rem; font-family: var(--serif); }
.chapter-steps h3 a { color: var(--ink); text-decoration: none; }
.chapter-steps h3 a:hover { color: var(--accent); text-decoration: underline; }
.chapter-steps time { font: 400 .82rem/1 var(--mono); color: var(--ink-soft); letter-spacing: .04em; }
.chapter-steps .abstract { margin: .45rem 0 0; color: var(--ink-soft); font-size: .97rem; line-height: 1.6; max-width: 46ch; }

/* Scroll-driven drift for the sticky numeral, progressive only. */
@keyframes ghost-drift {
  from { transform: translateY(1rem); }
  to { transform: translateY(-1rem); }
}
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) {
    html.js .ghost {
      animation: ghost-drift linear both;
      animation-timeline: view();
      animation-range: cover 15% cover 85%;
    }
  }
}

/* ---- chapter rail (built by scroll.js from [data-chapter]) ---- */
.chapter-rail {
  position: fixed;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 25;
}
.chapter-rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .9rem;
  justify-items: end;
}
.chapter-rail a {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font: 600 .7rem/1 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
}
.chapter-rail a::after {
  content: '';
  width: 1.25rem;
  height: 1px;
  background: var(--rule);
  transition: width .3s ease, background .3s ease;
}
.chapter-rail .label { opacity: 0; transform: translateX(.3rem); transition: opacity .3s ease, transform .3s ease; }
.chapter-rail a:hover,
.chapter-rail a.is-active,
.chapter-rail a:focus-visible { color: var(--accent); }
.chapter-rail a:hover .label,
.chapter-rail a.is-active .label,
.chapter-rail a:focus-visible .label { opacity: 1; transform: none; }
.chapter-rail a.is-active::after { width: 2.25rem; background: var(--accent); }
.chapter-rail a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

@media (max-width: 86rem), (hover: none) {
  .chapter-rail { display: none; }
}

/* ---- article scenes: list chapters scrolled into the sticky panel ---- */
.scene-list {
  list-style: none;
  margin: 1.6rem 0 0;
  padding: 0;
  display: grid;
  gap: .55rem;
}
.scene-list li { margin: 0; }
.scene-list a {
  font: 600 .74rem/1.3 var(--sans);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  display: inline-flex;
  gap: .6rem;
  align-items: baseline;
}
.scene-list a .scene-list-num { color: var(--accent); font-variant-numeric: tabular-nums; }
.scene-list a:hover,
.scene-list a.is-active { color: var(--accent); }
.scene-list a.is-active { text-decoration: underline; text-underline-offset: .25em; }