/* Квиз-студия IJA. Дополнения к дизайн-системе прототипа для рабочей версии. */

/* ---------- Логотип Академии ---------- */
/* Белая картинка с прозрачностью служит маской: логотип берёт цвет текста
   и одинаково виден на тёмных и светлых экранах. Без .full видна только монограмма. */
.brand-logo {
  --h: 24px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
  height: var(--h);
  width: calc(var(--h) * 776 / 390);
  background-color: currentColor;
  -webkit-mask: url('/assets/logo-ija.webp') left center / auto 100% no-repeat;
  mask: url('/assets/logo-ija.webp') left center / auto 100% no-repeat;
}

.brand-logo.full {
  --h: 40px;
  width: calc(var(--h) * 2000 / 390);
}

@media (max-width: 640px) {
  .brand-logo.full {
    --h: 32px;
  }
}

/* В шапке эфира, плитке продукта и превью логотип стоит вместо текста и растёт вместе с ним */
.brand-mark .brand-logo,
.mini-logo .brand-logo,
.pv-top .brand-logo,
.product-logo .brand-logo {
  --h: 1.1em;
}

/* Белый на тёмных экранах и чёрный в студии получаются из цвета текста.
   На светлых экранах эфира и в их превью логотип синий, как акцент Академии. */
.theme-light .brand-mark .brand-logo,
.pv-screen.light .brand-logo,
.mini.light .brand-logo {
  color: #006ee6;
}

/* На узком экране входа логотип не должен прилипать к заголовку */
.auth-art {
  gap: 32px;
}

@media (forced-colors: active) {
  .brand-logo {
    forced-color-adjust: none;
    background-color: CanvasText;
  }
}

/* ---------- Ввод кода из письма ---------- */
.code-input {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.code-input input {
  width: 100%;
  height: 58px;
  padding: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  border-radius: 14px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--text);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.live .code-input input {
  background: var(--fill);
}

.code-input input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--focus);
}

.code-input input:nth-child(3) {
  margin-right: 8px;
}

.form-error {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--r-s);
  background: var(--danger-tint);
  color: var(--danger-text);
  font-size: var(--fs-subhead);
  font-weight: 500;
}

.form-error .icon {
  margin-top: 2px;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-s);
  background: var(--action-tint);
  color: var(--on-action-tint);
  font-size: var(--fs-footnote);
  font-weight: 500;
  line-height: 1.45;
}

.notice.warn {
  background: var(--warning-tint);
  color: var(--warning-text);
}

.notice .icon {
  margin-top: 1px;
}

.toast.error .icon {
  color: #ff8f8f;
}

.link-btn {
  padding: 0;
  min-height: 0;
  font-weight: 600;
  color: var(--action);
}

.link-btn:disabled {
  color: var(--text-3);
  cursor: default;
}

/* ---------- Загрузка ---------- */
.skeleton {
  border-radius: var(--r-l);
  background: linear-gradient(90deg, var(--fill) 0%, var(--fill-2) 50%, var(--fill) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  min-height: 220px;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.page-loading {
  display: grid;
  place-items: center;
  min-height: 50vh;
  color: var(--text-2);
}

.spinner-lg {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--fill-2);
  border-top-color: var(--action);
  animation: spin 700ms linear infinite;
}

/* ---------- Карточка квиза: статус эфира ---------- */
.live-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 7px;
  background: var(--danger-tint);
  color: var(--danger-text);
  font-size: var(--fs-caption);
  font-weight: 700;
}

.live-chip .live-dot {
  width: 7px;
  height: 7px;
  background: var(--danger);
}

.self-chip {
  background: var(--success-tint);
  color: var(--success-text);
}

.self-chip .live-dot {
  background: var(--success);
}

/* ---------- Код для встраивания ---------- */
.code-box {
  position: relative;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 14px 16px;
  border-radius: var(--r-s);
  background: var(--ink);
  color: #d6e7ff;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 180px;
  overflow: auto;
}

.copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-row .input {
  font-size: var(--fs-subhead);
  min-width: 0;
}

