/* ============================================================
   Модуль 00 — Підготовка до навчання
   Дизайн-система: синій «хендбук» + бічний зміст
   ============================================================ */

:root {
  --paper:      #ffffff;
  --paper-2:    #f4f8fd;
  --ink:        #1b2130;
  --ink-2:      #59617a;
  --azure:      #1e7ce8;
  --azure-deep: #0b5cc4;
  --mist:       #e9f2fd;
  --mist-2:     #d6e7fb;
  --line:       #e6ecf4;
  --signal:     #e8622c;
  --signal-bg:  #fdece3;
  --code-bg:    #eef2f8;

  --grad: linear-gradient(135deg, #0B5CC4 0%, #1E7CE8 46%, #33B6FF 100%);

  --font-display: "Unbounded", "Onest", system-ui, sans-serif;
  --font-text: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --rail-w: 268px;
  --content-w: 720px;
  --radius: 16px;

  --shadow: 0 1px 2px rgba(20, 40, 80, .04), 0 10px 30px rgba(20, 40, 80, .06);
}

[data-theme="dark"] {
  --paper:      #14171f;
  --paper-2:    #1a1e28;
  --ink:        #e8ebf2;
  --ink-2:      #99a2b7;
  --azure:      #5aa4f0;
  --azure-deep: #2e93ff;
  --mist:       #17263a;
  --mist-2:     #1e3350;
  --line:       #262c38;
  --signal:     #f0865a;
  --signal-bg:  #2a1a12;
  --code-bg:    #1e2531;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 34px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  font-family: var(--font-text);
  font-size: 17.5px;
  line-height: 1.72;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--mist-2); color: var(--ink); }

a {
  color: var(--azure);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  text-decoration-color: color-mix(in srgb, var(--azure) 45%, transparent);
  transition: color .15s, text-decoration-color .15s;
  overflow-wrap: anywhere;
}
a:hover { color: var(--azure-deep); text-decoration-color: currentColor; }

code {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: .86em;
  background: var(--code-bg);
  padding: .12em .42em;
  border-radius: 6px;
}

:focus-visible {
  outline: 2.5px solid var(--azure);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Reading progress ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: transparent;
  z-index: 60;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--grad);
}

/* ---------- Shell / layout ---------- */
.shell {
  display: flex;
  align-items: flex-start;
  gap: 40px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ---------- Contents rail ---------- */
.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 44px 8px 44px 0;
}
.rail__inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  padding-right: 8px;
}
.rail__kicker {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.rail__title {
  margin: 2px 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -.01em;
}
.toc { display: flex; flex-direction: column; gap: 2px; }
.toc a {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.toc a:hover { background: var(--paper-2); color: var(--ink); }
.toc a.is-active {
  background: var(--mist);
  color: var(--azure-deep);
  border-left-color: var(--azure);
}
.toc__num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .82rem;
  opacity: .6;
  min-width: 20px;
}
.toc a.is-active .toc__num { opacity: 1; color: var(--azure); }
.toc__label { font-size: .9rem; line-height: 1.35; }

.theme {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  align-self: flex-start;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2);
  font: inherit;
  font-size: .86rem;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.theme:hover { border-color: var(--mist-2); color: var(--ink); }
.theme__icon {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--grad);
  box-shadow: inset -4px -4px 0 0 var(--paper);
}
[data-theme="dark"] .theme__icon { box-shadow: none; }

/* ---------- Main document ---------- */
.doc {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(var(--content-w) + 8px);
  padding: 44px 0 96px;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 52px 44px 44px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 20px 50px rgba(11, 92, 196, .28);
}
.hero__glow {
  position: absolute;
  width: 420px; height: 420px;
  right: -120px; top: -180px;
  background: radial-gradient(circle, rgba(255,255,255,.35), transparent 62%);
  pointer-events: none;
}
.hero__badge {
  margin: 0 0 22px;
  display: inline-block;
  font-size: .74rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.28);
  backdrop-filter: blur(2px);
}
.hero__title {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.04;
  font-size: clamp(2.1rem, 5.2vw, 3.35rem);
}
.hero__module {
  display: block;
  font-size: .5em;
  font-weight: 700;
  letter-spacing: .02em;
  opacity: .85;
  margin-bottom: .35em;
}
.hero__sub {
  position: relative;
  margin: 20px 0 0;
  font-size: 1.02rem;
  opacity: .92;
}
.hero__meta {
  position: relative;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 26px 0 0;
  padding: 0;
}
.hero__meta li {
  font-size: .8rem;
  padding: 5px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
}

