/* ============================================================
   СОЦИАРХИЯ · мобильная версия v17
   Заменяет mobile-v16.css. Подключается последним на всех 4 страницах.
   Правки Евгения Бычковского (21.09.2026):
     1. гранату перенести наверх;
     2. «СОЦИАРХИЯ» — целиком в одну строку;
     3. кнопки не разрывают текст, стоят внизу — на каждой странице.
   Десктоп (>600px) не затрагивается.
   ============================================================ */

@media (max-width: 600px) {

  html, body { max-width: 100% !important; overflow-x: clip !important; }

  /* ---------- 1. ОБЛОЖКА: ГРАНАТА НАВЕРХУ ---------- */

  .hero { min-height: auto !important; padding: 10px 0 56px !important; }
  .hero > .wrap { width: 100% !important; padding: 0 18px !important; }

  /* декоративные слои, которые на телефоне ложились под текст */
  .hero .hero-network-shield,
  .hero .hero-consciousness-backdrop { display: none !important; }
  .hero::after { content: none !important; display: none !important; }

  /* граната выходит из абсолютного позиционирования в поток —
     и встаёт первым блоком, над заголовком */
  .hero .hero-grenade-permanent {
    position: static !important;
    display: block !important;
    width: min(62vw, 240px) !important;
    height: auto !important;
    max-height: 34vh !important;
    margin: 0 auto 6px !important;
    transform: none !important;
    object-fit: contain !important;
    opacity: 1 !important;
    filter: none !important;
  }

  /* ---------- 2. «СОЦИАРХИЯ» В ОДНУ СТРОКУ ---------- */

  .hero .kicker { font-size: 10px !important; line-height: 1.5 !important; margin-bottom: 10px !important; }

  .hero h1 {
    max-width: 100% !important;
    font-size: clamp(34px, 12.4vw, 54px) !important;
    line-height: .95 !important;
    letter-spacing: -.045em !important;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: keep-all !important;
    margin-bottom: 10px !important;
  }

  .hero-etymology, .hero-def, p[data-creed], .hero .wrap .hero-counter-bottom {
    max-width: 100% !important; padding-left: 0 !important; margin-left: 0 !important;
  }
  .hero-def, p[data-creed] { font-size: 17px !important; line-height: 1.55 !important; margin-top: 26px !important; }
  .hero-etymology { gap: 4px !important; }

  /* ---------- 3. КНОПКИ — ВНИЗУ, НЕ ПОВЕРХ ТЕКСТА ---------- */

  /* главная: CTA на всю ширину, в конце своего блока */
  .hero .wrap .hero-tail,
  .hero .wrap .hero-tail .hero-counter-bottom,
  .hero .wrap .hero-tail .hero-idea-cta, .hero-idea-cta {
    width: 100% !important; max-width: 100% !important; margin-left: 0 !important;
  }
  .cta-row, .gate-row, .krug-actions, .hero .actions, .dissertation-actions {
    display: grid !important; grid-template-columns: 1fr !important; gap: 10px !important;
    width: 100% !important; max-width: 100% !important;
  }
  .cta-row .btn, .gate-row .btn, .gate-row .gate-plain, .krug-actions .btn,
  .hero .actions .btn, .dissertation-actions .btn, .hero-idea-cta .btn.btn-primary {
    width: 100% !important; min-width: 0 !important; max-width: 100% !important;
    padding: 14px 16px !important; font-size: 16px !important;
    white-space: normal !important; text-align: center !important;
  }

  /* плавающие джойстики/рельсы закрывали текст — убираем,
     навигация уходит в нижнюю панель */
  .nav-joystick, .reader-rail, .reader-joystick, .reader-to-top, .to-top { display: none !important; }

  /* ---------- ЧИТАЛКИ: узкая верхняя строка + нижняя панель ---------- */

  header.top {
    /* backdrop-filter делает шапку containing block для position:fixed —
       без этого кнопки «прилипают» к шапке вместо низа экрана */
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    filter: none !important; transform: none !important;
    /* без блюра фон должен быть непрозрачным, иначе текст просвечивает */
    background-color: var(--bg, #09090b) !important;
    position: sticky !important; top: 0 !important;
    height: auto !important; min-height: 48px !important;
    padding: 6px 12px !important;
    display: flex !important; flex-wrap: nowrap !important;
    align-items: center !important; justify-content: space-between !important;
    gap: 10px !important; z-index: 60 !important;
  }
  header.top > a {
    font-size: 12px !important; white-space: nowrap !important;
    min-height: 36px !important; display: flex !important; align-items: center !important;
  }
  header.top > strong {
    display: block !important; margin: 0 !important; text-align: right !important;
    font-size: 13px !important; line-height: 1.15 !important; letter-spacing: .06em !important;
    white-space: nowrap !important; max-width: 56vw !important;
    overflow: hidden !important; text-overflow: ellipsis !important;
  }
  .reader-title-version { display: none !important; }

  /* фон нижней панели (fixed-псевдоэлемент считается от вьюпорта) */
  header.top::after {
    content: "" !important; position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important;
    height: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
    background: var(--panel, #121216) !important;
    border-top: 1px solid var(--line, rgba(240, 236, 230, .16)) !important;
    z-index: 90 !important; pointer-events: none !important;
  }

  /* левая кнопка панели: «Содержание» (reader.html) */
  header.top .toc-toggle,
  /* или select с оглавлением (страницы диссертации) */
  header.top .mobile-toc[aria-label="Оглавление"] {
    position: fixed !important;
    left: 10px !important;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    width: 112px !important; max-width: 34vw !important; min-width: 0 !important;
    height: 42px !important; margin: 0 !important;
    padding: 0 10px !important; font-size: 13px !important;
    text-align: left !important; z-index: 95 !important;
    display: block !important;
  }
  /* в reader.html дублирующий select не нужен */
  header.top .mobile-toc[aria-label="Выбрать главу"] { display: none !important; }

  /* правая группа панели: тема, режим, размер текста */
  header.top .controls {
    position: fixed !important;
    right: 10px !important;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    display: flex !important; flex-wrap: nowrap !important;
    justify-content: flex-end !important; align-items: center !important;
    gap: 5px !important; margin: 0 !important; min-width: 0 !important;
    z-index: 95 !important;
  }
  header.top .controls button {
    width: 40px !important; min-width: 40px !important; height: 42px !important;
    padding: 0 !important; font-size: 15px !important; line-height: 1 !important;
  }
  header.top .controls .mode-toggle {
    width: auto !important; min-width: 0 !important; padding: 0 7px !important;
    font-size: 10px !important; letter-spacing: .02em !important;
  }
  .mode-label { display: inline !important; }

  /* текст не должен прятаться под нижней панелью */
  .layout { display: block !important; min-height: auto !important; }
  main, body.continuous main {
    padding: 26px 18px calc(118px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .chapter, .front, .dissertation-article, .book-frontmatter {
    font-size: 18px !important; line-height: 1.7 !important;
  }
  .chapter h2, body.continuous .chapter h2, .front h1, .chapter h1 {
    font-size: clamp(26px, 8.6vw, 34px) !important; line-height: 1.12 !important;
    overflow-wrap: anywhere !important;
  }

  /* «Предыдущая / Следующая» — в столбик, на всю ширину, над панелью */
  .bottom-nav {
    display: grid !important; grid-template-columns: 1fr !important;
    gap: 10px !important; max-width: 100% !important; margin: 44px 0 8px !important;
  }
  .bottom-nav button { width: 100% !important; min-height: 48px !important; }

  /* панель оглавления поверх нижней панели */
  #reader-contents.is-open { z-index: 120 !important; }
  .toc-backdrop { z-index: 110 !important; }
}

/* ---------- узкие телефоны ---------- */
@media (max-width: 360px) {
  .hero h1 { font-size: clamp(30px, 12vw, 42px) !important; }
  .hero .hero-grenade-permanent { width: min(58vw, 200px) !important; max-height: 28vh !important; }

  header.top { padding: 6px 8px !important; }
  header.top > strong { max-width: 52vw !important; font-size: 12px !important; }
  header.top .toc-toggle,
  header.top .mobile-toc[aria-label="Оглавление"] {
    left: 8px !important; width: 118px !important; font-size: 12px !important; padding: 0 8px !important;
  }
  header.top .controls { right: 8px !important; gap: 4px !important; }
  header.top .controls button { width: 38px !important; min-width: 38px !important; height: 42px !important; }
  header.top .controls .mode-toggle { padding: 0 6px !important; }
  .mode-label { display: none !important; }
}
