/* =============================================================================
   Студия Аиста — главная страница.
   Подключается ПОСЛЕ site.css. Только раскладка главной + сцены-«гифки».
   Разметка сцен описывает финальный кадр (static-first); анимации живут
   исключительно внутри @media (prefers-reduced-motion: no-preference)
   и включаются классом .is-live, который вешает site.js по IntersectionObserver.
   ========================================================================== */

/* --- 1. Герой ---------------------------------------------------------------- */
/* Экраны продуктов стоят выше сгиба: скептик видит, что именно мы делаем,
   до первой прокрутки. Композиция статическая — анимированные сцены живут
   ниже, в блоках продуктов, и дублировать их здесь незачем. */
.hero { padding-block: clamp(44px, 6vw, 84px) 0; overflow: hidden; }
.hero-grid {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr);
  gap: clamp(32px, 5vw, 72px);
}
.hero-text { min-width: 0; }
.hero-text h1 { max-width: 13ch; font-size: clamp(38px, 5.2vw, 64px); }
.hero-lead { margin-top: clamp(18px, 2vw, 24px); max-width: 52ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: clamp(26px, 3vw, 36px); }

.hero-stage { position: relative; margin: 0; min-width: 0; }
.hero-win { position: relative; z-index: 2; max-width: 520px; margin-left: auto; }
.hero-win .win-body { min-height: 240px; }
/* Терминал перекрывает только внутренний отступ окна, а не строку документа. */
.hero-term {
  position: relative; z-index: 3;
  width: min(340px, 66%); margin-top: -16px; margin-left: clamp(0px, 3vw, 40px);
}
.hero-term .win-body { min-height: 0; padding: 12px 14px; font-size: 11.5px; line-height: 1.7; }

@media (max-width: 1040px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: clamp(30px, 5vw, 48px); }
  .hero-text h1 { max-width: 16ch; }
  .hero-stage { max-width: 620px; }
}
/* На узком экране композиция из трёх окон превращается в кашу:
   оставляем один экран — тот, что показывает работающий продукт. */
@media (max-width: 620px) {
  .hero-term { width: 100%; margin-left: 0; }
}

/* --- 2. Полоса статусов ------------------------------------------------------ */
.home-status { margin-top: clamp(40px, 5.5vw, 76px); }

/* --- 3. Продуктовые экраны ---------------------------------------------------- */
#products { scroll-margin-top: 72px; }

.prow { display: grid; align-content: center; padding-block: clamp(56px, 8vw, 112px); }
.prow-grid {
  display: grid; align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(32px, 5.5vw, 84px);
}
.prow--flip .prow-media { order: -1; }
.prow-text .lead { margin-top: clamp(12px, 1.4vw, 18px); }
.p-prose { margin-top: 16px; max-width: 52ch; color: var(--muted); }
.prow-text .tlink { margin-top: 10px; }
.p-link {
  text-decoration: underline; text-decoration-color: var(--line-3);
  text-decoration-thickness: 2px; text-underline-offset: 6px;
  transition: text-decoration-color .16s var(--ease);
}
.p-link:hover { text-decoration-color: var(--accent); }
.on-dark .p-link { text-decoration-color: var(--dark-line-2); }
.on-dark .p-link:hover { text-decoration-color: var(--accent); }

/* Подложка вместо тени; кликабельна только область мокапа — подпись
   и текст блока остаются выделяемыми. */
.prow-media .scene {
  padding: clamp(18px, 2.6vw, 36px);
  background: var(--sunk); border: 1px solid var(--line-2); border-radius: var(--r-l);
}
.prow-media .scene figcaption { max-width: 46ch; }
.scene-frame { position: relative; overflow: hidden; border-radius: var(--r-m); }
.p-overlay {
  position: absolute; inset: 0; z-index: 4;
  border-radius: var(--r-m); text-decoration: none;
}
.scene--win .win { max-width: 560px; margin-inline: auto; }
.win, .phone { transition: border-color .18s var(--ease); }
.p-overlay:hover ~ .win, .p-overlay:hover ~ .phone { border-color: rgba(255, 255, 255, .24); }

