/* ADMO OLYMPIADS — общая основа: палитра, шрифт из брендбука, стекло, элементы управления.
   Проход по вёрстке сделан по чек-листу unslop (Damir Sokolovsky, @heydamir, CC BY 4.0):
   сетка 4px, один акцент, три роли текста, без свечений и градиентов между оттенками. */

:root {
  /* Палитра: красный кирпич, белый глянец, матовый чёрный, нейтральный серый */
  --brick: #962715;
  --paper: #ffffff;
  --black: #1e1e20;
  --grey: #bbc3c6;
  --white: #ffffff;
  --canvas: #eef0f1; /* фон рабочих страниц: нейтральный серый, разбавленный белым */

  /* Роли цвета: кирпич — главное действие, чёрный — выбранное и фокус */
  --accent: var(--brick);
  --accent-ink: #7f2111; /* кирпич для мелкого текста на светлом */
  --accent-soft: rgb(150 39 21 / 8%);
  --select: var(--black);

  /* Текст: матовый чёрный и два нейтральных серых, три роли */
  --ink: #1e1e20;
  --ink-2: #4b5054;
  --ink-3: #62686c;
  --line: rgb(30 30 32 / 10%);
  --line-strong: rgb(30 30 32 / 18%);

  --positive: #17794b;
  --positive-soft: #dff3e7;
  --negative: #b3261e;
  --negative-soft: #fbe4e1;
  --warning-soft: #f6e7e4; /* бледный кирпич: пометки «тестовый режим», «проверьте» */

  --font: 'Nunito Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-control: 12px;
  --r-card: 16px;
  --r-panel: 28px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 160ms;
  --t-menu: 200ms;
  --t-enter: 420ms;

  /* Стекло */
  --glass-tint: rgb(255 255 255 / 56%);
  --glass-blur: 22px;
  --glass-shadow: 0 1px 2px rgb(30 30 32 / 5%), 0 16px 40px rgb(30 30 32 / 10%);
}

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

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

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ── Жидкое стекло ───────────────────────────────────────────────────────────
   Слой управления лежит поверх плоских цветных блоков бренда.
   База — матовое стекло (работает везде). В Chromium glass.js добавляет
   преломление по кромке: фон изгибается у края, как под толстым стеклом. */

.glass {
  position: relative;
  isolation: isolate;
  border-radius: var(--r-panel);
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.5);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.5);
  box-shadow: var(--glass-shadow);
}

/* Кромка: свет падает сверху слева, поэтому блик там ярче */
.glass::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: 1px;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    rgb(255 255 255 / 95%),
    rgb(255 255 255 / 30%) 30%,
    rgb(255 255 255 / 12%) 62%,
    rgb(255 255 255 / 60%)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
  pointer-events: none;
}

/* Внутренний объём: мягкий свет у верхней кромки и тень у нижней */
.glass::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  box-shadow:
    inset 0 1.5px 1px rgb(255 255 255 / 70%),
    inset 0 -1px 1px rgb(30 30 32 / 6%),
    inset 0 12px 24px -16px rgb(255 255 255 / 80%);
  pointer-events: none;
}

.glass > * {
  position: relative;
  z-index: 2;
}

/* Там, где нет backdrop-filter, стекло становится плотной светлой панелью */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: rgb(255 255 255 / 92%);
  }
}

.glass--dark {
  --glass-tint: rgb(30 30 32 / 62%);
  color: var(--paper);
}
.glass--dark::before {
  background: linear-gradient(
    135deg,
    rgb(255 255 255 / 42%),
    rgb(255 255 255 / 10%) 30%,
    rgb(255 255 255 / 4%) 62%,
    rgb(255 255 255 / 24%)
  );
}
.glass--dark::after {
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 14%);
}

/* ── Поля ────────────────────────────────────────────────────────────────── */

.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* иначе поле ввода распирает колонку своей «родной» шириной */
  gap: 8px;
  min-width: 0;
}

.field__label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

.field__label > :first-child {
  white-space: nowrap;
}
.field__hint {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-3);
}

.field__error {
  min-height: 0;
  font-size: 13px;
  line-height: 16px;
  color: var(--negative);
}
.field__error:empty {
  display: none;
}

