/* Базовые стили body будут определены позже после @font-face */

h1 {
  color: rgb(139, 0, 46);
}

p {
  font-size: 18px;
}
img {
  border: none;
  border-radius: 0;
  margin: 0;
  width: 1200px; /* Fixed width for the image */
  max-width: 100%; /* Ensure responsiveness */
  height: auto; /* Maintain aspect ratio */
  object-fit: cover; /* Заполняет пространство, сохраняя пропорции */
}

/* Адаптивные размеры для разных экранов */
@media (max-width: 1200px) {
  img {
    width: 100%;
    max-width: 1200px;
  }
}



section {
  margin: 40px auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 0 5px rgba(0,0,0,0.1);
  max-width: 1200px;
  width: 100%;
  box-sizing: border-box;
}

#topButton {
  position: fixed;
  bottom: 30px; /* default desktop offset */
  right: 30px;
  width: 56px;
  height: 56px;
  padding: 0;
  background-color: #000B2A; /* ergonomic color per request */
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  line-height: 56px;
  text-align: center;
  cursor: pointer;
  display: none; /* shown by script when needed */
  z-index: 1001; /* above nav */
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}

#topButton:hover {
  background-color: #09203b;
}

/* На мобильных экранах смещаем кнопку выше, чтобы она не пересекалась с бургер-кнопкой
   и не мешала содержимому. Делает кнопку компактной и эргономичной. */
@media (max-width: 768px) {
  #topButton {
    right: 16px;
    bottom: 92px; /* поднимем над бургером и возможным выпадающим меню */
    width: 56px;
    height: 56px;
    font-size: 18px;
    line-height: 56px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.22);
    display: none; /* visibility still controlled by script */
  }
}