/* ---------- Prose base ---------- */
.prose { margin-top: 8px; }
.prose p { margin: 0 0 1.05em; }
.prose strong { font-weight: 700; }
.prose em { font-style: italic; }

.prose ul, .prose ol { margin: 0 0 1.1em; padding-left: 1.35em; }
.prose li { margin: .35em 0; }
.prose ul li::marker { color: var(--azure); }

/* ---------- Chapter head ---------- */
.chapter { padding-top: 30px; margin-top: 34px; }
.chapter:first-of-type { margin-top: 40px; }
.chapter__head {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 4px 0 20px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.chapter__num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 3.9rem);
  line-height: .85;
  letter-spacing: -.03em;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  flex: 0 0 auto;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--azure);
}
.chapter__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  line-height: 1.2;
  letter-spacing: -.01em;
}

/* subsection headings inside prose */
.prose h3 {
  margin: 2em 0 .6em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.18rem;
  letter-spacing: -.01em;
  color: var(--ink);
}

/* ---------- Lede / quote ---------- */
.lede {
  margin: 0 0 1.4em;
  padding: 2px 0 2px 20px;
  border-left: 3px solid var(--azure);
  font-size: 1.08rem;
  font-style: italic;
  color: var(--ink-2);
}

/* ---------- Field (label + text) ---------- */
.field {
  margin: 1.1em 0;
  padding-left: 16px;
  border-left: 2px solid var(--mist-2);
}
.field__label {
  display: block;
  margin-bottom: 3px;
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--azure);
}
.field p:last-child, .field ul:last-child { margin-bottom: 0; }

/* ---------- Tool block ---------- */
.tool {
  margin: 26px 0;
  padding: 26px 26px 22px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tool > h3 {
  margin: 0 0 .5em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.24rem;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 12px;
}
.tool > p:first-of-type { margin-top: 0; }
.tool__idx {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--grad);
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
}
.tool__tag, .profile__tag {
  font-family: var(--font-text);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--azure);
  background: var(--mist);
  padding: 3px 9px;
  border-radius: 999px;
}

/* ---------- Providers grid ---------- */
.providers {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 16px;
}
.provider {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.provider p { margin: 0 0 .5em; font-size: .95rem; line-height: 1.55; }
.provider p:last-child { margin-bottom: 0; }
.provider b { color: var(--ink); }
.provider__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem !important;
  margin-bottom: .7em !important;
}
.provider__name span {
  font-family: var(--font-text);
  font-weight: 500;
  font-size: .74rem;
  color: var(--ink-2);
  margin-left: 6px;
}

/* ---------- Profiles ---------- */
.profiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 1.2em 0;
}
.profile {
  background: var(--mist);
  border: 1px solid var(--mist-2);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: .96rem;
  line-height: 1.5;
}
.profile__tag { display: inline-block; margin-bottom: 8px; }

/* ---------- Rules (numbered cards) ---------- */
.rules { list-style: none; counter-reset: rule; padding: 0; margin: 1.3em 0; }
.rules > li {
  counter-increment: rule;
  position: relative;
  padding: 22px 24px 18px 66px;
  margin-bottom: 14px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.rules > li::before {
  content: counter(rule, decimal-leading-zero);
  position: absolute;
  left: 24px; top: 20px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.rules > li > h3 {
  margin: 0 0 .4em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: -.01em;
}
.rules > li > p:last-child,
.rules > li > ul:last-child { margin-bottom: 0; }

/* ---------- Steps (ordered, inline numbers) ---------- */
.steps { list-style: none; counter-reset: step; padding: 0; margin: 1.1em 0; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 4px 0 4px 42px;
  margin: .55em 0;
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 2px;
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--mist);
  border: 1px solid var(--mist-2);
  color: var(--azure-deep);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .84rem;
}

/* ---------- Tasks (homework) ---------- */
.tasks { list-style: none; counter-reset: task; padding: 0; margin: 1.4em 0; }
.tasks > li {
  counter-increment: task;
  position: relative;
  padding: 24px 26px 20px 74px;
  margin-bottom: 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tasks > li::before {
  content: counter(task);
  position: absolute;
  left: 24px; top: 22px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--grad);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
}
.tasks > li > h3 {
  margin: 2px 0 .5em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.14rem;
  letter-spacing: -.01em;
}
.tasks p { margin: 0 0 .7em; }
.tasks > li > *:last-child { margin-bottom: 0; }
.tasks__hi {
  background: var(--mist);
  border-radius: 10px;
  padding: 12px 15px;
}
.tasks__link {
  font-size: .95rem;
}

/* ---------- Callouts ---------- */
.callout {
  display: flex;
  gap: 15px;
  margin: 1.6em 0;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--mist);
  border: 1px solid var(--mist-2);
  border-left: 4px solid var(--azure);
}
.callout__icon { flex: 0 0 auto; font-size: 1.4rem; line-height: 1.3; }
.callout__body { min-width: 0; }
.callout__body p { margin: 0 0 .55em; }
.callout__body p:last-child { margin-bottom: 0; }
.callout__title {
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--azure-deep);
  margin-bottom: .35em !important;
}
.callout--pin {
  background: var(--signal-bg);
  border-color: color-mix(in srgb, var(--signal) 30%, transparent);
  border-left-color: var(--signal);
}
.callout--pin .callout__title { color: var(--signal); }
.callout--summary {
  background: var(--paper-2);
  border-color: var(--line);
  border-left-color: var(--azure);
}