@media (max-width: 900px) {
  .prow-grid { grid-template-columns: 1fr; gap: 34px; }
  .prow--flip .prow-media { order: 0; }
}

/* --- 4. Как мы работаем ------------------------------------------------------- */
.principles {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: clamp(26px, 3.2vw, 42px) clamp(32px, 5vw, 76px);
}
.pr p { margin-top: 8px; max-width: 46ch; color: var(--muted); }
@media (max-width: 760px) { .principles { grid-template-columns: 1fr; } }

/* --- 5. Что нового ------------------------------------------------------------ */
.news { list-style: none; border-top: 1px solid var(--line); }
.news li {
  display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 6px 28px;
  padding: 18px 0; border-bottom: 1px solid var(--line);
}
.news time { font-size: var(--fs-1); font-weight: 600; color: var(--muted); }
@media (max-width: 620px) { .news li { grid-template-columns: 1fr; } }

/* --- 6. Финальный экран -------------------------------------------------------- */
.final-grid { display: grid; justify-items: start; gap: clamp(24px, 3vw, 34px); }
.final h2 { max-width: 21ch; }
/* На широком экране заголовок и кнопка встают в строку: раньше правая половина
   финального экрана оставалась пустой. */
@media (min-width: 860px) {
  .final-grid {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center; gap: clamp(32px, 5vw, 72px);
  }
  .final h2 { max-width: 26ch; }
}

/* =============================================================================
   Мокапы: добавки к скинам site.css. Всё — финальный кадр сценария.
   ========================================================================== */

/* Переключатель текста внутри мокапа: показан только последний вариант */
.swap { display: inline-grid; justify-items: end; }
.swap > span { grid-area: 1 / 1; }
.swap > span:not(:last-child) { opacity: 0; }

