@view-transition { navigation: auto; }

/* ==========================================================================
   ЛИТЕРА — база
   Система: материал (картон/бумага/туш/сурик), фиксированные шкалы кеглей
   и отступов, одна кривая движения. Никаких градиентов и размытий.
   ========================================================================== */

:root {
  /* материал */
  --graphite: #1b1d1c;
  --graphite-2: #242726;
  --paper: #e8e4d9;
  --paper-2: #ded9cb;
  --paper-3: #cfc9b7;
  --ink: #1a1a18;
  --ink-2: #3c3c37;
  --ink-3: #55544d;
  --red: #bf2f1c;
  --red-2: #8d2113;
  --cardboard-red: #a83a29;
  --cardboard-red-2: #8a2f21;
  --cardboard-slate: #4d5959;
  --cardboard-slate-2: #3f4a4a;
  --ochre: #b08a3e;

  /* шкала кеглей: 1.0 → 1.25 с дисплейными ступенями */
  --s-12: 0.75rem;
  --s-14: 0.875rem;
  --s-16: 1rem;
  --s-19: 1.1875rem;
  --s-24: 1.5rem;
  --s-30: 1.875rem;
  --s-38: 2.375rem;
  --s-48: 3rem;
  --s-60: 3.75rem;
  --s-76: 4.75rem;
  --s-102: 6.375rem;
  --s-136: 8.5rem;

  /* отступы: шаг 4 px */
  --u-1: 4px;
  --u-2: 8px;
  --u-3: 12px;
  --u-4: 16px;
  --u-5: 24px;
  --u-6: 32px;
  --u-7: 48px;
  --u-8: 64px;
  --u-9: 96px;
  --u-10: 128px;

  --ease: cubic-bezier(0.22, 0.61, 0.21, 1);
  --slow: 720ms;
  --gutter: clamp(20px, 5.4vw, 88px);
  --measure: 33em; /* ≈ 62 знака книжного набора */

  --font-ui: "Golos Text", "DejaVu Sans", system-ui, sans-serif;
  --font-poster: "Unbounded", "Golos Text", sans-serif;
  --font-book: "Old Standard TT", "DejaVu Serif", Georgia, serif;

  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: var(--s-16);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Зерно: настоящая бумажная текстура (assets/img/paper-grain.png).
   Сила подобрана замером разброса яркости, а не на глаз:
   на бумаге — multiply 0.16 (σ ≈ 1.0), на графите — screen 0.20 (σ ≈ 1.8). */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: multiply;
  background-image: url("../img/paper-grain.png");
  background-size: 512px 512px;
  background-repeat: repeat;
}

h1, h2, h3, h4, p, figure, blockquote, dl, dd, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button { font: inherit; color: inherit; }

:where(h1, h2, h3) { text-wrap: balance; }
p { text-wrap: pretty; }

::selection {
  background: var(--red);
  color: var(--paper);
}

/* Фокус: типографская линейка, а не свечение. Всегда виден. */
:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}
.page-archive :focus-visible { outline-color: var(--paper); }

/* ---------- утилиты ---------- */

/* битая картинка: место сохраняется, подпись остаётся */
img[data-broken="true"] { opacity: 0; }

.u-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.u-meta {
  font-family: var(--font-ui);
  font-size: var(--s-12);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

.u-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.u-rule {
  border: 0;
  border-top: 1px solid currentColor;
  opacity: 0.35;
  margin: 0;
}

/* ---------- общий хром: главная ---------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--u-2) var(--u-5);
  padding: var(--u-5) var(--gutter) 0;
  color: var(--paper);
}

.masthead__mark {
  font-family: var(--font-ui);
  font-size: var(--s-14);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.masthead__meta {
  font-family: var(--font-ui);
  font-size: var(--s-12);
  letter-spacing: 0.02em;
  color: rgba(232, 228, 217, 0.62);
  text-align: right;
}

/* ---------- общий хром: страницы дел (корешок папки) ---------- */

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: var(--u-4) 0 var(--u-5);
  background-color: var(--rail-bg, var(--cardboard-red));
  background-image: url("../img/cardboard.png");
  background-size: 220px 220px;
  background-blend-mode: soft-light;
  color: var(--rail-ink, var(--paper));
  border-right: 1px solid rgba(0, 0, 0, 0.22);
}