@font-face {
  font-family: 'Noah';
  src: url('fonts/Noah-Bold.eot'); /* IE9 Compat Modes */
  src: url('fonts/Noah-Bold.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('fonts/Noah-Bold.woff2') format('woff2'), /* Super Modern Browsers */
       url('fonts/Noah-Bold.woff') format('woff'), /* Pretty Modern Browsers */
       url('fonts/Noah-Bold.ttf') format('truetype'); /* Safari, Android, iOS */
  font-weight: bold;
  font-style: normal;
  font-display: swap; /* Оптимизация загрузки шрифтов */
}

body {
  font-family: 'Noah', sans-serif;
  background-color: #f0f0f0;
  margin: 0;
  padding: 20px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}



.tab {
  padding: 24px 28px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 0 5px rgba(0,0,0,0.1);
  margin-top: 20px;
}

/* Дополнительные отступы для текстовых элементов, если они прилипают к краям */
.tab > p:not(.section-label),
.tab > h2,
.tab > h3,
.tab > h4 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.stream-card {
  background: linear-gradient(135deg, rgba(0, 11, 42, 0.08), rgba(0, 11, 42, 0.02));
  border: 1px solid rgba(0, 11, 42, 0.1);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-label {
  font-size: 1.15rem;
  font-weight: 700;
  color: #8b002e;
  margin: 0 0 16px;
}

/* Отступы для .section-label внутри .tab */
.tab > .section-label {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.preview-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 999px;
  background: #000B2A;
  color: #fff;
  border: none;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 11, 42, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.preview-toggle:active {
  transform: scale(0.96);
  box-shadow: 0 3px 10px rgba(0, 11, 42, 0.35);
}

.stream-status.offline {
  background: rgba(255, 99, 132, 0.08);
  border: 1px dashed rgba(255, 99, 132, 0.4);
  color: #850e38;
  padding: 16px;
  border-radius: 10px;
  font-size: 1rem;
  line-height: 1.6;
}

.stream-status.offline a {
  color: #631d60;
  font-weight: 600;
}

.stream-status.live {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stream-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.stream-player iframe,
.stream-player > div {
  width: 100%;
  height: 100%;
  display: block;
}

.stream-info {
  font-size: 0.95rem;
  color: #1f2933;
}

.stream-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  background: #000B2A;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s ease;
}

.stream-link:hover {
  opacity: 0.85;
}

.stream-link::after {
  content: '↗';
  font-size: 0.9em;
}

.stream-card [hidden] {
  display: none !important;
}

.pc-photo {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin: 16px auto;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
}

.theme-toggle {
  position: fixed;
  top: 22px;
  right: 22px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: #000B2A;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 11, 42, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  z-index: 220;
}

.theme-toggle:active {
  transform: scale(0.95);
  box-shadow: 0 3px 10px rgba(0, 11, 42, 0.45);
}

.theme-toggle::before {
  content: '☀';
}


/* База и сетка */
*{box-sizing:border-box}
html{font-size:16px}
/* body уже определен выше с font-family и другими стилями */

/* Контейнеры */
.container {
  width: 100%;
  max-width: 1200px; /* Consistent with image width */
  margin-inline: auto;
  padding-inline: 1rem;
}

/* Флюидная типографика и отступы */
:root{
  --space: clamp(0.75rem, 1vw + 0.25rem, 1.25rem);
  --fs-body: clamp(0.95rem, 0.5vw + 0.8rem, 1.1rem);
  --fs-h1: clamp(1.5rem, 4vw + 1rem, 3rem);
}
body{font-size:var(--fs-body)}
h1{font-size:var(--fs-h1);margin:0 0 var(--space)}

/* Картинки и видео */
img,video{max-width:100%;height:auto;display:block}

/* Таблицы, чтобы не ломали вёрстку */
.table-wrap{overflow:auto;-webkit-overflow-scrolling:touch}

/* Клики по ссылкам/кнопкам пальцем */
button, a{min-height:44px}

/* Стили для бургер-меню */
.burger {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: white;
}

/* На мобильных экранах */
@media (max-width: 768px) {
  .theme-toggle {
    top: 12px;
    right: 12px;
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #000B2A;
    padding: 0.5rem;
  }

  .burger {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 24px;
    padding: 0.5rem;
  }

  /* Меню выезжает снизу вверх: изначально смещено на 100% своей высоты вниз (вне экрана),
     при открытии переводится в translateY(0) и появляется над бургером. */
  #menu {
    position: fixed;
    /* Позиционируем меню над бургером (примерно) — при необходимости можно подогнать */
    bottom: 56px;
    left: 0;
    right: 0;
    background: #000B2A;
    padding: 1rem;
    display: flex;
    flex-direction: column-reverse; /* Разворачиваем порядок кнопок */
    gap: 0.5rem;
    max-height: 80vh; /* Максимальная высота 80% экрана */
    overflow-y: auto; /* Добавляем прокрутку если много пунктов */
    border-top: 2px solid rgba(255,255,255,0.1);
    /* Скрываем под экраном и делаем плавный переход */
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 280ms cubic-bezier(.2,.9,.2,1), opacity 180ms ease, visibility 0s linear 280ms;
  }

  /* Для мобильного скрываем меню через видимость/прозрачность, чтобы была плавная анимация.
     На десктопе правило ниже принудительно включает display:flex для удобства. */
  /* Вариант скрытого состояния через атрибут hidden — оставляем совместимость */
  #menu[hidden] {
    visibility: hidden;
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
    transition: transform 220ms ease, opacity 160ms ease, visibility 0s linear 220ms;
  }

  /* Класс, который выставляется скриптом при открытии меню — обеспечивает выезд снизу вверх */
  #menu.menu-open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    transition: transform 280ms cubic-bezier(.2,.9,.2,1), opacity 220ms ease;
  }

  #menu button {
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
    color: white;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 16px;
  }

  /* Добавляем отступ внизу страницы для бургер-меню */
  body {
    padding-bottom: 60px;
  }

  #menu button:hover {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* Container for main content */
