/* Анимации лендинга «Temfy: Создать комикс, манга» (разметка — scripts/build-comics.mjs, поведение — comics-demo.js).
   Телефон — общий с демо клинера (swipe-demo.css: .sd, .sd-phone, .sd-screen, .sd-status, .sd-try); размеры — в em от --w.
   Экран — как в приложении: жёлтый фон в точку, толстые чёрные рамки, красный заголовок, синие плашки. */

/* ---------- 1) Демо в hero: «Миссия: комикс» ---------- */
.cm .sd-phone { background: #111; box-shadow: .5em .6em 0 #000, 0 3em 6em rgba(0,0,0,.25), inset 0 0 0 .12em rgba(255,255,255,.1); }
.cm-screen {
  color: #111; text-align: left; font-weight: 700;
  background: radial-gradient(circle, rgba(200,150,0,.28) .14em, transparent .16em) 0 0 / .9em .9em, #fce02e;
}
.cm-top { display: flex; justify-content: space-between; align-items: center; padding: 0 1.3em; height: 2.9em; }
.cm-cred, .cm-gear { display: grid; place-items: center; height: 2.1em; min-width: 2.6em; padding: 0 .5em; border-radius: .5em; background: #1a5cd1; color: #fff; border: .14em solid #111; font-size: .95em; font-weight: 800; }
.cm-gear svg { width: 1.2em; height: 1.2em; fill: none; stroke: #fff; stroke-width: 2; }
.cm-head { margin: .2em 1.1em 0; padding: .55em .9em .6em; background: #db1f2e; color: #fff; border: .16em solid #111; }
.cm-head b { display: block; font-size: 1.45em; font-weight: 900; letter-spacing: .01em; line-height: 1.1; }
.cm-head small { display: block; font-size: .72em; font-weight: 600; opacity: .9; margin-top: .2em; }
.cm-box { margin: .65em 1.1em 0; background: #fff; border: .16em solid #111; }
.cm-heroes { display: flex; align-items: center; gap: .4em; padding: .45em .55em; }
.cm-av { flex: none; width: 2.2em; height: 2.2em; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 900; border: .12em solid #111; background: #f02b45; }
.cm-av + .cm-av { background: #1a5cd1; margin-left: -.7em; }
.cm-add { font-size: .82em; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cm-label { margin: .65em 1.1em 0; padding: .45em .7em; background: #1a5cd1; color: #fff; border: .16em solid #111; font-size: .82em; font-weight: 800; }
.cm-label + .cm-box { margin-top: 0; border-top: none; }
.cm-styles { overflow: hidden; padding: .55em 0 .35em; }
.cm-styles-in { display: flex; gap: .5em; padding: 0 .55em; width: max-content; transition: transform .6s cubic-bezier(.3,.7,.3,1); }
.cm-st { display: flex; flex-direction: column; align-items: center; gap: .25em; width: 5.6em; cursor: pointer; }
.cm-st img { display: block; width: 5.6em; height: 5.6em; object-fit: cover; border: .14em solid #111; transition: transform .3s ease, box-shadow .3s ease; }
.cm-st small { font-size: .72em; font-weight: 800; }
.cm-st.on img { box-shadow: 0 0 0 .2em #f02b45; transform: scale(1.04); }
.cm-st.on small { color: #db1f2e; }
.cm-story { padding: .6em .7em; min-height: 4.6em; }
.cm-story p { margin: 0; font-size: .9em; font-weight: 500; line-height: 1.3; color: #222; }
.cm-story p.typing::after { content: ""; display: inline-block; width: .08em; height: 1em; margin-left: .05em; vertical-align: -.15em; background: #111; animation: cm-caret .8s steps(1) infinite; }
@keyframes cm-caret { 50% { opacity: 0; } }
.cm-pages { display: flex; align-items: center; gap: .8em; margin: .65em 1.1em 0; padding: .5em .7em; background: #1a5cd1; color: #fff; border: .16em solid #111; font-size: .85em; }
.cm-pages b { display: inline-block; min-width: .8em; font-variant-numeric: tabular-nums; }
.cm-pages b.bump { animation: cm-bump .35s ease; }
@keyframes cm-bump { 50% { transform: scale(1.4); } }
.cm-slider { position: relative; flex: 1; height: .35em; border-radius: .2em; background: rgba(255,255,255,.35); }
.cm-slider i { position: absolute; top: 50%; left: calc(var(--p) * 100%); width: 1.1em; height: 1.1em; margin: -.55em 0 0 -.55em; border-radius: 50%; background: #f02b45; border: .12em solid #111; transition: left .35s ease; }
.cm-create { display: block; margin: .7em 1.1em 0; padding: .7em; text-align: center; background: #f02b45; color: #fff; border: .16em solid #111; box-shadow: .25em .25em 0 #111; font-size: 1.05em; font-weight: 900; letter-spacing: .02em; transition: transform .15s ease, box-shadow .15s ease; }
.cm-create.tap { transform: translate(.2em, .2em); box-shadow: .05em .05em 0 #111; }
.cm-tabs { position: absolute; left: 50%; bottom: 1.2em; transform: translateX(-50%); display: flex; gap: .4em; padding: .35em; border-radius: 2em; background: rgba(255,255,255,.92); box-shadow: 0 .3em 1em rgba(0,0,0,.15); }
.cm-tabs span { display: flex; flex-direction: column; align-items: center; gap: .1em; padding: .3em .9em; border-radius: 1.6em; font-size: .68em; font-weight: 600; color: #666; }
.cm-tabs span.on { background: #e6efff; color: #1a5cd1; }
.cm-tabs svg { width: 1.6em; height: 1.6em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cm .sd-try { bottom: 5.4em; }

/* «Рисуем ваш комикс» и страница-результат — поверх формы */
.cm-draw, .cm-result { position: absolute; inset: 0; z-index: 5; opacity: 0; pointer-events: none; transition: opacity .4s ease; }
.cm-draw { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1em; background: rgba(252,224,46,.94); }
.cm-draw b { font-size: 1.3em; font-weight: 900; text-align: center; padding: 0 1.5em; }
.cm-pow { display: grid; place-items: center; width: 7em; height: 7em; color: #fff; font-size: 1.5em; font-weight: 900; font-style: italic; -webkit-text-stroke: .05em #111; background: #f02b45; clip-path: polygon(50% 0, 61% 26%, 90% 10%, 76% 38%, 100% 50%, 76% 62%, 90% 90%, 61% 74%, 50% 100%, 39% 74%, 10% 90%, 24% 62%, 0 50%, 24% 38%, 10% 10%, 39% 26%); }
.cm.drawing .cm-pow { animation: cm-pow 1.1s ease-in-out infinite; }
@keyframes cm-pow { 50% { transform: scale(1.12) rotate(-6deg); } }
.cm-prog { width: 60%; height: .9em; border: .14em solid #111; background: #fff; overflow: hidden; }
.cm-prog i { display: block; height: 100%; width: 0; background: repeating-linear-gradient(-45deg, #1a5cd1 0 .5em, #3f7cf0 .5em 1em); }
.cm.drawing .cm-prog i { width: 100%; transition: width 2.6s linear; }
.cm.drawing .cm-draw { opacity: 1; }
.cm-result { padding-top: 4.4em; background: radial-gradient(circle, rgba(200,150,0,.28) .14em, transparent .16em) 0 0 / .9em .9em, #fce02e; }
.cm.done .cm-result { opacity: 1; }
.cm-page { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, 1fr); gap: .4em; height: 37em; margin: .7em 1.1em 0; padding: .4em; background: #fff; border: .16em solid #111; }
.cm-page i {
  border: .14em solid #111; background-image: var(--img); background-repeat: no-repeat;
  background-size: calc(var(--s) * 100%); background-position: var(--x) var(--y);
  opacity: 0; transform: scale(.6) rotate(-4deg);
  transition: opacity .3s ease, transform .5s cubic-bezier(.2,1.5,.4,1); transition-delay: calc(var(--i) * 220ms);
}
.cm.done .cm-page i { opacity: 1; transform: none; }

/* ---------- 2) Шесть стилей ---------- */
.cs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; max-width: 900px; margin: 0 auto; }
@media (max-width: 760px) { .cs { grid-template-columns: repeat(2, 1fr); gap: 14px; } }
.cs-card {
  margin: 0; background: #fff; border: 3px solid #111; box-shadow: 6px 6px 0 #111; overflow: hidden;
  transition: transform .45s cubic-bezier(.2,1.4,.4,1), box-shadow .3s ease, opacity .4s ease; transition-delay: calc(var(--i) * 110ms);
}
.cs-card img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-bottom: 3px solid #111; }
.cs-card figcaption { padding: 10px 12px 12px; }
.cs-card b { display: block; font-size: 17px; font-weight: 900; text-transform: uppercase; letter-spacing: .3px; }
.cs-card span { display: block; color: #444; font-size: 13.5px; line-height: 1.35; margin-top: 2px; }
.cs.reset .cs-card { opacity: 0; transform: scale(.7) rotate(calc((var(--i) - 2.5) * 3deg)); }
.cs .cs-card.on { transform: translateY(-6px) rotate(-1.5deg); box-shadow: 10px 12px 0 #db1f2e; transition-delay: 0s; }

/* ---------- 3) Сюжетная арка ---------- */
.ca { position: relative; max-width: 900px; margin: 0 auto 6px; padding: 26px; background: #fff; border: 3px solid #111; box-shadow: 6px 6px 0 #111; }
@media (max-width: 480px) { .ca { padding: 20px 14px; } }
.ca-title { display: block; font-size: 20px; font-weight: 900; text-transform: uppercase; }
.ca-sub { margin: 4px 0 18px; color: #444; font-size: 14.5px; }
.ca-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; counter-reset: none; }
@media (max-width: 860px) { .ca-steps { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 420px) { .ca-steps { grid-template-columns: repeat(2, 1fr); } }
.ca-steps li { position: relative; padding: 12px 10px; border: 2.5px solid #111; background: #fff7c2; min-width: 0; transition: background .35s ease, transform .4s cubic-bezier(.2,1.4,.4,1), color .35s ease; transition-delay: calc(var(--i) * 380ms); }
.ca-steps b { display: block; font-size: 14.5px; font-weight: 900; line-height: 1.2; overflow-wrap: anywhere; }
.ca-steps small { display: block; margin-top: 3px; font-size: 12.5px; color: #555; line-height: 1.3; transition: color .35s ease; transition-delay: inherit; }
.ca-n { display: grid; place-items: center; width: 26px; height: 26px; margin-bottom: 8px; border-radius: 50%; background: #1a5cd1; color: #fff; font-weight: 900; font-size: 13px; border: 2px solid #111; }
.ca-steps li:nth-child(4) { background: #db1f2e; color: #fff; }
.ca-steps li:nth-child(4) small { color: rgba(255,255,255,.88); }
.ca.reset .ca-steps li { background: #fff; color: #bbb; transform: scale(.94); }
.ca.reset .ca-steps li small { color: #ccc; }
.ca.reset .ca-n { background: #ccc; }

@media (prefers-reduced-motion: reduce) {
  .cm-page i, .cs-card, .ca-steps li, .cm-styles-in { transition: none; }
  .cm.drawing .cm-pow { animation: none; }
}