.rail__home {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: inherit;
  text-decoration: none;
  border: 1px solid currentColor;
  transition: background-color 180ms var(--ease), color 180ms var(--ease);
}

.rail__home:hover { background: var(--rail-ink, var(--paper)); color: var(--rail-bg, var(--red)); }

.rail__label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--font-ui);
  font-size: var(--s-12);
  font-weight: 500;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.9;
}

.rail__holes {
  display: grid;
  gap: var(--u-5);
  margin-bottom: var(--u-6);
}

.rail__holes span {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.34);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.14);
}

@media (max-width: 900px) {
  .rail {
    position: sticky;
    top: 0;
    right: 0;
    width: 100%;
    height: 52px;
    flex-direction: row;
    justify-content: space-between;
    padding: 0 var(--u-4);
    border-right: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.22);
  }
  .rail__label { writing-mode: horizontal-tb; letter-spacing: 0.16em; font-size: var(--s-12); }
  .rail__holes { display: none; }
}

/* ---------- биография: общий блок для обоих дел ---------- */

.bio {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(30px, 4.6vw, 72px) var(--gutter) clamp(34px, 5.2vw, 80px);
  border-top: 1px solid rgba(26, 26, 24, 0.24);
}

.bio__title {
  margin-bottom: clamp(14px, 1.8vw, 22px);
  font-family: var(--font-book);
  font-weight: 700;
  font-size: clamp(26px, 3.6vw, 48px);
  line-height: 1.04;
  letter-spacing: -0.015em;
}

.bio__lead {
  max-width: 62ch;
  font-family: var(--font-book);
  font-size: clamp(18px, 1.5vw, 23px);
  line-height: 1.5;
  color: var(--ink);
  hanging-punctuation: first;
}

.bio__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 0.5fr);
  gap: clamp(20px, 3.6vw, 56px);
  align-items: start;
  margin-top: clamp(22px, 3vw, 38px);
}

.bio__prose { min-width: 0; }

.bio__prose p {
  max-width: 64ch;
  font-family: var(--font-book);
  font-size: clamp(16px, 1.14vw, 19px);
  line-height: 1.62;
  color: var(--ink);
  hanging-punctuation: first;
}

.bio__prose p + p { margin-top: 0.8em; text-indent: 1.4em; }

.bio__plate { margin: 0; }

.bio__plate img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 18%;
  border: 1px solid rgba(26, 26, 24, 0.25);
  filter: grayscale(1) contrast(1.03);
}

.bio__plate figcaption {
  margin-top: var(--u-2);
  font-family: var(--font-ui);
  font-size: var(--s-12);
  line-height: 1.45;
  color: var(--ink-3);
}

.bio__sub {
  margin-top: clamp(26px, 3.6vw, 48px);
  padding-top: clamp(12px, 1.6vw, 18px);
  border-top: 1px solid rgba(26, 26, 24, 0.24);
  font-family: var(--font-ui);
  font-size: var(--s-12);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- хронология ---------- */

.tl { margin-top: clamp(12px, 1.8vw, 20px); }

.tl__item {
  display: grid;
  grid-template-columns: 6.4em minmax(0, 1fr);
  gap: clamp(12px, 2.6vw, 36px);
  padding: clamp(11px, 1.4vw, 18px) 0;
  border-bottom: 1px solid rgba(26, 26, 24, 0.14);
}

.tl__item:last-child { border-bottom: 0; }

.tl__year {
  font-family: var(--tl-year, var(--font-book));
  font-weight: 700;
  font-size: clamp(15px, 1.35vw, 20px);
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.tl__body { min-width: 0; }

.tl__head {
  margin-bottom: 0.2em;
  font-family: var(--font-book);
  font-weight: 700;
  font-size: clamp(16px, 1.22vw, 20px);
  line-height: 1.35;
}

.tl__text {
  max-width: 58ch;
  font-family: var(--font-book);
  font-size: clamp(15px, 1.06vw, 18px);
  line-height: 1.58;
  color: var(--ink-2);
}

/* хроника: список в центре, снимки — отдельными колонками по бокам.
   Снимки стоят на своих местах через --at (процент высоты списка), поэтому
   ни один пункт не растягивается из-за картинки. */
.bio-chron {
  --lane: clamp(124px, 13.2vw, 190px);
  position: relative;
  display: grid;
  grid-template-columns: var(--lane) minmax(0, 1fr) var(--lane);
  gap: clamp(12px, 2.4vw, 40px);
  padding-bottom: clamp(28px, 4vw, 72px);
}

.bio-chron .tl { grid-column: 2; margin-top: 0; }

.bio-chron__lane {
  position: relative;
  align-self: stretch;
  min-width: 0;
}

/* тонкая линейка поля: связывает снимки со списком, как в конторской книге */
.bio-chron__lane::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(26, 26, 24, 0.14);
}

.bio-chron__lane--left::before { right: calc(clamp(12px, 2.4vw, 40px) / -2); }
.bio-chron__lane--right::before { left: calc(clamp(12px, 2.4vw, 40px) / -2); }

.tl-photo {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--at, 50) * 1%);
  margin: 0;
}

