/* app.css — базовые стили каркаса (вне Tailwind-сборки).
   Использует CSS-токены из style.css (:root / .dark). Подключается после style.css.

   v5 «Calm Premium», плоский вариант (Flat): Onest, сплошные поверхности +
   1px hairline, тени не больше --shadow-sm у карточек (--shadow-lg — модалки
   и тосты), скругления 12/20/24px, индиго-акцент только на главных действиях
   и выбранных состояниях. Без градиентов, «аврор», свечений и стекла.
   Движение 150–220ms ease-out; prefers-reduced-motion уважается. */

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html {
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Выделение текста — мягкая акцентная подложка. */
::selection { background: rgba(var(--accent-rgb), 0.22); color: var(--text); }

/* Фокус с клавиатуры — единое кольцо акцента (доступность). */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Мгновенная смена темы: на время переключения глушим все переходы/анимации,
   чтобы тяжёлые слои не кроссфейдили и не подтормаживали. */
html.theme-anim-off,
html.theme-anim-off *,
html.theme-anim-off *::before,
html.theme-anim-off *::after {
  transition: none !important;
  animation-duration: 0s !important;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Точка статуса «онлайн/активна»: живое состояние — тихий пульс прозрачностью
   (без масштаба и неонового свечения). */
@keyframes bnPulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.pulse-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  animation: bnPulse 2.4s ease-in-out infinite;
}
.status-dot {
  position: relative;
  display: inline-block; flex-shrink: 0;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok);
}
.status-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--ok); opacity: .3;
  animation: statusPing 2.8s ease-out infinite;
}
@keyframes statusPing { 0% { transform: scale(1); opacity: .3; } 70%, 100% { transform: scale(2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pulse-dot, .status-dot::after { animation: none !important; }
}

/* ── Фон лендинга/входа ──────────────────────────────────────────────────────
   Flat: «аврора» (размытые radial-пятна) убрана — фон страницы сплошной
   (--bg). Разметка <div class="aurora"> из шаблонов удалена; правило ниже
   прячет её в закэшированных htmx-страницах. .aurora-content оставлен. */
.aurora { display: none; }
.aurora-content { position: relative; z-index: 1; }

/* fadeInUp для карточек — короткий и мягкий. */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card-appear { opacity: 0; animation: fadeInUp 0.32s var(--ease-out, ease-out) forwards; }
@media (prefers-reduced-motion: reduce) {
  .card-appear { opacity: 1; animation: none; }
}

/* Кликабельная карточка: hover — только рамка темнее, без подъёма. */
.card-hover { transition: border-color .2s ease-out; }
.card-hover:hover { border-color: var(--hairline-strong); }

/* CTA на лендинге — пилюля. */
.btn-pill { border-radius: 999px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

/* Залитые акцентом кнопки в разметке кабинета (bg-accent text-white): в тёмной
   теме акцент светлый — текст берём из --accent-fg ради контраста. */
.bg-accent.text-white { color: var(--accent-fg); }

/* Прогресс-бар трафика: обычное состояние — акцент, дальше warn/error. */
.traffic-bar-green  { background: var(--accent); }
.traffic-bar-yellow { background: var(--warn); }
.traffic-bar-red    { background: var(--error); }

/* Skeleton shimmer для Telegram-виджета (auth) */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}
.tg-skeleton {
  width: 220px; height: 44px; border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
}

/* ── Вход (/auth) ─────────────────────────────────────────────────────────── */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card, 20px);
  box-shadow: var(--shadow-sm);
  padding: 28px 20px;
}
@media (min-width: 640px) {
  .auth-card { padding: 36px 32px; }
}
/* OTP-ячейки сжимаются на узких экранах, чтобы шесть штук влезали в карточку. */
.auth-card .otp-cell { flex: 1 1 0; min-width: 0; max-width: 2.75rem; width: auto; }
.auth-benefits {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 14px;
  max-width: 400px;
}
.auth-benefits li {
  display: flex; align-items: center; gap: 12px;
  font-size: 15px; font-weight: 500; color: var(--text-2);
}
.auth-benefit-ico {
  flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-line);
}

/* Yandex SmartCaptcha (auth) */
.yandex-captcha-wrap { color-scheme: light; min-height: 100px; }
.dark .yandex-captcha-wrap { color-scheme: dark; }
.dark .yandex-captcha-wrap iframe {
  filter: invert(0.93) hue-rotate(180deg) brightness(0.96);
  border-radius: 12px;
}

