/* =====================================================================
   Шрифт — Google Sans (вариативный, self-hosted в assets/fonts)
   ===================================================================== */
@font-face {
  font-family: 'Google Sans';
  src: url('assets/fonts/GoogleSans.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Google Sans';
  src: url('assets/fonts/GoogleSans-Italic.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* =====================================================================
   Токены — зеркалят content-and-tokens.md
   ===================================================================== */
:root {
  /* Цвета */
  --c-bg: #F3F3F3;
  --c-surface: #FFFFFF;
  --c-text: #050505;
  --c-text-muted: #595959;
  --c-field: #F2F2EF;
  --c-accent: #F9E48B;
  --c-text-muted-2: #848484;
  --c-dark: #010101;
  --c-pill: #E3E3E3;
  --c-danger: #FF3D3D;
  --c-link: #4498FF;

  /* Типографика */
  --font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --tracking: -0.03em;

  /* Спейсинг и размеры */
  --card-w: 463px;
  --card-pad: 40px;
  --radius-card: 24px;
  --radius-field: 8px;
  --field-h: 48px;
  --field-pad-x: 16px;
  --gap-title: 18px;
  --gap-block: 24px;
  --gap-field: 8px;
  --gap-option: 8px;
  --radius-pill: 999px;

  /* Тень карточки (упрощённая из Figma) */
  --shadow-card: 0 2px 8px rgba(49, 45, 33, 0.04), 0 24px 56px rgba(49, 45, 33, 0.06);
}

/* =====================================================================
   База
   ===================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-family);
  letter-spacing: var(--tracking);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =====================================================================
   Сцена экрана — фон на весь вьюпорт, карточка по центру
   ===================================================================== */
.stage {
  position: relative;
  min-height: 100vh;
  display: none;
  place-items: center;
  padding: 40px 20px;
  overflow: hidden;
}
.stage.is-active { display: grid; }

/* Иллюстрации по бокам, за карточкой */
.illus {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: min(34vw, 422px);
  height: auto;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}
.illus--left  { left:  max(16px, calc(50% - 560px)); }
.illus--right { right: max(16px, calc(50% - 560px)); }

@media (max-width: 1024px) {
  .illus { display: none; }
}

/* =====================================================================
   Карточка
   ===================================================================== */
.card {
  position: relative;
  z-index: 1;
  width: min(var(--card-w), 100%);
  padding: var(--card-pad);
  background: var(--c-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--gap-block);
}

.card__text {
  display: flex;
  flex-direction: column;
  gap: var(--gap-title);
}

.title {
  margin: 0;
  font-size: 28px;
  line-height: 32px;
  font-weight: 500;
  color: var(--c-text);
}

.subtitle {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
  font-weight: 400;
  color: var(--c-text-muted);
}

/* =====================================================================
   Форма
   ===================================================================== */
.card__form {
  display: flex;
  flex-direction: column;
  gap: var(--gap-field);
}

.field {
  height: var(--field-h);
  padding: 0 var(--field-pad-x);
  border: none;
  border-radius: var(--radius-field);
  background: var(--c-field);
  font-family: inherit;
  font-size: 14px;
  line-height: 22px;
  letter-spacing: var(--tracking);
  color: var(--c-text);
}
.field::placeholder { color: var(--c-text-muted); opacity: 1; }
.field:focus { outline: 2px solid rgba(5, 5, 5, 0.12); outline-offset: 0; }

.btn {
  height: var(--field-h);
  border: none;
  border-radius: var(--radius-field);
  background: var(--c-accent);
  font-family: inherit;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  letter-spacing: var(--tracking);
  color: var(--c-text);
  cursor: pointer;
  transition: filter 0.15s ease;
}
.btn:hover { filter: brightness(0.96); }
.btn:active { filter: brightness(0.92); }
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: none;
}

/* =====================================================================
   Экран 2 · Выбор типа собеседования
   ===================================================================== */
.choose {
  display: flex;
  flex-direction: column;
  gap: var(--gap-block);
}

.options {
  display: flex;
  flex-direction: column;
  gap: var(--gap-option);
}

.option {
  width: 100%;
  margin: 0;
  padding: 20px;
  border: none;
  border-radius: var(--radius-field);
  background: var(--c-bg);
  font-family: inherit;
  letter-spacing: var(--tracking);
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.option:not(:disabled):hover { filter: brightness(0.97); }
.option:disabled { cursor: default; }
.option--dev { opacity: 0.5; } /* dev-опция приглушена целиком */

.option__head {
  display: flex;
  align-items: center;
  gap: 4px;
}
.option__title {
  flex: 1; /* растёт → бейджи уходят к правому краю */
  font-size: 16px;
  line-height: 22px;
  font-weight: 500;
  color: var(--c-text);
}

.badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  line-height: 12px;
  color: var(--c-text);
  white-space: nowrap;
}
.badge--time { background: var(--c-pill); font-weight: 400; } /* время — серый */
.badge--dev { background: var(--c-accent); font-weight: 500; } /* «в разработке» — жёлтый */

.option__desc {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--c-text-muted-2);
}

/* Обёртка карточка + промо-баннер (экран 2) */
.choose-wrap {
  position: relative;
  z-index: 1;
  width: min(var(--card-w), 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.choose-wrap .card {
  width: 100%;
}

/* Промо-баннер (тг-ссылка) */
.promo-banner {
  width: min(var(--card-w), 100%);
  padding: 24px;
  background: #191919;
  border-radius: var(--radius-card);
}
.promo-banner__text {
  margin: 0;
  font-size: 16px;
  line-height: 22px;
  color: #ffffff;
}
.promo-banner__link {
  color: #69C1FF;
  text-decoration: underline;
}

/* Звёздочка-тултип у «Лучший» */
.asterisk {
  position: relative;
  color: #9E9E9E;
  cursor: default;
}
.asterisk__tip {
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--c-pill);
  font-size: 14px;
  font-weight: 400;
  line-height: 16px;
  color: var(--c-text-muted);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2;
}
.asterisk:hover .asterisk__tip,
.asterisk:focus .asterisk__tip {
  opacity: 1;
}

/* =====================================================================
   Экран 3 · Короткое погружение
   ===================================================================== */
.intro {
  display: flex;
  flex-direction: column;
  gap: var(--gap-block);
}

.back-link {
  align-self: flex-start;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  letter-spacing: var(--tracking);
  font-size: 16px;
  line-height: 22px;
  font-weight: 500;
  color: var(--c-text);
  cursor: pointer;
}

.cc-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

/* =====================================================================
   Экран 4 · Лоадер
   ===================================================================== */
.loader {
  width: 64px;
  height: 64px;
  animation: spin 0.8s linear infinite;
}
.loader-box.is-terminal .loader {
  display: none;
}
.loader-retry {
  margin-top: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loader-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.loader-text {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--c-text);
  text-align: center;
  max-width: 960px;
}

/* =====================================================================
   Экран 5 · Разговор
   ===================================================================== */
.stage--call { place-items: stretch; }

.call {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Пилюли сверху: статус + таймер */
.pills {
  display: flex;
  gap: 4px;
}
.pill {
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  background: var(--c-pill);
  font-size: 14px;
  line-height: 1;
  color: var(--c-dark);
  white-space: nowrap;
}

/* Центр: siriwave в круге */
.wave-wrap {
  flex: 1;
  width: 100%;
  display: grid;
  place-items: center;
}
.wave-circle {
  width: 360px;
  height: 360px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
}
#wave {
  width: 100%;
  height: 100%;
}

/* Низ: спич-бабл + 3 контрола (кнопки центрированы, бабл слева) */
.controls {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
.ctrl-row {
  display: flex;
  gap: 8px;
}
.ctrl {
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.ctrl:hover { filter: brightness(1.12); }
.ctrl--dark { background: var(--c-dark); }
.ctrl--red { background: var(--c-danger); }
.ctrl--mic.is-attention {
  animation: micAttentionPulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(255, 184, 77, 0.72);
}

.ctrl-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.mic-level {
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}
.mic-level::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--mic-pct, 0%);
  background: #4ade80;
  border-radius: 2px;
  transition: width 80ms ease;
}
.mic-level.is-attention::after {
  width: 100%;
  background: #ffb84d;
  animation: micLevelPulse 1.1s ease-in-out infinite;
}
.ctrl img {
  width: 32px;
  height: 32px;
  display: block;
}

/* Онбординг-поповеры на контролах — появляются по очереди (app.js).
   Отступ до кнопки 8px = хвост 11px + зазор 8px = 19px от края кнопки. */
.pop {
  position: absolute;
  padding: 16px;
  border-radius: 12px;
  background: var(--c-pill);
  font-size: 14px;
  line-height: 16px;
  color: var(--c-dark);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.pop.is-visible { opacity: 1; }
.pop.is-attention { background: #ffb84d; }
.pop::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
}

/* 1 · микрофон — слева от кнопки, хвост вправо */
.pop--mic {
  top: 50%;
  right: calc(50% + 123px);
  transform: translateY(-50%);
}
.pop--mic::after {
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 11px solid var(--c-pill);
}
.pop--mic.is-attention::after {
  border-left-color: #ffb84d;
}

@keyframes micAttentionPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 184, 77, 0.72);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 16px rgba(255, 184, 77, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 184, 77, 0);
  }
}

