/* ==========================================================================
   Components: кнопки, бейджи, чипы, подсказки, формы, шапка, прогресс,
   кнопка «вверх», табы, аккордеон, таблица, ретро-элементы
   ========================================================================== */

/* --- Кнопки --- */
.btn {
  --bg: var(--c-blue-600); --fg: #fff; --bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 12px 24px; border-radius: var(--r-pill); border: 1.5px solid var(--bd);
  background: var(--bg); color: var(--fg); font-weight: 700; font-size: var(--fs-16); line-height: 1.2; text-decoration: none; text-align: center;
  transition: transform var(--t-fast) var(--ease-out), background var(--t-fast), box-shadow var(--t-med);
}
.btn:hover { --bg: var(--c-blue-700); color: var(--fg); transform: translateY(-1px); box-shadow: var(--sh-2); }
.btn:active { transform: translateY(1px); }
.btn--ghost { --bg: var(--c-white); --fg: var(--c-ink); --bd: var(--c-line-strong); }
.btn--ghost:hover { --bg: var(--c-blue-50); --fg: var(--c-blue-700); }
.btn--green { --bg: var(--c-green-600); }
.btn--green:hover { --bg: var(--c-green-700); }
.btn--sm { min-height: 44px; padding: 8px 18px; font-size: var(--fs-14); }
.btn .i { width: 20px; height: 20px; }

/* --- Бейджи / чипы --- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-pill);
  font-size: var(--fs-12); font-weight: 700; line-height: 1.3; background: var(--c-mist); color: var(--c-ink-2); white-space: nowrap;
}
.badge--blue  { background: var(--c-blue-50);  color: var(--c-blue-700); }
.badge--green { background: var(--c-green-50); color: var(--c-green-700); }
.badge--warn  { background: var(--c-warn-bg);  color: var(--c-warn); }
.badge--bad   { background: var(--c-bad-bg);   color: var(--c-bad); }
.badge--sun   { background: var(--c-retro-sun); color: var(--c-ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border-radius: var(--r-pill);
  border: 1.5px solid var(--c-line-strong); background: var(--c-white); color: var(--c-ink); font-weight: 600; font-size: var(--fs-14);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip:hover { border-color: var(--c-blue-400); color: var(--c-blue-700); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--c-ink); border-color: var(--c-ink); color: #fff; }
.chip[aria-pressed="true"]:hover, .chip.is-active:hover { background: var(--c-blue-700); border-color: var(--c-blue-700); color: #fff; box-shadow: var(--sh-2); }
.chip:active { transform: translateY(1px); }

/* --- Подсказки: hover/focus на десктопе, видимы сразу на тач-устройствах --- */
[data-tip] { position: relative; }
.tip-host { position: relative; display: inline-flex; align-items: center; gap: 6px; cursor: help; text-decoration: underline dotted var(--c-blue-400); text-underline-offset: 4px; }
.tip {
  position: absolute; left: 50%; bottom: calc(100% + 12px); z-index: var(--z-tooltip);
  width: max-content; max-width: min(320px, calc(100vw - 32px)); padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--c-ink); color: #fff; font-size: var(--fs-14); font-weight: 500; line-height: 1.45; text-align: left;
  box-shadow: var(--sh-3); opacity: 0; transform: translate(-50%, 6px); pointer-events: none;
  transition: opacity var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.tip::after { content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: var(--c-ink); }
.tip-host:hover .tip, .tip-host:focus-visible .tip, .tip-host:focus-within .tip { opacity: 1; transform: translate(-50%, 0); }
.has-float-tips .tip-host > .tip { display: none; }
.floating-tip::after { display: none; }
/* На тач-экранах: подсказка превращается в видимую строку под элементом */
@media (hover: none) {
  .tip-host { display: inline; text-decoration: none; cursor: auto; }
  .tip {
    position: static; display: block; width: auto; max-width: none; margin-top: 6px; opacity: 1; transform: none;
    background: var(--c-blue-50); color: var(--c-ink-2); box-shadow: none; border-left: 0; font-size: var(--fs-12);
  }
  .tip::after { display: none; }
  .tip::before { content: 'ⓘ '; color: var(--c-blue-700); font-weight: 700; }
  th .tip-host .tip { display: none; }
}
/* Глобальная всплывающая подсказка (для таблиц/canvas через JS) */
.floating-tip { position: fixed; z-index: var(--z-tooltip); pointer-events: none; }

