/* =========================================================
   THEME TOKENS (Light / Dark)
   ========================================================= */

/* Светлая тема */
:root{
  /* База */
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #1f2a37;
  --muted: #6b7280;

  /* Акценты / бренд */
  --accent: #0ea5b7;
  --accent-hover: #0b90a0;
  --brand-title: #0ea5b7;
  --brand-underline: #0ea5b7;

  /* Навигация */
  --nav-bg: #ffffff;
  --nav-link: #1f2a37;
  --nav-link-hover: #0b90a0;

  /* Границы / тени */
  --border: #e5e7eb;
  --shadow: 0 12px 28px rgba(0,0,0,.10);

  /* Формы */
  --input-bg: #ffffff;
  --input-text: #1f2a37;
  --input-border: #cfd6de;
  --input-ph: #8a93a1;

  /* Dropdown */
  --dropdown-bg: #ffffff;
  --dropdown-border: #e5e7eb;

  /* Кнопка поиска */
  --search-btn-bg: #1b2753;
  --search-btn-text: #ffffff;
  --search-btn-border: #1b2753;

  /* Тумблер темы */
  --toggle-bg: #1b2753;
  --toggle-icon: #ffffff;

  /* Общая высота превью */
  --thumb-h: 200px;

  /* ===== стеклянный режим ===== */
  --nav-bg-rgb: 255,255,255;
  --nav-bg-alpha: .7;
  --surface-rgb: 255,255,255; /* для rgba поверхностей */
  --glass-alpha: .72;
  --glass-blur: 10px;

  /* ===== СИНИЙ ТИНТ (светлая) ===== */
  --tint-rgb: 14,165,183;      /* #0ea5b7 */
  --tint-alpha: .18;
  --tint-alpha-strong: .28;
}

/* Тёмная тема */
html.theme-dark,
body.theme-dark{
  --bg: #1b2753;
  --surface: #121826;
  --text: #f3f7fd;
  --muted: #b5c1d1;

  --accent: #67e8f9;
  --accent-hover: #22d3ee;

  --nav-bg: #1b2753;
  --nav-link: #ffffff;
  --nav-link-hover: #00e3f8;

  --brand-title: #00e3f8;
  --brand-underline: #00e3f8;

  --border: #2a344a;
  --shadow: 0 12px 28px rgba(0,0,0,.35);

  --input-bg: #0e1324;
  --input-text: #eaf2ff;
  --input-border: #2a344a;
  --input-ph: #96a3ba;

  --dropdown-bg: #111a33;
  --dropdown-border: #2a344a;

  --search-btn-bg: #00e3f8;
  --search-btn-text: #1b2753;
  --search-btn-border: #00e3f8;

  --toggle-bg: #ffffff;
  --toggle-icon: #1b2753;

  /* стеклянный режим */
  --nav-bg-rgb: 27,39,83;        /* #1b2753 */
  --nav-bg-alpha: .7;
  --surface-rgb: 18,24,38;       /* #121826 */
  --glass-alpha: .58;
  --glass-blur: 12px;

  /* СИНИЙ ТИНТ (тёмная) */
  --tint-rgb: 27,39,83;          /* #1b2753 */
  --tint-alpha: .22;
  --tint-alpha-strong: .32;
}


/* =========================================================
   BASE
   ========================================================= */

html, body{
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
}

html.theme-dark body{
  background-color: var(--bg) !important;
}

a{ color: var(--accent); }
a:hover{ color: var(--accent-hover); }

.text-title{ color: var(--brand-title) !important; }
.text-title-underline{ position: relative; }
.text-title-underline::after{
  content:"";
  position:absolute; left:0; right:0; bottom:-2px;
  height:2px; border-radius:2px; background: var(--brand-underline);
}

.navbar, .card, .dropdown-menu, .modal-content, .form-control, body, html{
  transition: background-color .18s ease, color .18s ease,
              border-color .18s ease, box-shadow .18s ease;
}

.theme-hr{
  border: 0; border-top: 1px solid var(--border);
  opacity: .7; margin: .75rem 0 1.25rem;
}


/* =========================================================
   NAVBAR
   ========================================================= */

.navbar.my-navbar {
  background-color: rgba(var(--nav-bg-rgb), var(--nav-bg-alpha)) !important;
  backdrop-filter: saturate(1.05) blur(6px);
  -webkit-backdrop-filter: saturate(1.05) blur(6px);
}

.dropdown-menu {
  background: var(--dropdown-bg);
  border-color: var(--dropdown-border);
  box-shadow: var(--shadow);
}

