/* ============================================
   CABINET — вход и личный кабинет
   Только токены из variables.css.
   Сначала телефон (360–390), потом 768 и 1024.
   ============================================ */

/* В кабинете нет якорей: плавная прокрутка из reset.css мешает при смене экрана */
html {
  scroll-behavior: auto;
}

.cab-body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- Фокус: олива видна и на cream, и на white --- */
.cab-body :focus-visible {
  outline: 2px solid var(--olive);
  outline-offset: 3px;
}

/* Заголовок экрана получает фокус программно (смена экрана), рамка ему не нужна */
.cab-body [tabindex="-1"]:focus {
  outline: none;
}

/* ============================================
   Шапка
   ============================================ */

.cab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: calc(720px + 2 * var(--container-padding));
  min-height: 3.75rem;
  margin: 0 auto;
  padding: 0.5rem var(--container-padding);
}

.cab-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1;
  letter-spacing: 0.15em;
  color: var(--warm-black);
}

.cab-logo img {
  width: 28px;
  height: 28px;
  filter: brightness(0);
}

.cab-nav {
  display: flex;
  gap: 1.25rem;
}

.cab-help,
.cab-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-caps);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.cab-help:hover,
.cab-nav-link:hover {
  color: var(--warm-black);
}

.cab-nav-link[aria-current] {
  color: var(--warm-black);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--gold);
  text-underline-offset: 0.45rem;
}

/* ============================================
   Общие элементы
   ============================================ */

.cab-title {
  font-size: var(--text-3xl);
  font-weight: 300;
  line-height: 1.15;
  margin-bottom: var(--space-sm);
}

.cab-text {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
  margin-bottom: var(--space-md);
}

.cab-text strong {
  color: var(--warm-black);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cab-email {
  display: block;
  margin: 0.2rem 0;
}

.cab-meta {
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--text-muted);
  font-variant-numeric: lining-nums tabular-nums;
  text-wrap: pretty;
}

.cab-body .btn-primary {
  min-height: 3rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.cab-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3rem;
  padding: 0.75rem 1.25rem;
  font-size: var(--text-btn);
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  color: var(--warm-black);
  border: 1px solid var(--taupe);
  border-radius: 2px;
  transition: border-color var(--transition-fast);
}

.cab-secondary:hover {
  border-color: var(--warm-black);
}

.cab-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cab-actions > * {
  width: 100%;
}

.cab-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--text-sm);
  color: var(--warm-black);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition-fast);
}

.cab-link:hover {
  text-decoration-color: var(--warm-black);
}

.cab-link[disabled] {
  color: var(--text-muted);
  text-decoration: none;
  cursor: default;
}

/* ============================================
   LOGIN — /login/
   До 768 без карточки: форма сразу под шапкой
   ============================================ */

.cab-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0 var(--container-padding) 3rem;
}

.cab-card {
  width: 100%;
  max-width: 420px;
  padding: 1rem 0 0;
}

.cab-card[hidden] {
  display: none;
}

.cab-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cab-label {
  margin-bottom: 0.5rem;
  font-size: var(--text-caps);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cab-input {
  width: 100%;
  /* 16px и больше: iOS не зумит поле при фокусе */
  font: 500 1.3125rem/1.3 var(--font-body);
  font-variant-numeric: lining-nums;
  color: var(--warm-black);
  background: var(--white);
  border: 1px solid var(--text-muted);
  border-radius: 2px;
  padding: 0.85rem 1rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.cab-input::placeholder {
  color: var(--taupe);
  opacity: 1;
}

.cab-input[aria-invalid="true"] {
  border-color: var(--warm-black);
}

/* после общего :focus-visible: у поля своя рамка */
.cab-input:focus {
  outline: none;
  border-color: var(--warm-black);
  box-shadow: 0 0 0 1px var(--warm-black);
}

/* Ровные цифры (lining): у старостильных единица похожа на I */
.cab-input--code {
  font-size: 1.75rem;
  font-weight: 500;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: 0.35em;
  text-align: center;
  padding: 0.6rem 0 0.6rem 0.35em;
}

.cab-turnstile:empty {
  display: none;
}

.cab-turnstile iframe {
  margin-top: 0.75rem;
}

.cab-submit {
  width: 100%;
  margin-top: 1rem;
}

.cab-body .cab-submit {
  padding-top: 0.95rem;
  padding-bottom: 0.95rem;
}

.cab-submit[disabled] {
  opacity: 0.6;
  cursor: progress;
}

.cab-error {
  margin-top: 0.75rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--gold);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--warm-black);
}