/* ---------- Выбор продукта при запуске ---------- */
.pick-list .row {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.pick-list .row[aria-pressed='true'] {
  background: var(--action-tint);
}

.pick-list .row[aria-pressed='true']::after {
  content: '';
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  background: var(--action) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4L18 8'/%3E%3C/svg%3E") center / 12px no-repeat;
}

/* ---------- Редактор: пустые состояния и подсказки ---------- */
.q-item {
  grid-template-columns: 18px 22px minmax(0, 1fr) auto;
}

.q-item .q-warn {
  color: var(--warning-text);
  margin-left: auto;
  align-self: center;
}

.ed-empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--text-2);
}

.ed-empty .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
  color: var(--text-3);
}

.problems {
  display: grid;
  gap: 4px;
}

.tag-input {
  border: 0;
  background: transparent;
  min-width: 90px;
  width: 110px;
  font-size: var(--fs-caption);
  font-weight: 600;
  padding: 0 6px;
  height: 24px;
  border-radius: 7px;
  outline: 1px dashed var(--hairline-strong);
}

.tag-input:focus {
  outline: 2px solid var(--brand);
}

.tag button {
  display: inline-grid;
  place-items: center;
  margin-right: -4px;
  color: inherit;
  opacity: 0.6;
}

/* ---------- Итоговая диаграмма квиза ---------- */
.sum {
  display: grid;
  gap: 14px;
}

.sum-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.sum-big {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(48px, 9vw, 72px);
  line-height: 0.9;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--text) 20%, #8cc4ff 60%, #b9a6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.theme-light .sum-big,
body:not(.live) .sum-big {
  background: linear-gradient(120deg, var(--ink) 20%, var(--action) 65%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
}

.sum-card {
  padding: 16px 16px 14px;
  border-radius: var(--r-m);
  background: var(--surface);
  border: 1px solid var(--hairline);
  display: grid;
  gap: 10px;
  animation: row-in-sum 480ms var(--ease-out) both;
}

@keyframes row-in-sum {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.sum-q {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.sum-q b {
  flex: 1;
  font-weight: 650;
  line-height: 1.3;
}

.sum-num {
  flex: none;
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--fill-2);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.sum-pct {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px;
  background: var(--fill-2);
}

.sum-pct.good {
  background: var(--success-tint);
  color: var(--success-text);
}

.sum-pct.bad {
  background: var(--danger-tint);
  color: var(--danger-text);
}

.sum-bars {
  display: grid;
  gap: 6px;
}

.sum-bar {
  --p: 0;
  --c: var(--opt-1);
  position: relative;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px 7px 7px;
  border-radius: 10px;
  overflow: hidden;
  isolation: isolate;
  background: var(--fill);
  font-size: 14px;
}

.sum-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--c) 32%, transparent);
  transform-origin: left center;
  transform: scaleX(var(--p));
  transition: transform 900ms var(--ease-out);
}

body:not(.live) .sum-bar::before,
.theme-light .sum-bar::before {
  background: color-mix(in srgb, var(--c) 22%, transparent);
}

.sum-bar .letter {
  width: 24px;
  height: 24px;
  font-size: 12px;
  border-radius: 7px;
}

.sum-bar span {
  min-width: 0;
  font-weight: 550;
  line-height: 1.25;
}

.sum-bar .sum-v {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.sum-bar .sum-v small {
  font-weight: 600;
  color: var(--text-2);
  margin-left: 4px;
}

.sum-bar.correct {
  box-shadow: inset 0 0 0 2px var(--success);
}

.sum-flag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
  white-space: nowrap;
}

.sum-flag.ok {
  background: var(--success);
  color: #001a0c;
}

.theme-light .sum-flag.ok,
body:not(.live) .sum-flag.ok {
  color: #fff;
}

.sum-flag.mine {
  background: var(--fill-2);
  color: var(--text);
}

.sum-flag .icon {
  width: 11px;
  height: 11px;
  stroke-width: 3;
}

.sum-cloud {
  font-size: 14px;
  padding: 6px 0;
  min-height: 60px;
}

