/* =========================
   РусскаяРечь — базовые стили
   Light theme, mobile-first
   Полная версия (исправления шапки/меню включены)
   ========================= */

:root{
  --bg: #fbfcfe;
  --surface: #ffffff;
  --surface-2:#f4f7fb;
  --text:#0f172a;
  --muted:#475569;
  --border:#e2e8f0;
  --accent:#2563eb;
  --accent-2:#1d4ed8;
  --ok:#0f766e;
  --warn:#b45309;

  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);

  --radius: 16px;
  --radius-sm: 12px;

  --max: 1120px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono","Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans","Liberation Sans", sans-serif;
}

*{ box-sizing:border-box; }
html{ scroll-behavior:smooth; }

body{
  margin:0;
  font-family: var(--sans);
  color:var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, #eaf2ff 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #e8fbff 0%, transparent 55%),
    var(--bg);
  line-height:1.6;
}

img{ max-width:100%; height:auto; display:block; }

a{ color:var(--accent); text-decoration:none; }
a:hover{ color:var(--accent-2); text-decoration:underline; }

.container{
  width: min(var(--max), calc(100% - 32px));
  margin-inline:auto;
}

/* =========================
   Accessibility
   ========================= */
.skip-link{
  position:absolute;
  left:-999px;
  top:auto;
  width:1px;
  height:1px;
  overflow:hidden;
}
.skip-link:focus{
  left:16px;
  top:16px;
  width:auto;
  height:auto;
  padding:10px 12px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  box-shadow:var(--shadow);
  z-index:9999;
}

/* =========================
   Header (FIXED overflow)
   ========================= */
.site-header{
  position: sticky;
  top:0;
  z-index:1000;
  background: rgba(251,252,254,0.80);
  backdrop-filter: blur(10px);
  border-bottom:1px solid rgba(226,232,240,0.8);
}

.header-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 12px 0;
}

/* критично для предотвращения распирания: флекс-детям разрешаем сжиматься */
.header-inner > *{ min-width:0; }

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0; /* FIX */
  text-decoration:none;
}
.brand-mark{
  flex:0 0 auto;
  width:34px; height:34px;
  border-radius:12px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 60%, #06b6d4 100%);
  box-shadow: 0 10px 25px rgba(37,99,235,0.25);
}
.brand-title{
  display:flex;
  flex-direction:column;
  line-height:1.1;
  min-width:0;
}
.brand-title strong{
  font-size: 14px;
  letter-spacing:0.2px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 220px;
}
.brand-title span{
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 220px;
}

/* Верхнее меню: по умолчанию скрыто (mobile-first) */
.nav{ display:none; }

/* Actions */
.header-actions{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

/* Search (по умолчанию скрыт на мобиле) */
.search{
  display:none;
  align-items:center;
  gap:8px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:999px;
  padding:8px 10px;
  box-shadow: var(--shadow-sm);
  min-width:0;
}
.search input{
  border:none;
  outline:none;
  width: min(220px, 34vw); /* FIX: не фиксируем жестко */
  font-size:14px;
  background: transparent;
  color: var(--text);
  min-width:0;
}

/* Buttons */
.icon-btn, .btn{
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius:999px;
  padding:10px 12px;
  cursor:pointer;
  box-shadow: var(--shadow-sm);
}
.icon-btn:hover, .btn:hover{ border-color:#cbd5e1; }

.btn-primary{
  border-color: rgba(37,99,235,0.35);
  background: linear-gradient(180deg, rgba(37,99,235,0.10), rgba(37,99,235,0.06));
  color: var(--accent-2);
}
.btn-primary:hover{ border-color: rgba(37,99,235,0.55); }

/* Mobile nav */
.mobile-toggle{ display:inline-flex; }

.mobile-drawer{
  display:none;
  border-top:1px solid var(--border);
  background: rgba(251,252,254,0.92);
  backdrop-filter: blur(10px);
}
.mobile-drawer.open{ display:block; }
.mobile-drawer .container{ padding: 10px 0 14px; }

.mobile-drawer nav{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px;
}
.mobile-drawer a{
  border:1px solid var(--border);
  border-radius: 12px;
  padding:10px 12px;
  background: var(--surface);
  color: var(--text);
}
.mobile-drawer a:hover{
  border-color:#cbd5e1;
  text-decoration:none;
}

/* =========================
   Hero
   ========================= */
.hero{ padding: 28px 0 16px; }

.hero-card{
  background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(255,255,255,0.86));
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}

.hero-inner{
  display:grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: 18px;
}

.kicker{
  display:inline-flex;
  align-items:center;
  gap:10px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap:wrap;
}
.badge{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border-radius:999px;
  border:1px solid var(--border);
  background: rgba(244,247,251,0.9);
  font-size: 12px;
  color: var(--muted);
}

h1{
  margin: 6px 0 0;
  font-size: 28px;
  line-height:1.15;
  letter-spacing: -0.3px;
}

.lead{
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 70ch;
}

.hero-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top: 14px;
}

.hero-illustration{
  display:flex;
  align-items:center;
  justify-content:center;
  background:
    radial-gradient(400px 200px at 40% 30%, rgba(37,99,235,0.14), transparent 60%),
    radial-gradient(420px 220px at 70% 60%, rgba(14,165,233,0.14), transparent 60%),
    rgba(244,247,251,0.8);
  border:1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius-sm);
  padding: 16px;
  min-height: 200px;
}

