/* daily-digest — Substack/Stratechery: серифный, бумажный, для долгого чтения */

:root {
  /* свет */
  --bg: #fffdf8;             /* тёплый кремовый, мягче чем #fff */
  --bg-card: #fbf8ef;
  --fg: #1a1a1a;             /* мягкий чёрный, не #000 */
  --fg-soft: #2c2a26;
  --muted: #7a756d;
  --rule: #e3ddc9;
  --rule-soft: #efe9d6;
  --link: #1a1a1a;           /* ссылки чёрные, отличаются только подчёркиванием */
  --link-hover: #b53e1c;
  --accent-warn: #b53e1c;
  --accent-insight: #2c7a4c;
  --accent-cta: #8c6a1e;
  --code-bg: #f1ecd9;
  --selection: #f5e8c1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1815;
    --bg-card: #25201c;
    --fg: #e8e3d6;
    --fg-soft: #d3cdc0;
    --muted: #948f83;
    --rule: #3d3833;
    --rule-soft: #2d2925;
    --link: #e8e3d6;
    --link-hover: #f0a98a;
    --accent-warn: #f0a98a;
    --accent-insight: #7ed4a4;
    --accent-cta: #d4b275;
    --code-bg: #2a2521;
    --selection: #4a3f26;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  /* Цепочка от премиум-серифных к гарантированным — без зависимости от веб-шрифтов */
  font-family: "Charter", "Bitstream Charter", "Iowan Old Style",
               "Source Serif Pro", "Lyon Text",
               Georgia, "Times New Roman", "Noto Serif", serif;
  font-size: 19px;
  line-height: 1.7;
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); color: var(--fg); }

main, .container {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s, color 0.15s;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover);
}

/* --- ЗАГОЛОВКИ --- */

h1, h2, h3, h4 {
  color: var(--fg);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-top: 2.4rem;
  margin-bottom: 0.6rem;
}

h1 {
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 0.4rem;
  margin-bottom: 0.3rem;
  line-height: 1.2;
}

h2 {
  font-size: 1.45rem;
  font-weight: 600;
  margin-top: 2.6rem;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1.8rem;
}

p {
  margin: 1.1rem 0;
  hanging-punctuation: first;
}

/* первый абзац после H1 — чуть приподнят и крупнее */
article > p:first-of-type,
article > blockquote:first-of-type + p {
  font-size: 1.08em;
  color: var(--fg-soft);
}

ul, ol {
  margin: 1.1rem 0;
  padding-left: 1.6em;
}

li { margin: 0.4rem 0; }

li::marker { color: var(--muted); }

blockquote {
  margin: 1.6rem 0;
  padding: 0.2rem 0 0.2rem 1.4rem;
  border-left: 2px solid var(--rule);
  color: var(--fg-soft);
  font-style: italic;
}

blockquote p { margin: 0.4rem 0; }

/* --- КОД (моноширинный остров в серифном море) --- */

code {
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 1.8rem 0;
  border-radius: 4px;
  border: 1px solid var(--rule-soft);
}

pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem auto;
  width: 60%;
}

/* --- ТАБЛИЦЫ --- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6rem 0;
  font-size: 0.95em;
  font-feature-settings: "tnum" 1;
}

th, td {
  border-bottom: 1px solid var(--rule);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  font-weight: 600;
  color: var(--fg);
  border-bottom: 2px solid var(--rule);
}

/* --- ШАПКА САЙТА --- */

.site-header {
  margin-bottom: 2.4rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  text-align: center;
}

.site-header .site-title {
  font-size: 1.4rem;
  margin: 0;
  letter-spacing: -0.005em;
  font-weight: 600;
  color: var(--fg);
  font-family: inherit; /* serif — единый бренд с текстом статей */
}

.site-header .site-title a {
  color: var(--fg);
  text-decoration: none;
}

.site-header .site-title a:hover {
  color: var(--link-hover);
}

.site-header .tagline {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.3rem 0 0;
  font-style: italic;
  font-family: inherit; /* serif */
}

/* --- МЕТА статьи (дата, время чтения) --- */

.meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.4rem 0 1.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "tnum" 1;
}

/* --- ТЕГИ --- */

.tags {
  margin: 0 0 2.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

.tag {
  font-size: 0.78rem;
  padding: 3px 10px;
  border: 1px solid var(--rule);
  text-decoration: none;
  color: var(--muted);
  border-radius: 999px;
  letter-spacing: 0.02em;
  background: var(--bg);
}

.tag:visited { color: var(--muted); }
.tag:hover { color: var(--fg); border-color: var(--fg-soft); }

/* --- ФУТЕР --- */

.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

.site-footer a {
  color: var(--muted);
  text-decoration-color: var(--rule);
}

.site-footer a:hover { color: var(--fg); }

/* --- CALLOUTS (выноски) — мягкие, без агрессивных рамок --- */

.callout {
  margin: 1.8rem 0;
  padding: 18px 22px;
  background: var(--bg-card);
  border-left: 3px solid var(--rule);
  border-radius: 0 4px 4px 0;
}

.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.callout .callout-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.callout.warning {
  border-left-color: var(--accent-warn);
}

.callout.warning .callout-title { color: var(--accent-warn); }

.callout.insight {
  border-left-color: var(--accent-insight);
}

.callout.insight .callout-title { color: var(--accent-insight); }

.callout.cta {
  border-left-color: var(--accent-cta);
}

.callout.cta .callout-title { color: var(--accent-cta); }

.callout.note,
.callout.tip {
  border-left-color: var(--muted);
}

/* --- ЛЕНТА ПОСТОВ --- */

.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list li {
  margin: 0;
  padding: 1.6rem 0;
  border-bottom: 1px solid var(--rule);
  display: block;
}

.post-list li:last-child { border-bottom: none; }

.post-list .post-date {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "tnum" 1;
}

.post-list .post-body {}

.post-list .post-title {
  margin: 0 0 0.4rem;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.post-list .post-title a {
  color: var(--fg);
  text-decoration: none;
}

.post-list .post-title a:hover {
  color: var(--link-hover);
}

.post-list .post-teaser {
  margin: 0.3rem 0 0;
  color: var(--fg-soft);
  font-size: 1.02rem;
  line-height: 1.55;
}

.post-list .post-reading {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 0.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

/* --- ИЗОБРАЖЕНИЯ --- */

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.6rem auto;
  border-radius: 4px;
}

figure { margin: 1.8rem 0; }

figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
  font-style: italic;
}

/* --- АДАПТИВ --- */

@media (max-width: 640px) {
  html, body { font-size: 17px; }
  main, .container { padding: 28px 18px 60px; }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.25rem; }
  .post-list .post-title { font-size: 1.3rem; }
  .site-footer { flex-direction: column; gap: 0.4rem; text-align: center; }
}

@media (min-width: 1100px) {
  html, body { font-size: 20px; }
}
