/* ==========================================================================
   Каркас: шапка, прогресс чтения, навигация по секциям, своя полоса,
   кнопка «наверх», подвал
   ========================================================================== */

/* --- Прогресс чтения (горизонтальная полоса) --- */
.progress {
  position: fixed; inset: 0 0 auto 0; height: 5px; z-index: 120;
  background: transparent; pointer-events: none;
}
.progress__bar {
  height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--c-green) 0%, #3aa56a 40%, var(--c-blue) 100%);
  border-radius: 0 4px 4px 0;
}

/* --- Шапка --- */
.header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  background: rgba(255,255,255,.86);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color var(--t-mid) var(--ease), box-shadow var(--t-mid);
}
.header.is-scrolled { border-bottom-color: var(--c-line); box-shadow: 0 6px 20px -16px rgba(15,27,38,.4); }
.header__in { height: 100%; display: flex; align-items: center; gap: var(--sp-5); }
.logo { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--c-ink); min-width: 0; }
.logo:hover { color: var(--c-ink); }
.logo__mark {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 14px; display: grid; place-items: center;
  background: var(--c-green); color: #fff;
}
.logo__mark svg { width: 24px; height: 24px; }
.logo__txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.logo__name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo__sub { font-family: var(--f-mono); font-size: 12px; color: var(--c-ink-3); letter-spacing: .06em; text-transform: uppercase; }

.nav { margin-left: auto; display: flex; gap: 4px; }
.nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: var(--r-pill);
  font-size: 16px; font-weight: 600; color: var(--c-ink-2); text-decoration: none; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav a:hover { background: var(--s-stone); color: var(--c-ink); }
