/* ===== Theme / Base ===== */
:root{
  --bg:#0b0d10; --card:#121419; --text:#e9eef5; --muted:#a7b0bd; --line:#1b2028;
  --accent:#66e0a3; --red:#ff5a5a; --green:#47d16a;
  --header-h-desktop:72px; --header-h-mobile:124px;
  --card-hover:#151922; --line-hover:#2a313b;
  --hero-pad:16px; --hero-gap:12px;
}
/* Светлая тема */
:root.theme-light{
  --bg:#ffffff; --card:#f7f8fa; --text:#0b0d10; --muted:#5a6573; --line:#e5e9f0;
  --accent:#0b84ff; --red:#d11a2a; --green:#0a7d2f;
  --card-hover:#fafafa; --line-hover:#cbd5e1;
}

*{ box-sizing:border-box }
html{
  scrollbar-gutter: stable;
  overflow-y: scroll;
}
html,body{ height:100% }
body{
  padding-top:var(--header-h-desktop);
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg); color:var(--text);
}
img{ max-width:100%; display:block }
a{ color:inherit }
.container{ max-width:1180px; margin:0 auto; padding:16px }
.muted{ color:var(--muted) }

/* ===== Header (fixed + blur) ===== */
.site-header{
  position:fixed; top:0; left:0; right:0; z-index:100;
  border-bottom:1px solid var(--line);
  background:rgba(15,18,22,.7);
  backdrop-filter:saturate(150%) blur(8px);
  -webkit-backdrop-filter:saturate(150%) blur(8px);
}
.header-row{ display:flex; align-items:center; gap:24px }
.logo{ display:flex; align-items:center; gap:12px; color:inherit; text-decoration:none }
.logo-text{ display:flex; flex-direction:column; line-height:1; white-space:nowrap; }
.brand{ font-weight:800; letter-spacing:.3px }
.slogan{ font-size:12px; color:var(--muted) }

/* top nav (без дублей) */
.top-nav{
  margin-left:auto; display:flex; gap:16px; white-space:nowrap;
}
.top-nav a{
  color:inherit; text-decoration:none; opacity:.9; display:inline-block;
}
.top-nav a:hover{ opacity:1 }

/* ===== Ticker ===== */
.ticker{
  display:flex; gap:14px; justify-content:flex-start;
  overflow:hidden; white-space:nowrap; min-width:0;
}
.tick{
  display:flex; flex:0 0 auto; align-items:center; gap:6px;
  padding:6px 8px; border:1px solid var(--line); border-radius:12px;
  background:#0e1116; white-space:nowrap;
}
.tick img{ width:16px; height:16px }
.tick .price{
  display:inline-block; min-width:76px; text-align:right;
  font-variant-numeric: tabular-nums;
}
.tick .delta{ display:inline-block; min-width:40px; text-align:right; }
.tick .delta.up{ color:var(--green) }
.tick .delta.down{ color:var(--red) }

/* Mobile header stacked */
.header-mobile{ display:none; border-top:1px solid var(--line); padding-top:10px }

.m-brand{
  display:flex; align-items:center; gap:10px; justify-content:center;
  color:inherit; text-decoration:none; border-radius:12px;
}
.m-brand:focus-visible{ outline:3px solid var(--accent); outline-offset:3px; }

.ticker-mobile{
  display:flex; justify-content:center; align-items:center; gap:6px;
  padding:6px 0 10px; width:100%; flex-wrap:nowrap;
}
.ticker-mobile .tick{
  padding:4px 6px; margin-top:15px; border-radius:10px; font-size:9px; line-height:1; gap:3px;
}
.ticker-mobile .tick img{ width:14px; height:14px; }
.ticker-mobile .sym{ font-weight:600; }
.ticker-mobile .price{ font-variant-numeric: tabular-nums; }
.ticker-mobile .delta{ font-size:11px; }

/* ===== Home: Hero ===== */
.hero-grid{
  display:grid; grid-template-columns:1fr 1fr; gap:20px; margin:16px 0;
}
.hero-card{
  background:var(--card); border:1px solid var(--line); border-radius:12px;
  cursor:pointer;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease, background-color .2s ease, color .2s ease;
}
.hero-card.placeholder{ visibility:hidden }

.hero-link{
  display:grid; grid-template-rows:auto 1fr auto; gap:var(--hero-gap);
  padding:var(--hero-pad); border-radius:inherit; color:inherit; text-decoration:none; height:100%;
}

