/**
 * mobile.css — School Gov UA Theme
 * Повна мобільна адаптація: телефони, планшети, десктоп
 * Підключається ОСТАННІМ у libraries.yml
 */

/* =====================================================
   МОБІЛЬНЕ МЕНЮ — ГАМБУРГЕР
   ===================================================== */

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  padding: 8px;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.45);
  border-radius: 6px;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  transition: border-color .2s;
  -webkit-tap-highlight-color: transparent;
}
.hamburger:hover { border-color: rgba(255,255,255,.8); }
.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
  transform-origin: center;
}
.hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* =====================================================
   МОБІЛЬНЕ МЕНЮ — OVERLAY
   ===================================================== */

.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 299;
  opacity: 0;
  transition: opacity .25s ease;
}
.mobile-nav-overlay.is-open {
  display: block;
  opacity: 1;
}

/* =====================================================
   МОБІЛЬНЕ МЕНЮ — DRAWER (висувна панель)
   ===================================================== */

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(320px, 88vw);
  height: 100%;
  background: #122a6b;
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-nav-drawer.is-open {
  transform: translateX(0);
  box-shadow: 6px 0 24px rgba(0,0,0,.35);
}

.mobile-nav-drawer__head {
  background: #1b3d8f;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  flex-shrink: 0;
}
.mobile-nav-drawer__logo {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}
.mobile-nav-drawer__name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: .03em;
  line-height: 1.25;
}
.mobile-nav-drawer__close {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,.12);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  flex-shrink: 0;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-drawer__close:hover { background: rgba(255,255,255,.22); }

.mobile-nav-drawer__menu {
  flex: 1;
  padding: 8px 0;
  list-style: none;
  margin: 0;
}
.mobile-nav-drawer__menu li {
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.mobile-nav-drawer__menu li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,.88);
  text-decoration: none;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-drawer__menu li a:hover,
.mobile-nav-drawer__menu li a.is-active {
  background: rgba(255,255,255,.1);
  color: #f5a800;
}
.mobile-nav-drawer__menu li a .arrow {
  font-size: 11px;
  opacity: .5;
  transition: transform .2s;
}
.mobile-nav-drawer__submenu {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0;
  background: rgba(0,0,0,.2);
}
.mobile-nav-drawer__submenu.open { display: block; }
.mobile-nav-drawer__submenu a {
  padding: 10px 18px 10px 32px !important;
  font-size: 13px !important;
  color: rgba(255,255,255,.7) !important;
}
.mobile-nav-drawer__submenu a:hover { color: #f5a800 !important; }

.mobile-nav-drawer__footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.mobile-nav-drawer__footer a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 14px;
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,.1);
  transition: background .15s;
}
.mobile-nav-drawer__footer a:hover { background: rgba(255,255,255,.22); }

/* =====================================================
   ДЕСКТОП: ≥ 1025px — базова верстка
   ===================================================== */

@media (min-width: 1025px) {
  .hamburger { display: none !important; }
  .mobile-nav-drawer { display: none !important; }
  .mobile-nav-overlay { display: none !important; }
}

/* =====================================================
   ПЛАНШЕТ: ≤ 1024px
   ===================================================== */

