/* =====================================================================
   Полировка и плавность (по принципам make-interfaces-feel-better):
   типографика, тени вместо жёстких границ, нажатия, поэтапные появления,
   переходы между страницами. Подключается последним.
   ===================================================================== */

/* Плавные переходы между страницами (Chrome/Edge; в остальных — обычная навигация) */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .18s ease both; }
::view-transition-new(root) { animation: vt-in .32s var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Типографика ---------- */
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
h1, h2, h3, .r-host, .pv-host, .page-title { text-wrap: balance; }
p, li, .lead, .f-detail, dd { text-wrap: pretty; }
.hero-stats b, .ov-val, .pill, .grade b, .pv-grade b, .big-num, td, .counter, .progress-steps, .tab .cnt { font-variant-numeric: tabular-nums; }

/* ---------- Поверхности: многослойные тени дают глубину без тяжёлых рамок ---------- */
.card, .finding, .ov, .unlock, .table-wrap {
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 4%),
    0 1px 2px rgb(0 0 0 / 30%),
    0 12px 32px -16px rgb(0 0 0 / 55%);
}
:root[data-theme="light"] .card, :root[data-theme="light"] .finding, :root[data-theme="light"] .ov, :root[data-theme="light"] .table-wrap {
  box-shadow: 0 1px 2px rgb(16 16 20 / 6%), 0 10px 30px -18px rgb(16 16 20 / 18%);
}
/* концентрические радиусы: внешний = внутренний + отступ */
.preview { border-radius: 26px; }
.pv-list li { border-radius: 12px; }
.scan-box { border-radius: 18px; } .scan-box .btn { border-radius: 12px; }
.unlock { border-radius: 26px; } .unlock .input { border-radius: 12px; }

/* ---------- Взаимодействия ---------- */
.btn, .ov, .tab, .chip-q, .icon-btn, .f-order, .nav a, .dots button {
  transition-property: transform, background-color, border-color, box-shadow, color, filter, background-position;
  transition-duration: .2s; transition-timing-function: var(--ease-out);
}
.btn:active, .ov:active, .chip-q:active, .icon-btn:active, .tab:active { transform: scale(.97); }
/* градиентная кнопка — мягкий «перелив» при наведении */
.btn-primary { background-image: linear-gradient(90deg, var(--g1), var(--g2), var(--g1)); background-size: 200% 100%; background-position: 0 0; }
.btn-primary:hover { background-position: 100% 0; }
/* карточки чуть приподнимаются при наведении (только на устройствах с мышью) */
@media (hover: hover) {
  .feat, .step, .price, .law-item, .ov { transition-property: transform, box-shadow, border-color; transition-duration: .35s; transition-timing-function: var(--ease-out); }
  .feat:hover, .step:hover, .price:hover, .law-item:hover { transform: translateY(-3px); box-shadow: inset 0 1px 0 rgb(255 255 255 / 5%), 0 18px 40px -18px var(--glow); }
  .ov:hover { transform: translateY(-2px); }
  .f-order:hover { transform: translateX(2px); }
}
/* минимальная зона нажатия 40×40 для мелких элементов */
.f-order, .check { position: relative; }
.f-order::after { content: ""; position: absolute; inset: -10px -6px; }

/* Шапка: тень появляется, когда страница прокручена */
.site-header { transition: box-shadow .3s ease, background-color .3s ease; }
.site-header.scrolled { box-shadow: 0 8px 30px -12px rgb(0 0 0 / 60%); }

/* ---------- Появления: поэтапно и только сдвигом (контент виден, даже если анимации не идут) ---------- */
.reveal { opacity: 1; transform: translateY(16px); transition: transform .8s var(--ease-out); }
.reveal.in { transform: none; }
.grid-feat > .reveal:nth-child(2), .steps-row > .reveal:nth-child(2), .prices > .reveal:nth-child(2), .law-list > .reveal:nth-child(2) { transition-delay: .06s; }
.grid-feat > .reveal:nth-child(3), .steps-row > .reveal:nth-child(3), .prices > .reveal:nth-child(3), .law-list > .reveal:nth-child(3) { transition-delay: .12s; }
.grid-feat > .reveal:nth-child(4), .steps-row > .reveal:nth-child(4), .law-list > .reveal:nth-child(4) { transition-delay: .18s; }
.grid-feat > .reveal:nth-child(5), .law-list > .reveal:nth-child(5) { transition-delay: .24s; }
.grid-feat > .reveal:nth-child(6), .law-list > .reveal:nth-child(6) { transition-delay: .3s; }
.grid-feat > .reveal:nth-child(7) { transition-delay: .36s; }

