/* ===========================================================
   СВОД — S5 «Живая демонстрация».
   Главный блок сайта: симуляция разбора документа.
   =========================================================== */

.scene { overflow: hidden; }

/* Правило .section--dark .mono-label специфичнее одиночных классов,
   поэтому цветные лейблы внутри тёмной секции переопределяем явно. */
.section--dark .section-label--lime { color: var(--lime-500); }
.section--dark .cmp__result-label { color: var(--coral-500); }
.section--dark .field--low .field__label { color: var(--coral-500); }

/* Мягкий свет сверху — единственный градиент на тёмном */
.scene::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(900px 620px at 50% 120px, rgba(201, 242, 77, .08), transparent 70%);
  pointer-events: none;
}
.scene > .container { position: relative; z-index: 1; }

/* ---------- Заголовок ---------- */
.scene__head { text-align: center; margin-bottom: 64px; }
.scene__head .h2 { max-width: 880px; margin-inline: auto; }
.scene__head .lead { max-width: 680px; margin: 24px auto 0; }

/* ---------- Панель ---------- */
.scene__panel {
  display: grid;
  grid-template-columns: 300px 1fr 400px;
  column-gap: 32px;
  background: var(--deep-surface);
  border: 1px solid var(--deep-line);
  border-radius: var(--r-xl);
  padding: 32px;
  min-height: 640px;
}
.scene__zone { min-width: 0; }
.scene__zone + .scene__zone {
  border-left: 1px solid var(--deep-line);
  padding-left: 32px;
  margin-left: -1px;
}
.scene__zone-label { margin-bottom: 24px; }

/* ---------- Зона A: источник ---------- */
.scene__sources { display: flex; flex-direction: column; gap: 8px; }
.scene__source {
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding-inline: 16px;
  background: transparent;
  border: 0;
  border-left: 2px solid rgba(255, 255, 255, .12);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--deep-muted);
  font-size: 15px; font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: color var(--t-instant) var(--e-out),
              border-color var(--t-instant) var(--e-out),
              background-color var(--t-instant) var(--e-out);
}
.scene__source svg { width: 18px; height: 18px; flex: none; opacity: .7; }
.scene__source:hover { color: var(--deep-text); border-left-color: rgba(255,255,255,.3); }
.scene__source[aria-selected="true"] {
  background: rgba(255, 255, 255, .08);
  border-left-color: var(--lime-500);
  color: var(--deep-text);
  font-weight: 600;
}
.scene__source[aria-selected="true"] svg { opacity: 1; }
.scene__source:focus-visible { outline: 2px solid var(--lime-500); outline-offset: 2px; }

/* Миниатюра документа */
.scene__doc {
  position: relative;
  margin-top: 32px;
  height: 340px;
  border-radius: var(--r-md);
  background: #F7F7F4;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--t-slow) var(--e-out), transform var(--t-slow) var(--e-out);
}
.scene__doc.is-in { opacity: 1; transform: none; }
.scene__doc--tilt { transform: rotate(-1.2deg) translateY(12px); }
.scene__doc--tilt.is-in { transform: rotate(-1.2deg); }

.scene__doc-page { padding: 18px; display: flex; flex-direction: column; gap: 7px; }
.scene__doc-page i { display: block; height: 4px; border-radius: 2px; background: #C9CCC2; }
.scene__doc-page i.w40 { width: 40% } .scene__doc-page i.w55 { width: 55% }
.scene__doc-page i.w70 { width: 70% } .scene__doc-page i.w85 { width: 85% }
.scene__doc-page i.w100 { width: 100% }
.scene__doc-page i.tall { height: 9px; background: #A8ADA1; margin-bottom: 4px; }
.scene__doc-page .rule { height: 1px; background: #DCDED6; margin-block: 5px; }

/* Замятость фото и шум скана */
.scene__doc--photo::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(112deg, rgba(0,0,0,.14) 0%, transparent 22%, transparent 74%, rgba(0,0,0,.10) 100%);
}
.scene__doc--scan::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.03) 0 1px, transparent 1px 3px);
}