.tl-photo img {
  width: 100%;
  border: 1px solid rgba(26, 26, 24, 0.22);
  background: var(--paper-2);
  filter: grayscale(1) contrast(1.03);
}

.tl-photo figcaption {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.42;
  color: var(--ink-3);
}

.tl-photo__year {
  display: block;
  margin-bottom: 2px;
  font-family: var(--tl-year, var(--font-book));
  font-weight: 700;
  font-size: var(--s-14);
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* уже 1100 px: снимки уходят под хронологию общей галереей в две колонки */
@media (max-width: 1100px) {
  .bio-chron {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--u-4);
    padding-bottom: 0;
  }
  .bio-chron .tl { grid-column: 1 / -1; order: 1; }
  .bio-chron__lane { display: contents; }
  .bio-chron__lane::before { display: none; }
  .tl-photo { position: static; grid-column: auto; order: 2; }
}

@media (max-width: 420px) {
  .bio-chron { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .bio__grid { grid-template-columns: minmax(0, 1fr); }
  .bio__plate { max-width: 420px; }
  .bio__prose p + p { text-indent: 0; }
  .tl__item { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tl__year { font-size: var(--s-14); color: var(--ink-3); letter-spacing: 0.03em; }
}

@media print {
  .bio__plate img,
  .tl-photo img { filter: none; }
  .bio-chron { grid-template-columns: minmax(0, 1fr); }
  .bio-chron__lane { display: none; }
  .tl__item { break-inside: avoid; }
}

/* ---------- колофон ---------- */

.colophon {
  padding: var(--u-8) var(--gutter) var(--u-9);
  font-family: var(--font-ui);
  font-size: var(--s-14);
  line-height: 1.6;
  border-top: 1px solid currentColor;
}

.colophon__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--u-6);
  max-width: 1180px;
}

.colophon h2 {
  font-size: var(--s-12);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: var(--u-3);
}

.colophon p { margin-bottom: var(--u-2); color: var(--ink-2); max-width: 42ch; }
.colophon strong { font-weight: 600; color: currentColor; }
.colophon a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.colophon a:hover { color: var(--red); }

/* ---------- ссылки и кнопки ---------- */

.link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  transition: text-decoration-color 160ms var(--ease);
}

.link:hover { text-decoration-color: currentColor; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--u-2);
  padding: var(--u-2) var(--u-4);
  font-family: var(--font-ui);
  font-size: var(--s-14);
  font-weight: 500;
  background: transparent;
  border: 1px solid currentColor;
  cursor: pointer;
  transition: background-color 160ms var(--ease), color 160ms var(--ease);
}

.btn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

/* ---------- появление (только там, где движение осмысленно) ---------- */

.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 560ms var(--ease), transform 560ms var(--ease);
}

.reveal.is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ---------- печать ---------- */

@media print {
  body { background: #fff; color: #000; }
  body::after { display: none; }
  .rail, .masthead, .folder__hint { display: none; }
  a { text-decoration: none; }
  .colophon { page-break-before: always; }
}
