/* ==========================================================================
   base.css — минимальная база вместо Pico CSS
   Дефолты элементов. Токены (--ink, --muted, --hairline, --accent, ...)
   определены в custom.css.
   ========================================================================== */

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

:root {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;

  background-color: var(--bg, #fff);
  color: var(--ink, #373c44);
  font-family: var(--font-serif, Georgia, serif);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.6;
}

body {
  width: 100%;
  margin: 0;
}

body > footer,
body > header,
body > main {
  padding-block: 1rem;
}

/* --------------------------------------------------------------------------
   Контейнер
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 576px) {
  .container {
    padding-inline: 0;
  }
}

/* --------------------------------------------------------------------------
   Заголовки
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 1rem;
  font-family: var(--font-serif, Georgia, serif);
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
}

h1 { font-size: 2rem; line-height: 1.125; }
h2 { font-size: 1.75rem; line-height: 1.15; }
h3 { font-size: 1.5rem; line-height: 1.175; }
h4 { font-size: 1.25rem; line-height: 1.2; }
h5 { font-size: 1.125rem; line-height: 1.225; }
h6 { font-size: 1rem; line-height: 1.25; }

/* --------------------------------------------------------------------------
   Текстовые блоки
   -------------------------------------------------------------------------- */
address, blockquote, dl, ol, p, pre, table, ul {
  margin: 0 0 1rem;
  font-style: normal;
  font-weight: 400;
}

:where(article, address, blockquote, dl, figure, form, ol, p, pre, table, ul) ~ :is(h1, h2, h3, h4, h5, h6) {
  margin-top: 1rem;
}

:where(ol, ul) li {
  margin-bottom: 0.25rem;
}

ul li {
  list-style: square;
}

/* --------------------------------------------------------------------------
   Ссылки
   -------------------------------------------------------------------------- */
:where(a:not([role="button"])),
[role="link"] {
  color: var(--accent, #0172ad);
  background-color: transparent;
  text-decoration: underline;
  text-underline-offset: 0.1rem;
}

:where(a:not([role="button"])):is(:hover, :active, :focus),
[role="link"]:is(:hover, :active, :focus) {
  color: var(--accent-hover, #015887);
}

/* --------------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------------- */
button {
  margin: 0;
  overflow: visible;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  text-transform: none;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Код
   -------------------------------------------------------------------------- */
code, kbd, pre, samp {
  font-family: var(--font-mono, monospace);
  font-size: 0.875em;
  border-radius: 0.25rem;
  background: var(--code-bg, #f3f4f6);
  color: var(--muted, #646b79);
  font-weight: 400;
  line-height: initial;
}

code, kbd, samp {
  display: inline-block;
  padding: 0.375rem;
}

pre {
  display: block;
  margin-bottom: 1rem;
  overflow-x: auto;
}

pre > code,
pre > samp {
  display: block;
  padding: 1rem;
  background: 0 0;
  font-size: inherit;
  font-family: inherit;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Фигуры и медиа
   -------------------------------------------------------------------------- */
figure {
  display: block;
  margin: 0;
  padding: 0;
}

figure figcaption {
  padding: 0.5rem 0;
  color: var(--muted, #646b79);
}

:where(audio, canvas, iframe, img, svg, video) {
  vertical-align: middle;
}

img {
  max-width: 100%;
  height: auto;
  border-style: none;
}

hr {
  height: 0;
  margin: 1rem 0;
  border: 0;
  border-top: 1px solid var(--hairline, #e7eaef);
}

/* --------------------------------------------------------------------------
   Фокус
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 0.125rem solid var(--accent, #0172ad);
  outline-offset: 0.125rem;
}
/* Inter — интерфейс */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter/inter-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: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter/inter-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter/inter-cyrillic-500-normal.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter/inter-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* Literata — текст */
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/literata/literata-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: 'Literata';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/literata/literata-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/literata/literata-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: 'Literata';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/literata/literata-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Literata';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/literata/literata-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: 'Literata';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/literata/literata-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Literata';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/literata/literata-cyrillic-400-italic.woff2') format('woff2');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'Literata';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/literata/literata-latin-400-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
/* ==========================================================================
   1. Токены
   ========================================================================== */
:root {
  /* Шрифты */
  --font-serif: 'Literata', Georgia, serif;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, 'Cascadia Code', monospace;

  /* Цвета */
  --bg: #fbfbf9;
  --ink: #26324a;
  --navy: #16233b;
  --muted: #5b6b82;
  --accent: #2f80ed;
  --success: #1a7f37;
  --danger: #c0392b;
  --code-bg: #eef2f8;
  --code-border: #dde6f1;
  --accent-hover: #1b66c9;
  --accent-focus: rgba(47, 128, 237, 0.25);
  --hairline: #d7e2f0;

  /* Ширина текстовой колонки */
  --measure: 37em;
}

/* ==========================================================================
   2. База
   ========================================================================== */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

p, li {
  hyphens: auto;
  text-wrap: pretty;
}

/* ==========================================================================
   3. Лейаут
   ========================================================================== */
main.container {
  flex: 1;
  max-width: var(--measure);
  padding-top: 2rem;
}

/* На главной между вступлением и списком эссе — больше воздуха */
body.home main.container {
  padding-top: 4rem;
}

/* Имя автора над заголовком эссе — ссылка на главную */
.site-name {
  display: inline-block;
  margin-bottom: 2rem;
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--navy);
  text-decoration: none;
}

.site-name:hover {
  color: var(--accent);
}

body > footer {
  width: 100%;
  padding-block: 1.5rem 2rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 1.5rem;
  max-width: var(--measure);
  margin-inline: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
}

.site-footer__copy,
.site-footer__links {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.5;
}

.site-footer__copy,
.site-footer__links,
.site-footer__links a {
  color: var(--muted);
}

.site-footer__links a {
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ==========================================================================
   4. Типографика
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.22;
}

h2 {
  font-size: 1.4em;
  line-height: 1.25;
}

h3 {
  font-size: 1.2em;
  line-height: 1.3;
}

h4 {
  font-size: 1.05em;
  line-height: 1.4;
}

main > header h1 {
  margin-bottom: 0.5rem;
}

/* Заголовок на странице эссе крупнее, чем в списке на главной */
article > header h1 {
  font-size: clamp(2rem, 6vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--navy);
}

figure {
  margin: 2rem auto;
  max-width: 80%;
  text-align: center;
}

figure img {
  display: block;
  margin: 0 auto;
}

figure figcaption {
  font-size: 0.78rem;
  line-height: 1.4;
}

blockquote {
  margin: 1.75rem 0;
  padding: 0.15rem 0 0.15rem 1.25rem;
  border-inline-start: 2px solid var(--hairline);
  color: var(--muted);
  font-style: italic;
}

/* ==========================================================================
   5. Главная
   ========================================================================== */
.home-header {
  width: 100%;
  max-width: var(--measure);
  padding-top: 5rem;
}

.home-header h1 {
  margin-bottom: 1.1rem;
  font-size: clamp(2.1rem, 7vw, 2.9rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--navy);
}

.home-header__lead {
  max-width: 30em;
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.55;
  hyphens: manual;
}

.home-header__lead a {
  text-decoration-color: var(--hairline);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.home-header__lead a:hover {
  text-decoration-color: currentColor;
}

/* ==========================================================================
   6. Список эссе
   ========================================================================== */
.essay {
  margin: 0 0 3rem;
}

.essay:last-of-type {
  margin-bottom: 0;
}

.essay__meta {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 0.6rem;
}

.essay__num {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.essay__rule {
  flex: 1;
  height: 1px;
  background: var(--hairline);
}

.essay > header {
  margin: 0 0 0.75rem;
}

.essay header h2 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 5vw, 2.15rem);
  line-height: 1.18;
  color: var(--navy);
}

.essay header h2 a {
  color: inherit;
  text-decoration: none;
}

.essay header h2 a:hover {
  color: var(--accent);
}

.essay__summary {
  color: var(--muted);
  margin-bottom: 1rem;
}

.essay__more {
  margin: 0;
}

.essay__more a {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.essay__more a::after {
  content: " →";
}

.essay__more a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ==========================================================================
   7. Футер эссе
   ========================================================================== */
.essay-date {
  margin: 0 0 2rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--muted);
}

.essay-end {
  margin-top: 2.5rem;
}

.essay-actions {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
}

.essay-actions a,
.essay-actions button {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-decoration: none;
}

.essay-actions a:hover,
.essay-actions button:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.essay-actions button.is-copied {
  color: var(--success);
  text-decoration: none;
}

.essay-actions__sep {
  margin-inline: 0.6em;
  color: var(--muted);
}

/* Соседние эссе: подпись-направление и название */
.essay-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-block: 2.5rem 1rem;
}

.essay-nav__link {
  display: block;
  font-weight: 600;
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--navy);
  text-decoration: none;
}

.essay-nav__link:hover {
  color: var(--accent);
}

.essay-nav__link--next {
  grid-column: 2;
  text-align: right;
}

.essay-nav__label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

/* ==========================================================================
   8. Код
   ========================================================================== */
code {
  font-size: 0.85em;
}

:not(pre) > code {
  padding: 0.15em 0.35em;
  border-radius: 6px;
  background: var(--code-bg);
}

.highlight {
  margin: 1.75rem 0;
}

.highlight pre {
  border-radius: 10px;
  border: 1px solid var(--code-border);
  font-size: 0.85em;
}

/* Подсветка синтаксиса (Chroma в режиме классов).
   Палитра собрана из токенов сайта, чтобы код не выпадал из эссе. */
.chroma {
  background: var(--code-bg);
  color: var(--ink);
}

.chroma code {
  color: inherit;
}

/* Комментарии */
.chroma .c,
.chroma .ch,
.chroma .cm,
.chroma .cp,
.chroma .cpf,
.chroma .c1,
.chroma .cs {
  color: var(--muted);
  font-style: italic;
}

/* Ключевые слова: switch, case, return, true */
.chroma .k,
.chroma .kc,
.chroma .kd,
.chroma .kn,
.chroma .kp,
.chroma .kr,
.chroma .kt {
  color: var(--navy);
  font-weight: 600;
}

/* Операторы и пунктуация: <, >=, &&, :, ; */
.chroma .o,
.chroma .ow,
.chroma .p {
  color: var(--muted);
}

/* Строки */
.chroma .s,
.chroma .sa,
.chroma .sb,
.chroma .sc,
.chroma .dl,
.chroma .sd,
.chroma .s1,
.chroma .s2,
.chroma .se,
.chroma .sh,
.chroma .si,
.chroma .sx,
.chroma .sr,
.chroma .ss {
  color: var(--success);
}

/* Числа */
.chroma .m,
.chroma .mb,
.chroma .mf,
.chroma .mh,
.chroma .mi,
.chroma .mo {
  color: var(--accent-hover);
}

/* Имена: функции, классы, атрибуты, встроенные */
.chroma .na,
.chroma .nb,
.chroma .bp,
.chroma .nc,
.chroma .nd,
.chroma .ne,
.chroma .nf,
.chroma .fm,
.chroma .nl,
.chroma .nn,
.chroma .nt,
.chroma .nv,
.chroma .py {
  color: var(--accent);
}

/* Диффы и ошибки */
.chroma .gd { color: var(--danger); }
.chroma .gi { color: var(--success); }
.chroma .err { color: var(--danger); }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: 600; }

/* ==========================================================================
   9. Шеринг
   ========================================================================== */
/* «Поделиться» появляется только при включённом JS */
.essay-share,
.essay-actions__sep {
  display: none;
}

.js .essay-share,
.js .essay-actions__sep {
  display: inline;
}

/* ==========================================================================
   10. Адаптив
   ========================================================================== */
@media (max-width: 575px) {
  .essay-nav {
    grid-template-columns: 1fr;
  }

  .essay-nav__link--next {
    grid-column: auto;
    text-align: left;
  }
}

/* ==========================================================================
   11. Переходы между страницами (View Transitions)
   ========================================================================== */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: 120ms ease-out both vt-fade-out;
}

::view-transition-new(root) {
  animation: 120ms ease-in both vt-fade-in;
}

@keyframes vt-fade-out {
  to { opacity: 0; }
}

@keyframes vt-fade-in {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}
