/* ═══════════════════════════════════════════════════════════════════════════
   ytserv.ru — общие стили для всех страниц
   Подключать: <link rel="stylesheet" href="/styles.css">
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Дизайн-токены ─────────────────────────────────────────────────────────── */
:root {
  /* Нейтральная шкала (off-white → off-black) */
  --n-0:   #f8f9fb;
  --n-1:   #f0f2f5;
  --n-2:   #e2e5ea;
  --n-3:   #c8cdd6;
  --n-4:   #8b93a8;
  --n-5:   #4b5263;
  --n-6:   #2a2f3d;
  --n-7:   #1a1d27;
  --n-8:   #111318;

  /* Акцент — синий */
  --accent:      #2563eb;
  --accent-h:    #1d4fd8;
  --accent-soft: rgba(37,99,235,.12);
  --accent-text: #ffffff;

  /* Семантические роли — светлая тема */
  --bg:          var(--n-0);
  --surface:     #ffffff;
  --surface-2:   var(--n-1);
  --border:      var(--n-2);
  --text:        var(--n-8);
  --text-muted:  var(--n-4);
  --text-subtle: var(--n-3);

  /* Статусные цвета */
  --success:      #16a34a;
  --success-bg:   #f0fdf4;
  --success-brd:  #bbf7d0;
  --success-text: #14532d;

  --danger:      #dc2626;
  --danger-bg:   #fef2f2;
  --danger-brd:  #fecaca;
  --danger-text: #991b1b;

  --info-bg:   #eff6ff;
  --info-brd:  #bfdbfe;
  --info-text: #1e40af;

  --warning-bg:   #fffbeb;
  --warning-brd:  #fde68a;
  --warning-text: #92400e;

  /* Типографика */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code',
               ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Масштаб текста */
  --text-xs:  0.75rem;    /* 12px */
  --text-sm:  0.875rem;   /* 14px */
  --text-md:  1rem;       /* 16px */
  --text-lg:  1.125rem;   /* 18px */
  --text-xl:  1.25rem;    /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: clamp(1.6rem, 4vw, 2.4rem);

  /* Радиусы (три значения) */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;

  /* Тени */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.06);

  /* Анимация */
  --ease: cubic-bezier(.4,0,.2,1);
  --duration: 160ms;
  --transition: var(--duration) var(--ease);
}

/* ── Тёмная тема ────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:         var(--n-8);
    --surface:    var(--n-7);
    --surface-2:  var(--n-6);
    --border:     #2d3147;
    --text:       #f0f2f8;
    --text-muted: #8b93a8;
    --text-subtle:#4b5263;

    --accent:     #3b82f6;
    --accent-h:   #2563eb;
    --accent-soft:rgba(59,130,246,.15);

    --success-bg:   #0f291e;
    --success-brd:  #166534;
    --success-text: #86efac;

    --danger-bg:   #2d1515;
    --danger-brd:  #7f1d1d;
    --danger-text: #fca5a5;

    --info-bg:   #1a2540;
    --info-brd:  #1e3a6e;
    --info-text: #93c5fd;

    --warning-bg:   #281e08;
    --warning-brd:  #78350f;
    --warning-text: #fcd34d;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
  }
}

/* ── Reset & Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* ── Шапка ──────────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.logo {
  font-weight: 700;
  font-size: var(--text-xl);
  color: var(--accent);
  letter-spacing: -.5px;
  white-space: nowrap;
}
.logo span { color: var(--text); }
.logo:hover { text-decoration: none; }

/* Партнёрская ссылка в шапке */
.header-partner {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  transition: border-color var(--transition), color var(--transition),
              background var(--transition);
  white-space: nowrap;
}
.header-partner:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

/* ── Основной контейнер ─────────────────────────────────────────────────────── */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 80px;
}

/* ── Hero ───────────────────────────────────────────────────────────────────── */
.hero {
  text-align: center;
  margin-bottom: 36px;
}
.hero h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: 10px;
}
.hero p {
  color: var(--text-muted);
  font-size: var(--text-lg);
  max-width: 480px;
  margin: 0 auto;
}