@keyframes micLevelPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

/* 2 · субтитры — над центральной кнопкой, хвост вниз */
.pop--cc {
  left: 50%;
  bottom: calc(100% + 19px);
  transform: translateX(-50%);
}
.pop--cc::after {
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 11px solid var(--c-pill);
}

/* 3 · завершить — справа от красной кнопки, хвост влево */
.pop--end {
  top: 50%;
  left: calc(50% + 123px);
  transform: translateY(-50%);
}
.pop--end::after {
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-right: 11px solid var(--c-pill);
}

@media (max-width: 720px) {
  .pop { display: none; }
}

/* =====================================================================
   Экран 7 · Фидбек + транскрибация
   ===================================================================== */
.stage--feedback {
  place-items: start center;
  overflow: visible;
}
.fb {
  width: 560px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 48px;
}
/* атрибут hidden должен перебивать display:flex у .fb-md / .tr */
.fb-pane[hidden] { display: none; }

/* Таб-свитчер (Feedback / Текст разговора) */
.tabs {
  align-self: flex-start;
  display: inline-flex;
  border-radius: 12px;
  overflow: hidden;
}
.tab {
  padding: 16px 20px;
  border: none;
  font-family: inherit;
  letter-spacing: var(--tracking);
  font-size: 16px;
  font-weight: 500;
  line-height: 16px;
  cursor: pointer;
  background: var(--c-pill);
  color: var(--c-text);
}
.tab--active {
  background: var(--c-dark);
  color: #ffffff;
}

