/* ==========================================================================
   LifeOS — направление B «Тихий технический блокнот»
   Дизайнер B, фаза 3. Скетч: hero + «Введение».
   ========================================================================== */

/* ---- Шрифты: self-hosted, кириллица + латиница ---- */
@font-face {
  font-family: "Lora";
  src: url("fonts/lora-cyrillic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0400-04FF, U+0500-052F, U+2DE0-2DFF, U+A640-A69F;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/lora-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/lora-cyrillic-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0400-04FF, U+0500-052F;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/lora-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/lora-cyrillic-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0400-04FF, U+0500-052F;
}
@font-face {
  font-family: "Lora";
  src: url("fonts/lora-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-cyrillic-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0400-04FF, U+0500-052F;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-cyrillic-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0400-04FF, U+0500-052F;
}
@font-face {
  font-family: "Onest";
  src: url("fonts/onest-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}

/* ---- Токены ---- */
:root {
  /* тёмная тема — по умолчанию (см. манифест) */
  --bg: #15130f;
  --surface: #1d1a15;
  --hairline: rgba(235, 228, 216, 0.09);
  --text: #ebe4d8;
  --text-muted: #948c7e;
  --accent: #6e8b94;
  --accent-strong: #86a4ad;
  --shadow-ink: 10, 8, 5;

  --font-display: "Lora", "Noto Serif", Georgia, serif;
  --font-body: "Onest", "Noto Sans", Arial, sans-serif;

  /* шкала ×1.25, база 1rem = 16px */
  --fs-body: 1rem;        /* 16px */
  --fs-meta: 1.125rem;    /* 18px */
  --fs-lead: 1.25rem;     /* 20px */
  --fs-h3: 1.5625rem;     /* 25px */
  --fs-h2: 1.953rem;      /* 31px */
  --fs-h1: 2.441rem;      /* 39px, десктопный пол для h1 внутри статьи */

  /* 8pt-сетка */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 32px;
  --sp-6: 48px;
  --sp-8: 64px;
  --sp-12: 96px;
  --sp-16: 128px;

  --measure: 66ch;
  --ease-quiet: cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f3ea;
    --surface: #efe9dc;
    --hairline: rgba(33, 29, 23, 0.10);
    --text: #211d17;
    --text-muted: #6b6255;
    --accent: #3e5c64;
    --accent-strong: #2f474e;
    --shadow-ink: 33, 29, 23;
  }
}

/* ---- Сброс и база ---- */
* { box-sizing: border-box; }
html {
  color-scheme: dark light;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 var(--sp-3); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration-color: var(--hairline);
}

::selection {
  background: var(--text);
  color: var(--bg);
}

:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 3px;
}

/* ---- Skip-link ---- */
.skip-link {
  position: absolute;
  left: var(--sp-2);
  top: -48px;
  background: var(--surface);
  color: var(--text);
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--hairline);
  font-family: var(--font-body);
  font-size: 0.875rem;
  z-index: 100;
  transition: top 160ms var(--ease-quiet);
}
.skip-link:focus-visible {
  top: var(--sp-2);
}

/* ---- Layout shell ---- */
.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1024px) {
  .page {
    grid-template-columns: 240px minmax(0, 1fr);
  }
}

/* ---- Masthead (тихая шапка — корешок книги, не бренд-лого) ---- */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-3) 0;
  grid-column: 1 / -1;
}

.wordmark {
  font-family: var(--font-display);
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}
.wordmark strong {
  font-weight: 500;
  color: var(--text);
}

.wordmark-rule {
  display: block;
  width: 40px;
  height: 1px;
  margin-top: 8px;
  background: var(--accent);
  transform-origin: left;
  animation: draw-rule 700ms var(--ease-quiet) 200ms both;
}