/* --- Шапка --- */
.site-header {
  position: sticky; top: 0; z-index: var(--z-nav);
  background: rgba(247,250,253,.86); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color var(--t-med), background var(--t-med);
}
.site-header.is-scrolled { border-color: var(--c-line); background: rgba(255,255,255,.92); }
.site-header__row { display: flex; align-items: center; gap: var(--sp-6); min-height: 72px; }
.logo { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--c-ink); min-width: 0; }
.logo__mark { width: 44px; height: 44px; flex: none; }
.logo__text { font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.15; letter-spacing: -.01em; }
.logo__text small { display: block; font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--c-ink-3); }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a { padding: 10px 14px; border-radius: var(--r-pill); color: var(--c-ink-2); font-weight: 600; font-size: var(--fs-14); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--c-blue-50); color: var(--c-blue-700); }
.nav a.is-current { background: var(--c-ink); color: #fff; }
.nav-toggle { display: none; margin-left: auto; width: 48px; height: 48px; border-radius: 14px; border: 1.5px solid var(--c-line-strong); background: #fff; place-items: center; }
@media (max-width: 1180px) {
  .nav { position: fixed; inset: 72px 0 auto 0; flex-direction: column; align-items: stretch; gap: 2px; padding: 12px var(--gutter) 24px;
    background: #fff; border-bottom: 1px solid var(--c-line); box-shadow: var(--sh-3); max-height: calc(100dvh - 72px); overflow-y: auto;
    transform: translateY(-8px); opacity: 0; visibility: hidden; transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast); }
  .nav.is-open { transform: none; opacity: 1; visibility: visible; }
  .nav a { padding: 14px 16px; font-size: var(--fs-16); }
  .nav-toggle { display: grid; }
}

/* --- Прогресс чтения (горизонтальная полоса) --- */
.read-progress { position: fixed; left: 0; top: 0; z-index: calc(var(--z-nav) + 1); height: 4px; width: 100%; pointer-events: none; }
.read-progress__bar { height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--c-blue-400), var(--c-teal-500), var(--c-green-300)); }

/* --- Кастомная вертикальная полоса-«топливомер» + метки разделов --- */
.fuel-rail { position: fixed; right: 10px; top: 50%; transform: translateY(-50%); z-index: var(--z-sticky);
  display: flex; flex-direction: column; align-items: center; gap: 8px; }
.fuel-rail__tube { position: relative; width: 12px; height: min(56vh, 460px); border-radius: 12px; background: var(--c-white); border: 1.5px solid var(--c-line-strong); overflow: hidden; box-shadow: var(--sh-1); }
.fuel-rail__fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(0deg, var(--c-green-600), var(--c-teal-500) 50%, var(--c-blue-400)); transition: height .12s linear; }
.fuel-rail__fill::before { content: ''; position: absolute; left: -30%; right: -30%; top: -4px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.6); }
.fuel-rail__marks { position: absolute; inset: 0; }
.fuel-rail__mark { position: absolute; left: 50%; width: 24px; height: 24px; transform: translate(-50%, -50%); border: 0; background: transparent; padding: 0; }
.fuel-rail__mark::before { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: var(--c-line-strong); transition: background var(--t-fast), transform var(--t-fast); }
.fuel-rail__mark.is-passed::before { background: #fff; }
.fuel-rail__mark.is-current::before { background: var(--c-retro-sun); transform: scale(1.6); box-shadow: 0 0 0 2px var(--c-ink); }
.fuel-rail__label { position: absolute; right: 28px; top: 50%; transform: translateY(-50%); white-space: nowrap; padding: 6px 10px; border-radius: 8px; background: var(--c-ink); color: #fff; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity var(--t-fast); }
.fuel-rail__mark:hover .fuel-rail__label, .fuel-rail__mark:focus-visible .fuel-rail__label { opacity: 1; }
.fuel-rail__cap { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--c-ink-3); }
@media (max-width: 1180px) { .fuel-rail { display: none; } }
/* Скрываем системный скроллбар только там, где есть наш «топливомер» */
@media (min-width: 1181px) and (pointer: fine) {
  html { scrollbar-width: none; }
  html::-webkit-scrollbar { width: 0; height: 0; }
}

/* --- «Где мы сейчас» — плашка с названием раздела (мобайл и десктоп) --- */
.where-now { position: fixed; left: 50%; bottom: 16px; z-index: var(--z-sticky); transform: translate(-50%, 140%);
  display: inline-flex; align-items: center; gap: 10px; max-width: calc(100vw - 104px); padding: 10px 16px 10px 12px; border-radius: var(--r-pill);
  background: rgba(10,26,43,.92); color: #fff; font-size: var(--fs-14); font-weight: 600; box-shadow: var(--sh-3);
  transition: transform var(--t-med) var(--ease-out); }
.where-now.is-visible { transform: translate(-50%, 0); }
.where-now__num { font-family: var(--font-mono); font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--c-retro-sun); color: var(--c-ink); }
.where-now__txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- Кнопка «вверх» с кольцом прогресса --- */
.to-top { position: fixed; right: 16px; bottom: 16px; z-index: var(--z-sticky); width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--c-white); color: var(--c-ink); box-shadow: var(--sh-3); display: grid; place-items: center;
  opacity: 0; transform: translateY(20px) scale(.9); pointer-events: none; transition: opacity var(--t-med), transform var(--t-med) var(--ease-spring); }
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg.ring { position: absolute; inset: 0; width: 56px; height: 56px; transform: rotate(-90deg); }
.to-top .ring circle { fill: none; stroke-width: 3; }
.to-top .ring .bg { stroke: var(--c-line); }
.to-top .ring .fg { stroke: var(--c-green-600); stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.to-top .i { width: 22px; height: 22px; }
@media (min-width: 1181px) { .to-top { right: 40px; } }

/* --- Табы --- */
.tabs { display: flex; gap: 6px; padding: 6px; border-radius: var(--r-pill); background: var(--c-mist); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; min-height: 44px; padding: 8px 18px; border-radius: var(--r-pill); border: 0; background: transparent; color: var(--c-ink-2); font-weight: 700; font-size: var(--fs-14); white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--c-white); color: var(--c-ink); box-shadow: var(--sh-2); }

