/* The Knowledge Academy — заявление о зачислении
   Konsepsiya: sahifa maktab qabul jurnalining varag'i.
   Chapda chekka chizig'i (поля), unda yozuvlar raqamlari; maydonlar chiziq ustiga yoziladi. */

:root {
  --desk:       #E4E9F2;
  --paper:      #F8FAFD;
  --rule:       #CBD5E6;
  --ink:        #2E2758;
  --ink-wet:    #4B3FA8;
  --ink-faint:  #6E6A8C;
  --stamp:      #B03A2E;

  --display: "Spectral", Georgia, "Times New Roman", serif;
  --body: "Golos Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --util: "JetBrains Mono", "Cascadia Mono", Consolas, ui-monospace, monospace;

  --margin-rule: 76px;    /* chekka chizig'igacha */
  --margin-pad: 104px;    /* matn boshlanadigan joy */
  --margin-gutter: 18px;  /* varaq chetidan raqamgacha */

  /* Yozuv chiziqlarining eng katta eni. Varaqning o'zi ekranni to'liq
     egallaydi, lekin bitta qatorli maydon 1100px dan uzun bo'lsa ko'z
     chiziq boshidan oxirigacha yurishga qiynaladi. */
  --line-max: 1100px;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--body);
  font-size: 19px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Varaq ────────────────────────────────────────────────────────── */

/* Varaq ekranni to'liq egallaydi: oldin 700px edi va katta monitorda
   ikki yonida keng bo'sh stol qolib ketardi. Endi qog'oz chetdan chetga,
   balandligi ham kamida bir ekran. */
.sheet {
  position: relative;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 88px clamp(28px, 4vw, 72px) 112px var(--margin-pad);
  background: var(--paper);
}

/* Chekka chizig'i — butun varaq bo'ylab */
.sheet::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--margin-rule);
  width: 1.5px;
  background: var(--stamp);
  opacity: .3;
}

/* ── Sarlavha ─────────────────────────────────────────────────────── */

.masthead { margin-bottom: 76px; }

.mark {
  display: block;
  width: 68px;
  height: 68px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 16px;
  font-family: var(--util);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

h1 {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: clamp(2.2rem, 1.6rem + 2.4vw, 3.6rem);
  font-weight: 600;
  line-height: 1.06;
  letter-spacing: -.022em;
}

.lede {
  margin: 0;
  max-width: 46ch;
  font-size: 17.5px;
  line-height: 1.62;
  color: var(--ink-faint);
}

.notice {
  margin: 0 0 44px;
  max-width: var(--line-max);
  padding: 16px 20px;
  border-left: 3px solid var(--stamp);
  background: rgba(176, 58, 46, .06);
  font-size: 16.5px;
}

/* ── Yozuvlar ─────────────────────────────────────────────────────── */

.entries {
  counter-reset: entry;
  border: 0;
  margin: 0;
  padding: 0;
}

.entry {
  position: relative;
  counter-increment: entry;
  /* Yorliq o'z chizig'iga yaqinroq (≈40px), keyingi yozuvgacha uzoqroq (46px):
     yaqinlik yorliqni o'z maydoniga bog'laydi. */
  margin: 0 0 54px;
  padding: 0;
}

/* Chekkadagi tartib raqami — to'ldirilgach siyohga aylanadi */
.entry::before {
  content: counter(entry, decimal-leading-zero);
  position: absolute;
  top: 1px;
  left: calc(-1 * var(--margin-pad) + var(--margin-gutter));
  width: calc(var(--margin-rule) - var(--margin-gutter) - 14px);
  text-align: right;
  font-family: var(--util);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--ink-faint);
  opacity: .6;
  transition: color .18s ease, opacity .18s ease;
}

.entry.is-filled::before { color: var(--ink-wet); opacity: 1; }
.entry.is-error::before  { color: var(--stamp);  opacity: 1; }

.entry > label,
.entry > .group-label {
  display: block;
  margin: 0 0 10px;
  padding: 0;
  max-width: 62ch;
  font-family: var(--util);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: .075em;
  text-transform: uppercase;
  color: var(--ink-faint);
  transition: color .18s ease;
}

.entry:focus-within > label,
.entry:focus-within > .group-label { color: var(--ink-wet); }