.main-content {
  width: 1200px;
  max-width: 100%;
  margin: 0 auto;
  display: block;
}

/* Content styles */
h1, p, .tab, #tabs-container, #visit-counter {
  width: 1200px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 0;
  padding-right: 0;
}

/* Отступы для заголовков на странице */
h1, h2, h3, h4, h5, h6 {
  padding-left: 1rem;
  padding-right: 1rem;
}

/* Убираем отступы для заголовков внутри .tab (они используют padding контейнера) */
.tab h1,
.tab h2,
.tab h3,
.tab h4,
.tab h5,
.tab h6 {
  padding-left: 0;
  padding-right: 0;
}

.tab {
  margin-top: 20px;
}

/* На десктопе */
@media (min-width: 769px) {
  .nav {
    position: sticky;
    top: 0;
    padding: 0;
    background-color: #000B2A;
    z-index: 1000;
    border-radius: 0;
    width: 100%;
    margin: 0;
  }

  .burger {
    display: none !important;
  }

  #menu {
    position: static;
    display: flex !important;
    flex-direction: row;
    gap: 0.5rem;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: none;
  }

  #menu[hidden] {
    display: flex !important;
  }

  #menu button {
    color: white;
    background: transparent;
    border: none;
    padding: 1rem 0.9rem;
    border-radius: 0;
    width: auto;
  }

  #menu button:hover {
    background: rgba(255, 255, 255, 0.1);
  }
  
  /* Убираем отступ для десктопа */
  body {
    padding-bottom: 20px;
  }

  /* Set the button bar width to 1200px for desktop */
  .button-bar {
    width: 1200px; /* Matches the image width */
    max-width: 100%; /* Ensure responsiveness */
    margin: 0 auto; /* Centers the button bar */
  }

  /* Дропдаун "Работа с изображением и видео" (только десктоп) */
  #menu .menu-group {
    position: relative;
    display: flex;
    align-items: stretch;
  }

  #menu .has-submenu {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }

  #menu .submenu {
    position: absolute;
    top: 100%;
    left: 0;
    background: #000B2A;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    padding: 0.25rem 0;
    display: flex;
    flex-direction: column;
    min-width: 260px;
    z-index: 1200;
  }

  #menu .submenu[hidden] {
    display: none;
  }

  #menu .submenu button {
    width: 100%;
    text-align: left;
    padding: 0.6rem 1rem;
    border-radius: 0;
    font-size: 0.95rem;
    white-space: nowrap;
  }

  #menu .submenu button:hover {
    background: rgba(255, 255, 255, 0.12);
  }
}

.full-width-image {
  width: 100%;
  height: auto;
  border: none;
  border-radius: 0;
}

/* Стили для шакализатора */
.controls-container {
  width: calc(50% - 30px);
  max-width: 600px;
  padding-right: 20px;
}

.preview-container {
  position: fixed;
  left: 50%;
  width: calc(50% - 30px);
  max-width: 800px;
  background: #fff;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  transition: all 0.3s ease-in-out;
  height: auto;
}

.preview-wrap {
  width: 100%;
  margin-bottom: 10px;
}

.preview-wrap canvas {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid #eee;
}

