/* ==========================================================================
   HamachiInfo — layout.css
   Сетки, шапка, футер, сайдбар, основные layout-паттерны
   ========================================================================== */

/* ---- Grid System ---- */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 { grid-template-columns: 1fr; }
}

/* ---- Flex utilities ---- */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-xl { gap: 2rem; }

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  display: flex;
  flex-direction: column;
  background: rgba(13, 15, 20, 0.7);
  border-bottom: 1px solid transparent;
  transition: all var(--transition);
}

[data-theme="light"] .site-header {
  background: rgba(240, 242, 248, 0.7);
}

.site-header.scrolled {
  background: rgba(13, 15, 20, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--border-active);
}

[data-theme="light"] .site-header.scrolled {
  background: rgba(240, 242, 248, 0.92);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 2rem;
  height: var(--header-height);
  flex: 1;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}

.logo:hover {
  text-decoration: none;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo-text em {
  color: var(--accent-primary);
  font-style: normal;
}

/* Main nav */
.main-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  padding: 0.45rem 0.875rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent-primary);
  background: var(--border-active);
  text-decoration: none;
}

/* Header actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

/* Reading progress bar */
.reading-progress-bar {
  height: 2px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  width: 0%;
  transition: width 0.1s linear;
  position: absolute;
  bottom: 0;
  left: 0;
}

/* Mobile menu toggle — hidden on desktop */
.mobile-menu-toggle {
  display: none;
}

/* Mobile nav overlay */
.mobile-nav {
  position: fixed;
  top: 0;
  right: -100%;
  width: 280px;
  height: 100vh;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  z-index: 2000;
  padding: 5rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}

.mobile-nav.open {
  right: 0;
}

.mobile-nav .nav-link {
  display: block;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.mobile-nav .nav-link:last-child {
  border-bottom: none;
}

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.nav-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* ---- Breadcrumbs ---- */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  color: var(--accent-primary);
}

.breadcrumb-item:last-child {
  color: var(--accent-primary);
}

.breadcrumb-sep {
  color: var(--text-muted);
}

/* ---- Page layout with sidebar ---- */
.page-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 3rem;
  align-items: start;
}

.page-content {
  min-width: 0;
}

.page-sidebar {
  position: sticky;
  top: calc(var(--header-height) + 2rem);
}

@media (max-width: 1024px) {
  .page-layout {
    grid-template-columns: 1fr;
  }
  .page-sidebar {
    position: static;
    order: -1;
  }
}

/* Table of Contents */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.toc-title {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.toc-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.toc-item {
  margin-bottom: 0;
}

.toc-link {
  display: block;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 4px;
  border-left: 2px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--accent-primary);
  background: var(--border-active);
  text-decoration: none;
}

.toc-link.active {
  color: var(--accent-primary);
  border-left-color: var(--accent-primary);
  background: rgba(0,212,255,0.05);
}

.toc-link--h3 {
  padding-left: 1.25rem;
  font-size: 0.8rem;
}

/* ---- Hero section ---- */
.hero {
  padding: 6rem 0 5rem;
  position: relative;
  overflow: hidden;
}

.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}

.hero-content {
  position: relative;
  z-index: 2;
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-primary);
  background: rgba(0,212,255,0.08);
  border: 1px solid var(--border-active);
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
  margin-bottom: 1.5rem;
}

.hero-title {
  margin-bottom: 1.25rem;
  font-size: clamp(2.2rem, 5vw, 3.75rem);
}

.hero-title .accent {
  color: var(--accent-primary);
  display: block;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 44ch;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
}

@media (max-width: 768px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
  .hero {
    padding: 4rem 0 3.5rem;
  }
  .hero-visual {
    order: -1;
  }
}

/* ---- Stats bar ---- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 3rem 0;
}

.stats-bar .stat-card {
  background: var(--bg-secondary);
  border-radius: 0;
  border: none;
}

@media (max-width: 768px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-bar {
    grid-template-columns: 1fr;
  }
}

/* ---- Section header ---- */
.section-header {
  margin-bottom: 2.5rem;
}

.section-header--center {
  text-align: center;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 2.5rem;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 4rem 0 2rem;
  margin-top: 5rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-col h4 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.footer-col > p {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 30ch;
  line-height: 1.6;
  margin-top: 0.75rem;
}

.footer-col nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.footer-col nav a {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-col nav a:hover {
  color: var(--accent-primary);
  text-decoration: none;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.footer-bottom p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---- Page hero (inner pages) ---- */
.page-hero {
  padding: 3.5rem 0 2.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 3rem;
}

.page-hero-title {
  margin-bottom: 0.75rem;
}

.page-hero-desc {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 60ch;
  margin-bottom: 0;
}

/* ---- Next step block ---- */
.next-step {
  border: 1px solid var(--border-active);
  background: rgba(0,212,255,0.04);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 3rem;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition);
}

.next-step:hover {
  background: rgba(0,212,255,0.08);
  transform: translateX(4px);
  text-decoration: none;
  color: inherit;
}

.next-step-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.next-step-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0;
}

.next-step-arrow {
  margin-left: auto;
  color: var(--accent-primary);
  flex-shrink: 0;
}

/* ---- Responsive utilities ---- */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .mobile-menu-toggle { display: flex !important; }
  .main-nav { display: none; }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  h1 { font-size: clamp(1.75rem, 8vw, 2.5rem); }
}
