/* TaalFlash 3.0 F8-01 — стили единой навигации (static/js/nav.js): шапка, нижняя панель, панели «Ещё» и профиля.
   Три диапазона ширины: ≤768 — нижняя панель из пяти вкладок; 769–959 — пункты уходят в гамбургер; ≥960 — пункты в шапке. */

/* ── Шапка ── */
.nav { background: var(--white); border-bottom: 2px solid var(--orange); position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow); }
.nav-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-left)); height: 60px;
  display: flex; align-items: center; gap: 12px;
}
.nav-logo { font-size: 20px; font-weight: 800; color: var(--blue-ink); display: flex; align-items: center; gap: 8px; flex: 0 0 auto; white-space: nowrap; }
.nav-logo span { color: var(--orange-ink); }
.nav-items { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; }
.nav-links { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: auto; }
.nav-link, .nav-more-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: var(--radius-s); border: 0; background: none;
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--text-s); white-space: nowrap; cursor: pointer; transition: background .2s, color .2s;
}
.nav-link:hover, .nav-more-btn:hover, .nav-link.active, .nav-more-btn.active, .nav-more-btn[aria-expanded="true"] { color: var(--blue-ink); background: var(--blue-bg); }
.nav-link.active, .nav-more-btn.active { box-shadow: inset 0 -2px 0 var(--orange); }
.nav-user { display: flex; align-items: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 700; color: var(--text); background: none; border: 0; border-radius: var(--radius-s); padding: 4px 8px; cursor: pointer; text-decoration: none; }
.nav-user:hover, .nav-user[aria-expanded="true"] { background: var(--blue-bg); color: var(--blue-ink); }
/* Текст только для скринридеров */
.nav-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nav-user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-avatar { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%; background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
[data-theme="dark"] .nav-avatar { background: var(--blue-l); }
.nav-hamburger {
  display: none; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; font-size: 20px; line-height: 1;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
.theme-toggle { color: var(--text); }
.nav a:focus-visible, .nav button:focus-visible, .tab-bar a:focus-visible, .tab-bar button:focus-visible, .nav-panel a:focus-visible, .nav-panel button:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}

/* ── Панели «Ещё» и профиля ── */
.nav-backdrop { position: fixed; inset: 0; z-index: 1190; background: rgba(10,12,40,.45); }
.nav-panel {
  position: fixed; z-index: 1200; width: 320px; max-width: calc(100vw - 16px); max-height: calc(100vh - 80px); overflow-y: auto;
  background: var(--white); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-h); padding: 8px;
}
.nav-panel[hidden], .nav-backdrop[hidden] { display: none; }
.nav-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 4px; }
.nav-panel-title { font-size: 12px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--text-s); }
.nav-panel-close { display: none; width: 40px; height: 40px; border-radius: 10px; background: var(--bg); color: var(--text); font-size: 18px; line-height: 1; border: 1px solid var(--border); }
.nav-panel-group { padding: 4px 0; border-top: 1px solid var(--border); }
.nav-panel-group:first-of-type { border-top: 0; }
.nav-panel a, .nav-panel .nav-panel-act {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-s);
  font: inherit; font-size: 15px; font-weight: 700; color: var(--text); background: none; border: 0; text-align: left; cursor: pointer; text-decoration: none;
}
.nav-panel a:hover, .nav-panel .nav-panel-act:hover { background: var(--blue-bg); color: var(--blue-ink); }
.nav-panel a.active { background: var(--orange-bg); color: var(--orange-ink); }
.nav-panel .ti { width: 28px; text-align: center; font-size: 18px; flex: 0 0 auto; }
.nav-panel-danger { color: var(--red-ink) !important; }

/* ── Нижняя панель ── */
.tab-bar { display: none; }
.tab-bar a, .tab-bar button {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 1px 7px;
  font: inherit; font-size: 12px; font-weight: 700; line-height: 1.25; color: var(--text-s); background: none; border: 0; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: color .18s;
}
.tab-bar a > span:not(.ti), .tab-bar button > span:not(.ti) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-bar .ti { width: min(44px, 100%); height: 32px; display: flex; align-items: center; justify-content: center; font-size: 22px; border-radius: 12px; transition: background .18s, transform .18s; }
.tab-bar a.active, .tab-bar button.active { color: var(--orange-ink); }
.tab-bar a.active .ti, .tab-bar button.active .ti { background: var(--orange-bg); transform: translateY(-2px); }
.tab-bar a:active .ti, .tab-bar button:active .ti { transform: scale(.92); }

