/* ==========================================================================
   Sahel Sounds — стили лонгрида
   1. Переменные
   2. Сброс и база
   3. Шапка и подвал
   4. Раскладка страницы
   5. Оглавление
   6. Статья: текст
   7. Статья: фото и подписи
   8. Видео (YouTube)
   9. Ссылки «Где слушать»
   10. Мобильное меню
   11. Адаптив: планшет
   12. Адаптив: телефон
   ========================================================================== */


/* 1. Переменные
   ========================================================================== */

:root {
  /* Цвета */
  --color-bg: #faf8f4;
  --color-ink: #141414;
  --color-gray: #82817f;
  --color-accent: #446df6;
  --color-frame-blue: #30438e;
  --color-frame-pink: #b81d9f;

  /* Шрифт */
  --font: 'Onest', system-ui, sans-serif;

  /* Размеры */
  --page-max: 1440px;
  --gutter: 80px;
  --toc-width: 240px;
  --article-width: 680px;
  --radius: 12px;

  /* Отступы */
  --gap-sections: 60px;
  --gap-block: 32px;
  --gap-figure: 20px;
  --gap-heading: 16px;

  /* Шапка */
  --header-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  --header-offset: 80px; /* отступ от верха для липкого оглавления и якорей */
}


/* 2. Сброс и база
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}


/* 3. Шапка и подвал
   ========================================================================== */

/* Шапка зафиксирована сверху. После начала прокрутки (класс .is-scrolled
   ставит js/header.js) она становится ниже и получает тень */
.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 20;
  background: var(--color-bg);
  transition: box-shadow 0.25s ease;
}

.site-header .bar {
  transition: padding 0.25s ease;
}

.site-header.is-scrolled {
  box-shadow: var(--header-shadow);
}

.site-header.is-scrolled .bar {
  padding-top: 12px;
  padding-bottom: 12px;
}

.bar {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 32px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  display: block;
  color: var(--color-ink);
}

.logo-svg {
  display: block;
  width: 81px;
  height: 24px;
}

.socials {
  display: flex;
  align-items: center;
  gap: 16px;
}

.socials a {
  display: block;
  width: 28px;
  height: 28px;
  color: var(--color-gray);
  transition: color 0.2s;
}

.socials a:hover {
  color: var(--color-ink);
}

/* Правая часть шапки: язык, соцсети, кнопка меню */
.header-end {
  display: flex;
  align-items: center;
  gap: 32px;
}

/* Переключатель языка: кнопка-пилюля и выпадающий список */
.lang {
  position: relative;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 5px 3px 11px; /* 4/6/12 по макету минус 1px обводки */
  border: 1px solid var(--color-ink);
  border-radius: 1000px;
  background: none;
  color: var(--color-ink);
  font: 600 16px/20px var(--font);
  cursor: pointer;
}

.lang-chevron {
  display: block;
  transition: transform 0.2s ease;
}

.lang-btn[aria-expanded="true"] .lang-chevron {
  transform: rotate(180deg);
}

.lang-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--color-bg);
  border-radius: 12px;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.08);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.lang.is-open .lang-list {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.lang-list li {
  margin: 0;
  padding: 0;
}

.lang-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 4px;
  color: var(--color-ink);
  font: 600 16px/20px var(--font);
  text-decoration: none;
  transition: background-color 0.15s;
}

.lang-list li:first-child a {
  border-radius: 8px 8px 4px 4px;
}

.lang-list li:last-child a {
  border-radius: 4px 4px 8px 8px;
}

.lang-list a[aria-current] {
  padding-right: 4px;
}

.lang-list a:hover,
.lang-list a:focus-visible {
  background: #f2ede2;
  outline: none;
}

.lang-check {
  display: block;
}

/* Иконки встроены через <svg>, цвет берут из color (fill="currentColor") */
.icon {
  display: block;
  width: 28px;
  height: 28px;
}

.mail {
  font-size: 20px;
  line-height: 1.4;
  color: var(--color-gray);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-position: from-font;
  transition: color 0.2s, text-decoration-color 0.2s;
}

/* Подчёркивание появляется при наведении (на телефоне видно всегда, см. раздел 12) */
.mail:hover,
.mail:focus-visible {
  color: var(--color-ink);
  text-decoration-color: currentColor;
}


/* 4. Раскладка страницы
   ========================================================================== */

.layout {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 228px var(--gutter) 108px; /* 92px шапка + 136px воздуха */
  display: flex;
  align-items: flex-start;
  gap: 60px;
}


/* 5. Оглавление (липкое, с подсветкой текущего раздела)
   ========================================================================== */

.toc {
  position: sticky;
  top: var(--header-offset);
  flex: 0 0 var(--toc-width);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toc-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.28;
  text-transform: uppercase;
  color: var(--color-gray);
}