/* --- Аккордеон (FAQ, дисклеймеры) --- */
.acc { border-top: 1px solid var(--c-line); }
.acc details { border-bottom: 1px solid var(--c-line); }
.acc summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; padding: 18px 4px; cursor: pointer; font-weight: 700; font-size: var(--fs-18); }
.acc summary::-webkit-details-marker { display: none; }
.acc summary { border-radius: var(--r-sm); transition: color var(--t-fast), background var(--t-fast), padding var(--t-fast); }
.acc summary:hover { color: var(--c-blue-700); background: var(--c-blue-50); padding-left: 14px; padding-right: 14px; }
.acc summary:hover::after { background-color: var(--c-blue-100); transform: rotate(90deg); }
.acc details[open] summary:hover::after { transform: rotate(45deg) scale(1.08); }
.acc summary::after { content: ''; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--c-blue-50) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A4FA6' stroke-width='2' stroke-linecap='round'><path d='M12 6v12M6 12h12'/></svg>") center/18px no-repeat; transition: transform var(--t-med) var(--ease-out); }
.acc details[open] summary::after { transform: rotate(45deg); }
.acc__body { padding: 0 4px 22px; color: var(--c-ink-2); max-width: 80ch; }

/* --- Формы / калькуляторы --- */
.field { display: grid; gap: 8px; min-width: 0; }
.field label, .field .label { font-weight: 700; font-size: var(--fs-14); color: var(--c-ink-2); }
.input, .select {
  width: 100%; min-height: 52px; padding: 12px 16px; border-radius: var(--r-sm); border: 1.5px solid var(--c-line-strong); background: #fff;
  font-size: var(--fs-16); font-weight: 600; transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus { outline: none; border-color: var(--c-blue-600); box-shadow: 0 0 0 4px var(--c-blue-100); }
.select { appearance: none; background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A1A2B' stroke-width='2' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>") right 14px center/18px no-repeat; padding-right: 44px; }
.range { width: 100%; height: 44px; appearance: none; background: transparent; }
.range::-webkit-slider-runnable-track { height: 8px; border-radius: 8px; background: linear-gradient(90deg, var(--c-blue-600) var(--p, 50%), var(--c-line) var(--p, 50%)); }
.range::-moz-range-track { height: 8px; border-radius: 8px; background: var(--c-line); }
.range::-moz-range-progress { height: 8px; border-radius: 8px; background: var(--c-blue-600); }
.range::-webkit-slider-thumb { appearance: none; width: 28px; height: 28px; margin-top: -10px; border-radius: 50%; background: #fff; border: 3px solid var(--c-blue-600); box-shadow: var(--sh-2); }
.range::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--c-blue-600); }
.result {
  padding: 20px 22px; border-radius: var(--r-md); background: var(--c-blue-900); color: #fff;
}
.result__label { font-size: var(--fs-12); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .1em; color: #A9D1FF; }
.result__value { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-32); line-height: 1.1; letter-spacing: -.02em; overflow-wrap: anywhere; }
.result__note { font-size: var(--fs-14); color: #D6E6F8; margin-top: 6px; }

/* --- Таблица рейтинга --- */
.table-wrap { position: relative; overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--c-line); background: #fff; -webkit-overflow-scrolling: touch; }
.table-wrap:focus-visible { box-shadow: var(--sh-focus); }
.rtable { min-width: 980px; font-size: var(--fs-14); }
.rtable th { position: sticky; top: 0; z-index: 2; background: var(--c-mist); text-align: left; font-weight: 700; color: var(--c-ink-2); padding: 14px 16px; white-space: nowrap; }
.rtable td { padding: 14px 16px; border-top: 1px solid var(--c-line); vertical-align: middle; }
.rtable tbody tr { transition: background var(--t-fast); }
.rtable tbody tr:hover { background: var(--c-blue-50); }
.rtable .col-rank { width: 64px; font-family: var(--font-display); font-weight: 700; font-size: var(--fs-18); }
.rtable .col-name { position: sticky; left: 0; z-index: 1; background: inherit; min-width: 220px; }
.rtable thead .col-name { z-index: 3; }
.rtable tbody tr .col-name { background: #fff; }
.rtable tbody tr:hover .col-name { background: var(--c-blue-50); }
.scorebar { position: relative; height: 10px; min-width: 120px; border-radius: 10px; background: var(--c-mist); overflow: hidden; }
.scorebar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: linear-gradient(90deg, var(--c-blue-400), var(--c-green-600)); }

/* --- Ретро: табличка «Service», хромированная рамка, вывеска --- */
.retro-sign { display: inline-flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 14px;
  background: var(--c-retro-cream); border: 2px solid var(--c-ink); box-shadow: 4px 4px 0 var(--c-ink);
  font-family: var(--font-display); font-weight: 800; font-size: var(--fs-14); letter-spacing: .06em; text-transform: uppercase; color: var(--c-ink); }
.retro-sign__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c-retro-cherry); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--c-ink); }
.chrome { background: var(--c-retro-chrome); border: 1.5px solid #9FB1C3; }
.stripe-top { position: relative; }
.stripe-top::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 10px;
  background: repeating-linear-gradient(90deg, var(--c-retro-cherry) 0 40px, var(--c-retro-cream) 40px 56px, var(--c-blue-600) 56px 96px, var(--c-retro-cream) 96px 112px); }

