/* Эссе «Золотая рыбка по подписке» — типографика.
   Палитра: светлая тёплая бумага + графит + терракота (дуотон иллюстраций).
   Установка: максимум воздуха, лёгкие заголовки. */

/* ---------- шрифт: Literata (variable, self-host, OFL) ---------- */

@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/literata-400-normal-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/literata-400-normal-cyrillic.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 700;
  font-display: swap;
  src: url("fonts/literata-400-italic-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/literata-400-italic-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------- палитра ---------- */

:root {
  color-scheme: light; /* одна тема: страница не подстраивается под тёмную систему */
  --paper: #faf7f1;
  --ink: #34302a;
  --muted: #8f8578;
  --accent: #a8492a;
  --line: #e8e2d7;
  --pocket-bg: #f3efe7;
  interpolate-size: allow-keywords; /* плавное раскрытие details там, где умеют */
}

/* ---------- база ---------- */

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.06rem/1.75 "Literata", Georgia, "Times New Roman", serif;
  font-feature-settings: "liga", "kern";
  text-rendering: optimizeLegibility;
}

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

article, .masthead, .colophon {
  max-width: 33rem; /* ~66 знаков в строке */
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

p { margin: 0 0 1.5em; hyphens: manual; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 560; }

/* ---------- шапка и подвал ---------- */

.masthead { padding-top: 7rem; }

h1 {
  font-size: 2.45rem;
  font-weight: 400;
  line-height: 1.14;
  margin: 0 0 0.8rem;
  letter-spacing: -0.015em;
}

.subtitle {
  font-style: italic;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.5;
  margin-bottom: 0.8rem;
}

.byline {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  margin: 0 0 0.5rem;
}

.langswitch {
  font-size: 0.85rem;
  margin: 0 0 2.4rem;
}
.langswitch a { color: var(--muted); text-decoration-color: var(--line); }

.controls { margin-bottom: 3rem; }

.controls button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  cursor: pointer;
}

.colophon {
  margin-top: 6rem;
  padding-top: 1.4rem;
  padding-bottom: 4rem;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- заголовки и разделители ---------- */

h2 {
  font-size: 1.55rem;
  font-weight: 460;
  line-height: 1.3;
  margin: 4.5rem 0 1.3rem;
  letter-spacing: -0.005em;
}
h2 .anchor {
  font-size: 0.8em;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
h2:hover .anchor { opacity: 1; }

h3 { font-size: 1.15rem; font-weight: 520; margin: 2.8rem 0 0.7rem; }
h3 .anchor {
  font-size: 0.82em;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
h3:hover .anchor { opacity: 1; }

hr { border: 0; margin: 3.5rem 0; text-align: center; }
hr::after { content: "⁂"; color: var(--muted); font-size: 1rem; letter-spacing: 0.3em; }

/* ---------- цитаты, код, списки ---------- */

blockquote {
  margin: 2.4rem 0;
  padding-left: 1.2rem;
  border-left: 2px solid var(--accent);
  font-style: italic;
  font-size: 1.12rem;
  color: var(--muted);
}
blockquote p { margin: 0; }

pre {
  background: var(--pocket-bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font: 0.78rem/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  margin: 1.9rem 0;
}

code { font: 0.88em ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

ul { margin: 0 0 1.5em; padding-left: 1.3rem; }
li { margin-bottom: 0.5em; }
li::marker { color: var(--accent); }

/* ---------- иллюстрации ---------- */

figure { margin: 3rem 0; }

figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  background: #fff;
  cursor: zoom-in;
}

/* ---------- лайтбокс ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  overflow: auto;
  padding: 4vmin;
  background: rgba(22, 18, 12, 0.82);
  cursor: zoom-out;
}
.lightbox.open { display: block; }
.lightbox img {
  display: block;
  margin: 0 auto;
  max-width: min(100%, 1500px);
  height: auto;
  border-radius: 4px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

figcaption {
  margin-top: 0.6rem;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- карманы ---------- */

details.pocket {
  margin: 2.2rem 0;
  border-left: 2px solid var(--accent);
  background: var(--pocket-bg);
  border-radius: 0 3px 3px 0;
}

details.pocket summary {
  list-style: none;
  cursor: pointer;
  padding: 0.7rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.01em;
}
details.pocket summary::-webkit-details-marker { display: none; }
details.pocket summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.55em;
  transition: transform 0.2s;
}
details.pocket[open] summary::before { transform: rotate(90deg); }

details.pocket .anchor {
  margin-left: 0.6em;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s;
}
details.pocket summary:hover .anchor { opacity: 1; }

.pocket-body { padding: 0.1rem 1.2rem 1rem; font-size: 0.99rem; }
.pocket-body > p:last-child { margin-bottom: 0.2em; }

/* плавное раскрытие — прогрессивно (Chrome/Edge); остальным мгновенно */
details.pocket::details-content {
  block-size: 0;
  overflow: clip;
  transition: block-size 0.3s, content-visibility 0.3s allow-discrete;
}
details.pocket[open]::details-content { block-size: auto; }

/* ---------- маргиналии ---------- */

.aside {
  margin: 1.9rem 0;
  padding: 0.7rem 1rem;
  border-left: 2px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
}
.aside p { margin: 0; }

@media (min-width: 78rem) {
  article { position: relative; }
  .aside {
    float: right;
    clear: right;
    width: 15rem;
    margin: 0.2rem -19rem 1rem 1.5rem;
    border-left: none;
    border-top: 1px solid var(--line);
    padding: 0.6rem 0 0;
  }
}

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

@media print {
  details.pocket { border: none; background: none; }
  details.pocket summary { display: none; }
  details.pocket::details-content { block-size: auto; content-visibility: visible; }
  .controls { display: none; }
}