/* Сканирующая линия */
.scene__scanline {
  position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: var(--lime-500);
  box-shadow: 0 0 18px 2px rgba(201, 242, 77, .55);
  opacity: 0;
  z-index: 2;
}
.scene__scanline.is-running { animation: scanpass 900ms var(--e-inout) forwards; }
@keyframes scanpass {
  0%   { opacity: 0; transform: translateY(0); }
  10%  { opacity: .8; }
  90%  { opacity: .8; }
  100% { opacity: 0; transform: translateY(340px); }
}

/* ---------- Зона B: разбор ---------- */
.fields { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
/* Фиксированная высота: скелетон лежит поверх значения, а не в потоке,
   иначе при заполнении полей список дёргается вверх на каждом такте. */
.field { position: relative; min-height: 48px; }
.field__row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.field__label { color: var(--deep-muted); flex: none; }
.field__value {
  font-family: var(--font-mono); font-size: 14px; line-height: 20px;
  color: var(--deep-text);
  text-align: right;
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--t-base) var(--e-out), transform var(--t-base) var(--e-out);
}
.field.is-filled .field__value { opacity: 1; transform: none; }

.field__skeleton {
  position: absolute;
  right: 0; top: 6px;
  height: 8px; width: 46%; border-radius: 4px;
  background: rgba(255, 255, 255, .07);
  transition: opacity var(--t-fast) var(--e-out);
}
.field.is-filled .field__skeleton { opacity: 0; }

/* Измеритель уверенности: короткая шкала + число.
   На всю ширину поля он читался бы как декоративное подчёркивание. */
.field__meter {
  margin-top: 7px;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  opacity: 0;
  transition: opacity var(--t-fast) var(--e-out);
}
.field.is-filled .field__meter { opacity: 1; }

.field__bar {
  width: 56px; height: 3px; border-radius: 2px;
  background: rgba(255, 255, 255, .10);
  overflow: hidden;
}
.field__fill {
  display: block; height: 100%; width: 0;
  background: var(--lime-500);
  border-radius: 2px;
  transition: width var(--t-base) var(--e-out);
}
.field__conf {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--deep-muted);
  min-width: 26px; text-align: right;
}
.field--low .field__fill { background: var(--coral-500); }
.field--low .field__conf { color: var(--coral-500); }
.field--low .field__label { color: var(--coral-500); }

/* ---------- Зона C: сверка ---------- */
.cmp { display: flex; flex-direction: column; }
.cmp__head, .cmp__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 66px 66px;
  gap: 8px;
  align-items: center;
  padding: 0 10px;
}
.cmp__head {
  height: 32px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--deep-muted);
  border-bottom: 1px solid var(--deep-line);
}
.cmp__head span:not(:first-child),
.cmp__row  span:not(:first-child) { text-align: right; }

.cmp__row {
  height: 48px;
  border-bottom: 1px solid var(--deep-line);
  font-size: 13px;
  color: var(--deep-text);
  border-radius: var(--r-sm);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--t-base) var(--e-out), transform var(--t-base) var(--e-out),
              background-color var(--t-base) var(--e-out), box-shadow var(--t-fast) var(--e-out);
}
.cmp__row.is-in { opacity: 1; transform: none; }
.cmp__row.is-checked { box-shadow: inset 0 0 0 1px rgba(201, 242, 77, .6); }
.cmp__row.is-diff { background: rgba(255, 90, 60, .12); box-shadow: none; }
.cmp__name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp__num { font-family: var(--font-mono); font-size: 13px; }
.cmp__row.is-diff .cmp__num--fact { color: var(--coral-500); font-weight: 500; }

/* Итоговая карточка расхождения */
.cmp__result {
  margin-top: 24px;
  padding: 16px;
  border-radius: var(--r-md);
  background: rgba(255, 90, 60, .10);
  border: 1px solid rgba(255, 90, 60, .30);
  opacity: 0;
  transform: scale(.97);
  transition: opacity var(--t-base) var(--e-out), transform var(--t-base) var(--e-out);
}
.cmp__result.is-in { opacity: 1; transform: none; }
.cmp__result-label { color: var(--coral-500); margin-bottom: 8px; }
.cmp__result-text { font-size: 14px; line-height: 21px; color: var(--deep-text); }
.cmp__result-text b { font-family: var(--font-mono); font-weight: 500; }