/* ── Карточка ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-md);
}

/* ── Строка ввода ───────────────────────────────────────────────────────────── */
.input-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.url-input {
  flex: 1;
  height: 52px;
  padding: 0 16px;
  font-size: var(--text-md);
  font-family: var(--font-sans);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.url-input::placeholder { color: var(--text-muted); }
.url-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.url-input:disabled { opacity: .6; cursor: not-allowed; }

/* ── Кнопки ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  border: none;
  cursor: pointer;
  border-radius: var(--r-md);
  transition: background var(--transition), transform var(--transition),
              opacity var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn:active { transform: scale(.97); }
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

/* Основная кнопка */
.btn-primary {
  height: 52px;
  padding: 0 22px;
  font-size: var(--text-md);
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

/* Маленькая кнопка скачивания */
.btn-download {
  height: 38px;
  padding: 0 16px;
  font-size: var(--text-sm);
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--r-sm);
}
.btn-download:hover:not(:disabled) {
  background: var(--accent-h);
  text-decoration: none;
}

/* Спиннер внутри кнопки */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
  flex-shrink: 0;
}
.btn.loading .spinner   { display: block; }
.btn.loading .btn-text  { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Строка опций ───────────────────────────────────────────────────────────── */
.options-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.options-row label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.select-quality {
  height: 36px;
  padding: 0 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.select-quality:focus { border-color: var(--accent); }

/* ── Панель статуса ─────────────────────────────────────────────────────────── */
.panel {
  margin-top: 20px;
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-size: var(--text-sm);
  display: none;
}
.panel.visible  { display: block; }
.panel.info     { background: var(--info-bg);    border: 1px solid var(--info-brd);    color: var(--info-text);    }
.panel.error    { background: var(--danger-bg);  border: 1px solid var(--danger-brd);  color: var(--danger-text);  }
.panel.success  { background: var(--success-bg); border: 1px solid var(--success-brd); color: var(--success-text); }
.panel.warning  { background: var(--warning-bg); border: 1px solid var(--warning-brd); color: var(--warning-text); }
.panel-title    { font-weight: 600; margin-bottom: 4px; }

/* ── Прогресс-бар ───────────────────────────────────────────────────────────── */
.progress-wrap { margin-top: 12px; display: none; }
.progress-wrap.visible { display: block; }

.progress-bar-bg {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  width: 0%;
  transition: width .3s ease;
}
.progress-bar.indeterminate {
  width: 40%;
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0%   { transform: translateX(-150%); }
  100% { transform: translateX(350%); }
}
.progress-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Инфо о видео ───────────────────────────────────────────────────────────── */
.video-info         { display: none; margin-top: 20px; gap: 14px; }
.video-info.visible { display: flex; }

.thumb {
  width: 140px;
  min-width: 140px;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.thumb-placeholder {
  width: 140px;
  min-width: 140px;
  aspect-ratio: 16/9;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 2rem;
}
.video-meta   { flex: 1; min-width: 0; }
.video-title  {
  font-weight: 600;
  font-size: var(--text-sm);
  margin-bottom: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.video-sub { font-size: var(--text-xs); color: var(--text-muted); margin-bottom: 10px; }

/* ── Блок поддерживаемых сайтов ─────────────────────────────────────────────── */
.sites-section { margin-top: 48px; }
.sites-section h2 {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.sites-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.site-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition),
              color var(--transition), background var(--transition);
  text-decoration: none;
  cursor: pointer;
}
.site-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
  text-decoration: none;
}
.site-icon { font-size: 1rem; line-height: 1; }

/* ── FAQ блок ───────────────────────────────────────────────────────────────── */
.faq-section { margin-top: 56px; }
.faq-section h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -.3px;
}

.faq-item {
  border-bottom: 1px solid var(--border);
}
.faq-question {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text);
  padding: 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  line-height: 1.4;
  transition: color var(--transition);
}
.faq-question:hover { color: var(--accent); }
.faq-question:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.faq-arrow {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform var(--transition);
}
.faq-item.open .faq-arrow { transform: rotate(180deg); }

.faq-answer {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.6;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s var(--ease), padding .3s var(--ease);
  padding-bottom: 0;
}
.faq-item.open .faq-answer {
  max-height: 400px;
  padding-bottom: 16px;
}

/* ── Рекламный блок ─────────────────────────────────────────────────────────── */
.ad-slot {
  margin: 32px 0;
  min-height: 90px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  font-size: var(--text-xs);
}

/* Баннер-ожидание (показывается пока идёт скачивание) */
.ad-waiting {
  display: none;
  margin-top: 20px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-align: center;
}
.ad-waiting.visible { display: block; }
.ad-waiting-title {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 12px;
}
.ad-timer {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  margin-top: 8px;
}

/* ── Подвал ─────────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: var(--text-sm);
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ── Утилиты ────────────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Адаптив ─────────────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .site-header { padding: 0 16px; }
  .header-partner span { display: none; } /* скрыть текст, оставить эмодзи */

  main { padding: 32px 12px 64px; }

  .input-row { flex-direction: column; }
  .btn-primary { width: 100%; }

  .video-info.visible { flex-direction: column; }
  .thumb, .thumb-placeholder {
    width: 100%;
    min-width: unset;
  }

  .card { padding: 20px 16px; }
}

/* ── Доступность: нет анимации ───────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
  }
}