.cab-error--ok {
  border-left-color: var(--olive);
}

.cab-error[hidden] {
  display: none;
}

.cab-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1.25rem;
  margin-top: 0.75rem;
}

@media (min-width: 768px) {
  .cab-main {
    align-items: center;
    padding-top: 1rem;
    padding-bottom: 6rem;
  }

  .cab-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 2px;
    box-shadow: var(--shadow-card);
    padding: 2.75rem 2.5rem;
  }
}

/* ============================================
   ACCOUNT — /account/
   ============================================ */

.cab-page {
  flex: 1;
  width: 100%;
  max-width: calc(720px + 2 * var(--container-padding));
  margin: 0 auto;
  padding: 0 var(--container-padding) 4rem;
  outline: none;
}

.cab-page .cab-title {
  margin: 1rem 0 1.25rem;
}

/* Загрузка: появляется через 300 мс, чтобы не мигать на быстрой сети */
.cab-loading {
  min-height: 50vh;
  min-height: 50svh;
  display: grid;
  place-items: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  opacity: 0;
  animation: cab-show 0s linear 0.3s forwards;
}

@keyframes cab-show {
  to {
    opacity: 1;
  }
}

/* --- Назад --- */
.cab-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  min-height: 44px;
  font-size: var(--text-sm);
  color: var(--warm-black);
}

.cab-back::before {
  content: '←';
  content: '←' / '';
  flex: 0 0 auto;
  color: var(--text-muted);
}

.cab-back-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}

.cab-back:hover .cab-back-label {
  text-decoration-color: var(--warm-black);
}

/* --- Шапка программы: H1, подзаголовок, мета --- */
.cab-page .cab-head {
  margin: 0.25rem 0 1.25rem;
}

.cab-page .cab-head .cab-title {
  margin: 0 0 0.5rem;
}

.cab-sub {
  font-size: var(--text-base);
  line-height: 1.4;
  color: var(--warm-black);
  margin-bottom: 0.25rem;
}

.cab-section-title {
  font-family: var(--font-body);
  font-size: var(--text-caps);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 1.25rem 0 0;
}

/* --- Обложки (кадры из видео Лили, 4:5) --- */
.cab-thumb {
  display: block;
}

.cab-cover {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--blush);
}

/* --- «Продолжить»: одна программа, одна золотая кнопка --- */
.cab-continue {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  margin-bottom: 0.5rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--warm-black);
  transition: box-shadow var(--transition-fast);
}

.cab-continue:hover {
  box-shadow: var(--shadow-card);
}

.cab-continue-body {
  min-width: 0;
}

.cab-continue-title {
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 0.375rem;
}

.cab-continue .cab-meta {
  display: block;
  font-size: var(--text-xs);
}

.cab-bar {
  display: block;
  height: 2px;
  margin-top: 0.75rem;
  background: var(--border);
}

.cab-bar > span {
  display: block;
  height: 100%;
  background: var(--gold);
}

.cab-continue .btn-primary {
  grid-column: 1 / -1;
  width: 100%;
}

.cab-continue:hover .btn-primary::before {
  transform: translateX(0);
}

/* --- Строки программ --- */
.cab-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  gap: 1rem;
  align-items: center;
  min-height: 4.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--warm-black);
}

.cab-row-body {
  min-width: 0;
}

.cab-row-title {
  display: block;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.2;
  transition: color var(--transition-fast);
}

.cab-row-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--text-muted);
  font-variant-numeric: lining-nums tabular-nums;
  text-wrap: pretty;
}

.cab-row-price {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--warm-black);
  font-variant-numeric: lining-nums tabular-nums;
}

.cab-row-arrow {
  font-size: var(--text-lg);
  color: var(--gold);
  transition: transform var(--transition-fast);
}

.cab-row:hover .cab-row-title {
  color: var(--olive);
}

.cab-row:hover .cab-row-arrow {
  transform: translateX(3px);
}

/* --- Список видео программы --- */
.cab-videos {
  margin-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.cab-video {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-height: 3.75rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--warm-black);
}

.cab-video-body {
  flex: 1;
  min-width: 0;
}

.cab-video-title {
  display: block;
  font-size: var(--text-base);
  line-height: 1.4;
}

.cab-video-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: lining-nums tabular-nums;
}