/* Мобильная версия */
@media (max-width: 1024px) {
  .controls-container {
    width: 100%;
    max-width: none;
    padding-right: 0;
    margin-bottom: 350px; /* Место для плавающего превью */
  }

  /* На мобильных примагничиваем окно предпросмотра к верху страницы.
     Его высота ограничиваем (по умолчанию) так, чтобы надпись-нота была видна.
     Точная высота будет подстраиваться через JS (измеряется высота .note). */
  .preview-container {
    position: fixed;
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-width: none;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 0 0 12px 12px; /* закругление снизу */
    padding: 12px 15px;
    transition: transform 0.2s ease-in-out, max-height 180ms ease;
    overflow: hidden; /* содержимое прокручивается внутри .preview-wrap */
    z-index: 100;
    max-height: calc(100vh - 48px); /* fallback — оставляем место для примечания */
  }

  .preview-wrap {
    /* Высота превью ограничивается контейнером .preview-container. */
    max-height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .preview-wrap canvas {
    max-height: 280px;
    object-fit: contain;
    margin: 0 auto;
    max-width: 600px;
  }

  .preview-container.hidden {
    transform: translateY(100%);
  }

  #section6.tab.active .preview-toggle {
    display: inline-flex;
    position: fixed;
    left: 16px;
    right: auto;
    bottom: 160px;
    z-index: 200;
  }

  #section6 .preview-container[hidden] {
    display: none !important;
  }
}

/* Стили для панели управления шакализатора */
.control {
  margin-bottom: 15px;
}

.control label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

.control input[type="range"] {
  width: 100%;
}

.value {
  float: right;
  font-weight: normal;
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.actions button {
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  min-width: 120px;
  color: #000B2A;
  font-weight: 600;
}

.actions button.primary {
  background: #000B2A;
  color: #fff;
  border-color: #000B2A;
}

.actions button:hover {
  opacity: 0.9;
}

.actions button:disabled {
  opacity: 0.65;
  cursor: default;
}
.presets {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.pill {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #000B2A;
  background: transparent;
  color: #000B2A;
  cursor: pointer;
  transition: all 0.2s;
}

.pill:hover {
  background: #000B2A;
  color: white;
}

/* Добавляем анимации */
.preview-container {
  transition: all 0.3s ease-in-out;
}

@media (max-width: 768px) {
  .preview-container {
    transition: transform 0.3s ease-in-out;
  }
  
  .preview-container.hidden {
    transform: translateY(100%);
  }
}

/* Тёмный режим */
body.dark-mode {
  background: #000B2A;
  color: #fff;
}

body.dark-mode h1,
body.dark-mode h2,
body.dark-mode p,
body.dark-mode label,
body.dark-mode small,
body.dark-mode .section-label,
body.dark-mode .actions button,
body.dark-mode .actions button.primary,
body.dark-mode .controls-container .panel h2,
body.dark-mode .value,
body.dark-mode .switch,
body.dark-mode .pill,
body.dark-mode .stream-info {
  color: #fff;
}

body.dark-mode a {
  color: #d6efff;
}

body.dark-mode .tab {
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 14px rgba(0,0,0,0.45);
}

body.dark-mode .section-label {
  color: #fff;
}

body.dark-mode .stream-card {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.18);
}

body.dark-mode .stream-status.offline {
  background: rgba(255, 99, 132, 0.22);
  border-color: rgba(255, 99, 132, 0.45);
  color: #fff;
}

body.dark-mode .stream-status.offline a {
  color: #fff;
}

body.dark-mode .stream-player {
  background: #000B2A;
}

body.dark-mode .stream-link {
  background: transparent;
  border: 1px solid #fff;
  color: #fff;
}

body.dark-mode .preview-container {
  background: rgba(0, 11, 42, 0.92);
  color: #fff;
}

body.dark-mode .controls-container .panel {
  background: rgba(0, 11, 42, 0.85);
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}

body.dark-mode .actions button {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.28);
  color: #fff;
}

body.dark-mode .actions button.primary {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.28);
  color: #fff;
}

body.dark-mode .pill {
  border-color: rgba(255,255,255,0.6);
  background: transparent;
}

body.dark-mode .pill:hover {
  background: rgba(255,255,255,0.2);
}

body.dark-mode #topButton {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

body.dark-mode #topButton:hover {
  background: rgba(255,255,255,0.32);
}

body.dark-mode .pc-photo {
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
}

body.dark-mode .theme-toggle {
  background: #13204a;
  color: #fff;
}

body.dark-mode .theme-toggle::before {
  content: '☽';
}

