/* ==========================================================================
   Embedded Systems Laboratory — статический сайт
   CSS: дизайн-система, светлая/тёмная тема, адаптивность, доступность
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Дизайн-токены
   -------------------------------------------------------------------------- */
:root {
  /* Светлая тема */
  --bg: #f6f8fb;
  --bg-elev: #ffffff;
  --bg-sunken: #eef1f6;
  --bg-inset: #e9edf3;
  --text: #1b2129;
  --text-muted: #5a6572;
  --text-faint: #8b94a1;
  --border: #dce2ea;
  --border-strong: #c4ccd8;
  --accent: #1456c9;
  --accent-ink: #ffffff;
  --accent-soft: #e4edfb;
  --accent-strong: #0f3f96;
  --amber: #9a5b06;
  --amber-soft: #f9eeda;
  --teal: #0c7a72;
  --teal-soft: #daf0ec;
  --danger: #b3261e;
  --code-bg: #f0f3f8;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.05), 0 6px 18px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.06), 0 12px 32px rgba(16, 24, 40, 0.10);
  --grid-line: rgba(20, 40, 70, 0.05);
  --mark-ink: #1456c9;
}

[data-theme="dark"] {
  /* Тёмная тема */
  --bg: #0d1218;
  --bg-elev: #141b23;
  --bg-sunken: #10161d;
  --bg-inset: #0b1016;
  --text: #e6ebf1;
  --text-muted: #9fa9b7;
  --text-faint: #69747f;
  --border: #26313d;
  --border-strong: #39444f;
  --accent: #63a1f7;
  --accent-ink: #0d1218;
  --accent-soft: #1b2a3e;
  --accent-strong: #8fbcfb;
  --amber: #e8b45a;
  --amber-soft: #2b2414;
  --teal: #43c9bb;
  --teal-soft: #132b2a;
  --danger: #ff8a80;
  --code-bg: #0e141b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
  --grid-line: rgba(140, 170, 210, 0.055);
  --mark-ink: #63a1f7;
}

/* --------------------------------------------------------------------------
   2. Сброс и базовые стили
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 44px 44px;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 0.55em;
  font-weight: 650;
  line-height: 1.22;
  letter-spacing: -0.015em;
  color: var(--text);
}

figure { margin: 0; }

h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.45rem, 2.6vw, 2rem); }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-strong); }

ul, ol { margin: 0 0 1.1em 1.25em; padding: 0; }
li { margin-bottom: 0.35em; }

img, svg { display: inline-block; vertical-align: middle; }
img { max-width: 100%; height: auto; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.2em 0;
}

code, kbd, pre, samp {
  font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Consolas, Menlo, monospace;
}

code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.12em 0.4em;
  font-size: 0.88em;
  color: var(--text);
}

kbd {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.08em 0.45em;
  font-size: 0.82em;
}

::selection { background: var(--accent-soft); color: var(--text); }

/* Доступность: скип-ссылка */
.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 1000;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  font-weight: 600;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0.75rem;
  color: var(--accent-ink);
}

/* Видимый фокус */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   3. Типографические утилиты
   -------------------------------------------------------------------------- */
.lead {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--text-muted);
  line-height: 1.65;
}

.mono {
  font-family: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Consolas, Menlo, monospace;
}

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.88rem; }
.tight { margin-bottom: 0.35em; }
.mb0 { margin-bottom: 0; }

.text-center { text-align: center; }

/* --------------------------------------------------------------------------
   4. Каркас страницы
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  flex-shrink: 0;
}
.brand:hover { color: var(--text); }

.brand-mark {
  width: 36px;
  height: 36px;
  color: var(--mark-ink);
}

.brand-text {
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
}
.brand-text small {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.main-nav ul {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
}

.main-nav a {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
}
.main-nav a:hover {
  color: var(--text);
  background: var(--bg-sunken);
}
.main-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Переключатель темы */
.theme-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  border-radius: 10px;
  padding: 2px;
  gap: 2px;
}
.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-switch button svg { width: 17px; height: 17px; }
.theme-switch button:hover { color: var(--text); background: var(--bg-sunken); }
.theme-switch button[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

/* Мобильное меню */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
}
.nav-toggle svg { width: 20px; height: 20px; }