/* Первый экран — заголовок, текст и форма появляются друг за другом */
.land-hero .wrap > div:first-child > * { animation: rise .7s var(--ease-out) backwards; }
.land-hero .wrap > div:first-child > :nth-child(2) { animation-delay: .06s; }
.land-hero .wrap > div:first-child > :nth-child(3) { animation-delay: .12s; }
.land-hero .wrap > div:first-child > :nth-child(4) { animation-delay: .18s; }
.land-hero .wrap > div:first-child > :nth-child(n+5) { animation-delay: .24s; }
.preview { animation: rise .9s .15s var(--ease-out) backwards; }
@keyframes rise { from { transform: translateY(14px); } }

/* Отчёт: пункты при смене вкладки «подтягиваются» по очереди */
.panel:not([hidden]) .finding { animation: rise .45s var(--ease-out) backwards; }
.panel:not([hidden]) .finding:nth-child(2) { animation-delay: .03s; }
.panel:not([hidden]) .finding:nth-child(3) { animation-delay: .06s; }
.panel:not([hidden]) .finding:nth-child(4) { animation-delay: .09s; }
.panel:not([hidden]) .finding:nth-child(n+5) { animation-delay: .12s; }
.overview .ov { animation: rise .5s var(--ease-out) backwards; }
.overview .ov:nth-child(2) { animation-delay: .04s; } .overview .ov:nth-child(3) { animation-delay: .08s; }
.overview .ov:nth-child(4) { animation-delay: .12s; } .overview .ov:nth-child(n+5) { animation-delay: .16s; }
.toast { transition-property: opacity, transform; }

/* ---------- AI-разбор ---------- */
.ai-card { padding: 26px; background:
  linear-gradient(color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--surface) 92%, transparent)) padding-box,
  var(--grad) border-box; border: 1px solid transparent; }