@keyframes draw-rule {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---- Оглавление: десктоп-рейл ---- */
.toc-desktop {
  display: none;
}

@media (min-width: 1024px) {
  .toc-desktop {
    display: block;
    grid-row: 2 / 3;
    grid-column: 1 / 2;
    padding: var(--sp-6) var(--sp-3) var(--sp-6) var(--sp-4);
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100vh;
    overflow-y: auto;
  }
}

.toc-desktop__eyebrow,
.toc-mobile summary {
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 var(--sp-2);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.toc-list a {
  display: flex;
  gap: var(--sp-1);
  align-items: baseline;
  padding: 8px 8px;
  text-decoration: none;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: color 160ms var(--ease-quiet), background 160ms var(--ease-quiet);
}

.toc-list a:hover {
  color: var(--text);
}

.toc-list a[aria-current="page"] {
  color: var(--text);
  background: var(--surface);
  font-weight: 500;
}

.toc-list a[aria-current="page"] .toc-num {
  color: var(--accent-strong);
}

.toc-num {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.75rem;
  min-width: 1.4em;
}

/* ---- Оглавление: мобильный disclosure ---- */
.toc-mobile {
  grid-column: 1 / -1;
  padding: var(--sp-2) var(--sp-3) 0;
}

@media (min-width: 1024px) {
  .toc-mobile { display: none; }
}

.toc-mobile summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--sp-1) 0;
}
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary::after {
  content: "+";
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--accent);
}
.toc-mobile[open] summary::after {
  content: "\2212";
}
.toc-mobile .toc-list {
  padding: var(--sp-2) 0 var(--sp-3);
  border-bottom: 1px solid var(--hairline);
}

/* ---- Main ---- */
main {
  grid-column: 1 / -1;
  min-width: 0;
}

@media (min-width: 1024px) {
  main { grid-column: 2 / 3; }
}

section {
  padding: var(--sp-12) var(--sp-3);
}

@media (min-width: 640px) {
  section { padding: var(--sp-16) var(--sp-6); }
}

.section-inner {
  max-width: var(--measure);
  margin: 0 auto;
}

/* ---- Hero ---- */
.hero {
  min-height: 86vh;
  display: flex;
  align-items: center;
  padding-top: var(--sp-8);
}

.hero__eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 var(--sp-3);
  opacity: 0;
  animation: rise-in 640ms var(--ease-quiet) 120ms forwards;
}

.hero__tagline {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.9rem, 1.2rem + 3vw, 3.4rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: var(--text);
  max-width: 18ch;
  opacity: 0;
  animation: rise-in 720ms var(--ease-quiet) 260ms forwards;
}

.hero__tagline em {
  font-style: italic;
  color: var(--accent-strong);
}

.hero__sub {
  margin-top: var(--sp-4);
  max-width: 52ch;
  color: var(--text-muted);
  font-size: var(--fs-lead);
  line-height: 1.55;
  opacity: 0;
  animation: rise-in 720ms var(--ease-quiet) 420ms forwards;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  opacity: 0;
  animation: rise-in 720ms var(--ease-quiet) 560ms forwards;
}

.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 16px 24px;
  min-height: 44px;
  border: 1px solid var(--accent);
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  transition: background 180ms var(--ease-quiet), border-color 180ms var(--ease-quiet);
}
.cta-primary:hover {
  background: rgba(110, 139, 148, 0.14);
  border-color: var(--accent-strong);
}

.cta-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 4px;
  min-height: 44px;
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--hairline);
}
.cta-secondary:hover {
  color: var(--text);
  border-bottom-color: var(--text-muted);
}

/* ---- Введение ---- */
.chapter {
  border-top: 1px solid var(--hairline);
}

.chapter__head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
}

.chapter__num {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.chapter__head h2 {
  font-size: var(--fs-h1);
}

.chapter__lede {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-h3);
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 34ch;
  margin-bottom: var(--sp-8);
}

.chapter__body blockquote {
  position: relative;
  margin: 0 0 var(--sp-8);
  padding-left: var(--sp-6);
  max-width: var(--measure);
}

.chapter__body blockquote::before {
  content: "\201C";
  position: absolute;
  left: 0;
  top: -0.2em;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 2.6em;
  line-height: 1;
  color: var(--accent);
  opacity: 0.55;
}

.chapter__body blockquote p {
  font-family: var(--font-display);
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: var(--text);
}

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

.chapter__pivot {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-h2);
  line-height: 1.3;
  color: var(--accent-strong);
  max-width: 22ch;
  margin: var(--sp-8) 0;
}

.chapter__note {
  margin-top: var(--sp-8);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--hairline);
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 52ch;
}

/* ---- Footer ---- */
footer {
  grid-column: 1 / -1;
  padding: var(--sp-6) var(--sp-3) var(--sp-8);
  border-top: 1px solid var(--hairline);
  color: var(--text-muted);
  font-size: 0.8125rem;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  justify-content: space-between;
}

footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--hairline);
}
footer a:hover { color: var(--text); }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .wordmark-rule,
  .hero__eyebrow,
  .hero__tagline,
  .hero__sub,
  .hero__actions {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