.optional {
  margin-left: .5em;
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: none;
  color: var(--ink-faint);
  opacity: .85;
}

/* ── Yozuv chiziqlari ─────────────────────────────────────────────── */

.entry input[type="text"],
.entry input[type="date"],
.entry input[type="tel"],
.entry input[type="email"] {
  display: block;
  width: 100%;
  max-width: var(--line-max);
  margin: 0;
  padding: 6px 6px 14px;
  border: 0;
  border-bottom: 1.5px solid var(--rule);
  border-radius: 0;
  background: transparent;
  font-family: var(--body);
  font-size: 21px;
  line-height: 1.4;
  color: var(--ink);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.entry input::placeholder { color: var(--ink-faint); opacity: .7; }

/* To'ldirilmagan sana maydonining "дд.мм.гггг" matni haqiqiy qiymatdek
   ko'rinmasligi uchun so'niq bo'ladi (forma novalidate — brauzer bloklamaydi). */
.entry input[type="date"]:invalid:not(:focus) { color: var(--ink-faint); opacity: .7; }

.entry input:focus {
  outline: none;
  border-bottom-color: var(--ink-wet);
  box-shadow: 0 1px 0 0 var(--ink-wet);
  background-color: rgba(75, 63, 168, .045);
}

/* Erkin yozuv maydoni — haqiqiy daftar chiziqlari ustida */
.entry textarea {
  display: block;
  width: 100%;
  max-width: var(--line-max);
  margin: 0;
  padding: 0 6px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  /* Chiziqlar oralig'i line-height bilan bir xil bo'lishi shart, aks holda
     yozuv chiziqdan sirg'alib ketadi. */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 35px,
    var(--rule) 35px,
    var(--rule) 36px
  );
  background-attachment: local;
  font-family: var(--body);
  font-size: 21px;
  line-height: 36px;
  color: var(--ink);
  resize: vertical;
  transition: background-color .18s ease;
}

.entry textarea:focus {
  outline: none;
  background-color: rgba(75, 63, 168, .045);
}

/* ── Tanlov ───────────────────────────────────────────────────────── */

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 40px;
  padding-top: 8px;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 20px;
  color: var(--ink);
}

.choice input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 21px;
  height: 21px;
  margin: 0;
  border: 1.5px solid var(--rule);
  border-radius: 50%;
  background: transparent;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.choice input:checked {
  border-color: var(--ink-wet);
  box-shadow: inset 0 0 0 5px var(--ink-wet);
}

.choice input:focus-visible {
  outline: 2px solid var(--ink-wet);
  outline-offset: 3px;
}

.choice:hover input:not(:checked) { border-color: var(--ink-faint); }

/* ── Xatolar ──────────────────────────────────────────────────────── */

.entry.is-error input { border-bottom-color: var(--stamp); }

/* Xato holatida ham fokus aniq ko'rinishi kerak — chiziq qalinlashadi */
.entry.is-error input:focus { box-shadow: 0 1px 0 0 var(--stamp); }

/* textarea'da pastki chegara yo'q — chiziqlar fon bo'lgani uchun soya bilan belgilanadi */
.entry.is-error textarea { box-shadow: 0 1px 0 0 var(--stamp); }

.err {
  margin: 10px 0 0;
  font-size: 15.5px;
  line-height: 1.4;
  color: var(--stamp);
}

.err:empty { display: none; }

/* ── Yuborish ─────────────────────────────────────────────────────── */

.actions { margin-top: 60px; }

#submit {
  padding: 19px 40px;
  border: 0;
  border-radius: 3px;
  background: var(--ink-wet);
  color: #fff;
  font-family: var(--util);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color .18s ease, transform .12s ease;
}

#submit:hover { background: var(--ink); }
#submit:active { transform: translateY(1px); }
#submit:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

#submit[disabled] { opacity: .55; cursor: progress; }

.form-error {
  margin: 18px 0 0;
  max-width: 50ch;
  font-size: 16px;
  color: var(--stamp);
}

.form-error:empty { display: none; }

/* ── Shtamp ───────────────────────────────────────────────────────── */

.receipt { padding: 24px 0 8px; }

