/* ============================================================
   Тичорат ва Рушд — NPS
   Дизайн-система и стили. Без зависимостей, без веб-шрифтов.
   ============================================================ */

/* ---------- 1. Токены ---------- */

:root {
  color-scheme: light dark;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI",
          Inter, Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --ease: cubic-bezier(.22, .8, .24, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur: 460ms;

  --shell: 720px;

  /* — светлая тема — */
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --surface-2: #F7F8FB;
  --line: #E5E8EF;
  --line-2: #D6DBE5;
  --ink: #111520;
  --ink-2: #3D4453;
  --ink-3: #79808F;

  --accent: #3352E1;
  --accent-2: #2743C6;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(51, 82, 225, .09);
  --accent-ring: rgba(51, 82, 225, .24);

  --ok: #12A150;
  --warn: #A9600B;
  --danger: #CE3A3A;
  --danger-soft: rgba(206, 58, 58, .08);
  --warn-soft: rgba(169, 96, 11, .09);

  --glow-1: rgba(51, 82, 225, .10);
  --glow-2: rgba(96, 124, 200, .12);

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .04);
  --shadow-2: 0 1px 2px rgba(16, 24, 40, .05),
              0 12px 28px -10px rgba(16, 24, 40, .10),
              0 36px 68px -28px rgba(16, 24, 40, .14);
  --shadow-accent: 0 6px 16px -6px rgba(51, 82, 225, .50);
}

/* — тёмная тема — */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C0E13;
    --surface: #14171E;
    --surface-2: #1A1E27;
    --line: #232833;
    --line-2: #2E3542;
    --ink: #EBEEF5;
    --ink-2: #AEB6C4;
    --ink-3: #7C8595;

    --accent: #6B8AFF;
    --accent-2: #89A2FF;
    --accent-ink: #0A0D14;
    --accent-soft: rgba(107, 138, 255, .14);
    --accent-ring: rgba(107, 138, 255, .30);

    --ok: #3DD68C;
    --warn: #E0A455;
    --danger: #F1746F;
    --danger-soft: rgba(241, 116, 111, .12);
    --warn-soft: rgba(224, 164, 85, .12);

    --glow-1: rgba(75, 106, 220, .16);
    --glow-2: rgba(52, 74, 150, .18);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .40);
    --shadow-2: 0 1px 2px rgba(0, 0, 0, .40),
                0 18px 44px -14px rgba(0, 0, 0, .60);
    --shadow-accent: 0 6px 18px -6px rgba(107, 138, 255, .40);
  }
}

:root[data-theme="dark"] {
  --bg: #0C0E13;
  --surface: #14171E;
  --surface-2: #1A1E27;
  --line: #232833;
  --line-2: #2E3542;
  --ink: #EBEEF5;
  --ink-2: #AEB6C4;
  --ink-3: #7C8595;

  --accent: #6B8AFF;
  --accent-2: #89A2FF;
  --accent-ink: #0A0D14;
  --accent-soft: rgba(107, 138, 255, .14);
  --accent-ring: rgba(107, 138, 255, .30);

  --ok: #3DD68C;
  --warn: #E0A455;
  --danger: #F1746F;
  --danger-soft: rgba(241, 116, 111, .12);
  --warn-soft: rgba(224, 164, 85, .12);

  --glow-1: rgba(75, 106, 220, .16);
  --glow-2: rgba(52, 74, 150, .18);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .40);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .40),
              0 18px 44px -14px rgba(0, 0, 0, .60);
  --shadow-accent: 0 6px 18px -6px rgba(107, 138, 255, .40);
}

/* ---------- 2. Сброс ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, figure { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
svg { display: block; }

::selection { background: var(--accent-soft); color: var(--ink); }

:where(a, button, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ---------- 3. Фон ---------- */

.ambient {
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(48rem 34rem at 18% 0%, var(--glow-1), transparent 62%),
    radial-gradient(44rem 34rem at 88% 100%, var(--glow-2), transparent 62%);
  animation: drift 44s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(2%, -1.5%, 0) scale(1.06); }
}

/* ---------- 4. Шапка ---------- */

.topbar {
  width: min(100% - 40px, var(--shell));
  margin: 0 auto;
  padding: 26px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: fadeDown 700ms var(--ease-out) both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow-1);
  flex: none;
}

.brand__mark svg { width: 20px; height: 18px; }

.brand__name {
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: -.012em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: color 200ms var(--ease), border-color 200ms var(--ease),
              transform 200ms var(--ease), box-shadow 200ms var(--ease);
}

.icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-1);
}

.icon-btn:active { transform: translateY(0) scale(.96); }