/* ---------- Footer ---------- */
.foot {
  margin-top: 80px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
}
.foot__title { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1rem; color: var(--ink); }
.foot__sub { margin: 4px 0 0; font-size: .88rem; }

/* ---------- Mobile topbar (hidden on desktop) ---------- */
.topbar { display: none; }
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 40, .5);
  backdrop-filter: blur(1px);
  z-index: 40;
  opacity: 0;
  transition: opacity .2s;
}
.scrim.is-open { opacity: 1; }

/* ---------- Back to top ---------- */
.totop {
  position: fixed;
  right: 22px; bottom: 22px;
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--azure-deep);
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 45;
  transition: transform .18s, opacity .18s;
}
.totop:hover { transform: translateY(-2px); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 960px) {
  html { scroll-padding-top: 72px; }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 12px 18px;
    background: color-mix(in srgb, var(--paper) 86%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
  }
  .topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    font-size: 1rem;
  }
  .topbar__mark { font-size: 1.15rem; }
  .topbar__toc {
    font: inherit;
    font-weight: 600;
    font-size: .9rem;
    color: var(--azure-deep);
    background: var(--mist);
    border: 1px solid var(--mist-2);
    border-radius: 999px;
    padding: 7px 18px;
    cursor: pointer;
  }

  .shell { flex-direction: column; gap: 0; padding: 0 20px; max-width: 760px; }

  .rail {
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    width: min(310px, 84vw);
    flex-basis: auto;
    z-index: 50;
    padding: 26px 18px;
    background: var(--paper);
    border-right: 1px solid var(--line);
    box-shadow: 0 20px 60px rgba(10, 20, 40, .2);
    transform: translateX(-104%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
  }
  .rail.is-open { transform: translateX(0); }
  .rail__inner { overflow-y: auto; }

  .doc { padding: 22px 0 80px; max-width: 100%; }

  .hero { padding: 38px 26px 32px; border-radius: 18px; }
  .tool { padding: 22px 20px 18px; }
  .tasks > li { padding: 22px 20px 18px 66px; }
  .tasks > li::before { left: 20px; }
  .rules > li { padding: 20px 20px 16px 60px; }
  .rules > li::before { left: 20px; }
}

@media (max-width: 560px) {
  body { font-size: 16.5px; }
  .shell { padding: 0 15px; }
  .hero { padding: 32px 20px 28px; }
  .providers { grid-template-columns: 1fr; }
  .profiles { grid-template-columns: 1fr; }
  .chapter__head { gap: 14px; }
  .tool > h3 { font-size: 1.12rem; }
  .callout { padding: 15px 16px; gap: 12px; }
}

/* ---------- Motion / reveal ---------- */
.chapter { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .js .chapter { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
  .js .chapter.is-in { opacity: 1; transform: none; }
}

@media print {
  .rail, .topbar, .totop, .progress, .theme { display: none !important; }
  .shell { display: block; padding: 0; }
  .doc { max-width: 100%; padding: 0; }
  .hero { box-shadow: none; }
  a { text-decoration: none; }
}