/* --- Сцена 1: ЛегалДокс -------------------------------------------------------- */
.skin-doc .d-turn { display: grid; justify-items: end; }
.skin-doc .d-turn > * { grid-area: 1 / 1; }
.skin-doc .d-opts { display: flex; gap: 7px; opacity: 0; }
.skin-doc .d-opt {
  padding: 7px 12px; font-size: 11.5px; font-weight: 600; color: #101828;
  background: #FFFFFF; border: 1px solid #D7DEEE; border-radius: 999px;
}
/* финальный кадр: все шаги пройдены */
.skin-doc .d-steps li { color: #101828; }
.skin-doc .d-dot { background: var(--doc-blue); }
.skin-doc .d-line { font: 11px/1.5 Georgia, 'Times New Roman', serif; color: #3A4254; }
.skin-doc .d-ref { padding: 0 2px; border-radius: 3px; }
.skin-doc .d-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.skin-doc .d-btn { transform-origin: left center; }
.scene--win .pointer, .scene--win .tap { left: 17%; top: 92%; }
.scene--win .pointer { margin: -2px 0 0 -3px; transform-origin: 17% 10%; }

/* --- Сцена 2: Аиста Дайери ------------------------------------------------------ */
.phone-screen.skin-diary { grid-template-rows: auto auto auto 1fr; align-content: stretch; }
.skin-diary .y-rec { align-self: center; }
.skin-diary .y-wave { transform-origin: bottom; }
.skin-diary .y-time { display: inline-flex; align-items: center; gap: 6px; }
.skin-diary .y-live { width: 6px; height: 6px; border-radius: 50%; background: #D8674A; }


/* =============================================================================
   АНИМАЦИИ. Цикл 15с, бесшовный: в конце цикла содержимое гасится и
   возвращается в исходное состояние, поэтому кадр 100% совпадает с кадром 0%.
   ========================================================================== */
@media (prefers-reduced-motion: no-preference) {

/* --- Сцена 1: ЛегалДокс --------------------------------------------------------- */
.scene--win.is-live .pointer { animation: s1-path 15s linear infinite, s1-cursor 15s linear infinite; }
.scene--win.is-live .tap { animation: s1-path 15s linear infinite, s1-tap 15s linear infinite; }
.scene--win.is-live .d-opts { animation: s1-opts 15s linear infinite; }
.scene--win.is-live .d-a { animation: s1-a 15s linear infinite; }
.scene--win.is-live .d-step { animation: s1-step 15s linear infinite; }
.scene--win.is-live .d-step .d-dot { animation: s1-dot 15s linear infinite; }
.scene--win.is-live .d-step:nth-child(2), .scene--win.is-live .d-step:nth-child(2) .d-dot { animation-delay: .55s; }
.scene--win.is-live .d-step:nth-child(3), .scene--win.is-live .d-step:nth-child(3) .d-dot { animation-delay: 1.1s; }
.scene--win.is-live .d-sheet > * { animation: s1-type 15s linear infinite; }
.scene--win.is-live .d-sheet > :nth-child(2) { animation-delay: .22s; }
.scene--win.is-live .d-sheet > :nth-child(3) { animation-delay: .44s; }
.scene--win.is-live .d-sheet > :nth-child(4) { animation-delay: .66s; }
.scene--win.is-live .d-sheet > :nth-child(5) { animation-delay: .88s; }
.scene--win.is-live .d-sheet > :nth-child(6) { animation-delay: 1.1s; }
.scene--win.is-live .d-ref { animation: s1-ref 15s linear infinite; }
.scene--win.is-live .d-ok { animation: s1-ok 15s linear infinite; }
.scene--win.is-live .d-btn { animation: s1-btn 15s linear infinite; }
.scene--win.is-live .d-file { animation: s1-file 15s linear infinite; }
.scene--win.is-live .d-state > span:first-child { animation: s1-state-a 15s linear infinite; }
.scene--win.is-live .d-state > span:last-child { animation: s1-state-b 15s linear infinite; }

@keyframes s1-path {
  0%   { left: 84%; top: 74%; }
  4%   { left: 84%; top: 74%; animation-timing-function: cubic-bezier(.45, 0, .15, 1); }
  11%  { left: 72%; top: 34%; }
  16%  { left: 72%; top: 34%; animation-timing-function: cubic-bezier(.45, 0, .15, 1); }
  22%  { left: 86%; top: 60%; }
  52%  { left: 86%; top: 60%; animation-timing-function: cubic-bezier(.45, 0, .15, 1); }
  60%  { left: 17%; top: 92%; }
  100% { left: 17%; top: 92%; }
}
@keyframes s1-cursor {
  0%, 2%  { opacity: 0; transform: none; }
  5%      { opacity: 1; transform: none; }
  11%     { transform: none; }
  12.5%   { transform: scale(.82); }
  14.5%   { transform: none; }
  59%     { transform: none; }
  61%     { transform: scale(.82); }
  63%     { transform: none; }
  88%     { opacity: 1; }
  93%     { opacity: 0; }
  100%    { opacity: 0; transform: none; }
}
@keyframes s1-tap {
  0%, 11.5% { opacity: 0; transform: scale(.35); }
  12.5%     { opacity: .85; transform: scale(.6); }
  17%       { opacity: 0; transform: scale(1.3); }
  60%       { opacity: 0; transform: scale(.35); }
  61%       { opacity: .85; transform: scale(.6); }
  65.5%     { opacity: 0; transform: scale(1.3); }
  100%      { opacity: 0; transform: scale(.35); }
}
@keyframes s1-opts {
  0%, 12%   { opacity: 1; transform: none; }
  14%       { opacity: 0; transform: translateY(-4px); }
  87%       { opacity: 0; transform: translateY(-4px); }
  93%, 100% { opacity: 1; transform: none; }
}
@keyframes s1-a {
  0%, 12%   { opacity: 0; transform: translateY(5px); }
  16%       { opacity: 1; transform: none; }
  87%       { opacity: 1; transform: none; }
  91%, 100% { opacity: 0; transform: translateY(5px); }
}
@keyframes s1-step {
  0%, 17%   { color: #6B7385; }
  20.5%, 87% { color: #101828; }
  91%, 100% { color: #6B7385; }
}
@keyframes s1-dot {
  0%, 17%   { background: #DCE3F2; }
  20.5%, 87% { background: #1F4ED8; }
  91%, 100% { background: #DCE3F2; }
}
@keyframes s1-type {
  0%, 28%   { opacity: 0; clip-path: inset(0 100% 0 0); }
  29%       { opacity: 1; clip-path: inset(0 100% 0 0); }
  33%       { opacity: 1; clip-path: inset(0 0 0 0); }
  87%       { opacity: 1; clip-path: inset(0 0 0 0); }
  90%, 100% { opacity: 0; clip-path: inset(0 0 0 0); }
}
@keyframes s1-ref {
  0%, 40%   { background: rgba(31, 78, 216, 0); }
  44%, 56%  { background: rgba(31, 78, 216, .15); }
  62%, 100% { background: rgba(31, 78, 216, 0); }
}
@keyframes s1-ok {
  0%, 50%   { opacity: 0; transform: translateY(4px); }
  54%, 87%  { opacity: 1; transform: none; }
  91%, 100% { opacity: 0; transform: translateY(4px); }
}
@keyframes s1-btn {
  0%, 60%  { transform: none; }
  61.5%    { transform: scale(.95); }
  64%      { transform: none; }
  100%     { transform: none; }
}
@keyframes s1-file {
  0%, 63%   { opacity: 0; transform: translateY(5px) scale(.96); }
  67%, 87%  { opacity: 1; transform: none; }
  91%, 100% { opacity: 0; transform: translateY(5px) scale(.96); }
}
@keyframes s1-state-a { 0%, 50% { opacity: 1; } 54%, 87% { opacity: 0; } 92%, 100% { opacity: 1; } }
@keyframes s1-state-b { 0%, 50% { opacity: 0; } 54%, 87% { opacity: 1; } 92%, 100% { opacity: 0; } }

/* --- Сцена 2: Аиста Дайери ------------------------------------------------------- */
.scene--diary.is-live .pointer { animation: s2-path 15s linear infinite, s2-cursor 15s linear infinite; }
.scene--diary.is-live .tap { animation: s2-path 15s linear infinite, s2-tap 15s linear infinite; }
.scene--diary.is-live .y-rec { animation: s2-rec 15s linear infinite; }
.scene--diary.is-live .y-time { animation: s2-time 15s linear infinite; }
.scene--diary.is-live .y-live { animation: s2-live 15s linear infinite; }
.scene--diary.is-live .y-wave { animation: s2-wave 15s linear infinite; }
.scene--diary.is-live .y-wave i { animation: s2-osc .86s ease-in-out infinite; }
.scene--diary.is-live .y-wave i:nth-child(6n+2) { animation-delay: -.14s; }
.scene--diary.is-live .y-wave i:nth-child(6n+3) { animation-delay: -.28s; }
.scene--diary.is-live .y-wave i:nth-child(6n+4) { animation-delay: -.43s; }
.scene--diary.is-live .y-wave i:nth-child(6n+5) { animation-delay: -.57s; }
.scene--diary.is-live .y-wave i:nth-child(6n+6) { animation-delay: -.71s; }
.scene--diary.is-live .y-text span { animation: s2-word 15s linear infinite; animation-delay: calc(var(--i) * .15s); }
.scene--diary.is-live .y-chip { animation: s2-chip 15s linear infinite; }
.scene--diary.is-live .y-chip:nth-child(2) { animation-delay: .35s; }
.scene--diary.is-live .y-chip:nth-child(3) { animation-delay: .7s; }
.scene--diary.is-live .y-today i { animation: s2-today 15s linear infinite; }

@keyframes s2-path {
  0%   { left: 50%; top: 118%; }
  4%   { left: 50%; top: 118%; animation-timing-function: cubic-bezier(.45, 0, .15, 1); }
  11%  { left: 50%; top: 84%; }
  16%  { left: 50%; top: 84%; animation-timing-function: cubic-bezier(.5, 0, .3, 1); }
  24%  { left: 66%; top: 116%; }
  100% { left: 66%; top: 116%; }
}
@keyframes s2-cursor {
  0%, 2% { opacity: 0; transform: none; }
  5%     { opacity: 1; transform: none; }
  11%    { transform: none; }
  12.5%  { transform: scale(.88) translateY(3px); }
  15%    { transform: none; }
  20%    { opacity: 1; }
  25%    { opacity: 0; }
  100%   { opacity: 0; transform: none; }
}
@keyframes s2-tap {
  0%, 11.5% { opacity: 0; transform: scale(.35); }
  12.5%     { opacity: .85; transform: scale(.6); }
  17%       { opacity: 0; transform: scale(1.35); }
  100%      { opacity: 0; transform: scale(.35); }
}
@keyframes s2-rec {
  0%, 11.5% { transform: none; }
  13%       { transform: scale(.9); }
  42%       { transform: scale(.9); }
  45%, 100% { transform: none; }
}
@keyframes s2-time {
  0%, 12%   { opacity: 0; }
  15%, 87%  { opacity: 1; }
  91%, 100% { opacity: 0; }
}
@keyframes s2-live {
  0%, 13%  { opacity: 0; }
  15%, 40% { opacity: 1; }
  43%, 100% { opacity: 0; }
}
@keyframes s2-wave {
  0%, 12%   { transform: scaleY(.07); opacity: .5; }
  15%, 40%  { transform: scaleY(1); opacity: 1; }
  44%, 87%  { transform: scaleY(.4); opacity: .75; }
  92%, 100% { transform: scaleY(.07); opacity: .5; }
}
@keyframes s2-osc {
  0%, 100% { transform: scaleY(.4); }
  50%      { transform: scaleY(1); }
}
@keyframes s2-word {
  0%, 22%  { opacity: 0; transform: translateY(3px); }
  25%, 85% { opacity: 1; transform: none; }
  88%, 100% { opacity: 0; transform: translateY(3px); }
}
@keyframes s2-chip {
  0%, 40%   { opacity: 0; transform: translateY(5px); }
  44%, 86%  { opacity: 1; transform: none; }
  89%, 100% { opacity: 0; transform: translateY(5px); }
}
@keyframes s2-today {
  0%, 52%   { outline-color: transparent; outline-offset: 1px; }
  55%       { outline-color: var(--dy-hi); outline-offset: 5px; }
  59%, 87%  { outline-color: var(--dy-hi); outline-offset: 1px; }
  91%, 100% { outline-color: transparent; outline-offset: 1px; }
}


} /* /prefers-reduced-motion: no-preference */

/* Мелкая правовая оговорка в блоке продукта */
.p-fine { margin-top: 14px; font-size: 13.5px; line-height: 1.5; color: var(--muted); max-width: 46ch; }

/* --- Заголовок направления --------------------------------------------------- */
.dirhead { padding-block: clamp(56px, 7vw, 96px) 0; }
.dirhead h2 + .lead { margin-top: 12px; }

/* --- Блок «Для разработчиков» ------------------------------------------------- */
/* Компактнее, чем экраны продуктов выше: у этих двух сервисов своя аудитория,
   и разворачивать под каждый полноэкранный блок значило бы удлинять главную
   вдвое ради читателя, который сюда, скорее всего, не дойдёт. */
.devs .badge { margin-bottom: 14px; }
.devrow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(20px, 2.6vw, 34px); margin-top: clamp(28px, 3.4vw, 44px); }
.devcard {
  display: flex; flex-direction: column; align-items: start; gap: 14px;
  padding: clamp(20px, 2.4vw, 30px);
  background: rgba(255,255,255,.02); border: 1px solid var(--dark-line-2);
  border-radius: var(--r-l);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.devcard, .devcard > * { min-width: 0; max-width: 100%; }
.devcard h3 { color: var(--on-dark); }
.devcard > p { color: var(--on-dark-mut); max-width: 44ch; }
.devcard .tlink { margin-top: auto; }
.devterm { width: 100%; border-color: var(--dark-line); }
.devterm .win-body { min-height: 0; padding: 13px 15px; font-size: 11.5px; line-height: 1.75; }
@media (max-width: 860px) { .devrow { grid-template-columns: minmax(0, 1fr); } }

/* --- Статус над заголовком продукта ------------------------------------------ */
.prow-text .badge { margin-bottom: 14px; }
