/* The page is a squared school notebook with a red margin: the «тетрадка» Foma writes into. */
:root {
  --paper: #fbfcfd;
  --grid: #dce6f0;
  --margin: #e0564a;
  --ink: #2f3e9e;
  --text: #1d2433;
  --muted: #56607a;
  --tg: #1b78b8; /* Telegram blue, darkened for 4.5:1 with white text */
  --tg-chat: #dfe8f0;
  --bubble-out: #e3f6d0;
  --bubble-in: #ffffff;
  --cell: 22px;
  --edge: 28px; /* where the margin line runs */
  --gutter: 20px; /* from the margin line to the text */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--text);
  font: 400 17px/1.55 Onest, system-ui, sans-serif;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
}

/* The margin line follows the text column, so the topics in the margin sit next to their dialogues. */
.notebook { position: relative; max-width: 1120px; margin: 0 auto; }
.notebook::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--edge) - 1px);
  width: 2px;
  background: var(--margin);
}

a { color: var(--ink); }

:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 4px; }

.top, main, footer {
  position: relative;
  padding-left: calc(var(--edge) + var(--gutter));
  padding-right: 20px;
}

/* Header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; white-space: nowrap; }
.top-cta { font-weight: 500; text-decoration: none; white-space: nowrap; }
.top-cta .long { display: none; }
.top-cta:hover { text-decoration: underline; }

/* Hero */
.hero {
  display: grid;
  gap: 40px;
  padding: 36px 0 72px;
}
h1 {
  margin: 0;
  font-size: clamp(34px, 7.6vw, 64px);
  line-height: 1.02;
  font-weight: 800;
  letter-spacing: -0.035em;
  max-width: 12ch;
}
.lead { margin: 22px 0 0; max-width: 34em; font-size: 19px; color: var(--muted); }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 30px; }
.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 24px;
  border-radius: 999px;
  background: var(--tg);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  text-decoration: none;
  transition: background-color .15s;
}
.cta:hover { background: #155f93; }
.cta svg { width: 22px; height: 22px; fill: currentColor; }
.cta-note { color: var(--muted); font-size: 15px; }

/* Hero scene: the phone and the notebook page it writes on */
.scene { position: relative; display: grid; justify-items: start; }
.phone {
  width: min(320px, 100%);
  border-radius: 34px;
  border: 9px solid #1f2533;
  background: var(--tg-chat);
  overflow: hidden;
  box-shadow: 0 24px 48px -24px rgba(31, 37, 51, .45);
}
.phone-bar { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; font-size: 15px; line-height: 1.2; }
.phone-bar small { display: block; color: var(--muted); font-size: 13px; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; }
.chat { display: grid; gap: 8px; padding: 16px 12px 22px; min-height: 250px; align-content: start; }

.msg {
  margin: 0;
  max-width: 88%;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.4;
}
.msg.out { justify-self: end; background: var(--bubble-out); border-bottom-right-radius: 5px; }
.msg.in { justify-self: start; background: var(--bubble-in); border-bottom-left-radius: 5px; }

.voice { display: flex; align-items: center; gap: 8px; }
.play { width: 30px; height: 30px; border-radius: 50%; background: #4fae4e; position: relative; flex: none; }
.play::after { content: ""; position: absolute; left: 12px; top: 9px; border-left: 9px solid #fff; border-top: 6px solid transparent; border-bottom: 6px solid transparent; }
.wave { display: flex; align-items: center; gap: 2px; height: 22px; }
.wave i { width: 3px; border-radius: 2px; background: #4fae4e; }
.wave i:nth-child(4n+1) { height: 8px; } .wave i:nth-child(4n+2) { height: 18px; }
.wave i:nth-child(4n+3) { height: 12px; } .wave i:nth-child(4n) { height: 20px; }
.dur { font-size: 12px; color: #4b8a3c; }
.said { justify-self: end; margin: -2px 4px 4px 0; max-width: 88%; font-size: 13px; color: var(--muted); text-align: right; }
.pair .said { font-size: 14px; }

.reply { display: grid; }
.reply > span { grid-area: 1 / 1; }
.working { opacity: 0; color: var(--muted); }

/* The input bar: at rest a field and a mic; while recording — red dot, timer, live wave, the mic held down */
.composer { display: grid; padding: 8px 10px 12px; background: #fff; border-top: 1px solid #d5dee7; }
.composer > div { grid-area: 1 / 1; display: flex; align-items: center; gap: 8px; min-height: 40px; }
.field { flex: 1; padding: 9px 14px; border-radius: 20px; background: #f1f4f7; color: #8a93a6; font-size: 15px; }
.mic { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; }
.mic svg { width: 24px; height: 24px; fill: #7d8799; }
.mic.hot { background: var(--tg); box-shadow: 0 0 0 7px rgba(27, 120, 184, .18); }
.mic.hot svg { fill: #fff; }
.rec { opacity: 0; padding-left: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--margin); flex: none; }
.timer { display: grid; font-size: 15px; font-variant-numeric: tabular-nums; }
.timer i { grid-area: 1 / 1; font-style: normal; opacity: 0; }
.timer i:last-child { opacity: 1; }
.rec-wave { flex: 1; display: flex; align-items: center; gap: 3px; height: 26px; }
.rec-wave i { width: 3px; border-radius: 2px; background: var(--tg); }
.rec-wave i:nth-child(3n+1) { height: 10px; } .rec-wave i:nth-child(3n+2) { height: 22px; } .rec-wave i:nth-child(3n) { height: 15px; }

.page {
  justify-self: end;
  margin: -34px 0 0;
  padding: 10px 20px 6px 26px;
  width: max-content;
  max-width: 100%;
  background: var(--paper);
  border-left: 2px solid var(--margin);
  transform: rotate(-2deg);
  box-shadow: 0 10px 30px -18px rgba(31, 37, 51, .5);
}
.hand { margin: 0; font: 700 26px/34px Caveat, cursive; color: var(--ink); white-space: nowrap; }

/* One orchestrated moment: the mic held down → the voice sent → «Работаю…» → answer → the line written by hand. */
@media (prefers-reduced-motion: no-preference) {
  .rec { animation: shown 2.3s linear .3s both; }
  .idle { animation: hidden 2.3s linear .3s both; }
  .timer i { animation: tick .5s steps(1) forwards; } /* hidden until its turn, hidden after it */
  .timer i:nth-child(1) { animation-delay: .4s; }
  .timer i:nth-child(2) { animation-delay: .9s; }
  .timer i:nth-child(3) { animation-delay: 1.4s; }
  .timer i:last-child { animation: last-tick .01s linear 1.9s both; }
  .rec-wave i { animation: grow .45s ease-out both; }
  .rec-wave i:nth-child(1) { animation-delay: .5s; } .rec-wave i:nth-child(2) { animation-delay: .65s; }
  .rec-wave i:nth-child(3) { animation-delay: .8s; } .rec-wave i:nth-child(4) { animation-delay: .95s; }
  .rec-wave i:nth-child(5) { animation-delay: 1.1s; } .rec-wave i:nth-child(6) { animation-delay: 1.25s; }
  .rec-wave i:nth-child(7) { animation-delay: 1.4s; } .rec-wave i:nth-child(8) { animation-delay: 1.55s; }
  .rec-wave i:nth-child(9) { animation-delay: 1.7s; } .rec-wave i:nth-child(10) { animation-delay: 1.85s; }
  .rec-wave i:nth-child(11) { animation-delay: 2s; } .rec-wave i:nth-child(12) { animation-delay: 2.15s; }
  .mic.hot { animation: pulse 1s ease-in-out .3s 2 both; }
  .step-1 { animation: appear .4s ease-out 2.6s both; }
  .step-2 { animation: appear .4s ease-out 3.5s both; }
  .working { animation: working 1.5s linear 3.5s both; }
  .done { animation: appear .35s ease-out 5s both; }
  .page { animation: appear .5s ease-out 5.3s both; }
  .line-1 { animation: write 1.1s steps(22) 5.7s both; }
  .line-2 { animation: write .7s steps(14) 6.9s both; }
}
@keyframes appear { from { opacity: 0; transform: translateY(6px); } }
@keyframes working { 0%, 90% { opacity: 1; } 100% { opacity: 0; } }
@keyframes shown { 0% { opacity: 0; } 4%, 96% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hidden { 0% { opacity: 1; } 4%, 96% { opacity: 0; } 100% { opacity: 1; } }
@keyframes tick { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes last-tick { from { opacity: 0; } to { opacity: 1; } }
@keyframes grow { from { transform: scaleY(.1); opacity: 0; } }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(27, 120, 184, .1); } }
@keyframes write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.page { transform: rotate(-2deg); }

/* Sections */
section h2 {
  margin: 0 0 12px;
  font-size: clamp(28px, 5vw, 40px);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.025em;
}
.examples, .steps, .skills, .price, .faq, .final { padding: 56px 0; }
.section-lead { margin: 0 0 32px; color: var(--muted); max-width: 36em; }

/* Examples: the margin holds the notebook's topic, the page holds the dialogue */
.sheet { display: grid; gap: 40px; max-width: 760px; }
.example { display: grid; grid-template-columns: 1fr; gap: 6px; }
.margin {
  margin: 0;
  font: 700 26px/1 Caveat, cursive;
  color: var(--margin);
}
.pair { display: grid; gap: 8px; max-width: 560px; }
.pair .msg { max-width: min(460px, 92%); font-size: 16px; }
.pair .msg.in { border: 1px solid #cfdae5; }
.photo { display: flex; align-items: center; gap: 10px; }
.receipt { display: grid; gap: 4px; width: 38px; padding: 7px 6px; background: #fff; border-radius: 3px; border: 1px solid #cfdae5; }
.receipt i { height: 3px; background: #b7c4d2; border-radius: 2px; }
.receipt i:nth-child(2n) { width: 70%; }
.receipt b { height: 5px; background: var(--text); border-radius: 2px; margin-top: 2px; }

/* Steps: a real sequence, so numbered */
.steps ol { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 22px; max-width: 40em; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding-left: 52px; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -12px;
  font: 700 44px/1 Caveat, cursive;
  color: var(--ink);
}

.skills ul { margin: 20px 0 0; padding: 0; list-style: none; display: grid; gap: 12px 40px; max-width: 900px; }
.skills li { position: relative; padding-left: 26px; }
.skills li::before { content: "✓"; position: absolute; left: 0; top: -3px; font: 700 26px/1 Caveat, cursive; color: var(--ink); }

.price-line { margin: 8px 0 14px; font-size: clamp(24px, 4vw, 32px); font-weight: 700; letter-spacing: -0.01em; }
.free { color: var(--ink); }
.price p:last-child { max-width: 36em; margin: 0; color: var(--muted); }

.faq details { max-width: 44em; border-bottom: 1px solid var(--grid); }
.faq summary { cursor: pointer; padding: 16px 32px 16px 0; font-weight: 700; list-style: none; position: relative; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 4px; top: 10px; font: 700 30px/1 Caveat, cursive; color: var(--ink); transition: transform .2s; }
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { margin: 0 0 18px; color: var(--muted); }

.final { padding-bottom: 88px; }
.final p { margin: 0 0 26px; color: var(--muted); font-size: 19px; }

footer { padding-top: 24px; padding-bottom: 40px; color: var(--muted); font-size: 15px; display: flex; flex-wrap: wrap; gap: 8px 32px; }
footer p { margin: 0; }
footer .note { flex-basis: 100%; font-size: 13px; }

/* Terms page */
.terms { max-width: 44em; padding: 24px 0 72px; }
.terms h1 { font-size: clamp(28px, 5vw, 40px); max-width: none; margin-bottom: 20px; }
.terms h2 { margin: 32px 0 8px; font-size: 20px; line-height: 1.3; }
.terms p { margin: 0 0 10px; }

@media (min-width: 720px) {
  :root { --edge: 64px; --gutter: 32px; }
  .example { grid-template-columns: 150px 1fr; gap: var(--gutter); align-items: start; margin-left: calc(-150px - var(--gutter)); }
  .margin { text-align: right; padding: 6px 12px 0 0; }
  .skills ul { grid-template-columns: 1fr 1fr; }
  .top-cta .long { display: inline; }
}

@media (min-width: 720px) and (max-width: 1239px) {
  .example { margin-left: 0; grid-template-columns: 130px 1fr; }
  .margin { text-align: left; }
}

@media (min-width: 1000px) {
  .hero { grid-template-columns: 1.1fr .9fr; align-items: center; padding-top: 56px; }
  .scene { justify-items: center; }
  .page { margin-right: -12px; }
}