/* Markdown-фидбек */
.fb-md {
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 14px;
  line-height: 20px;
  color: var(--c-dark);
}
.fb-md > p { margin: 0; }
.fb-md section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fb-md h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}
.fb-md ul,
.fb-md ol {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Транскрибация */
.tr {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.tr-turn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.tr-who {
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  line-height: 12px;
  color: var(--c-dark);
}
.tr-who--ai { background: #ffffff; color: var(--c-text); }
.tr-who--user { background: var(--c-accent); }
.tr-text {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--c-dark);
}

/* =====================================================================
   Субтитры (экран 5)
   ===================================================================== */
.cc-panel {
  width: 424px;
  max-width: 90%;
  max-height: 305px;
  background: var(--c-pill);
  border-radius: 18px;
  padding: 0;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.cc-panel[hidden] { display: none; }
.cc-panel::before,
.cc-panel::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 32px;
  pointer-events: none;
  z-index: 1;
  border-radius: 18px;
}
.cc-panel::before {
  top: 0;
  background: linear-gradient(to bottom, var(--c-pill), transparent);
}
.cc-panel::after {
  bottom: 0;
  background: linear-gradient(to top, var(--c-pill), transparent);
}
.cc-panel__messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex: 1;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;
}
.cc-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cc-msg__label {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}
.cc-msg__label--ai {
  background: #fff;
  color: var(--c-text);
}
.cc-msg__label--user {
  background: var(--c-accent);
  color: var(--c-text);
}
.cc-msg__text {
  margin: 0;
  font-size: 12px;
  line-height: 18px;
  color: var(--c-dark);
}

/* CC кнопка в активном состоянии */
.ctrl--active {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

/* Кнопки экрана 7 */
.fb-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.btn--restart,
.btn--download {
  flex: 1;
}
.btn--download {
  background: var(--c-dark);
  color: #fff;
}

/* Кнопки внизу фидбека */
.fb-actions {
  display: flex;
  gap: 8px;
}
.fb-btn {
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: var(--radius-field);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: var(--tracking);
  color: var(--c-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: filter 0.15s ease;
}
.fb-btn:hover { filter: brightness(0.96); }
.fb-btn--outline {
  background: none;
  border: 1px solid #BFBFBF;
}
.fb-btn--accent {
  background: var(--c-accent);
}

@media (max-width: 620px) {
  .fb { width: 100%; }
  .fb-actions { flex-direction: column; }
}