.sum-ref {
  font-size: 13px;
  color: var(--text-2);
}

/* Компактные полосы «% верных по вопросам» на экране для показа */
.qbars {
  display: grid;
  gap: 0.9cqw;
  align-content: center;
}

.qbar {
  --p: 0;
  display: grid;
  grid-template-columns: 2.2em 1fr 3.4em;
  gap: 1em;
  align-items: center;
  font-size: 1.45cqw;
}

.qbar-n {
  font-weight: 700;
  color: var(--text-2);
}

.qbar-body {
  display: grid;
  gap: 0.35em;
  min-width: 0;
}

.qbar-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.qbar-track {
  height: 0.55em;
  border-radius: 999px;
  background: var(--fill-2);
  overflow: hidden;
}

.qbar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--violet));
  transform-origin: left;
  transform: scaleX(var(--p));
  transition: transform 1100ms var(--ease-out);
}

.qbar-v {
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-aspect-ratio: 1/1) {
  .qbar {
    font-size: 14px;
  }
}

/* Живая диаграмма у участника после ответа */
.p-live {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  margin-top: 6px;
}

.p-live-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.p-live .cloud {
  font-size: 15px;
  min-height: 80px;
}

/* Панель управления экраном для показа */
.screen-bar .proto-label {
  min-width: 0;
}

/* ---------- Админка ---------- */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  margin-right: 6px;
}

.status-dot.on {
  background: var(--success);
}

/* ---------- Встраивание: страница внутри iframe ---------- */
.embedded .p-top .brand-link {
  pointer-events: none;
}

.embedded .p-wrap {
  min-height: auto;
}

/* ---------- Главная: эфирная субстанция с бриллиантиками в hero ---------- */
.aether {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1600ms ease;
}

.aether.on {
  opacity: 1;
}

.aether canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.map-hero .map-hero-in {
  z-index: 1;
}

/* ---------- Подсказка для страниц-ошибок ---------- */
.center-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

/* ---------- Библиотека ---------- */
.lib-row { align-items: flex-start; padding-top: 14px; padding-bottom: 14px; }
.lib-row input[type='checkbox'] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--action); flex: none; cursor: pointer; }
.lib-text { font-weight: 600; line-height: 1.35; text-align: left; color: var(--text); }
.lib-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.lib-type { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-footnote); color: var(--text-2); margin-right: 4px; }
.lib-used { font-size: var(--fs-footnote); color: var(--text-2); white-space: nowrap; }
.selbar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 20px; border-radius: 999px; background: rgba(0, 10, 23, 0.9); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); color: #fff; font-weight: 600; box-shadow: var(--shadow-float); transition: transform 320ms var(--ease-drawer), opacity 200ms ease; }
.selbar.off { transform: translate(-50%, 140%); opacity: 0; pointer-events: none; }
@media (min-width: 1024px) { .selbar { margin-left: calc(var(--sidebar-w) / 2); } }
@media (max-width: 1023px) { .selbar { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }
@media (max-width: 640px) { .lib-row .btn-add { display: none; } }
.select-pill { width: auto; min-height: 36px; padding: 6px 34px 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; }

/* Шрифт вопросов берётся из стиля продукта */
.q-text,
.p-q-text {
  font-family: var(--q-font, inherit);
}

/* Цвет буквы варианта берётся у кнопки, а не у самой буквы */
.p-opt .letter {
  --c: inherit;
}

/* Недоступная кнопка должна выглядеть недоступной */
.btn:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* ---------- Фото в вопросах: общие куски для студии и экранов эфира ---------- */
.photo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.photo-thumb {
  display: inline-block;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  background: var(--fill);
}

.q-photos {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.q-photos.n2 {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.q-photo {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: var(--fill);
}

.photo-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  pointer-events: none;
}

.photo-zoom .icon {
  width: 16px;
  height: 16px;
}

/* Строка диаграммы с маленьким фото варианта */
.sum-bar.has-thumb {
  grid-template-columns: 24px 32px 1fr auto;
}

.sum-bar .photo-thumb {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.answer-card .photo-thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}