.icon-btn svg {
  position: absolute;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 240ms var(--ease), transform 340ms var(--ease);
}

.icon-btn { position: relative; }
.icon-btn__moon { opacity: 0; transform: rotate(-60deg) scale(.6); }
.icon-btn__sun  { opacity: 1; transform: rotate(0) scale(1); }

:root[data-theme="dark"] .icon-btn__moon,
:root[data-theme="light"] .icon-btn__sun { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="dark"] .icon-btn__sun,
:root[data-theme="light"] .icon-btn__moon { opacity: 0; transform: rotate(60deg) scale(.6); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn__moon { opacity: 1; transform: rotate(0) scale(1); }
  :root:not([data-theme="light"]) .icon-btn__sun  { opacity: 0; transform: rotate(60deg) scale(.6); }
}

/* ---------- 5. Каркас ---------- */

.main {
  flex: 1;
  width: min(100% - 40px, var(--shell));
  margin: 0 auto;
  padding: clamp(28px, 6vh, 64px) 0 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: cardIn 780ms var(--ease-out) both 90ms;
}

@keyframes cardIn {
  from { opacity: 0; transform: translate3d(0, 18px, 0) scale(.985); }
  to   { opacity: 1; transform: none; }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translate3d(0, -10px, 0); }
  to   { opacity: 1; transform: none; }
}

.progress {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--line);
  opacity: 0;
  transition: opacity 400ms var(--ease);
  z-index: 2;
}

.progress.is-visible { opacity: 1; }

.progress__fill {
  height: 100%;
  width: 0;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 560ms var(--ease);
}

.stage {
  position: relative;
  padding: clamp(30px, 5.2vw, 52px);
  transition: height 480ms var(--ease);
}

.legal {
  margin: 0;
  text-align: center;
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--ink-3);
  animation: fadeDown 700ms var(--ease-out) both 240ms;
}

/* ---------- 6. Панели и переходы ---------- */

.panel { animation: panelIn var(--dur) var(--ease-out) both; }

.panel--center { text-align: center; display: grid; justify-items: center; }

.panel.is-leaving {
  position: absolute;
  inset: clamp(30px, 5.2vw, 52px) clamp(30px, 5.2vw, 52px) auto;
  pointer-events: none;
  animation: panelOut 300ms var(--ease) forwards;
}

@keyframes panelIn {
  from { opacity: 0; transform: translate3d(var(--dx, 26px), 0, 0); }
  to   { opacity: 1; transform: none; }
}

@keyframes panelOut {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translate3d(calc(var(--dx, 26px) * -.85), 0, 0); }
}

/* ---------- 7. Типографика ---------- */

.eyebrow {
  display: inline-block;
  margin-bottom: 18px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .6875rem;
  font-weight: 650;
  letter-spacing: .10em;
  text-transform: uppercase;
}

.title {
  font-size: clamp(1.75rem, 4.6vw, 2.375rem);
  font-weight: 650;
  letter-spacing: -.028em;
  line-height: 1.12;
  text-wrap: balance;
}

.title--sm { font-size: clamp(1.5rem, 3.8vw, 1.875rem); }

.lede {
  margin-top: 16px;
  max-width: 47ch;
  font-size: 1.0625rem;
  line-height: 1.62;
  color: var(--ink-2);
  text-wrap: pretty;
}

.lede--sm { font-size: .9688rem; margin-top: 10px; max-width: 60ch; }

.qhead {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.qhead__index {
  font-size: .8125rem;
  font-weight: 650;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.qhead__category {
  position: relative;
  padding-left: 11px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--ink-3);
  letter-spacing: -.005em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qhead__category::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 50%;
  background: var(--line-2);
}

.question {
  font-size: clamp(1.375rem, 3.5vw, 1.75rem);
  font-weight: 600;
  letter-spacing: -.022em;
  line-height: 1.3;
  text-wrap: pretty;
}

.question--sm { font-size: clamp(1.25rem, 3vw, 1.5rem); }

.meta-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 22px;
  font-size: .8125rem;
  color: var(--ink-3);
}

.meta-line__icon {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.hint {
  margin-top: 20px;
  font-size: .75rem;
  color: var(--ink-3);
}

.hint kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface-2);
  font-family: inherit;
  font-size: .6875rem;
  font-weight: 600;
  text-align: center;
  color: var(--ink-2);
}

/* Подсказка про клавиатуру бессмысленна там, где её нет. */
@media (hover: none), (max-width: 620px) { .hint { display: none; } }

/* ---------- 8. Шкала 1–10 ---------- */

.scale {
  margin-top: 30px;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}