.toc ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toc a {
  display: flex;
  align-items: stretch;
  gap: 8px;
  font-size: 16px;
  line-height: 1.28;
  color: var(--color-gray);
  text-decoration: none;
  transition: color 0.2s;
}

/* Полоска слева от пункта */
.toc a::before {
  content: "";
  flex: 0 0 2px;
  background: transparent;
  transition: background 0.2s;
}

.toc a:hover {
  color: var(--color-ink);
}

.toc a.active {
  font-weight: 600;
  color: var(--color-ink);
}

.toc a.active::before {
  background: var(--color-accent);
}


/* 6. Статья: текст
   ========================================================================== */

article {
  flex: 0 1 var(--article-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sections);
}

.intro {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

h1 {
  font-size: 44px;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.lead {
  font-size: 20px;
  line-height: 1.4;
  color: var(--color-gray);
}

section {
  display: flex;
  flex-direction: column;
  gap: var(--gap-heading);
  scroll-margin-top: var(--header-offset);
}

h2 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.16;
  letter-spacing: -0.01em;
}

.text p {
  font-size: 20px;
  line-height: 1.4;
}

.text p + p {
  margin-top: 12px;
}

/* Группы «текст + фото» внутри раздела */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap-figure);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--gap-block);
}


/* 7. Статья: фото и подписи
   ========================================================================== */

figure {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

figcaption {
  font-size: 16px;
  line-height: 1.28;
  color: var(--color-gray);
  text-align: center;
}

/* Два фото рядом */
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.pair img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
}

/* Одно широкое фото */
.wide img {
  width: 100%;
  aspect-ratio: 680 / 298;
  object-fit: cover;
  border-radius: var(--radius);
}

/* Рамки у обложек */
.framed {
  /* 2px, а не 1.5px как в макете: браузеры округляют 1.5px до 1px,
     и на светлых обложках рамка почти пропадает */
  border: 2px solid var(--color-gray);
}

.frame-blue {
  border: 4px solid var(--color-frame-blue);
}

.frame-pink {
  border: 4px solid var(--color-frame-pink);
}

/* Кадрирование отдельных фото */
.pos-balani {
  object-position: 65% center;
}

.pos-mdou-band {
  object-position: center 22%;
}

.pos-top {
  object-position: center top;
}


/* 8. Видео (YouTube)
   Превью с кнопкой, плеер грузится только по клику
   ========================================================================== */

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--color-ink);
}

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

.video-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  cursor: pointer;
  background: var(--color-ink);
}

.video-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
  transition: opacity 0.2s;
}

.video-poster:hover img {
  opacity: 1;
}

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 14px;
  background: rgba(20, 20, 20, 0.8);
  transition: background 0.2s;
}

.video-play::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 52%;
  transform: translate(-50%, -50%);
  border-style: solid;
  border-width: 10px 0 10px 17px;
  border-color: transparent transparent transparent #fff;
}

.video-poster:hover .video-play {
  background: var(--color-accent);
}

.video-time {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 14px;
  color: #fff;
  background: rgba(20, 20, 20, 0.8);
}

/* Пустое место под видео, пока не вставлен ID */
.video-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 1.5px dashed var(--color-gray);
  border-radius: var(--radius);
  font-size: 16px;
  color: var(--color-gray);
  text-align: center;
  background: var(--color-bg);
}

/* Группа из трёх видео в «Детективе» */
.video-group-title + figure {
  margin-top: 0;
}

.video-group {
  display: flex;
  flex-direction: column;
  gap: var(--gap-figure);
}

.video-group-title {
  /* До первого видео ровно 12px: компенсируем gap группы */
  margin-bottom: calc(12px - var(--gap-figure));
  font-size: 16px;
  font-weight: 600;
  line-height: 1.28;
  text-transform: uppercase;
  color: var(--color-gray);
}


/* 9. Ссылки «Где слушать»
   ========================================================================== */

.links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.links a {
  font-size: 20px;
  line-height: 1.4;
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-position: from-font;
  transition: text-decoration-color 0.2s;
}

/* Подчёркивание появляется только при наведении */
.links a:hover,
.links a:focus-visible {
  text-decoration-color: currentColor;
}


/* 10. Мобильное меню
   Кнопка и панель с содержанием видны только на узких экранах
   ========================================================================== */

.menu-btn {
  display: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-ink);
  cursor: pointer;
}

.menu-btn svg {
  display: block;
}

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 96px 16px 32px; /* 56px шапка + 40px */
  overflow-y: auto;
  background: var(--color-bg);

  /* Закрытое состояние: прозрачное и чуть выше */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-12px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0s linear 0.25s;
}

.mobile-menu.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    visibility 0s;
}

.mobile-menu .toc-title {
  margin-bottom: 24px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.28;
  text-transform: uppercase;
  color: var(--color-gray);
}