.input {
  display: flex;
  align-items: center;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: rgb(255 255 255 / 66%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
  transition:
    border-color var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease);
}
.input:hover {
  border-color: var(--line-strong);
}
.input:focus-within {
  border-color: var(--ink);
  background: rgb(255 255 255 / 92%);
  outline: 2px solid rgb(30 30 32 / 18%);
  outline-offset: 0;
}
.input input,
.input select,
.input textarea {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
}
.input input::placeholder,
.input textarea::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
.input__prefix {
  margin-right: 8px;
  color: var(--ink-2);
}
.input__icon {
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: 8px;
  color: var(--ink-3);
}
.input--locked {
  background: rgb(255 255 255 / 36%);
}
.input--locked input {
  cursor: default;
  text-overflow: ellipsis;
}

.field[data-invalid] .input {
  border-color: var(--negative);
}
.field[data-invalid] .input:focus-within {
  outline-color: rgb(194 51 44 / 24%);
}

/* ── Выбор одной плитки (класс, предмет, способ оплаты) ───────────────────── */

.choice {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: rgb(255 255 255 / 66%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition:
    border-color var(--t-fast) var(--ease),
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.choice input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.choice:hover {
  border-color: var(--line-strong);
  background: rgb(255 255 255 / 88%);
}
.choice:active {
  transform: scale(0.97);
}
.choice:has(input:checked) {
  border-color: var(--select);
  background: var(--select);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 16%);
  color: var(--paper);
}
.choice:has(input:focus-visible) {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ── Выпадающий список (dropdown.js) ─────────────────────────────────────────
   Поле выглядит как обычный .input; список — светлая карточка под полем.
   Выбранный вариант — чёрная плашка с галочкой, как выбранные класс и предмет. */

.dropdown {
  position: relative;
  padding: 0;
  cursor: pointer;
}
.dropdown__native {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  pointer-events: none;
}
.dropdown__trigger {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 44px 0 16px;
  overflow: hidden;
  border: 0;
  border-radius: inherit;
  outline: 0;
  background: none;
  color: var(--ink);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.dropdown__trigger.is-placeholder {
  color: var(--ink-3);
}
.dropdown__trigger:disabled {
  cursor: default;
}
.dropdown > .input__icon {
  position: absolute;
  top: 50%;
  right: 16px;
  margin: -9px 0 0;
  pointer-events: none;
  transition: transform var(--t-menu) var(--ease);
}
.dropdown.is-open > .input__icon {
  transform: rotate(180deg);
}

.dropdown__list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 30;
  max-height: min(328px, 50vh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow:
    0 1px 2px rgb(30 30 32 / 8%),
    0 18px 44px rgb(30 30 32 / 22%);
  list-style: none;
  cursor: default;
  transform-origin: top center;
  animation: dropdown-in var(--t-menu) var(--ease);
}
.dropdown.is-up .dropdown__list {
  top: auto;
  bottom: calc(100% + 6px);
  transform-origin: bottom center;
  animation-name: dropdown-in-up;
}
@keyframes dropdown-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}
@keyframes dropdown-in-up {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

.dropdown__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px 0 14px;
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  transition:
    background-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease);
}
.dropdown__option + .dropdown__option {
  margin-top: 2px;
}
.dropdown__option.is-active {
  background: rgb(30 30 32 / 6%);
}
.dropdown__option[aria-selected='true'] {
  background: var(--select);
  color: var(--paper);
  font-weight: 600;
}
.dropdown__check {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}
.dropdown__option[aria-selected='true'] .dropdown__check {
  opacity: 1;
}

/* ── Кнопки ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: rgb(255 255 255 / 72%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
  font-weight: 600;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.btn:hover {
  border-color: var(--line-strong);
  background: var(--white);
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.btn svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.btn--primary {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 18%);
  color: var(--paper);
}
.btn--primary:hover {
  border-color: var(--accent-ink);
  background: var(--accent-ink);
}

.btn--quiet {
  border-color: transparent;
  background: none;
  box-shadow: none;
  color: var(--ink-2);
}
.btn--quiet:hover {
  border-color: transparent;
  background: rgb(30 30 32 / 6%);
  color: var(--ink);
}

.btn--danger {
  color: var(--negative);
}
.btn--danger:hover {
  border-color: rgb(194 51 44 / 40%);
  background: var(--negative-soft);
}

.btn--sm {
  height: 32px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 14px;
}
.btn--icon {
  width: 40px;
  padding: 0;
}
.btn--icon.btn--sm {
  width: 32px;
}

/* ── Иконки: один набор, штрих 1.5 ───────────────────────────────────────── */

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Метка раздела в манере брендбука: «01 / РАЗДЕЛ» */
.eyebrow {
  font-size: 12px;
  font-weight: 800;
  line-height: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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