.scale__btn {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  cursor: pointer;
  animation: chipIn 480ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 26ms);
  transition: color 180ms var(--ease), background-color 180ms var(--ease),
              border-color 180ms var(--ease), box-shadow 180ms var(--ease),
              transform 180ms var(--ease);
}

@keyframes chipIn {
  from { opacity: 0; transform: translate3d(0, 10px, 0) scale(.94); }
  to   { opacity: 1; transform: none; }
}

@media (hover: hover) {
  .scale__btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateY(-3px);
  }
}

.scale__btn:active { transform: translateY(-1px) scale(.96); }

.scale__btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-accent);
  transform: translateY(-3px);
}

.scale__btn.is-pop { animation: chipPop 340ms var(--ease-out); }

@keyframes chipPop {
  0%   { transform: translateY(-3px) scale(1); }
  38%  { transform: translateY(-3px) scale(1.14); }
  100% { transform: translateY(-3px) scale(1); }
}

.scale-legend {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: .75rem;
  color: var(--ink-3);
}

.scale-legend span:last-child { text-align: right; }

@media (max-width: 620px) {
  .scale { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }
  .scale__btn { aspect-ratio: 5 / 4; font-size: 1.0625rem; }
}

/* ---------- 9. Кнопки ---------- */

.actions {
  margin-top: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.actions--center { justify-content: center; margin-top: 30px; }
.actions .btn--primary:last-child { margin-left: auto; }
.actions--center .btn--primary:last-child { margin-left: 0; }

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: .9375rem;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 200ms var(--ease), color 200ms var(--ease),
              border-color 200ms var(--ease), box-shadow 200ms var(--ease),
              transform 200ms var(--ease), opacity 200ms var(--ease);
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-accent);
}

.btn--primary:hover:not(:disabled) { background: var(--accent-2); transform: translateY(-2px); }
.btn--primary:active:not(:disabled) { transform: translateY(0) scale(.98); }

.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line-2);
}

.btn--ghost:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn--ghost:active:not(:disabled) { transform: scale(.98); }

.btn:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; }

.btn__arrow {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 240ms var(--ease);
}

.btn:hover:not(:disabled) .btn__arrow { transform: translateX(3px); }
.btn:hover:not(:disabled) .btn__arrow--back { transform: translateX(-3px); }

.spinner {
  display: none;
  width: 15px; height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: .85;
  animation: spin 620ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn.is-busy { pointer-events: none; opacity: .78; }
.btn.is-busy .spinner { display: block; }

/* ---------- 10. Поля ввода ---------- */

.field { margin-top: 22px; position: relative; }

.field__label {
  display: block;
  margin-bottom: 8px;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: -.005em;
}

.field__input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: .9688rem;
  line-height: 1.55;
  transition: border-color 200ms var(--ease), background-color 200ms var(--ease),
              box-shadow 200ms var(--ease);
}

.field__input::placeholder { color: var(--ink-3); opacity: .85; }

.field__input:hover { border-color: var(--line-2); background: var(--surface); }

.field__input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.field__input--area { resize: vertical; min-height: 104px; }

.field__counter {
  position: absolute;
  right: 4px;
  bottom: -19px;
  font-size: .6875rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ---------- 11. Уведомления ---------- */

.notice {
  margin-top: 22px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: .8438rem;
  line-height: 1.55;
  text-align: left;
  animation: panelIn 340ms var(--ease-out) both;
  --dx: 0px;
}

.notice--demo    { background: var(--warn-soft);   color: var(--warn);   }
.notice--pending { background: var(--warn-soft);   color: var(--warn);   max-width: 46ch; }
.notice--error   { background: var(--danger-soft); color: var(--danger); }

/* ---------- 12. Галочка «готово» ---------- */

.checkmark { display: block; width: 66px; height: 66px; margin-bottom: 26px; }

.checkmark svg {
  width: 100%; height: 100%;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.checkmark__circle {
  stroke: var(--ok);
  stroke-width: 2;
  opacity: .34;
  stroke-dasharray: 145;
  stroke-dashoffset: 145;
  animation: draw 800ms var(--ease-out) forwards 120ms;
}

.checkmark__tick {
  stroke: var(--ok);
  stroke-width: 3.2;
  stroke-dasharray: 34;
  stroke-dashoffset: 34;
  animation: draw 520ms var(--ease-out) forwards 520ms;
}

@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- 13. Мелочи ---------- */

@media (max-width: 480px) {
  .topbar { width: min(100% - 32px, var(--shell)); padding-top: 20px; }
  .main { width: min(100% - 32px, var(--shell)); padding-top: 22px; }
  .card { border-radius: var(--r-lg); }
  .brand__name { font-size: .875rem; }
  .actions { gap: 8px; }
  .btn { padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
  .ambient { animation: none; }
}