.mobile-menu ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Пункты появляются по очереди: задержку задаёт --i из js/menu.js */
.mobile-menu li,
.mobile-menu .toc-title,
.menu-socials {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.mobile-menu.is-open li,
.mobile-menu.is-open .toc-title,
.mobile-menu.is-open .menu-socials {
  opacity: 1;
  transform: none;
  transition-delay: calc(var(--i, 0) * 25ms + 60ms);
}

.mobile-menu ol a {
  display: flex;
  align-items: stretch;
  gap: 8px;
  font-size: 16px;
  line-height: 1.48;
  color: var(--color-gray);
  text-decoration: none;
}

.mobile-menu ol a::before {
  content: "";
  flex: 0 0 2px;
  background: transparent;
}

.mobile-menu ol a.active {
  font-weight: 600;
  color: var(--color-ink);
}

.mobile-menu ol a.active::before {
  background: var(--color-accent);
}

/* Соцсети прижаты к низу меню */
.menu-socials {
  align-self: center;
  margin-top: auto;
  padding-top: 40px;
  gap: 20px;
}

.menu-socials a,
.menu-socials .icon {
  width: 24px;
  height: 24px;
}

/* Кнопка: бургер и крестик плавно сменяют друг друга */
.menu-btn {
  position: relative;
}

.menu-btn svg {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.menu-btn .icon-close {
  position: absolute;
  inset: 0;
}

.menu-btn .icon-close,
.menu-btn[aria-expanded="true"] .icon-menu {
  opacity: 0;
  transform: rotate(-90deg);
}

.menu-btn[aria-expanded="true"] .icon-close {
  opacity: 1;
  transform: none;
}

/* Пока меню открыто, страница под ним не прокручивается */
body.menu-open {
  overflow: hidden;
}

/* Меню нужно только на узких экранах */
@media (min-width: 1061px) {
  .mobile-menu {
    display: none;
  }
}

/* Если в системе выключена анимация — меню появляется без движения */
@media (prefers-reduced-motion: reduce) {
  .mobile-menu,
  .mobile-menu li,
  .mobile-menu .toc-title,
  .menu-socials,
  .menu-btn svg {
    transition: none;
    transform: none;
  }
}


/* 11. Адаптив: планшет (до 1060px)
   Боковое оглавление прячется, вместо соцсетей в шапке — кнопка меню
   ========================================================================== */

@media (max-width: 1060px) {
  :root {
    --gutter: 24px;
    --header-offset: 88px;
  }

  /* На планшете и телефоне шапка всегда низкая, тень — только при прокрутке */
  .site-header .bar,
  .site-header.is-scrolled .bar {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .site-header .socials {
    display: none;
  }

  .header-end {
    gap: 16px;
  }

  .menu-btn {
    display: block;
  }

  .layout {
    padding-top: 136px; /* 56px шапка + 80px воздуха */
    padding-bottom: 40px;
  }

  .toc {
    display: none;
  }

  article {
    flex-basis: auto;
    max-width: var(--article-width);
    margin: 0 auto;
  }

}


/* 12. Адаптив: телефон (до 600px), по макету Mobile 360
   ========================================================================== */

@media (max-width: 600px) {
  :root {
    --gutter: 16px;
    --radius: 8px;
    --gap-sections: 40px;
    --gap-block: 24px;
    --gap-figure: 16px;
    --gap-heading: 8px;
  }

  .logo-svg {
    width: 67.5px;
    height: 20px;
  }

  /* Текст */
  .intro {
    gap: 16px;
  }

  h1 {
    font-size: 28px;
    line-height: 1.12;
    letter-spacing: -0.01em;
  }

  .lead {
    font-size: 16px;
    line-height: 1.48;
  }

  h2 {
    font-size: 24px;
    line-height: 1.16;
    letter-spacing: 0;
  }

  .text p {
    font-size: 16px;
    line-height: 1.48;
  }

  .text p + p {
    margin-top: 8px;
  }

  /* Фото: пары остаются в два столбца, но плотнее */
  .pair {
    gap: 8px;
  }

  .wide img {
    aspect-ratio: 328 / 144;
  }

  figcaption {
    font-size: 14px;
  }

  .frame-blue,
  .frame-pink {
    border-width: 3px;
  }

  /* Видео */
  .video-play {
    width: 56px;
    height: 40px;
    border-radius: 12px;
  }

  .video-group-title {
    font-size: 14px;
  }

  /* Ссылки «Где слушать» и почта: на телефоне подчёркнуты сразу */
  .links a {
    font-size: 16px;
    line-height: 1.48;
    text-decoration-color: currentColor;
  }

  .mail {
    font-size: 16px;
    text-decoration-color: currentColor;
  }

  /* Подвал: почта и иконки по центру, в столбик */
  footer.bar {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding-top: 32px;
    padding-bottom: 32px;
  }

  footer .socials {
    gap: 20px;
  }

  footer .socials a,
  footer .icon {
    width: 24px;
    height: 24px;
  }
}