.cab-video-equip,
.cab-watch-equip {
  display: block;
  margin-top: 0.15rem;
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--text-muted);
}

.cab-watch-equip {
  margin: 0 0 0.25rem;
}

.cab-access {
  margin-top: 0.25rem;
}

.cab-video-state {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--text-muted);
}

.cab-video-state--done {
  color: var(--olive);
}

.cab-video-state svg {
  width: 16px;
  height: 16px;
}

.cab-video--locked .cab-video-title {
  color: var(--text-muted);
}

a.cab-video:hover .cab-video-title {
  color: var(--olive);
}

/* Тренировка с обложкой: миниатюра 9:16 слева, текст сверху вровень с ней */
.cab-video--cover {
  align-items: flex-start;
}

.cab-video-cover {
  flex: 0 0 4.25rem;
  width: 4.25rem;
  height: auto;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  background: var(--blush);
  border-radius: var(--radius-md);
}

.cab-video--cover .cab-video-state {
  align-self: center;
}

.cab-video-preview {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--olive);
  font-variant-numeric: lining-nums tabular-nums;
}

.cab-video-about {
  display: block;
  margin-top: 0.375rem;
  font-size: var(--text-xs);
  line-height: 1.35;
  color: var(--text-muted);
  text-wrap: pretty;
}

.cab-watch-note {
  margin-bottom: var(--space-sm);
}

.cab-video-bar {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  background: var(--gold);
}

/* --- Просмотр: плеер в один экран --- */
.cab-player {
  position: relative;
  width: min(100%, calc((100vh - 8rem) * 9 / 16));
  width: min(100%, calc((100svh - 8rem) * 9 / 16));
  aspect-ratio: 9 / 16;
  margin: 0.5rem auto var(--space-md);
  background: var(--warm-black);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.cab-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Водяной знак зрителя на платном видео: email поверх кадра, раз в 15–25 с переезжает (account.js) */
.cab-watermark {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  max-width: 92%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--white);
  opacity: 0.4;
  text-shadow: 0 0 1px var(--warm-black), 0 0 2px var(--warm-black), 0 1px 4px var(--warm-black);
  pointer-events: none;
  user-select: none;
  transition: left 2.5s ease, top 2.5s ease, transform 2.5s ease;
}

/* Свой полноэкранный режим: разворачивается контейнер вместе со знаком */
.cab-player:fullscreen {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  aspect-ratio: auto;
  border-radius: 0;
}

.cab-player:-webkit-full-screen {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  aspect-ratio: auto;
  border-radius: 0;
}

.cab-player:fullscreen .cab-watermark {
  font-size: 1.125rem;
}

.cab-fs-exit {
  display: none;
  position: absolute;
  z-index: 3;
  top: max(0.75rem, env(safe-area-inset-top));
  right: 0.75rem;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--taupe);
  border-radius: 2px;
  background: var(--warm-black);
  color: var(--white);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
}

.cab-player:fullscreen .cab-fs-exit,
.cab-player:-webkit-full-screen .cab-fs-exit {
  display: inline-flex;
  align-items: center;
}

.cab-fs-actions {
  margin-bottom: 0.75rem;
}

@media (prefers-reduced-motion: reduce) {
  .cab-watermark {
    transition: none;
  }
}

.cab-player-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  text-align: center;
  color: var(--taupe);
  font-size: var(--text-sm);
  opacity: 0;
  animation: cab-show 0s linear 0.3s forwards;
}

.cab-page .cab-watch-title {
  font-size: var(--text-2xl);
  font-weight: 400;
  margin: 0 0 0.375rem;
}

.cab-watch-info > .cab-meta {
  margin-bottom: var(--space-sm);
}

.cab-video-desc {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
  margin-bottom: var(--space-md);
}