/* =========================
   Sections / Cards
   ========================= */
main{ padding: 14px 0 30px; }

.section{ margin-top: 16px; }

.section-title{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap:12px;
  margin: 10px 0 10px;
}
.section-title h2{
  margin:0;
  font-size: 18px;
  letter-spacing: -0.2px;
}
.section-title p{
  margin:0;
  color:var(--muted);
  font-size: 13px;
}

.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.card{
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 10px 25px rgba(15,23,42,0.06);
  min-width:0;
}
.card h3{
  margin: 0 0 6px;
  font-size: 16px;
}
.card p{
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}
.card .meta{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  margin-top: 10px;
}
.pill{
  font-size: 12px;
  color: var(--muted);
  border:1px solid var(--border);
  border-radius:999px;
  padding: 5px 10px;
  background: rgba(244,247,251,0.9);
}

.note{
  background: rgba(15,118,110,0.06);
  border: 1px solid rgba(15,118,110,0.18);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #064e3b;
}
.warn{
  background: rgba(180,83,9,0.06);
  border: 1px solid rgba(180,83,9,0.18);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #7c2d12;
}

.two-col{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* =========================
   Article typography
   ========================= */
.article{
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width:0;
}

.article h1, .article h2, .article h3{ scroll-margin-top: 92px; }

.article h1{
  font-size: 24px;
  margin: 0 0 6px;
}
.article .subtitle{
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}
.article h2{
  font-size: 18px;
  margin: 18px 0 8px;
}
.article h3{
  font-size: 15px;
  margin: 14px 0 6px;
}

.article p{ margin: 0 0 10px; color: var(--text); }

.article ul, .article ol{ margin: 8px 0 14px 20px; }
.article li{ margin: 6px 0; }

.article code{
  font-family: var(--mono);
  font-size: 0.95em;
  background: rgba(244,247,251,0.95);
  border: 1px solid rgba(226,232,240,0.9);
  padding: 2px 6px;
  border-radius: 8px;
}

.kbd{
  font-family: var(--mono);
  font-size: 12px;
  border:1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 8px;
  padding: 2px 6px;
  background: rgba(255,255,255,0.95);
}

.toc{
  background: rgba(244,247,251,0.85);
  border:1px solid rgba(226,232,240,0.95);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.toc strong{ display:block; margin-bottom:8px; }
.toc a{
  display:block;
  padding: 6px 0;
  color: var(--text);
}
.toc a:hover{
  color: var(--accent-2);
  text-decoration:none;
}

/* Tables */
.table{
  width:100%;
  border-collapse: collapse;
  overflow:hidden;
  border-radius: 14px;
  border:1px solid rgba(226,232,240,0.95);
}
.table th, .table td{
  text-align:left;
  padding:10px 12px;
  border-bottom:1px solid rgba(226,232,240,0.75);
  font-size: 14px;
}
.table th{
  background: rgba(244,247,251,0.9);
  font-weight: 600;
}

/* =========================
   Footer
   ========================= */
.site-footer{
  border-top:1px solid rgba(226,232,240,0.85);
  padding: 18px 0 28px;
  color: var(--muted);
}
.footer-grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.footer-grid a{ color: var(--muted); }
.footer-grid a:hover{ color: var(--accent-2); }
.small{ font-size: 12px; }

/* =========================
   Utilities
   ========================= */
.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.hr{ height:1px; background: rgba(226,232,240,0.9); margin: 14px 0; }
.hidden{ display:none !important; }

/* =========================
   Responsive
   ========================= */

/* Десктоп: показываем верхнее меню и поиск, убираем mobile-drawer */
@media (min-width: 980px){
  .mobile-toggle{ display:none; }
  .search{ display:flex; }

  /* верхняя навигация появляется и не распирает: прокрутка при необходимости */
  .nav{
    display:flex;
    align-items:center;
    gap:8px;

    flex: 1 1 auto;
    min-width:0;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
  }
  .nav::-webkit-scrollbar{ display:none; }

  .nav a{
    flex: 0 0 auto;
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:10px 12px;
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    text-decoration:none;
    white-space:nowrap;
  }
  .nav a:hover{
    background: rgba(37,99,235,0.08);
    text-decoration:none;
  }
  .nav a[aria-current="page"]{
    background: rgba(37,99,235,0.12);
    color: var(--accent-2);
  }

  .mobile-drawer{ display:none !important; }

  .hero-inner{
    grid-template-columns: 1.2fr 0.8fr;
    align-items:stretch;
    padding: 20px;
  }

  h1{ font-size: 34px; }
  .grid{ grid-template-columns: repeat(3, 1fr); }
  .two-col{ grid-template-columns: 1fr 1fr; }
  .footer-grid{ grid-template-columns: 2fr 1fr 1fr; }
}

/* Средние экраны (планшеты/узкие ноутбуки): не показываем верхнее меню, чтобы не ломало шапку */
@media (min-width: 860px) and (max-width: 979px){
  .search{ display:flex; }
  .nav{ display:none; }
  .mobile-toggle{ display:inline-flex; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior:auto; }
}