/* Кнопка переключения темы — круглая, поверхность + hairline + мягкая тень. */
.theme-btn {
  position: relative;
  width: 2.25rem; height: 2.25rem;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-sm);
  color: var(--text-2);
  transition: background-color .18s ease-out, border-color .18s ease-out, color .18s ease-out;
  cursor: pointer;
}
.theme-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--hairline-strong); }
.theme-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Toast notifications — карточка с мягкой тенью. */
#toast-container {
  position: fixed;
  z-index: 9999;
  left: max(0.75rem, env(safe-area-inset-left));
  right: max(0.75rem, env(safe-area-inset-right));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  pointer-events: none;
  max-width: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0.75rem 0.95rem;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.01em;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
  pointer-events: auto;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-icon {
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.02rem;
  font-size: .7rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-fg);
}
.toast.toast-warning .toast-icon { background: var(--warn); color: #fff; }
.toast.toast-error   .toast-icon { background: var(--error); color: #fff; }
.toast-text {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}
.toast.toast-bump { animation: toastBump .22s ease-out; }
@keyframes toastBump {
  0%   { transform: translateY(0) scale(1); }
  45%  { transform: translateY(0) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}
@media (min-width: 640px) {
  #toast-container {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(26rem, calc(100vw - 2rem));
    align-items: center;
  }
  .toast {
    width: auto;
    max-width: 100%;
  }
}

/* htmx page transition */
#main-content { opacity: 1; transition: opacity 180ms ease-out; }
#main-content.htmx-swapping { opacity: 0; }
#main-content.htmx-settling { opacity: 1; }

/* Прогресс-бар htmx вверху. */
#htmx-bar {
  position: fixed; top: 0; left: 0; width: 0; height: 2px;
  background: var(--accent); z-index: 9999;
  border-radius: 0 999px 999px 0;
  transition: width .3s ease-out, opacity .3s ease-out; opacity: 0;
}
#htmx-bar.htmx-request { opacity: 1; }

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hairline-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* Плавающая шапка: прячется при скролле вниз, возвращается при скролле вверх.
   --app-header-offset используют залипающие элементы (моб. таб-бар кабинета). */
:root { --app-header-offset: calc(3.5rem + env(safe-area-inset-top)); }
#app-nav { transition: transform .3s var(--ease-out, ease-out), opacity .25s ease-out; will-change: transform; }
#app-nav.app-nav-hidden { transform: translateY(-200%); opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  #app-nav { transition: opacity .2s ease-out; }
}

/* ── Global nav ─────────────────────────────────────────────────────────────
   Flat: сплошной фон холста (без стекла/размытия), hairline снизу. */
.app-nav-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--hairline);
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-bottom: 8px;
}
.app-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  min-height: 2.5rem;   /* вместе с отступами даёт 3.5rem — высоту спейсера */
}
/* Имя проекта: скруглённый акцентный знак + текст. */
.app-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
  border-radius: 10px;
}
.app-nav-mark {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-fg);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.app-nav-brand-text { overflow: hidden; text-overflow: ellipsis; }
/* Ссылки навигации: обычный регистр, приглушённые до hover. */
.app-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: color .18s ease-out, background-color .18s ease-out;
}
.app-nav-link:hover { color: var(--text); background: var(--surface-2); }
.app-nav-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Кнопка входа/кабинета — компактная пилюля. */
.app-nav-cta {
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 999px;
}

/* ── Footer ────────────────────────────────────────────────────────────────
   Спокойный, типографический: hairline сверху, обычный регистр. */
.app-footer {
  position: relative;
  z-index: 1;
  background: transparent;
  border-top: 1px solid var(--hairline);
  padding-block: 32px;
}
.app-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-bottom: 20px;
}
.app-footer-links a {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-2);
  border-radius: 6px;
  transition: color .18s ease-out;
}
.app-footer-links a:hover { color: var(--text); text-decoration: none; }
.app-footer-fine {
  margin: 20px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
}

/* ── Модалки и оверлеи ──────────────────────────────────────────────────── */
.modal-scrim {
  position: absolute;
  inset: 0;
  background: var(--modal-scrim) !important;
}
.modal-panel {
  background: var(--modal-surface) !important;
  border: 1px solid var(--modal-border) !important;
  border-radius: var(--radius-modal, 24px);
  box-shadow: var(--shadow-lg) !important;
  color: var(--text);
}
/* Старые вложенные bg-gray-50 в модалках должны быть частью новой поверхности. */
.modal-panel .bg-gray-50,
.modal-panel .bg-gray-50\/80,
.modal-panel .bg-gray-50\/70 {
  background-color: var(--modal-surface-2) !important;
}
.dark .modal-panel .dark\:bg-white\/\[0\.035\],
.dark .modal-panel .dark\:bg-white\/\[0\.04\],
.dark .modal-panel .dark\:bg-white\/\[0\.05\],
.dark .modal-panel .dark\:bg-white\/\[0\.06\],
.dark .modal-panel .dark\:bg-white\/\[0\.07\],
.dark .modal-panel .dark\:bg-white\/\[0\.08\] {
  background-color: var(--modal-surface-2) !important;
}