.stamp {
  display: inline-block;
  padding: 20px 38px 18px;
  border: 2.5px solid var(--stamp);
  box-shadow: inset 0 0 0 1px var(--paper), inset 0 0 0 3.5px var(--stamp);
  color: var(--stamp);
  text-align: center;
  transform: rotate(-3.5deg);
  transform-origin: 30% 50%;
  mix-blend-mode: multiply;
  opacity: .92;
}

.stamp-line,
.stamp-date {
  display: block;
  font-family: var(--util);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .28em;
  text-transform: uppercase;
}

.stamp-word {
  display: block;
  margin: 3px 0 5px;
  font-family: var(--util);
  font-size: 31px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.stamp-date { opacity: .8; }

.receipt-note {
  margin: 46px 0 0;
  max-width: 48ch;
  font-size: 17.5px;
  line-height: 1.62;
  color: var(--ink-faint);
}

/* ── Harakat ──────────────────────────────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: none; }
}

@keyframes press {
  0%   { opacity: 0; transform: rotate(-3.5deg) scale(1.5); }
  60%  { opacity: 1; transform: rotate(-3.5deg) scale(.97); }
  100% { opacity: .92; transform: rotate(-3.5deg) scale(1); }
}

.masthead, .entry, .actions {
  animation: rise .42s cubic-bezier(.22, .61, .36, 1) backwards;
}

.entry:nth-child(1)  { animation-delay: .05s; }
.entry:nth-child(2)  { animation-delay: .08s; }
.entry:nth-child(3)  { animation-delay: .11s; }
.entry:nth-child(4)  { animation-delay: .14s; }
.entry:nth-child(5)  { animation-delay: .17s; }
.entry:nth-child(6)  { animation-delay: .20s; }
.entry:nth-child(7)  { animation-delay: .23s; }
.entry:nth-child(8)  { animation-delay: .26s; }
.entry:nth-child(9)  { animation-delay: .29s; }
.entry:nth-child(10) { animation-delay: .32s; }
.entry:nth-child(11) { animation-delay: .35s; }
.actions { animation-delay: .38s; }

.receipt:not([hidden]) .stamp { animation: press .34s cubic-bezier(.2, .8, .3, 1) backwards; }
.receipt:not([hidden]) .receipt-note { animation: rise .5s .22s cubic-bezier(.22, .61, .36, 1) backwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
  }
}

/* ── Kichik ekranlar ──────────────────────────────────────────────── */

/* O'rta ekranlar — noutbukda chekka juda keng bo'lib ketmasin */
@media (max-width: 1100px) {
  :root { --margin-rule: 62px; --margin-pad: 84px; --margin-gutter: 14px; }

  body { font-size: 18px; }

  .sheet { padding-top: 72px; }

  .entry input[type="text"],
  .entry input[type="date"],
  .entry input[type="tel"],
  .entry input[type="email"],
  .entry textarea { font-size: 19px; }
}

@media (max-width: 620px) {
  :root { --margin-rule: 42px; --margin-pad: 58px; --margin-gutter: 8px; }

  body { font-size: 17px; }

  .sheet { padding: 48px 20px 72px var(--margin-pad); }

  .masthead { margin-bottom: 50px; }

  .mark { width: 56px; height: 56px; }

  .entry { margin-bottom: 36px; }

  .entry::before { font-size: 11.5px; }

  .entry > label,
  .entry > .group-label { font-size: 12px; }

  /* 16px dan kichik bo'lsa iOS fokusda sahifani kattalashtirib yuboradi */
  .entry input[type="text"],
  .entry input[type="date"],
  .entry input[type="tel"],
  .entry input[type="email"],
  .entry textarea { font-size: 17px; }

  .entry textarea {
    line-height: 32px;
    background-image: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 31px,
      var(--rule) 31px,
      var(--rule) 32px
    );
  }

  .choice { font-size: 18px; }

  .choices { gap: 14px 28px; }

  /* Tugma butun enni egallaydi, shuning uchun yon padding kerak emas:
     360px ekranda u "ОТПРАВИТЬ ЗАЯВЛЕНИЕ" ni ikkinchi qatorga tushirib
     yuborardi. */
  #submit {
    width: 100%;
    padding-left: 16px;
    padding-right: 16px;
  }
}