/* Герой и секции */
.hero {
  position: relative;
  padding: clamp(3.2rem, 8vw, 5.5rem) 0 clamp(2.5rem, 6vw, 4rem);
}
.hero-inner {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 2.5rem;
  align-items: center;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.1rem;
  letter-spacing: 0.03em;
}
.hero-eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.hero h1 { margin-bottom: 0.4em; }
.hero .lead { max-width: 34em; }
.hero-actions { margin-top: 1.6rem; }

.section {
  padding: clamp(2.6rem, 6vw, 4.2rem) 0;
}
.section-alt { background: var(--bg-sunken); }
.section-head {
  max-width: 48em;
  margin-bottom: 2rem;
}
.section-head h2 { margin-bottom: 0.4em; }
.section-head p { color: var(--text-muted); margin-bottom: 0; }

/* --------------------------------------------------------------------------
   5. Компоненты
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.62rem 1.15rem;
  border-radius: 10px;
  font-size: 0.94rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--accent-strong);
  color: var(--accent-ink);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; border-radius: 8px; }

/* Карточки */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 1.5rem 1.6rem;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 1.25rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 1.25rem;
}
.card-grid .card { margin-top: 0; }

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 0.9rem;
}
.card-icon svg { width: 24px; height: 24px; }

.card h3 { font-size: 1.06rem; margin-bottom: 0.5em; }
.card p { color: var(--text-muted); font-size: 0.94rem; margin-bottom: 0.6em; }
.card .card-link { font-size: 0.9rem; font-weight: 600; }
.card .tags { margin-top: 0.4rem; }

/* Теги / бейджи */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; margin: 0; }
.tag {
  display: inline-flex;
  align-items: center;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.76rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-muted);
}
.tag-accent { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.tag-teal { color: var(--teal); background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal) 25%, transparent); }
.tag-amber { color: var(--amber); background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }

/* Сводка проекта */
.proj-header { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.proj-header .card-icon { margin-bottom: 0; }

/* Таблицы */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--bg-elev);
}
caption {
  text-align: left;
  padding: 0.6rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
th, td {
  text-align: left;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
  background: var(--bg-sunken);
}
tbody tr:last-child td { border-bottom: 0; }

/* Блоки кода */
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.55;
  margin: 0 0 1.2em;
}
pre code { background: transparent; border: 0; padding: 0; font-size: 1em; }

/* Коллауты */
.callout {
  display: flex;
  gap: 0.8rem;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  margin: 0 0 1.4em;
}
.callout svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--accent); margin-top: 2px; }
.callout p { margin: 0; font-size: 0.92rem; }
.callout-title { font-weight: 700; display: block; margin-bottom: 0.2em; color: var(--text); }
.callout-info { border-color: color-mix(in srgb, var(--accent) 30%, transparent); background: var(--accent-soft); }
.callout-warn { border-color: color-mix(in srgb, var(--amber) 35%, transparent); background: var(--amber-soft); }
.callout-warn svg { color: var(--amber); }

/* Хлебные крошки */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  color: var(--text-faint);
  margin: 0 0 1.4rem;
  list-style: none;
}
.crumbs li { margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: 0.4rem; color: var(--text-faint); }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); }

/* Шаги (сценарии) */
.steps { counter-reset: step; list-style: none; margin: 0; }
.steps li {
  position: relative;
  counter-increment: step;
  padding: 0 0 1.5rem 3rem;
  margin: 0;
}
.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 0;
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.steps li::after {
  content: "";
  position: absolute;
  left: 1rem;
  top: 2.3rem;
  bottom: 0.2rem;
  width: 1px;
  background: var(--border);
}
.steps li:last-child::after { display: none; }
.steps h3 { margin-bottom: 0.3em; }
.steps p { color: var(--text-muted); margin-bottom: 0.3em; }
.steps .mono { font-size: 0.82rem; }