.navbar [role="search"] .input-group-append .btn,
.btk-search [role="search"] .input-group-append .btn {
  background: var(--search-btn-bg) !important;
  border-color: var(--search-btn-border) !important;
  color: var(--search-btn-text) !important;
}
.navbar [role="search"] .input-group-append .btn i,
.btk-search [role="search"] .input-group-append .btn i {
  color: var(--search-btn-text) !important;
}

.navbar.my-navbar .theme-toggle{
  background: var(--toggle-bg) !important;
  color: var(--toggle-icon) !important;
  border-color: var(--toggle-bg) !important;
}
.navbar.my-navbar .theme-toggle:hover{ filter: brightness(1.04); }

.navbar .btk-search-scope {
  position: relative;
  overflow: visible !important; /* не обрезаем подсказки */
  z-index: 9999; /* выше навбара и каруселей */
}


/* =========================================================
   SURFACES
   ========================================================= */

.card, .modal-content{
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.dropdown-menu{
  background: var(--dropdown-bg);
  border-color: var(--dropdown-border);
  box-shadow: var(--shadow);
}
.dropdown-item{ color: var(--text); }
.dropdown-item:hover{ background: rgba(255,255,255,.06); }

.form-control, .custom-select{
  background: var(--input-bg);
  color: var(--input-text);
  border-color: var(--input-border);
}
.form-control::placeholder{ color: var(--input-ph); }

.page-link{
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.page-link:hover{ background: rgba(255,255,255,.06); }


/* =========================================================
   SEARCH WIDGET STYLES (подсказки)
   ========================================================= */

.btk-suggest-wrap { position: relative; width: 100%; overflow: visible !important; }
.btk-suggest {
  position: absolute; top: 100%; left: 0; right: 0;
  margin-top: 2px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  z-index: 9999; max-height: 400px; overflow-y: auto; border-radius: 8px; padding: 0;
}
.suggest-list { list-style: none; margin: 0; padding: 0; }
.suggest-item { padding: 6px 8px; }
.suggest-item + .suggest-item { border-top: 1px solid rgba(0,0,0,.06); }
.suggest-item a { color: var(--text); display: flex; align-items: center; text-decoration: none; }
.suggest-item:hover { background: rgba(0,227,248,.08); }
.suggest-item .thumb{ width:40px;height:56px;flex:0 0 40px;border-radius:4px;overflow:hidden;background:#e9eef5;margin-right:.5rem;display:flex;align-items:center;justify-content:center;}
.suggest-item .thumb img{ width:100%;height:100%;object-fit:cover;display:block; }
.suggest-item .meta{ min-width: 0; }
.suggest-item .title{ font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.suggest-item .sg-year{ color: var(--muted); font-weight: 500; margin-left: 6px; }
.suggest-empty{ padding: 6px 8px; }
.suggest-footer{ position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); text-align: center; padding: 8px 10px; }
.all-results-link{ font-weight: 700; color: var(--accent); text-decoration: none; }
.all-results-link:hover{ color: var(--accent-hover); }
/* Подсветка совпадений */
.suggest-list .sg-hl{
  background: #ffe58f; color: inherit; padding: 0 .12rem; border-radius: .2rem; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
html.theme-dark .suggest-list .sg-hl{ background:#6b5b00; color:#fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); }


/* =========================================================
   LAYOUT / SECTIONS
   ========================================================= */

/* Превью фиксированной высоты */
.thumb-fixed{ width:100%; height:200px; object-fit:cover; object-position:center; }

/* Фон всей страницы */
.page-background { position: relative; background-size: cover; background-position: center; }
.page-overlay { position: absolute; inset:0; background: rgba(var(--tint-rgb), .16); }
html.theme-dark .page-overlay { background: rgba(var(--tint-rgb), .22); }
.page-content { position: relative; z-index: 2; }

/* Общие секции */
.categories-section { margin: 2rem 0; position: relative; z-index: 2; }

/* Параллакс */
.theme-section-parallax { background-attachment: fixed; background-size: cover; background-position: center; position: relative; color: #fff; }
.theme-section-parallax .overlay{
  position: absolute; inset:0;
  background: linear-gradient(180deg, rgba(var(--tint-rgb), .32), rgba(var(--tint-rgb), .46));
}
html.theme-dark .theme-section-parallax .overlay{
  background: linear-gradient(180deg, rgba(var(--tint-rgb), .38), rgba(var(--tint-rgb), .54));
}

/* Живой контент */
.live-content .live-counter { font-size: 2rem; font-weight: 700; color: var(--accent); }
.live-content .count-label { font-size: 0.95rem; color: var(--muted); }
.live-events { overflow: hidden; position: relative; height: 2rem; }
.live-events .events-wrapper { display: flex; flex-direction: column; animation: scrollEvents 12s linear infinite; }
.live-events .event-item { color: var(--text); font-size: 0.9rem; padding: 0.2rem 0; text-align: center; }
@keyframes scrollEvents { 0%{ transform: translateY(0);} 100%{ transform: translateY(-100%);} }


/* =========================================================
   GLOBAL GLASS MODE (включается классом body.use-glass)
   ========================================================= */

body.use-glass{ position: relative; background-attachment: fixed; }
body.use-glass::before{
  content:""; position: fixed; inset: 0; pointer-events:none; z-index:0;
  background:
    radial-gradient(1100px 380px at 10% -10%, rgba(0,227,248,.14), transparent 60%),
    radial-gradient(900px 300px at 100% 110%, rgba(0,227,248,.08), transparent 60%);
}
body.use-glass::after{
  content:""; position: fixed; inset:0; z-index:0;
  /* синий тинт вместо nav-bg */
  background: rgba(var(--tint-rgb), var(--tint-alpha));
  backdrop-filter: saturate(1.06) blur(6px);
  -webkit-backdrop-filter: saturate(1.06) blur(6px);
}
body.use-glass .page-content,
body.use-glass main,
body.use-glass #content,
body.use-glass .wrap{ position: relative; z-index:1; }

body.use-glass .card,
body.use-glass .modal-content,
body.use-glass .dropdown-menu,
body.use-glass .page-link,
body.use-glass .list-group,
body.use-glass .toast,
body.use-glass .popover,
body.use-glass .offcanvas{
  background: rgba(var(--surface-rgb), var(--glass-alpha)) !important;
  border-color: rgba(255,255,255,.18);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.05);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.05);
  color: var(--text);
}
body.use-glass .card{ box-shadow: 0 10px 30px rgba(0,0,0,.15); }

body.use-glass .dropdown-menu,
body.use-glass .btk-suggest{ z-index: 6000; }

body.use-glass .glass-section{
  position: relative;
  background: rgba(var(--surface-rgb), calc(var(--glass-alpha) - .12));
  backdrop-filter: blur(calc(var(--glass-blur) - 2px)) saturate(1.05);
  -webkit-backdrop-filter: blur(calc(var(--glass-blur) - 2px)) saturate(1.05);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  box-shadow: 0 14px 34px rgba(0,0,0,.16);
  overflow: hidden;
}
body.use-glass .glass-section::before{
  content:""; position:absolute; inset:0;
  background: linear-gradient(to bottom right, rgba(255,255,255,.06), rgba(255,255,255,0));
  pointer-events:none;
}


/* =========================================================
   FOOTER
   ========================================================= */

.site-footer{
  color:#fff;
  background: none;
  position: relative;
  overflow: hidden;
}

.site-footer .footer-hero{
  position: relative;
  padding: 48px 0 36px;
  background: rgba(var(--nav-bg-rgb), calc(var(--nav-bg-alpha) + .05));
  backdrop-filter: saturate(1.1) blur(8px);
  -webkit-backdrop-filter: saturate(1.1) blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.site-footer .footer-hero-overlay{
  position:absolute; inset:0;
  background: radial-gradient(1200px 400px at 10% -10%, rgba(0,227,248,.15), transparent 60%),
              radial-gradient(800px 300px at 100% 110%, rgba(0,227,248,.08), transparent 60%);
  pointer-events:none;
}
.site-footer .footer-title{ color: var(--brand-title); margin:0; }
.site-footer .footer-subtitle{ color: rgba(255,255,255,.85); }

.site-footer .footer-newsletter .form-control{
  background: rgba(255,255,255,.9);
  border-color: rgba(255,255,255,.35);
}
html.theme-dark .site-footer .footer-newsletter .form-control{
  background: rgba(0,0,0,.35);
  color: #fff;
  border-color: rgba(255,255,255,.15);
}

.site-footer .app-promo{
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
}
html.theme-dark .site-footer .app-promo{
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.12);
}
.site-footer .app-badge{
  width:54px;height:54px;border-radius:14px;
  display:flex;align-items:center;justify-content:center;
  background: linear-gradient(135deg, rgba(0,227,248,.8), rgba(14,165,183,.8));
  box-shadow: var(--shadow);
  font-size: 1.35rem;
}

.site-footer .footer-links{
  background: rgba(0,0,0,.25);
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.site-footer .footer-links h6{ color:#fff; margin-bottom:.25rem; }
.site-footer .footer-underline{ width:60px;height:2px;background:#fff;opacity:.9;border-radius:2px; }
.site-footer .footer-links a{ color:#fff; text-decoration:none; }
.site-footer .footer-links a:hover{ color: var(--brand-title); }

.site-footer .footer-bottom{
  background: rgba(0,0,0,.2);
  border-top: 1px solid rgba(255,255,255,.08);
}
.site-footer .socials .btn{
  border-color: rgba(255,255,255,.6);
  color: #fff;
}
.site-footer .socials .btn:hover{
  background: var(--brand-title);
  border-color: var(--brand-title);
  color: #1b2753;
}

@media (max-width: 991.98px){
  .site-footer .footer-hero{ padding: 36px 0 28px; }
}

/* ---------------------------
   GLASS — только внутри секции
   --------------------------- */
.glass-scope{
  position: relative;
  isolation: isolate; /* не даём смешиваться backdrop-filter через границы секции */
}
.glass-scope::before{
  content:"";
  position:absolute; inset:0;
  background:
    radial-gradient(1100px 380px at 10% -10%, rgba(0,227,248,.14), transparent 60%),
    radial-gradient(900px 300px at 100% 110%, rgba(0,227,248,.08), transparent 60%);
  z-index:0; pointer-events:none;
}
.glass-scope::after{
  content:"";
  position:absolute; inset:0;
  /* синий тинт локального стекла */
  background: linear-gradient(180deg, rgba(var(--tint-rgb), var(--tint-alpha)) 0%, rgba(var(--tint-rgb), var(--tint-alpha-strong)) 100%);
  backdrop-filter: saturate(1.06) blur(6px);
  -webkit-backdrop-filter: saturate(1.06) blur(6px);
  z-index:0;
}
.glass-scope .glass-content{ position: relative; z-index: 1; }

/* ---------------------------
   Хлебные крошки
   --------------------------- */
.crumbs-bar{
  margin: 0; padding: .5rem .75rem;
  background: rgba(var(--tint-rgb), .22);
  border: 1px solid rgba(255,255,255,.20);
  backdrop-filter: blur(8px) saturate(1.05);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.crumbs-bar .breadcrumb{ background: transparent; padding: 0; margin: 0; }
.crumbs-bar .breadcrumb-item a{ color: var(--accent); text-decoration: none; }
.crumbs-bar .breadcrumb-item a:hover{ color: var(--accent-hover); text-decoration: underline; }
.crumbs-bar .breadcrumb-item + .breadcrumb-item::before{ color: var(--muted); opacity: .85; }
.crumbs-bar .breadcrumb-item.active{ color: var(--text); font-weight: 600; }
html.theme-dark .crumbs-bar{ background: rgba(var(--tint-rgb), .28); border-color: rgba(255,255,255,.14); }

/* ===== BOOK VIEW (light/dark, glass) ===== */
.book-hero .book-cover img{
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.book-hero .book-meta{
  gap: .5rem .75rem;
  margin-top: .5rem;
}
.book-hero .meta-chip{
  display: inline-flex;
  align-items: center;
  background: rgba(var(--surface-rgb,255,255,255), .65);
  border: 1px solid rgba(255,255,255,.2);
  backdrop-filter: blur(8px) saturate(1.05);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  border-radius: 10px;
  padding: .35rem .5rem;
  font-size: .9rem;
}
html.theme-dark .book-hero .meta-chip{
  background: rgba(var(--surface-rgb,18,24,38), .55);
  border-color: rgba(255,255,255,.14);
}
.book-hero .meta-chip .label{
  color: var(--muted);
  margin-right: .4rem;
}
.book-hero .meta-chip.views{
  border-color: rgba(0,227,248,.25);
}

.book-desc, .book-toc{
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
}
.book-toc h1, .book-toc h2, .book-toc h3{
  margin-top: 1rem;
}

.separator{ opacity:.6; margin: 0 .25rem; }

.crumbs-bar{
  margin:0; padding:.5rem .75rem;
  background: rgba(var(--surface-rgb,255,255,255), .65);
  border: 1px solid rgba(255,255,255,.20);
  backdrop-filter: blur(8px) saturate(1.05);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
html.theme-dark .crumbs-bar{
  background: rgba(var(--surface-rgb,18,24,38), .55);
  border-color: rgba(255,255,255,.14);
}

/* стеклянная область-обёртка — ты её уже используешь */
.glass-scope{ position:relative; isolation:isolate; }
.glass-scope::before{
  content:""; position:absolute; inset:0;
  background:
    radial-gradient(1100px 380px at 10% -10%, rgba(0,227,248,.14), transparent 60%),
    radial-gradient(900px 300px at 100% 110%, rgba(0,227,248,.08), transparent 60%);
  z-index:0; pointer-events:none;
}
.glass-scope::after{
  content:""; position:absolute; inset:0; z-index:0;
  background: rgba(var(--nav-bg-rgb), calc(var(--nav-bg-alpha) + .05));
  backdrop-filter: saturate(1.06) blur(6px);
  -webkit-backdrop-filter: saturate(1.06) blur(6px);
}
.glass-scope .glass-content{ position:relative; z-index:1; }
