/*
  Компактное демо на первом экране: «задача → работа → результат → оплата».
  Стоит справа от заголовка как иллюстрация. Цвета берутся из переменных сайта.
*/
.demo { display: block; min-width: 0; width: 100%; font-size: 0.9rem; line-height: 1.5; }

/* ---------- Окно ---------- */
.demo-window {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  display: flex; flex-direction: column; min-width: 0;
  box-shadow: 0 24px 48px -32px color-mix(in srgb, var(--accent) 55%, transparent);
}
.demo-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }
.demo-bar i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); display: inline-block; flex: none; }
.demo-stage { margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-badge { margin-left: auto; flex: none; border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }

/* полоска прогресса из 6 этапов */
.demo-progress { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 0 14px 10px; border-bottom: 1px solid var(--line); }
.demo-progress i { height: 3px; border-radius: 3px; background: var(--line); position: relative; overflow: hidden; }
.demo-progress i::after { content: ''; position: absolute; inset: 0; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 0.45s ease; }
.demo-progress i.done::after { transform: scaleX(1); }
.demo-progress i.active::after { transform: scaleX(0.5); animation: demo-fill 1.4s ease-in-out infinite alternate; }

/* ---------- Лента сообщений ---------- */
.demo-log { height: 330px; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 9px; scroll-behavior: smooth; overscroll-behavior: contain; scrollbar-width: thin; }
.demo-log > * { flex-shrink: 0; }   /* сообщения не сжимаются, лента прокручивается */
.demo-empty { margin: auto; text-align: center; color: var(--muted); max-width: 18rem; }

.msg { max-width: 90%; border-radius: 12px; padding: 8px 11px; overflow-wrap: anywhere; animation: demo-in 0.35s ease both; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .who { display: block; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); margin-bottom: 2px; }
.msg ul { margin: 4px 0 0; padding-left: 1.1em; }
.msg li { margin: 1px 0; animation: demo-in 0.3s ease both; }
.msg li.ok { list-style: none; margin-left: -1.1em; }
.msg li.ok::before { content: '✓'; color: var(--accent); font-weight: 700; margin-right: 7px; }

.typing { display: inline-flex; gap: 4px; padding: 3px 0; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: demo-blink 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

.msg.code-msg { padding: 0; background: var(--code-bg); border: 1px solid #232c55; width: 94%; max-width: 94%; overflow: hidden; }
.code-msg .code-top { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; border-bottom: 1px solid #232c55; font-family: var(--font-mono); font-size: 0.68rem; color: var(--code-dim); }
.code-msg pre { margin: 0; padding: 9px 12px; font-family: var(--font-mono); font-size: 0.72rem; line-height: 1.6; color: var(--code-ink); white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2.6em; }
.code-msg .code-progress { height: 2px; background: #232c55; }
.code-msg .code-progress b { display: block; height: 100%; width: 0; background: var(--code-key); transition: width 0.2s linear; }
.cursor { display: inline-block; width: 6px; height: 1em; vertical-align: -2px; background: var(--code-key); animation: demo-caret 0.9s steps(1) infinite; }

.msg.card-result, .msg.card-pay { align-self: stretch; max-width: none; }
.msg.card-result { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.card-result h4, .card-pay h4 { margin: 0 0 3px; font-family: var(--font-title); font-weight: 600; font-size: 0.95rem; }
.card-result p { margin: 0; color: var(--muted); }
.card-result .tag { display: inline-block; margin-top: 6px; font-family: var(--font-mono); font-size: 0.7rem; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; color: var(--muted); }
.pay-rows { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 4px 0 10px; }
.pay-rows dt { color: var(--muted); }
.pay-rows dd { margin: 0; text-align: right; font-family: var(--font-mono); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.pay-rows .total { font-weight: 600; color: var(--ink); }
.pay-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pay-actions .btn { padding: 7px 14px; font-size: 0.85rem; border-radius: 8px; }
.pay-note { margin: 8px 0 0; font-size: 0.74rem; color: var(--muted); }
.paid { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.88rem; }
.paid svg { flex: none; width: 22px; height: 22px; }
.paid circle { stroke-dasharray: 76; stroke-dashoffset: 76; animation: demo-draw 0.5s ease forwards; }
.paid path { stroke-dasharray: 22; stroke-dashoffset: 22; animation: demo-draw 0.35s 0.45s ease forwards; }
.spinner { width: 13px; height: 13px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; vertical-align: -2px; margin-right: 7px; animation: demo-spin 0.7s linear infinite; }

/* ---------- Ввод задачи ---------- */
.demo-form { border-top: 1px solid var(--line); padding: 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.demo-input-row { display: flex; gap: 6px; }
.demo-input-row input {
  flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.demo-input-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.demo-input-row .btn { padding: 0; width: 40px; height: 40px; flex: none; border-radius: 9px; font-size: 1.05rem; display: grid; place-items: center; }
.demo-input-row .btn[disabled] { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }
.demo .form-error { font-size: 0.82rem; }
.demo-foot { margin: 8px 2px 0; font-size: 0.76rem; color: var(--muted); }

@media (max-width: 759px) {
  .demo-log { height: 300px; }
}

@keyframes demo-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes demo-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes demo-caret { 50% { opacity: 0; } }
@keyframes demo-draw { to { stroke-dashoffset: 0; } }
@keyframes demo-spin { to { transform: rotate(360deg); } }
@keyframes demo-fill { from { transform: scaleX(0.15); } to { transform: scaleX(0.85); } }

@media (prefers-reduced-motion: reduce) {
  .msg, .msg li, .cursor, .typing i, .spinner, .demo-progress i.active::after { animation: none !important; }
  .paid circle, .paid path { animation: none; stroke-dashoffset: 0; }
  .demo-log { scroll-behavior: auto; }
}

/* ---------- Крыло валькирии на фоне первого экрана ---------- */
.hero { position: relative; overflow: hidden; isolation: isolate; }
.hero-wing {
  position: absolute; z-index: -1; pointer-events: none;
  width: 720px; height: auto; left: calc(50% + 200px); top: -20px;
  color: var(--accent);
  transform-origin: 6% 96%;
  opacity: 0;
  animation: wing-in 1.6s ease 0.2s forwards, wing-breathe 9s ease-in-out 1.8s infinite alternate;
}
.hero-wing path { stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; }
.hero-wing .wf1 { fill: currentColor; fill-opacity: 0.045; stroke-opacity: 0.2; }
.hero-wing .wf2 { fill: currentColor; fill-opacity: 0.06; stroke-opacity: 0.2; }
.hero-wing .wf3 { fill: currentColor; fill-opacity: 0.08; stroke-opacity: 0.22; }
.hero-wing .wf4 { fill: currentColor; fill-opacity: 0.11; stroke-opacity: 0.25; }
.hero-wing .wsh { fill: none; stroke-opacity: 0.12; stroke-width: 1; }
@media (max-width: 759px) {
  .hero-wing { width: 520px; left: auto; right: -190px; top: auto; bottom: 150px; }
}
@keyframes wing-in { from { opacity: 0; transform: rotate(-7deg) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes wing-breathe { from { transform: rotate(0deg); } to { transform: rotate(-2.5deg); } }
@media (prefers-reduced-motion: reduce) {
  .hero-wing { animation: none; opacity: 1; }
}
