/* Голосовой тур. Экран управляется атрибутом hidden (не зависит от Tailwind). */

.tr {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  background: var(--st-bg);
  color: var(--st-text);
  font-family: var(--st-font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.tr[hidden], .tr [hidden] { display: none !important; }  /* в т.ч. для SVG-иконок: hidden у них сам не работает */

.tr-shell {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas: 'top' 'card' 'speech' 'ava' 'controls';
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
           max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
.tr-top      { grid-area: top; }
.tr-stage    { grid-area: card; }
.tr-speech   { grid-area: speech; }
.tr-ava-wrap { grid-area: ava; }
.tr-controls { grid-area: controls; }

/* ---------- верх: прогресс и выход ---------- */
.tr-top { display: flex; align-items: center; gap: 14px; min-height: 40px; }
.tr-progress { flex: 1; display: flex; gap: 5px; }
.tr-seg { flex: 1; height: 3px; border-radius: 3px; background: var(--st-line-strong); overflow: hidden; }
.tr-seg i { display: block; height: 100%; width: 0; background: var(--st-accent); }
.tr-seg.is-done i { width: 100%; }
.tr-seg.is-now i { width: 100%; animation: tr-fill var(--tr-dur, 6s) linear forwards; }
.tr-seg.is-paused i { animation-play-state: paused; }
.tr-seg.is-hold i { animation: none; width: 100%; }
@keyframes tr-fill { from { width: 0; } to { width: 100%; } }
.tr-exit {
  background: none; border: 0; padding: 10px 2px; font: inherit; font-size: 14px;
  color: var(--st-muted); cursor: pointer; transition: color 0.15s;
}
.tr-exit:hover { color: var(--st-text); }

/* ---------- демо-анкета ---------- */
.tr-card {
  width: 100%;
  max-width: 560px;
  border: 1px solid var(--st-line);
  border-radius: var(--st-radius);
  background: var(--st-surface);
  overflow: hidden;
  transition: opacity 0.35s;
}
.tr-card.is-offer { opacity: 0.35; }
.tr-part {
  padding: 12px 16px;
  border-bottom: 1px solid var(--st-line);
  transition: opacity 0.3s, background 0.3s, box-shadow 0.3s;
}
.tr-part:last-child { border-bottom: 0; }
.tr-card.has-focus .tr-part:not(.is-focus) { opacity: 0.28; }
.tr-part.is-focus { background: rgba(249, 115, 22, 0.07); box-shadow: inset 3px 0 0 var(--st-accent); }

.tr-row { display: flex; align-items: center; gap: 12px; }
.tr-ava-mini {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--st-surface-2); border: 1px solid var(--st-line); font-weight: 600;
}
.tr-name { font-weight: 600; font-size: 16px; }
.tr-sub { margin-top: 2px; font-size: 13px; color: var(--st-muted); }
.tr-tag {
  margin-left: auto; font-size: 11px; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--st-line-strong); color: var(--st-muted);
}
.tr-label { font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--st-muted); margin-bottom: 6px; }
.tr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tr-chip {
  font-size: 12.5px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--st-line-strong); color: #cdd3de;
}
.tr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tr-cols--stack { grid-template-columns: 1fr; gap: 10px; }
.tr-big { font-size: 15px; font-weight: 600; }
.tr-bar { height: 6px; border-radius: 6px; background: var(--st-line-strong); overflow: hidden; margin-top: 8px; }
.tr-bar i { display: block; height: 100%; width: 94%; background: var(--st-accent); }
.tr-match-num { margin-left: auto; font-size: 22px; font-weight: 700; color: var(--st-accent); }
.tr-text { font-size: 13.5px; line-height: 1.5; color: #c4cad6; }
.tr-lock { color: var(--st-muted); font-size: 13px; }

/* ---------- реплика ---------- */
.tr-speech { min-height: 7.2em; align-self: start; }
.tr-line {
  margin: 0;
  font-size: clamp(17px, 4.6vw, 21px);
  line-height: 1.5;
  max-width: 34em;
}
.tr-line.is-in { animation: tr-in 0.4s ease both; }
@keyframes tr-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.tr-offer { display: flex; gap: 10px; margin-top: 16px; }
.tr-offer[hidden] { display: none; }
.tr-offer .tr-btn { flex: 1; }

/* ---------- кнопки ---------- */
.tr-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--st-radius-sm);
  border: 1px solid var(--st-line-strong); background: transparent; color: var(--st-text);
  font: inherit; font-weight: 600; font-size: 15px; cursor: pointer;
  transition: background 0.15s, filter 0.15s, transform 0.1s;
}
.tr-btn:hover { background: rgba(255, 255, 255, 0.05); }
.tr-btn:active { transform: scale(0.985); }
.tr-btn--primary { background: var(--st-accent); border-color: var(--st-accent); color: var(--st-accent-ink); }
.tr-btn--primary:hover { background: var(--st-accent); filter: brightness(1.08); }
.tr-btn[hidden] { display: none; }

.tr-controls { display: flex; align-items: center; gap: 8px; }
.tr-ico {
  width: 48px; height: 48px; padding: 0; flex: none; border-radius: 50%;
  border: 1px solid var(--st-line-strong); background: transparent; color: var(--st-text);
  display: grid; place-items: center; cursor: pointer; transition: background 0.15s;
}
.tr-ico:hover { background: rgba(255, 255, 255, 0.06); }
.tr-ico[hidden] { display: none; }
.tr-ico svg { width: 20px; height: 20px; }
.tr-controls .tr-btn--primary { margin-left: auto; min-width: 128px; }