/* Пропуск навигации: виден только при фокусе с клавиатуры */
.skip-link {
  position: fixed; top: -48px; left: 8px; z-index: 6000; padding: 10px 16px; border-radius: var(--radius-s);
  background: var(--blue); color: #fff; font-weight: 800; font-size: 14px; text-decoration: none;
}
.skip-link:focus { top: 8px; outline: 3px solid var(--focus); outline-offset: 2px; }
#main:focus { outline: none; }
#my-decks { scroll-margin-top: 76px; }
/* Экраны входа: высота за вычетом шапки (иначе страница прокручивается на высоту шапки) */
body > .auth-wrap { min-height: calc(100vh - 60px); min-height: calc(100dvh - 60px); }

/* ── Узкая шапка (до 959): гамбургер вместо пунктов ── */
@media (max-width: 959px) {
  .nav-hamburger { display: inline-flex; flex: 0 0 auto; }
  .nav-items {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-wrap: wrap; gap: 4px; padding: 8px 16px 12px;
    background: var(--white); border-bottom: 2px solid var(--orange); box-shadow: var(--shadow-h);
  }
  .nav-items.open { display: flex; }
  .nav-user-name { display: none; }
}
@media (min-width: 960px) and (max-width: 1199px) { .nav-user-name { display: none; } }

/* ── Телефон и узкий планшет (до 768): нижняя панель, компактная шапка ── */
@media (max-width: 768px) {
  .nav { border-bottom: 1px solid var(--border); box-shadow: 0 1px 8px rgba(0,0,0,.06); }
  .nav-inner { height: auto; min-height: 56px; gap: 8px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .nav-hamburger, .nav-items { display: none !important; }
  .nav-links { gap: 4px; min-width: 0; }
  .nav-logo { font-size: clamp(20px, 6vw, 26px); }
  .nav-user { padding: 4px 2px; }
  .tab-bar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 999; background: var(--white); border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px rgba(26,35,126,.10); padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .page { padding-bottom: 84px; }
  body > .auth-wrap { min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px); padding-bottom: 84px; }
  /* панели превращаются в нижний лист */
  .nav-panel {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: auto; max-width: none; max-height: 80vh;
    border-radius: 18px 18px 0 0; border-bottom: 0; padding: 8px 8px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .nav-panel-close { display: inline-flex; align-items: center; justify-content: center; }
}
/* Узкий телефон: вместо слова «TaalFlash» значок */
@media (max-width: 400px) {
  .nav-logo { font-size: 0; gap: 0; }
  .nav-logo span { display: none; }
  .nav-logo::before { content: ""; display: block; width: 32px; height: 32px; border-radius: 8px; background: url(/taal/static/icons/icon-192.png) center / contain no-repeat; }
  .nav-inner { gap: 6px; }
}
@media (max-width: 360px) { .tab-bar a, .tab-bar button { font-size: 12px; letter-spacing: -.01em; } }

/* Предложение установить приложение (static/js/pwa.js): карточка снизу, на телефоне над нижней панелью */
.pwa-offer { position: fixed; z-index: 1100; left: 12px; right: 12px; bottom: 12px; max-width: 460px; margin: 0 auto; padding: 14px 16px; background: var(--white); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--orange); border-radius: var(--radius); box-shadow: var(--shadow-h); }
.pwa-offer-title { display: block; font-size: 16px; color: var(--blue-ink); }
.pwa-offer-text { margin: 4px 0 10px; font-size: 14px; line-height: 1.4; color: var(--text); }
.pwa-offer-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.pwa-offer-btns button { min-height: 44px; padding: 8px 16px; border-radius: var(--radius-s); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.pwa-offer-yes { background: var(--blue); color: #fff; border: 0; }
.pwa-offer-no { background: none; color: var(--text); border: 1px solid var(--border); }
@media (max-width: 768px) { .pwa-offer { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); } }

/* Уважаем настройку «уменьшить движение» */
@media (prefers-reduced-motion: reduce) {
  .nav-link, .nav-more-btn, .tab-bar a, .tab-bar button, .tab-bar .ti { transition: none; }
  .tab-bar a.active .ti, .tab-bar button.active .ti { transform: none; }
}
