/* ============================================================================
   tiles.css — единый кнопочный язык хабов и PWA-сеток
   Используется в /settings, /training, /communications, /profile и dashboard tiles
   ============================================================================ */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 18px 0 28px;
}
@media (max-width: 768px)  { .tile-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (max-width: 560px)  { .tile-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }

.tile-btn {
  --tile-from: #2563eb;
  --tile-to:   #7c3aed;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px;
  padding: 18px 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  text-decoration: none;
  color: var(--text);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tile-btn:hover { transform: translateY(-2px); border-color: transparent;
  box-shadow: 0 10px 28px -10px rgba(15, 23, 42, .25), 0 4px 12px -6px rgba(15, 23, 42, .15); }
.tile-btn:active { transform: translateY(0) scale(.98); }
.tile-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-1, #2563eb) 33%, transparent); outline-offset: 2px; }

.tile-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 28px;
  color: var(--brand-text, #fff);
  /* Брендовый gradient — переопределяется через CSS-переменные в base.html
     (см. --brand-1/2/3 из org.brand_color/_2/_3 для per-tenant кастомизации). */
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #a855f7 55%, #ec4899 100%));
  box-shadow: 0 8px 18px -6px rgba(124, 58, 237, .45),
              inset 0 -2px 6px rgba(0,0,0,.18),
              inset 0 1px 0 rgba(255,255,255,.25);
  flex: 0 0 auto;
  transition: transform .25s ease;
}
.tile-btn:hover .tile-icon { transform: scale(1.06) rotate(-3deg); }
/* Brand SVG-иконка поверх gradient-фона: размер как у emoji, цвет наследуется
   от .tile-icon { color: #fff } через stroke=currentColor. */
.tile-icon svg { width: 28px; height: 28px; display: block; }

.tile-title { font-size: 14.5px; font-weight: 700; line-height: 1.25; color: var(--text); }
.tile-hint  { font-size: 11.5px; color: var(--muted); line-height: 1.3; min-height: 1.3em; }

.tile-badge {
  position: absolute; top: 10px; right: 10px;
  background: #dc2626; color: #fff;
  border-radius: 999px; padding: 1px 6px;
  font-size: 10px; font-weight: 700;
  box-shadow: 0 2px 6px rgba(220,38,38,.4);
}

/* ============================================================================
   Legacy: 9 цветовых вариантов теперь no-op — все tile-* классы получают
   единый трёхцветный brand gradient через .tile-icon выше. Селектор оставлен
   пустым чтобы не плодить ошибок если кто-то добавит CSS-переопределение.
   ============================================================================ */
.tile-brand, .tile-warm, .tile-cool, .tile-green, .tile-slate,
.tile-pink, .tile-amber, .tile-night, .tile-rose { /* unified above */ }

/* ============================================================================
   Brand icon в заголовках hub-страниц (.hub-title-icon)
   и hero-блоков любых страниц (.h1-icon).
   Заменяет emoji 🧠/☀️/🌙/⚙️ слева от h1. Inline SVG через макрос icon().
   ============================================================================ */
.hub-title-icon,
.h1-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #a855f7 55%, #ec4899 100%));
  color: var(--brand-text, #fff);
  margin-right: 10px;
  vertical-align: -8px;
  box-shadow: 0 4px 10px -2px rgba(124, 58, 237, .35);
  flex-shrink: 0;
}
.hub-title-icon svg,
.h1-icon svg { width: 22px; height: 22px; display: block; }

/* Маленький брендовый круг inline в текст (badges, callout-баннеры).
   Размер 18×18 / 14×14 svg внутри. Используется в push-баннере, reasons и т.п. */
.inline-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand-gradient, linear-gradient(135deg, #2563eb 0%, #a855f7 55%, #ec4899 100%));
  color: var(--brand-text, #fff);
  vertical-align: -4px;
  margin-right: 4px;
  flex-shrink: 0;
}
.inline-icon svg { width: 11px; height: 11px; display: block; }

/* Маленькая иконка без фона для статистик (XP/Streak/Level). 14×14, цвет наследует. */
.stat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  vertical-align: -3px;
  margin-right: 2px;
  color: var(--brand);
}
.stat-icon svg { width: 14px; height: 14px; display: block; }
.stat-icon.coin { color: #f59e0b; }
.stat-icon.zap  { color: var(--brand-2, #a855f7); }
.stat-icon.fire { color: #ef4444; }
.stat-icon.diamond { color: var(--brand-3, #ec4899); }

/* Внутри hero-блоков с белым h1 (на цветном фоне gradient hero) — круг чуть
   мягче чтобы не «выпрыгивал». Перекрашиваем фон в полупрозрачный белый. */
.t-hero .h1-icon,
.m-hero .h1-icon,
.mn-hero .h1-icon,
.md-hero .h1-icon,
.wk-hero .h1-icon {
  background: rgba(255, 255, 255, .22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}

/* ============================================================================
   Hub header — приветствие или подзаголовок над сеткой
   ============================================================================ */
.hub-header {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 6px;
}
.hub-title { font-size: 24px; font-weight: 800; letter-spacing: -.01em; color: var(--text); margin: 0; }
.hub-subtitle { font-size: 14px; color: var(--muted); margin: 0; max-width: 60ch; }
.hub-section { margin-top: 24px; }
.hub-section-title {
  font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 8px 4px;
}

/* ============================================================================
   Bottom-nav — БРЕНДОВЫЙ единый UI (десктоп, мобила, PWA)
   Стиль: frosted glass + gradient pill на active + smooth bounce.
   ============================================================================ */
.bottom-nav {
  display: flex;
  position: fixed; left: 0; right: 0; bottom: 0;
  justify-content: space-around; align-items: stretch;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(226, 232, 240, 0.6);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 100;
  box-shadow: 0 -8px 24px -12px rgba(15, 23, 42, 0.12), 0 -1px 0 rgba(255, 255, 255, 0.6) inset;
}
/* На десктопе — floating pill, отделена от краёв */
@media (min-width: 900px) {
  .bottom-nav {
    left: 50%; right: auto; transform: translateX(-50%);
    max-width: 640px; width: calc(100% - 32px);
    bottom: 16px;
    border-radius: 22px;
    border: 1px solid rgba(226, 232, 240, 0.5);
    padding: 8px 10px;
    box-shadow: 0 12px 32px -10px rgba(15, 23, 42, 0.22), 0 2px 8px -2px rgba(15, 23, 42, 0.08);
  }
}
.bottom-nav .nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  text-decoration: none;
  color: #64748b;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: 14px;
  transition: all 0.18s cubic-bezier(0.4, 1.4, 0.6, 1);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}
.bottom-nav .nav-btn .nav-emoji,
.bottom-nav .nav-btn .nav-svg {
  font-size: 22px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  transition: transform 0.18s cubic-bezier(0.4, 1.4, 0.6, 1);
}
.bottom-nav .nav-btn .nav-svg svg { display: block; }
.bottom-nav .nav-btn:hover .nav-emoji,
.bottom-nav .nav-btn:active .nav-emoji,
.bottom-nav .nav-btn:hover .nav-svg,
.bottom-nav .nav-btn:active .nav-svg {
  transform: scale(1.12);
}
/* Active: gradient pill + белая иконка через currentColor.
   Использует --brand-gradient (палитра из настроек org) — меняется автоматически
   когда юзер меняет цвета бренда в /onboarding/settings. */
.bottom-nav .nav-btn[aria-current="page"] {
  color: var(--brand-text, #ffffff);
  background: var(--brand-gradient, linear-gradient(135deg, #7c3aed 0%, #2563eb 100%));
  box-shadow: 0 6px 16px -4px color-mix(in srgb, var(--brand-2, #a855f7) 45%, transparent),
              0 2px 4px color-mix(in srgb, var(--brand-1, #2563eb) 18%, transparent);
  transform: translateY(-2px);
}
.bottom-nav .nav-btn[aria-current="page"] .nav-emoji,
.bottom-nav .nav-btn[aria-current="page"] .nav-svg {
  transform: scale(1.05);
}
.bottom-nav .nav-btn:hover {
  background: color-mix(in srgb, var(--brand-2, #a855f7) 6%, transparent);
  color: var(--brand-1, #2563eb);
}
.bottom-nav .nav-btn:active {
  transform: scale(0.95);
}

main, .main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 768px) {
  main, .main { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)) !important; }
}
.sidebar, .pwa-mode .sidebar { display: none !important; }
.topbar .hamburger, .pwa-mode .topbar .hamburger { display: none !important; }
.coach-fab, .pwa-mode .coach-fab { bottom: calc(82px + env(safe-area-inset-bottom, 0px)); }
/* Единое центрирование контента: одинаково в браузере, мобиле и PWA */
.main, .pwa-mode .main {
  margin-left: 0 !important; margin-right: auto !important;
  padding-left: 24px; padding-right: 24px;
  max-width: 1240px; margin-left: auto !important;
}
@media (max-width: 768px) {
  .main, .pwa-mode .main { padding-left: 14px; padding-right: 14px; }
}