@media (max-width: 1024px) {
  :root {
    --container-pad: 1.25rem;
  }

  /* Переконуємось що sticky продовжує працювати */
  body > .dialog-off-canvas-main-canvas {
    overflow: visible !important;
    padding-top: 0 !important;
  }

  /* Хедер — менша висота на планшеті */
  .site-header .container {
    flex-wrap: nowrap;
    gap: 10px;
    height: 60px;
  }
  /* NAV під меншим хедером */
  .site-nav { top: 60px; }

  /* Компенсація: header(60) + nav(46) = 106px */
  .layout-main { padding-top: 134px; }

  .site-header__branding {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none !important;
  }
  .site-header__search { display: none !important; }
  .site-header__actions { display: flex !important; }
  .hamburger { display: flex !important; flex-shrink: 0; }

  /* Nav показуємо на планшеті */
  .site-nav { display: block; }

  /* Top-bar: прибираємо адресу, залишаємо email */
  #block-school-gov-adresatop { display: none !important; }

  /* Статистика */
  .statistics-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .stat-card__number { font-size: 2.2rem; }

  /* Two-col */
  .layout-two-col {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* News grid */
  .news-grid-3 { grid-template-columns: repeat(2, 1fr); }

  /* Admin grid */
  .admin-grid { grid-template-columns: repeat(3, 1fr); }

  /* Contacts */
  .contacts-grid { grid-template-columns: 1fr 1fr; }

  /* Footer */
  .footer-grid { grid-template-columns: 1fr 1fr; }

  /* Inner page */
  .layout-inner {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   МОБІЛЬНИЙ: ≤ 768px
   ===================================================== */

@media (max-width: 768px) {
  :root {
    --container-pad: 1rem;
    --fs-4xl: 1.9rem;
    --fs-3xl: 1.6rem;
    --fs-2xl: 1.4rem;
    --fs-xl:  1.2rem;
  }

  /* === ХЕДЕР — мобільний fixed === */
  .site-header {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1240px;
    z-index: 500;
  }
  .site-header .container {
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
    height: 56px;
  }
  .site-header__branding {
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
    max-width: none !important;
  }
  .site-header__logo img,
  .site-header__logo svg { width: 36px; height: 36px; }
  .site-header__text { min-width: 0; overflow: hidden; }
  .site-header__name {
    font-size: 12px; white-space: normal; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; line-height: 1.3;
  }
  .site-header__slogan { display: none; }
  .site-header__search { display: none !important; }
  .site-header__actions { display: flex !important; }
  .hamburger { display: flex !important; flex-shrink: 0; }
  .site-nav { display: none !important; }

  /* Компенсація: тільки header(56px) — nav прихований */
  .layout-main { padding-top: 56px !important; } /* header only, topbar scrollable */

  /* === HERO СЛАЙДЕР === */
  .hero-slider { min-height: 240px; }
  .hero-slide  { min-height: 240px; }
  .hero-slide__content {
    padding: 24px var(--container-pad);
  }
  .hero-slide__title {
    font-size: 1.5rem;
    max-width: 100%;
  }
  .hero-slide__text {
    font-size: 13px;
    max-width: 100%;
  }
  .hero-slide__label { font-size: 9px; }
  .hero-slider__arrow { display: none; }
  .hero-slide__actions { gap: 8px; }
  .hero-slide__actions .btn-lg {
    padding: .65em 1.2em;
    font-size: 13px;
  }

  /* === СТАТИСТИКА === */
  .statistics-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .stat-card {
    padding: 14px 16px;
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }
  .stat-card__number { font-size: 2.4rem; }
  .stat-card__label  { font-size: 1rem; }
  .stat-card__desc   { font-size: 11px; }

  /* === СЕКЦІЇ === */
  .page-section { padding: 20px 0; }
  .page-section__header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
  }
  .page-section__title { font-size: 1rem; }
  .page-section__more  { font-size: 12px; }

  /* === ОГОЛОШЕННЯ + РОЗКЛАД === */
  .layout-two-col { grid-template-columns: 1fr; }
  .ann-grid,
  .news-grid-2 { grid-template-columns: 1fr; }
  .news-grid-3 { grid-template-columns: 1fr; }

  /* === КАРТКИ === */
  .news-card,
  .announcement-card {
    border-radius: 8px;
  }
  .news-card__image,
  .announcement-card__image {
    aspect-ratio: 16/9;
  }
  .news-card__body { padding: 12px; }
  .news-card__title { font-size: 14px; }
  .news-card__excerpt { font-size: 12px; }
  .news-card__footer { gap: 8px; flex-wrap: wrap; }

  /* === АДМІНІСТРАЦІЯ === */
  .admin-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-card__photo { width: 70px; height: 70px; }
  .admin-card__name  { font-size: 12px; }

  /* === РОЗКЛАД ДЗВІНКІВ === */
  .bell-schedule { font-size: 13px; }
  .bell-schedule td, .bell-schedule th { padding: .5em .7em; }

  /* === КОНТАКТИ === */
  .contacts-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .map-wrapper { height: 220px; }
  .contact-item { font-size: 13px; }

  /* === СОЦМЕРЕЖІ в контактах === */
  .social-links { gap: 8px; }

  /* === КОРИСНІ ПОСИЛАННЯ === */
  .useful-links { gap: 8px; }
  .useful-link { font-size: 11px; padding: .45em .85em; }

  /* === FOOTER === */
  .footer-grid { grid-template-columns: 1fr; gap: 16px; }
  .footer-menu { flex-direction: row; flex-wrap: wrap; gap: 4px 16px; }
  .footer-menu a { font-size: 12px; }
  .site-footer { padding: 16px 0; }
  .site-footer__menu { padding: 10px 0; }

  /* === BREADCRUMB === */
  .breadcrumb { font-size: 12px; }

  /* === ВНУТРІШНЯ СТОРІНКА === */
  .layout-inner { padding: 14px 0; }
  .node__title { font-size: 1.4rem; }

  /* === ПАГІНАЦІЯ === */
  .pager { gap: 4px; }
  .pager__item a, .pager__item span { width: 32px; height: 32px; font-size: 12px; }

  /* === ТАБЛИЦЯ ДОКУМЕНТІВ === */
  .views-table { font-size: 12px; }
  .views-table td, .views-table th { padding: 6px 8px; }
  /* Горизонтальний скрол для таблиць */
  .view-content { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* =====================================================
   МАЛЕНЬКИЙ МОБІЛЬНИЙ: ≤ 480px
   ===================================================== */

@media (max-width: 480px) {
  :root { --container-pad: .875rem; }

  .site-header__name { max-width: 140px; font-size: 10px; }
  .site-header__logo img,
  .site-header__logo svg { width: 34px; height: 34px; }

  .hero-slider { min-height: 200px; }
  .hero-slide  { min-height: 200px; }
  .hero-slide__title { font-size: 1.25rem; }
  .hero-slide__text  { display: none; }
  .hero-slide__label { display: none; }

  .stat-card__number { font-size: 2rem; }
  .stat-card__label  { font-size: .9rem; }

  .admin-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-card__photo { width: 56px; height: 56px; }

  .page-section__title { font-size: .95rem; }

  /* Кнопки менші */
  .btn-sm { font-size: 11px; padding: .4em .8em; }
  .news-more,
  .btn.btn-secondary.btn-sm { font-size: 11px; padding: 4px 8px; }
}

/* =====================================================
   FIXES: Загальне для всіх мобільних
   ===================================================== */

@media (max-width: 1024px) {
  /* Запобігаємо горизонтальному скролу */
  html, body { overflow-x: hidden; max-width: 100vw; }

  /* Зображення не виходять за межі */
  img { max-width: 100%; height: auto; }

  /* Таблиці — горизонтальний скрол */
  table { min-width: 0; }
  .view-content { overflow-x: auto; }

  /* Не дати тексту злипатися з краями */
  .container { padding-left: var(--container-pad); padding-right: var(--container-pad); }

  /* Друпал системні повідомлення */
  .messages--status,
  .messages--warning,
  .messages--error { font-size: 13px; }
}