/* --- 3D-модели и canvas-сцены --- */
.model3d { position: relative; width: 100%; aspect-ratio: 4 / 3; min-height: 240px; border-radius: var(--r-lg); cursor: grab; touch-action: pan-y; outline: none; }
.model3d.is-grab { cursor: grabbing; }
.model3d canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.model3d__hint { position: absolute; left: 14px; bottom: 12px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.9); font-size: var(--fs-12); font-weight: 700; color: var(--c-ink-2); pointer-events: none; }
.model3d:not(.is-ready)::before { content: ''; position: absolute; inset: 30% 35%; border-radius: 50%; background: radial-gradient(circle, var(--c-blue-100), transparent 70%); animation: pulse3d 1.6s ease-in-out infinite; }
.model3d.is-fallback::before { animation: none; }
@keyframes pulse3d { 50% { transform: scale(1.15); opacity: .6; } }
.scene { display: block; width: 100%; height: 100%; }
.scene-box { position: relative; border-radius: var(--r-lg); overflow: hidden; }

/* --- Горизонтальная лента --- */
.hs { position: relative; }
.hs__track { display: grid; grid-auto-flow: column; grid-auto-columns: min(86%, 380px); gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 4px 12px; scrollbar-width: none; overscroll-behavior-x: contain; }
.hs__track::-webkit-scrollbar { display: none; }
.hs__track > * { scroll-snap-align: start; }
.hs__track.is-drag { scroll-snap-type: none; cursor: grabbing; user-select: none; }
.hs__nav { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.hs__bar { position: relative; flex: 1; height: 6px; border-radius: 6px; background: var(--c-line); overflow: hidden; }
.hs__bar > i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: inherit; background: linear-gradient(90deg, var(--c-blue-600), var(--c-green-600)); transition: left .1s linear; }
.hs__btn { width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid var(--c-line-strong); background: #fff; display: grid; place-items: center; color: var(--c-ink); }
.hs__btn:disabled { opacity: .35; cursor: default; }
.hs__btn .i { width: 20px; height: 20px; }

/* --- Появление блоков при скролле --- */
.reveal { opacity: 0; transform: translateY(28px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); transition-delay: var(--d, 0s); }
.reveal.is-in { opacity: 1; transform: none; }
.no-js .reveal { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } }

/* --- Пасхалка: пятно топлива расплывается по клику на фон --- */
.fx-layer { position: fixed; inset: 0; z-index: var(--z-fx); pointer-events: none; overflow: hidden; }
.fx-spill { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,.9) 0 8%, rgba(169,209,255,.55) 20%, rgba(111,211,164,.45) 42%, rgba(255,194,61,.35) 60%, rgba(200,120,255,.18) 74%, transparent 76%);
  animation: spill 2.6s var(--ease-out) forwards; mix-blend-mode: multiply; }
@keyframes spill { 0% { transform: scale(.2); opacity: .95; } 60% { opacity: .75; } 100% { transform: scale(22); opacity: 0; } }
.fx-ring { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid rgba(11,99,206,.35); animation: ring 1.4s var(--ease-out) forwards; }
@keyframes ring { to { transform: scale(12); opacity: 0; } }