/* --- Отказ, ошибки --- */
.cab-locked,
.cab-panel {
  margin-bottom: var(--space-md);
  padding: 1.5rem 1.25rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.cab-locked .cab-text,
.cab-panel .cab-text {
  color: var(--warm-black);
  margin-bottom: 1.25rem;
}

/* --- Профиль --- */
.cab-list {
  border-top: 1px solid var(--border);
  margin-bottom: var(--space-md);
}

.cab-list li {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.cab-list-label {
  font-size: var(--text-caps);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.cab-list-value {
  font-size: var(--text-base);
  color: var(--warm-black);
  overflow-wrap: anywhere;
}

.cab-list-note {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.cab-section-title + .cab-list {
  margin-top: 0.5rem;
}

.cab-section-title + .cab-text {
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.cab-empty-actions {
  margin-bottom: var(--space-lg);
}

.cab-logout {
  display: flex;
  justify-content: center;
  margin-top: var(--space-lg);
}

/* ============================================
   Планшет и десктоп
   ============================================ */

@media (min-width: 768px) {
  .cab-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .cab-actions > * {
    width: auto;
    flex: 0 0 auto;
    min-width: 12rem;
  }

  .cab-page .cab-title {
    margin-top: 1.5rem;
  }

  .cab-page .cab-head .cab-title,
  .cab-page .cab-watch-title {
    margin-top: 0;
  }

  /* На широком экране кнопка «Продолжить» справа, а не полосой во всю карточку */
  .cab-continue {
    grid-template-columns: 5.5rem 1fr auto;
    gap: 1.5rem;
    padding: 1rem 1.5rem 1rem 1rem;
  }

  .cab-continue .btn-primary {
    grid-column: auto;
    width: auto;
    min-width: 12rem;
  }

  .cab-locked,
  .cab-panel {
    padding: 1.75rem 2rem;
  }
}

/* Просмотр на десктопе: плеер слева, текст справа */
@media (min-width: 1024px) {
  .cab-wide .cab-header,
  .cab-wide .cab-page {
    max-width: calc(960px + 2 * var(--container-padding));
  }

  .cab-watch {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: var(--space-lg);
    align-items: start;
  }

  .cab-watch .cab-player {
    width: min(30rem, calc((100vh - 9rem) * 9 / 16));
    width: min(30rem, calc((100svh - 9rem) * 9 / 16));
    margin: 0.5rem 0 0;
  }

  .cab-watch-info {
    padding-top: 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .hero-fade {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .cab-body .btn-primary::before,
  .cab-row-arrow {
    transition: none;
  }
}

/* --- После оплаты: одна строка подтверждения (не плашка) --- */
.cab-paid {
  margin: 0 0 var(--space-md);
  padding-left: 0.75rem;
  border-left: 2px solid var(--gold);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: var(--warm-black);
}

.cab-inline-link {
  color: var(--warm-black);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}

/* «Чек» в строке покупки и ссылка в подписи: зона нажатия 44 px за счёт полей, высота строки не меняется */
.cab-list-note .cab-inline-link,
.cab-note a {
  display: inline-block;
  padding: 0.85rem 0.5rem;
  margin: -0.85rem -0.5rem;
}

/* --- Подпись под кнопками (страницы оплаты) --- */
.cab-note {
  margin-top: var(--space-md);
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-muted);
}

.cab-note a {
  color: var(--warm-black);
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
}

/* --- Чек (#/receipt/<id>): свой, вместо страницы Stripe. Всё по центру, суммы справа --- */
.cab-receipt {
  max-width: 26rem;
  margin: var(--space-sm) auto var(--space-md);
  padding: var(--space-lg) 1.25rem var(--space-md);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 2px;
  text-align: center;
}

.cab-receipt-brand {
  margin-bottom: var(--space-sm);
  font-size: var(--text-caps);
  font-weight: 600;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  color: var(--olive);
}

.cab-receipt-title {
  margin-bottom: 0.25rem;
}

.cab-receipt-meta {
  margin-bottom: var(--space-md);
  font-size: var(--text-xs);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--text-muted);
}

.cab-receipt-lines {
  margin-bottom: var(--space-md);
  border-top: 1px solid var(--border);
}

.cab-receipt-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  text-align: left;
}

.cab-receipt-line dd {
  flex: none;
  font-variant-numeric: lining-nums tabular-nums;
}

.cab-receipt-total {
  font-weight: 600;
  border-bottom-color: var(--gold);
}

.cab-receipt-note {
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.cab-receipt-note + .cab-receipt-note {
  margin-top: 0.5rem;
}

.cab-receipt-help .cab-inline-link {
  display: inline-block;
  padding: 0.85rem 0.25rem;
  margin: -0.85rem -0.25rem;
}

.cab-receipt-actions {
  max-width: 26rem;
  margin-inline: auto;
}

/* Печать и «Сохранить в PDF»: только сам чек */
@media print {
  .cab-header,
  .cab-back,
  .cab-receipt-actions {
    display: none !important;
  }

  .cab-body {
    background: #fff;
  }

  .cab-receipt {
    margin-top: 0;
    border: 0;
  }
}