.ai-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.ai-head p { margin: 4px 0 0; }
.ai-spark { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; background: var(--grad); color: var(--accent-text); box-shadow: 0 8px 24px -8px var(--glow); }
.ai-progress { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 0 0 14px; }
.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots::before, .ai-dots::after, .ai-dots { --d: 6px; }
.ai-dots::before, .ai-dots::after { content: ""; width: var(--d); height: var(--d); border-radius: 50%; background: var(--g1); animation: blink 1s infinite ease-in-out; }
.ai-dots::after { animation-delay: .2s; background: var(--g2); }
@keyframes blink { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-2px); } }
.ai-skel { display: grid; gap: 10px; }
.ai-skel i { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 60%, var(--line)), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.ai-skel i:nth-child(1) { width: 92%; } .ai-skel i:nth-child(2) { width: 76%; } .ai-skel i:nth-child(3) { width: 58%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.ai-summary { display: grid; gap: 10px; }
.ai-summary p { margin: 0; font-size: 16px; line-height: 1.6; }
.ai-summary .pill { justify-self: start; }
.ai-h { font-size: 16px; margin: 22px 0 10px; }
.ai-actions { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ai-action { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px; border-radius: 16px; background: var(--surface-2); animation: rise .5s var(--ease-out) backwards; }
.ai-action:nth-child(2) { animation-delay: .06s; } .ai-action:nth-child(3) { animation-delay: .12s; } .ai-action:nth-child(n+4) { animation-delay: .18s; }
.ai-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--grad); color: var(--accent-text); }
.ai-a-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.ai-action p { margin: 4px 0 0; }
.ai-quick ul, .ai-more ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.ai-more { margin-top: 14px; }
.ai-more summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.ai-more p { margin: 8px 0 0; color: var(--muted); }
.ai-note { margin: 18px 0 0; font-size: 12px; color: var(--faint); }
.ai-chat { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.chips-q { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-q { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 13px; cursor: pointer; }
.chip-q:hover { border-color: var(--g1); }
.ai-chat-log { display: grid; gap: 8px; margin-bottom: 12px; }
.ai-chat-log:empty { display: none; }
.ai-chat .msg { padding: 10px 14px; border-radius: 14px; background: var(--surface-2); font-size: 14.5px; max-width: 88%; white-space: pre-wrap; animation: rise .35s var(--ease-out) backwards; }
.ai-chat .msg.me { justify-self: end; background: color-mix(in srgb, var(--g1) 20%, var(--surface-2)); }
.ai-chat .msg.err { color: var(--fail); }
.ai-typing { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.ai-ask { display: flex; }

@media (max-width: 720px) {
  .ai-card { padding: 18px; }
  .ai-chat .msg { max-width: 100%; }
  .ai-ask { flex-direction: row; }
  .ai-ask .btn { padding: 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { transform: none; transition: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  .ai-dots::before, .ai-dots::after, .ai-skel i { animation: none; }
}

/* AI-тестировщик */
.pill.pass { background: var(--pass-bg, rgba(60,207,126,.14)); color: var(--pass); }
.tag.pass { background: rgba(60,207,126,.16); color: var(--pass); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.fail { background: var(--fail-bg); color: var(--fail); }
.ai-issues, .ai-cases { margin: 0; padding: 0 0 0 2px; list-style: none; display: grid; gap: 10px; }
.ai-cases { list-style: decimal; padding-left: 20px; }
.ai-issue { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); animation: rise .5s var(--ease-out) backwards; }
.ai-issue p { margin: 4px 0 0; }
.ai-checklist { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.ai-checklist li { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; }
.ai-checklist .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: var(--info); }
.ai-checklist .dot.fail { background: var(--fail); } .ai-checklist .dot.warn { background: var(--warn); } .ai-checklist .dot.pass { background: var(--pass); }

/* «Главное» — сводка главных проблем в начале отчёта */
.top-problems { margin-top: 20px; animation: rise .5s var(--ease-out) backwards; }
.tp-head { margin-bottom: 14px; }
.tp-head.tp-ok { display: flex; gap: 12px; align-items: center; margin-bottom: 0; }
.tp-check { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(60,207,126,.16); color: var(--pass); font-size: 20px; flex: none; }
.tp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tp-item { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 13px 15px; border-radius: 14px; background: var(--surface-2); cursor: pointer; transition: background .15s var(--ease-out), transform .1s var(--ease-out); }
.tp-item:hover { background: var(--surface-3, var(--hover, var(--surface-2))); }
.tp-item:hover .tp-arrow { transform: translateX(3px); opacity: 1; }
.tp-item:active { transform: scale(.994); }
.tp-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; }
.tp-dot.bad { background: var(--fail); box-shadow: 0 0 0 4px var(--fail-bg); }
.tp-dot.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-bg); }
.tp-t { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.tp-t b { font-weight: 650; }
.tp-cat { font-size: 12px; color: var(--muted); background: var(--surface); padding: 1px 9px; border-radius: 999px; white-space: nowrap; }
.tp-d { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.tp-arrow { color: var(--muted); opacity: .55; align-self: center; transition: transform .15s var(--ease-out), opacity .15s; }
.tp-more { margin: 12px 0 0; }
@media (max-width: 640px) { .tp-item { grid-template-columns: auto 1fr; } .tp-arrow { display: none; } }

/* Плавное появление раздела при переключении вкладок */
.panel-enter { animation: panelFade .3s var(--ease-out) both; }
@keyframes panelFade { from { opacity: 0; } to { opacity: 1; } }

/* Пустой/чистый раздел отчёта — видимая пометка вместо пустоты */
.empty-note { padding: 18px 2px; text-align: center; }