.tr :focus-visible { outline: 2px solid var(--st-accent); outline-offset: 2px; }

/* ---------- аватар ---------- */
.tr-ava-wrap { position: relative; min-height: 0; display: flex; justify-content: center; align-items: flex-end; }
.tr-glow {
  position: absolute; left: 50%; bottom: 8%; width: 70%; aspect-ratio: 1; transform: translateX(-50%);
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(249, 115, 22, 0.5), transparent 70%);
  opacity: calc(0.12 + var(--amp, 0) * 0.55);
  filter: blur(18px);
}
.tr-ava {
  position: relative; width: 100%; height: 100%; min-height: 0;
  transform-origin: 50% 100%;
  transform: translateY(calc(var(--amp, 0) * -5px)) scale(calc(1 + var(--amp, 0) * 0.014));
  animation: tr-breathe 5s ease-in-out infinite;
}
@keyframes tr-breathe { 50% { translate: 0 -3px; } }
.tr-ava img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; object-position: 50% 100%;
  opacity: 0; transition: opacity 0.28s ease;
  -webkit-user-drag: none; user-select: none;
}
.tr-ava img.is-on { opacity: 1; }

/* ---------- телефон: в карточке показываем только заголовок и выбранный блок ---------- */
@media (max-width: 760px) {
  .tr-part:not([data-part='head']):not(.is-focus) { display: none; }
  .tr-card.has-focus .tr-part[data-part='head']:not(.is-focus) { opacity: 0.55; }
  .tr-card.is-offer .tr-part[data-part='head'] { opacity: 1; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .tr-shell { gap: 8px; }
  .tr-speech { min-height: 6.6em; }
  .tr-line { font-size: 16px; }
  .tr-part { padding: 9px 14px; }
  .tr-ava-wrap { min-height: 110px; }
}

/* ---------- десктоп: аватар и анкета по центру экрана ---------- */
@media (min-width: 761px) {
  .tr-shell {
    max-width: 1180px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    /* пустые 1fr-строки сверху и снизу центрируют и аватар, и колонку с анкетой */
    grid-template-rows: auto minmax(0, 1fr) auto auto auto minmax(0, 1fr);
    grid-template-areas: 'top top' 'ava .' 'ava card' 'ava speech' 'ava controls' 'ava .';
    column-gap: 56px; row-gap: 18px;
    padding: 20px 32px 28px;
  }
  .tr-top { grid-column: 1 / -1; }
  .tr-ava-wrap {
    align-self: center; justify-self: center;
    width: 100%; max-width: 560px; aspect-ratio: 525 / 492; max-height: 100%;
  }
  .tr-stage { align-self: end; }
  .tr-speech { align-self: start; min-height: 7em; }
  .tr-line { font-size: 21px; }
  .tr-controls { align-self: start; }
}

/* ноутбуки: уплотняем карточку, чтобы всё влезало по высоте */
@media (min-width: 761px) and (max-height: 880px) {
  .tr-shell { row-gap: 12px; padding-top: 12px; padding-bottom: 18px; }
  .tr-part { padding: 8px 14px; }
  .tr-label { margin-bottom: 4px; }
  .tr-speech { min-height: 6em; }
  .tr-line { font-size: 19px; }
}
/* совсем низкие окна: как на телефоне, заголовок и выбранный блок */
@media (min-width: 761px) and (max-height: 700px) {
  .tr-part:not([data-part='head']):not(.is-focus) { display: none; }
  .tr-card.has-focus .tr-part[data-part='head']:not(.is-focus) { opacity: 0.55; }
  .tr-card.is-offer .tr-part[data-part='head'] { opacity: 1; }
}

/* ---------- ландшафт телефона ---------- */
@media (max-height: 500px) and (min-width: 561px) and (max-width: 1023px) {
  .tr-shell {
    grid-template-columns: minmax(150px, 0.5fr) minmax(0, 1.5fr);
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: 'ava top' 'ava card' 'ava speech' 'ava .' 'ava controls';
    column-gap: 20px; row-gap: 8px; padding: 10px 20px;
  }
  .tr-top { grid-column: auto; }
  .tr-ava-wrap { align-self: end; width: 100%; max-width: none; aspect-ratio: auto; max-height: none; height: 100%; }
  .tr-part:not([data-part='head']):not(.is-focus) { display: none; }
}


/* ---------- подпись говорящего ---------- */
.tr-who {
  margin: 0 0 6px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--st-accent);
}

/* ---------- блок «видео-хайлайт» в демо-анкете ---------- */
.tr-thumb {
  flex: none; width: 72px; height: 42px; border-radius: 8px; display: grid; place-items: center;
  color: var(--st-accent); border: 1px solid var(--st-line-strong);
  background: linear-gradient(135deg, #1d2432, #10141c);
}

/* ---------- плавное растворение среза плеч у аватара (маска только на картинки, свечение не трогаем) ---------- */
.tr-ava {
  -webkit-mask-image: linear-gradient(to bottom, #000 84%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 84%, transparent 100%);
}

@media (prefers-reduced-motion: reduce) {
  .tr-ava { animation: none; transform: none; }
  .tr-glow { opacity: 0.18; }
  .tr-line.is-in { animation: none; }
  .tr-seg.is-now i { animation: none; }
  .tr-ava img, .tr-card, .tr-part { transition: none; }
}