.hero-title{ margin:0 0 .6rem; line-height:1.15 }

.hero-row{
  display:grid; grid-template-columns:minmax(0,2fr) minmax(0,3fr); gap:16px; align-items:start;
}
.hero-card.no-image .hero-row{ grid-template-columns:1fr }

.hero-media{ margin-top:0; }
.hero-media img{ width:100%; height:auto; display:block; border-radius:8px; }

.hero-meta{
  justify-self:end; align-self:end; font-size:12px; line-height:1.1; color:var(--muted);
  text-align:right; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

.hero-card:hover, .hero-card:focus-within{
  transform:translateY(-2px); box-shadow:0 8px 24px rgba(0,0,0,.08);
  border-color:var(--line-hover); background:var(--card-hover);
}
.hero-card:hover .hero-title, .hero-card:focus-within .hero-title{ text-decoration:underline; }
.hero-link:focus-visible{ outline:3px solid var(--accent); outline-offset:3px; text-decoration:none; }

.hero-text{ display:flex; flex-direction:column; }
.hero-text > *:first-child{ margin-top:0; }

.hero-media{ aspect-ratio:16/9; overflow:hidden; border-radius:8px; }
.hero-media img{ width:100%; height:100%; object-fit:cover; display:block; }
.hcard-lead{ margin-top:0; }

/* ===== Events (public) ===== */
.page-title{ margin:18px 0 10px; font-size:26px; }

.events-tabs{ display:flex; gap:10px; margin:10px 0 14px; }
.events-tab{
  text-decoration:none; padding:8px 12px; border:1px solid var(--line);
  border-radius:10px; opacity:.95;
}
.events-tab.active, .events-tab:hover{ border-color:var(--accent); }

.events-filter{ display:flex; gap:8px; align-items:center; margin:10px 0 18px; }
.ev-inp{
  flex:1 1 auto; min-width:200px; padding:10px 12px;
  border:1px solid var(--line); border-radius:10px;
  background:var(--card); color:var(--text);
}
.ev-btn{
  padding:10px 12px; border:1px solid var(--line); border-radius:10px;
  background:var(--card); color:var(--text); cursor:pointer;
}
.ev-btn:hover{ border-color:var(--accent); }

.ev-empty{ opacity:.8; padding:16px 0; }

.events-grid{
  list-style:none; margin:0; padding:0;
  display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:16px;
}
@media (max-width: 980px){ .events-grid{ grid-template-columns:1fr; } }

.ev-card{ border:1px solid var(--line); border-radius:12px; background:var(--card); overflow:hidden; }
.ev-card__link{ color:inherit; text-decoration:none; display:block; }
.ev-card__cover{ aspect-ratio:16/9; background:#0e1116; }
.ev-card__cover img{ width:100%; height:100%; object-fit:cover; display:block; }
.ev-card__noimg{
  width:100%; height:100%; display:flex; align-items:center; justify-content:center; color:var(--muted);
}
.ev-card__body{ padding:12px; }
.ev-card__title{ margin:0 0 6px; font-size:18px; }
.ev-card__date{ margin:0 0 6px; font-size:18px; font-weight:700; }
.ev-card__venue-line{ color:var(--muted); margin-bottom:8px; }
.ev-card__subtitle{ color:var(--muted); margin-bottom:6px; }
.ev-card__meta{ font-size:13px; color:var(--muted); margin-bottom:8px; }
.ev-card__summary{ margin:0; opacity:.95; }

/* pager (единый, без дублей) */
.pager{ display:flex; gap:10px; align-items:center; margin:18px 0; }
.pager__link{
  text-decoration:none; border:1px solid var(--line); border-radius:10px; padding:8px 12px;
}
.pager__link.active, .pager__link:hover{ border-color:var(--accent); }

/* ===== View (event page) ===== */
.crumbs{ font-size:13px; opacity:.8; margin:10px 0 8px; }
.crumbs a{ color:inherit; text-decoration:none; }
.crumbs a:hover{ text-decoration:underline; }

.event-head{ margin:6px 0 12px; }
.event-title{ margin:0 0 6px; font-size:28px; }
.event-subtitle{ color:var(--muted); }
.event-meta{
  list-style:none; margin:10px 0 0; padding:0;
  display:flex; gap:10px; flex-wrap:wrap; color:var(--muted); font-size:14px;
}
/* ===== View (event page) ===== */
.event-cover{
  /* центрируем и жёстко ограничиваем ширину обложки */
  width: 100%;
  max-width: 600px;
  margin: 12px 0 18px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card);
}
.event-cover img{
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.event-body{ line-height:1.7; }
.event-body img{ max-width:100%; height:auto; border-radius:10px; }

/* ===== Lists / Buttons (вне events) ===== */
.section-title{ margin:16px 0 8px; font-size:20px }
.section-title.big{ font-size:26px }
.news-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:10px }
.news-item{ padding:6px 0 }
.news-link{ color:inherit; text-decoration:none; font-size:18px; line-height:1.35 }
.news-link:hover{ color:var(--accent) }
.load-more{
  margin:16px 0 28px; padding:12px 18px; border-radius:12px;
  border:1px solid var(--line); background:#12161c; color:var(--text); cursor:pointer;
}
.load-more:hover{ border-color:var(--accent) }
.nav-btn{
  display:inline-block; padding:8px 12px; border-radius:10px;
  border:1px solid var(--line); text-decoration:none; color:inherit;
}
.nav-btn:hover{ border-color:var(--accent) }
.nav-btn.disabled{ opacity:.4; pointer-events:none }

/* ===== Post ===== */
.post-title{ margin:12px 0 8px; font-size:28px }
.post-body{ margin-top:20px; color:#dce3ed; line-height:1.7; font-size:18px }
.post .thumb-left{ float:left; width:34%; min-width:200px; max-width:420px; margin:4px 16px 12px 0 }
.post .thumb-left img{ width:100%; height:auto; border-radius:14px; border:1px solid var(--line) }
.post .post-text{ overflow:hidden }
.post .post-body::after{ content:""; display:block; clear:both }
.post .meta{ color:var(--muted) }
.post-nav{ display:flex; justify-content:space-between; gap:12px; margin-top:30px }

/* Мета-инфо под заголовком новости */
.post-meta{
  display:flex; margin-top:10px; align-items:center; justify-content:right;
  gap:.5rem; color:var(--muted); font-size:14px; line-height:1.2; flex-wrap:nowrap;
}
.post-meta .meta-sep{ margin:0 .25rem; }
.post-meta .meta-source a{ color:inherit; text-decoration:none; }
.post-meta .meta-source a:hover{ text-decoration:underline; }

/* ===== Footer ===== */
.site-footer{ border-top:1px solid var(--line); background:#0f1216; margin-top:24px }
.footer-grid{ display:grid; grid-template-columns:1.4fr 1fr 1fr; gap:24px }
.footer-links{ display:flex; flex-direction:column; gap:8px; margin-top:8px }
.footer-links a{ color:inherit; text-decoration:none; opacity:.9 }
.footer-links a:hover{ opacity:1 }
.poll-placeholder{ border:1px dashed var(--line); border-radius:12px; padding:16px; color:var(--muted) }
.subfoot{ border-top:1px solid var(--line); opacity:.7; font-size:13px; padding-top:10px; margin-top:8px }
.subfoot-row{ display:flex; justify-content:space-between; margin-bottom:90px; align-items:center }
/* Theme-aware button */
.btn-theme,
#themeToggle{
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);   /* берём из темы */
  color: inherit;
  cursor: pointer;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.btn-theme:hover,
#themeToggle:hover{
  border-color: var(--accent);
}
.btn-theme:focus-visible,
#themeToggle:focus-visible{
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ===== Mobile bottom-sheet menu ===== */
.mobile-menu{
  position:fixed; left:0; right:0; bottom:16px; display:none;
  justify-content:flex-end; padding-right:20px; pointer-events:none; z-index:60;
}
.mobile-menu.open{ pointer-events:auto }

.menu-toggle{
  pointer-events:auto; width:64px; height:64px; border-radius:50%;
  border:2px solid #737171; background:#f4f4f4de; color:#0f0e0e;
  font-size:26px; display:flex; align-items:center; justify-content:center;
  box-shadow:none;
}
/* Light theme overrides */
:root.theme-light .menu-toggle{
  border:2px solid #0d0c0c; background:#484743de; color:#e3e3e3;
}

.menu-sheet{
  position:fixed; left:0; right:0; bottom:-240px; background:#0e1116;
  border-top-left-radius:18px; border-top-right-radius:18px;
  border:1px solid var(--line); padding:14px 20px;
  display:flex; flex-direction:column; gap:10px; transition:bottom .25s ease; z-index:55;
}
.menu-sheet.open{ bottom:0 }
.menu-sheet, .menu-sheet *{ pointer-events:auto }
.menu-item{
  color:inherit; text-decoration:none; padding:10px; border:1px solid var(--line);
  border-radius:12px; text-align:center;
}

/* ===== Light theme adjustments ===== */
:root.theme-light .site-header{ background:rgba(255,255,255,.7); border-bottom-color:var(--line);
  backdrop-filter:saturate(150%) blur(8px); -webkit-backdrop-filter:saturate(150%) blur(8px);
}
:root.theme-light .site-footer{ background:#fff; border-top-color:var(--line) }
:root.theme-light .tick{ background:#f2f5f9; border-color:var(--line) }
:root.theme-light .nav-btn,
:root.theme-light .load-more,
:root.theme-light .pager a,
:root.theme-light .poll-placeholder{ background:#f7f8fa; border-color:var(--line) }
:root.theme-light .post-body{ color:#222 }
:root.theme-light .hcard-title{ color:#0b0d10 }
:root.theme-light .hcard-lead{ color:#3b4652 }
:root.theme-light .hero-card{ background:#fff; border-color:var(--line) }

/* Подложка для закрытия по клику вне меню */
.menu-backdrop{
  position:fixed; inset:0; background:rgba(0,0,0,.35);
  opacity:0; pointer-events:none; z-index:50; transition:opacity .2s ease;
}
.mobile-menu.open ~ .menu-backdrop{ opacity:1; pointer-events:auto; }

/* Блокируем прокрутку фона, когда меню открыто */
body.menu-open{ overflow:hidden; }

/* ===== Responsive ===== */
@media (min-width: 981px){
  .site-header{ height:var(--header-h-desktop); }
  .header-row{
    display:grid; grid-template-columns:auto 1fr auto;
    align-items:center; height:var(--header-h-desktop); white-space:nowrap;
  }
  .hero-media img{ margin-top:5px; }
}

@media (max-width:980px){
  body{ padding-top:var(--header-h-mobile); }
  #ticker{ display:none; }
  .header-row{ display:none; }
  .hero-grid{ grid-template-columns:1fr; align-items:stretch; }
  .hero-row{ grid-template-columns:1fr; }
  .header-mobile{ display:block; }
  .top-nav{ display:none; }
  .post .thumb-left{ float:none; width:100%; max-width:none; margin:8px 0 12px; }
  .post-body{ font-size:17px; }
  .post-nav{ margin-top:35px; }
  .post-meta{
    display:flex; align-items:center; margin-top:30px; gap:8px;
    line-height:.7; flex-wrap:wrap;
  }
  .post-meta .meta-sep{ display:none; }
  .post-meta .meta-source{ display:block; width:100%; margin-top:4px; }
  .post-meta .meta-source::before{ content:"· "; }

  /* плавающая кнопка меню — справа */
  .mobile-menu{ left:auto; right:20px; bottom:16px; display:flex; justify-content:flex-end; }

  /* моб. кнопка «Тема» (внутри меню) */
  #themeToggleMobile{ background-color:#626466; color:#fff; }

  /* спрятать десктопную «Тему» на мобилках */
  #themeToggle, .btn-theme#themeToggle{ display:none !important; }
}

@media (max-width:560px){
  .footer-grid{ grid-template-columns:1fr; }
}

/* уважение к prefers-reduced-motion */
@media (prefers-reduced-motion: reduce){
  .hero-card{ transition:none; }
  .hero-card:hover, .hero-card:focus-within{ transform:none; }
}

/* === Mobile sheet / themes === */
.menu-sheet{ background:#373839; }
:root.theme-light .menu-sheet{ background:#f2f5f9; }
:root.theme-light .menu-item{ border:1px solid #b0b5bd; }

/* фон за меню на мобилке */
@media (max-width:980px){
  #backgroundMenu{
    z-index:54; display:none; height:100%; width:100%; position:fixed;
    background-color:#62646678;
    backdrop-filter:saturate(150%) blur(8px);
    -webkit-backdrop-filter:saturate(150%) blur(8px);
    top:0; margin:0;
  }
   .event-cover{
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
  }
}
