/* ====== Параметры оформления ====== */
:root {
  --bg: #fdffff;        /* Paper */
  --ink: #2f2e87;       /* Ink */
  --ink-soft: #57639f;  /* Secondary test */
  --accent: #46549e;    /* Selection */
  --card: #e0e5f9;      /* Card background */
  --rule: #d9d3c1;      /* Thin lines */
  --line: 0.0625rem;    /* Thinner line: ≈1px in rem */
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.05rem/1.7 Georgia, "Times New Roman", serif;
}

h1, h2, h3, p, figure, blockquote { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; height: auto; }
section { scroll-margin-top: 1.5rem; }


/* Header */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1.5rem;
  padding: .8rem clamp(1rem, 3vw, 2.25rem);
  border-bottom: var(--line) solid var(--rule);
}
.brand { font-size: 1.45rem; font-weight: 700; font-style: italic; }
.tagline {
  font-style: italic;
  color: var(--ink-soft);
  border-left: var(--line) solid var(--rule);
  padding-left: 1.4rem;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.4rem;
  margin-left: auto;
  font-size: .95rem;
}

/* Page grid */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);  /* Phone: one column */
  gap: 2.5rem;
  padding: 2rem clamp(1rem, 3vw, 2.25rem) 4rem;
}
.article { order: -1; }  /* Phone: article first */

@media (min-width: 55em) {   /* Tablet: TOC + article */
  .layout { grid-template-columns: 15rem minmax(0, 1fr); }
  .col-toc   { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: 2.5rem; }
  .col-toc > nav { position: sticky; top: 1.5rem; }
  .article   { grid-column: 2; grid-row: 1; }
  .col-aside { grid-column: 2; grid-row: 2; }
  .doodle    { margin-top: auto; }   /* рисунок прижат к низу колонки */
}
@media (min-width: 80em) {   /* Desktop: 3 columns */
  .layout { grid-template-columns: 15rem minmax(0, 1fr) 17rem; }
  .col-aside { grid-column: 3; grid-row: 1; position: sticky; top: 1.5rem; align-self: start; }
}

/* Right column */
.col-aside { display: grid; gap: 2.25rem; align-content: start; }
.aside-title { font-size: 1.02rem; margin-bottom: .8rem; }

/* TOC: header counters */
.toc { font-size: .95rem; line-height: 1.5; counter-reset: lvl1; }
.toc ul > li { counter-increment: lvl1; }
.toc ul > li > ul { counter-reset: lvl2; }
.toc ul > li > ul > li { counter-increment: lvl2; }
.toc ul > li::before { content: counter(lvl1) "."; }
.toc ul > li > ul > li::before { content: counter(lvl1) "." counter(lvl2) "."; }

.toc ul > li {
  display: grid;
  grid-template-columns: 3.2ch 1fr;  /* колонка под номер + текст */
  column-gap: .5em;
  align-items: baseline;
  padding: .18rem 0;
}
.toc ul > li::before { grid-column: 1; }
.toc ul > li > a,
.toc ul > li > ul { grid-column: 2; }
.toc ul > li li { color: var(--ink-soft); }

/* Quotes */
blockquote {
  background: var(--card);
  border-radius: .5em;
  padding: 1.1rem 1.4rem;
  font-style: italic;
}
.quote-source {
  margin-top: .6rem;
  font-style: normal;
  font-size: .85em;
  color: var(--ink-soft);
}

/* Article */
.article { min-width: 0; max-width: 52rem; margin-inline: auto; }

.article-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48%;
  gap: 1.25rem 2rem;
  align-items: start;
  padding-bottom: 1.75rem;
  margin-bottom: 2.5rem;
  border-bottom: var(--line) solid var(--rule);
}
.kicker { color: var(--ink-soft); font-size: .92rem; margin-bottom: .6rem; }
.article h1 {
  font-size: clamp(1.7rem, 1.15rem + 1.7vw, 2.4rem);
  line-height: 1.22;
}
.lede { margin-top: 1rem; font-size: 1.12em; }

.article h2 {
  font-size: clamp(1.5rem, 1.2rem + .9vw, 2rem);
  line-height: 1.25;
  margin: 2.75rem 0 1.1rem;
}
.article h3 { font-size: 1.3rem; margin: 2.25rem 0 .8rem; }
.article p {
    max-width: 70ch;
    text-align: justify;
}
.article p + p { margin-top: 1rem; }

.article blockquote {
  margin: 1.75rem 0;
  border-left: .3em solid var(--accent);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

@media (max-width: 40em) {   /* Phone: article header in column */
  .article-head { grid-template-columns: 1fr; }
  .hero { max-width: 22rem; }
}

/* Doodle (left-down corner) */
.doodle { color: var(--ink-soft); }
.doodle img { width: min(60%, 11rem); }
.doodle figcaption {
  margin-top: .8rem;
  font-family: "Segoe Script", "Comic Sans MS", cursive;
  font-size: .92rem;
  line-height: 1.55;
}

/* Links */
.ext-links { display: grid; gap: .65rem; font-size: .95rem; }
.ext-links a { display: flex; justify-content: space-between; gap: .75em; }
.ext-links a::after { content: "↗\FE0E"; color: var(--ink-soft); }
.ext-links a:hover::after { color: var(--accent); }

/* Small screens */
@media (max-width: 30em) {
  .tagline { display: none; }
}