/* Футер */
.site-footer {
  margin-top: 4rem;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 2rem;
  padding: 2.6rem 1.25rem 1.8rem;
}
.footer-grid h4 {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 0.9rem;
}
.footer-grid ul { list-style: none; margin: 0; }
.footer-grid li { margin-bottom: 0.45rem; }
.footer-grid a { color: var(--text-muted); font-size: 0.92rem; }
.footer-grid a:hover { color: var(--accent); }
.footer-about p { color: var(--text-muted); font-size: 0.9rem; }
.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 1.1rem 1.25rem;
  font-size: 0.82rem;
  color: var(--text-faint);
}
.footer-bottom .container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: space-between;
}
.footer-bottom p { margin: 0; }

/* Заголовок страницы */
.page-head { padding: clamp(2.4rem, 5vw, 3.6rem) 0 1.6rem; }
.page-head h1 { margin-bottom: 0.3em; }
.page-head .lead { max-width: 44em; }

/* --------------------------------------------------------------------------
   6. Диаграмма архитектуры
   -------------------------------------------------------------------------- */
.arch-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: var(--shadow-md);
  overflow-x: auto;
}
.arch-diagram {
  width: 100%;
  height: auto;
  display: block;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.arch-mobile { display: none; }

.arch-box {
  fill: var(--bg-elev);
  stroke: var(--border-strong);
  stroke-width: 1.4;
}
.arch-box-accent { fill: var(--accent-soft); stroke: color-mix(in srgb, var(--accent) 45%, transparent); }
.arch-box-teal { fill: var(--teal-soft); stroke: color-mix(in srgb, var(--teal) 45%, transparent); }
.arch-box-amber { fill: var(--amber-soft); stroke: color-mix(in srgb, var(--amber) 45%, transparent); }
.arch-box-dashed { stroke-dasharray: 6 5; }

.arch-title { fill: var(--text); font-size: 15px; font-weight: 650; }
.arch-sub { fill: var(--text-muted); font-size: 12px; }
.arch-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.arch-label { fill: var(--text-faint); font-size: 11px; letter-spacing: 0.04em; }
.arch-arrow { stroke: var(--text-faint); stroke-width: 1.6; fill: none; }
.arch-arrow-major { stroke: var(--accent); stroke-width: 2; }
.arch-arrow-teal { stroke: var(--teal); stroke-width: 2; }
.arch-dot { fill: var(--accent); }
.arch-port {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  fill: var(--text-muted);
}
.arch-tag {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  fill: var(--accent);
}
.arch-note { fill: var(--text-faint); font-size: 11px; font-style: italic; }

/* --------------------------------------------------------------------------
   7. Адаптивность
   -------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; gap: 2rem; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }

  .main-nav {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 1rem 1.25rem 2rem;
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    overflow-y: auto;
  }
  .main-nav.open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
  .main-nav ul {
    flex-direction: column;
    gap: 0.15rem;
  }
  .main-nav a {
    padding: 0.8rem 0.9rem;
    font-size: 1.02rem;
  }
  body.nav-open { overflow: hidden; }
}

@media (max-width: 720px) {
  .arch-desktop { display: none; }
  .arch-mobile { display: block; }
  .footer-grid { grid-template-columns: 1fr; gap: 1.5rem; }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .brand-text { display: none; }
  .hero-actions .btn { padding: 0.55rem 0.95rem; }
  .card { padding: 1.25rem; }
  .header-actions { gap: 0.35rem; }
  .theme-switch button { width: 30px; height: 28px; }
}

/* --------------------------------------------------------------------------
   8. Анимация и доступность
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- конец чанка 4 --- */