.nav a.is-active { background: var(--s-mint); color: var(--c-green-ink); }
.header__now {
  display: none; margin-left: auto; font-family: var(--f-mono); font-size: 14px; color: var(--c-green-ink);
  background: var(--s-mint); padding: 6px 12px; border-radius: var(--r-pill); max-width: 46vw;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.burger {
  display: none; width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--c-line-2);
  background: #fff; align-items: center; justify-content: center; flex: 0 0 48px;
}
.burger span, .burger span::before, .burger span::after { display: block; width: 20px; height: 2px; background: var(--c-ink); border-radius: 2px; position: relative; transition: transform var(--t-fast); }
.burger span::before, .burger span::after { content: ''; position: absolute; left: 0; }
.burger span::before { top: -6px; } .burger span::after { top: 6px; }
.burger[aria-expanded="true"] span { background: transparent; }
.burger[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.burger[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 1180px) {
  .nav { display: none; }
  .burger { display: inline-flex; margin-left: 12px; }
  .header__now { display: block; }
}
@media (max-width: 520px) {
  .logo__sub { display: none; }
  .logo__name { font-size: 16px; }
  .logo__mark { width: 38px; height: 38px; flex-basis: 38px; }
  .header__now { max-width: 34vw; font-size: 12px; }
}

/* --- Мобильное меню --- */
.drawer {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 99; background: var(--c-paper);
  padding: 24px var(--gutter) 40px; overflow-y: auto; transform: translateY(-8px); opacity: 0; visibility: hidden;
  transition: opacity var(--t-mid) var(--ease), transform var(--t-mid) var(--ease), visibility var(--t-mid);
}
.drawer.is-open { opacity: 1; transform: none; visibility: visible; }
.drawer ol { list-style: none; display: grid; gap: 8px; counter-reset: d; }
.drawer a {
  display: flex; align-items: baseline; gap: 14px; padding: 14px 18px; border-radius: var(--r-sm);
  background: #fff; color: var(--c-ink); text-decoration: none; font-weight: 700; font-size: 20px;
  counter-increment: d; border: 1px solid var(--c-line);
}
.drawer a::before { content: counter(d, decimal-leading-zero); font-family: var(--f-mono); font-size: 14px; color: var(--c-green); font-weight: 500; }
.drawer a.is-active { background: var(--s-mint); border-color: var(--s-mint-2); }

/* --- Боковой «где я» (точки-секции) --- */
.spy {
  position: fixed; right: 26px; top: 50%; transform: translateY(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 6px; padding: 10px 6px;
}
.spy a {
  position: relative; display: block; width: 28px; height: 18px;
}
.spy a::before {
  content: ''; position: absolute; right: 8px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
  background: var(--c-line-2); transition: all var(--t-mid) var(--ease);
}
.spy a.is-active::before { background: var(--c-green); width: 12px; height: 12px; margin-top: -6px; right: 6px; box-shadow: 0 0 0 4px rgba(19,112,59,.15); }
.spy a span {
  position: absolute; right: 36px; top: 50%; transform: translateY(-50%) translateX(6px); white-space: nowrap;
  background: var(--c-ink); color: #fff; font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: all var(--t-fast) var(--ease);
}
.spy a:hover span, .spy a:focus-visible span { opacity: 1; transform: translateY(-50%); }
@media (max-width: 1500px) { .spy { right: 18px; } }
@media (max-width: 1280px) { .spy { display: none; } }

/* --- Своя вертикальная полоса прокрутки (десктоп) --- */
.rail {
  position: fixed; right: 6px; top: calc(var(--header-h) + 10px); bottom: 10px; width: 6px; z-index: 95;
  border-radius: 6px; background: rgba(15,27,38,.06); opacity: 0; transition: opacity var(--t-mid);
}
.rail.is-visible, .rail:hover { opacity: 1; }
.rail__thumb {
  position: absolute; left: 0; right: 0; top: 0; min-height: 40px; border-radius: 6px;
  background: linear-gradient(180deg, var(--c-green), var(--c-blue)); cursor: grab;
}
.rail__thumb:active { cursor: grabbing; }
.rail:hover { width: 10px; right: 4px; }
html.has-rail { scrollbar-width: none; }
html.has-rail::-webkit-scrollbar { width: 0; height: 0; }
@media (hover: none), (max-width: 900px) { .rail { display: none; } }

/* --- Кнопка «наверх» --- */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 96; width: 64px; height: 64px; border-radius: 50%;
  border: 0; background: var(--c-ink); color: #fff; display: grid; place-items: center;
  box-shadow: var(--sh-2); transform: translateY(20px) scale(.9); opacity: 0; visibility: hidden;
  transition: all var(--t-mid) var(--ease);
}
.to-top.is-visible { transform: none; opacity: 1; visibility: visible; }
.to-top:hover { background: var(--c-green); }
.to-top svg.to-top__ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.to-top__ring circle { fill: none; stroke: #6fd39b; stroke-width: 3; stroke-linecap: round; }
.to-top__icon { width: 24px; height: 24px; position: relative; }
.to-top__tip {
  position: absolute; right: 74px; top: 50%; transform: translateY(-50%); white-space: nowrap;
  background: #fff; color: var(--c-ink); border: 1px solid var(--c-line); font-size: 15px; font-weight: 600;
  padding: 8px 12px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity var(--t-fast);
}
.to-top:hover .to-top__tip { opacity: 1; }
@media (max-width: 720px) { .to-top { width: 56px; height: 56px; right: 14px; bottom: 14px; } .to-top__tip { display: none; } }

/* --- Подвал --- */
.footer { background: var(--s-night); color: #e6eef5; padding: var(--sp-9) 0 var(--sp-7); margin-top: var(--section-gap); border-radius: var(--r-xl) var(--r-xl) 0 0; }
.footer a { color: #bfe3ff; }
.footer a:hover { color: #fff; }
.footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--sp-7); }
.footer h3 { font-size: 20px; margin-bottom: 14px; color: #fff; }
.footer ul { list-style: none; display: grid; gap: 8px; font-size: var(--fs-small); }
.footer__bottom { margin-top: var(--sp-8); padding-top: var(--sp-5); border-top: 1px solid rgba(255,255,255,.14); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; font-size: var(--fs-xs); color: #b9c8d4; }
.footer .logo { color: #fff; }
.footer .logo__sub { color: #a8bccb; }
.footer p { color: #cfdbe5; font-size: var(--fs-small); }
@media (max-width: 900px) { .footer__grid { grid-template-columns: 1fr; gap: var(--sp-6); } }