.cmp__ok {
  margin-top: 24px; padding: 16px;
  border-radius: var(--r-md);
  background: rgba(201, 242, 77, .08);
  border: 1px solid rgba(201, 242, 77, .25);
  font-size: 14px; line-height: 21px; color: var(--deep-text);
  opacity: 0;
  transition: opacity var(--t-base) var(--e-out);
}
.cmp__ok.is-in { opacity: 1; }

/* ---------- Ряд управления ---------- */
.scene__controls {
  margin-top: 32px;
  display: flex; align-items: center; gap: 24px;
  min-height: 44px;
}
.scene__progress {
  flex: 1; max-width: 400px; margin-inline: auto;
  height: 2px; border-radius: 2px;
  background: var(--deep-line);
  overflow: hidden;
}
.scene__progress i {
  display: block; height: 100%; width: 0;
  background: var(--lime-500);
  transition: width var(--t-base) var(--e-out);
}
.scene__stage { flex: none; }

/* ---------- Планшет ---------- */
@media (max-width: 1023px) {
  .scene__panel {
    grid-template-columns: 260px 1fr;
    row-gap: 32px;
    min-height: 0;
  }
  .scene__zone--c {
    grid-column: 1 / -1;
    border-left: 0; padding-left: 0; margin-left: 0;
    border-top: 1px solid var(--deep-line);
    padding-top: 32px;
  }
  .scene__doc { height: 260px; }
  @keyframes scanpass {
    0% { opacity: 0; transform: translateY(0) } 10% { opacity: .8 }
    90% { opacity: .8 } 100% { opacity: 0; transform: translateY(260px) }
  }
}

/* ---------- Мобильный: этапы вместо колонок ---------- */
@media (max-width: 767px) {
  .scene__head { margin-bottom: 40px; text-align: left; }
  .scene__head .h2, .scene__head .lead { margin-inline: 0; }

  .scene__panel {
    grid-template-columns: 1fr;
    row-gap: 28px;
    padding: 20px;
    border-radius: var(--r-lg);
  }
  .scene__zone + .scene__zone {
    border-left: 0; padding-left: 0; margin-left: 0;
    border-top: 1px solid var(--deep-line);
    padding-top: 28px;
  }
  .scene__zone--c { padding-top: 28px; }

  .scene__sources { flex-direction: row; overflow-x: auto; gap: 6px; scrollbar-width: none;
                     min-width: 0; max-width: 100%; }
  .scene__sources::-webkit-scrollbar { display: none; }
  .scene__source {
    height: 44px; flex: none; font-size: 14px;
    border-left: 0; border-bottom: 2px solid rgba(255,255,255,.12);
    border-radius: var(--r-sm) var(--r-sm) 0 0;
  }
  .scene__source[aria-selected="true"] { border-left: 0; border-bottom-color: var(--lime-500); }

  .scene__doc { height: 200px; margin-top: 24px; }
  @keyframes scanpass {
    0% { opacity: 0; transform: translateY(0) } 10% { opacity: .8 }
    90% { opacity: .8 } 100% { opacity: 0; transform: translateY(200px) }
  }

  .cmp__head, .cmp__row { grid-template-columns: 1fr 52px 62px 62px; gap: 6px; padding-inline: 6px; }
  .cmp__row { font-size: 12px; }

  .scene__controls { flex-wrap: wrap; gap: 16px; margin-top: 24px; }
  .scene__progress { order: 3; flex-basis: 100%; max-width: none; }
  .scene__controls .btn { flex: 1; }
}

/* Узкие телефоны: таблица сверки не влезает в 4 колонки штатной ширины.
   Шапка «Позиция» задавала min-content и распирала строку на 13px. */
@media (max-width: 400px) {
  .cmp__head, .cmp__row {
    grid-template-columns: minmax(0, 1fr) 42px 54px 54px;
    gap: 4px;
    padding-inline: 4px;
  }
  .cmp__head { font-size: 10px; }
  .cmp__head span, .cmp__row span {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}
