/* SKELETON.CSS — "Скелет" твоего SaaS-конструктора.
   Здесь НЕТ цветов и шрифтов. Они прилетают из Python-бэкенда.
   
   Ожидаемые переменные (вставляются в <head>):
   --font-heading
   --font-body
   
   --color-bg
   --color-block-bg    (фон карточек/секций)
   --color-text
   --color-text-muted  (второстепенный текст)
   --color-primary     (основной акцент/кнопки)
   --color-primary-fg  (текст на кнопке)
   --color-border
   
   --radius-btn
   --radius-card
   --shadow-card
*/

/* =========================================
   1. RESET & BASE
   ========================================= */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  color: var(--color-text);
  line-height: 1.2;
  margin-bottom: 1rem;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
}

h3 {
  font-size: 1.5rem;
}

p {
  margin-bottom: 1rem;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: opacity 0.2s;
}

a:hover {
  opacity: 0.8;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-card);
}

/* =========================================
   2. LAYOUT & UTILITIES
   ========================================= */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

.section {
  padding: 4rem 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.75rem;
  background-color: var(--color-primary);
  color: var(--color-primary-fg, #ffffff);
  border-radius: var(--radius-btn);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Cards */
.card {
  background-color: var(--color-block-bg);
  border-radius: var(--radius-card);
  padding: 2rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  transition: transform 0.3s;
}

.card:hover {
  transform: translateY(-4px);
}

/* =========================================
   3. HEADER & NAV
   ========================================= */
header {
  background-color: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  /* High priority for sticky header */
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--color-primary);
  z-index: 1001;
  /* Поверх мобильного меню */
}

/* Desktop Nav */
.main-nav {
  display: flex;
  gap: 2rem;
}

.main-nav a {
  color: var(--color-text);
  font-weight: 500;
}

.main-nav a:hover,
.main-nav a.active {
  color: var(--color-primary);
}

.menu-toggle {
  display: none;
  /* Hidden on desktop */
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10002;
  /* INCREASED - Above everything */
  color: var(--color-text);
}

/* Hide toggle button when menu is active */
.menu-toggle.active {
  display: none !important;
}

/* Styles for dynamically created close button */
.menu-close-btn {
  display: none !important;
  /* Hidden on desktop always */
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  z-index: 10003;
  /* INCREASED - Highest priority */
  color: #1f2937;
  /* HARDCODED dark color - menu has white bg regardless of theme */
  padding: 0.5rem;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

/* =========================================
   4. CONTACT PAGE
   ========================================= */
.contact-header {
  text-align: center;
  padding: 3rem 0;
  max-width: 800px;
  margin: 0 auto;
}

.contact-header p {
  color: var(--color-text-muted);
  font-size: 1.125rem;
}

.contact-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-bottom: 4rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.875rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  /* Используем тот же радиус, что у кнопок */
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.contact-info-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.contact-info-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.contact-icon {
  color: var(--color-primary);
  font-size: 1.5rem;
  line-height: 1;
}

/* =========================================
   5. ARTICLES / BLOG
   ========================================= */
.article-wrapper {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.article-content {
  font-size: 1.125rem;
  line-height: 1.8;
}

.article-content h2 {
  margin-top: 2.5rem;
}

.article-content ul {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.article-content li {
  margin-bottom: 0.5rem;
}

.article-content blockquote {
  border-left: 4px solid var(--color-primary);
  padding-left: 1.5rem;
  font-style: italic;
  color: var(--color-text-muted);
  margin: 2rem 0;
}

/* =========================================
   6. FOOTER
   ========================================= */
footer {
  margin-top: auto;
  /* Прижимает футер к низу */
  background-color: var(--color-block-bg);
  border-top: 1px solid var(--color-border);
  padding: 3rem 0;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}

.footer-col h4 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

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

.footer-nav a {
  color: var(--color-text-muted);
}

.footer-nav a:hover {
  color: var(--color-primary);
}

/* =========================================
   7. MOBILE ADAPTIVE (Unified)
   ========================================= */
@media (max-width: 768px) {

  /* Mobile Menu Logic */
  .menu-toggle {
    display: flex;
    /* Removed duplicate display: block */
    position: relative;
    z-index: 10002;
    /* INCREASED - Above everything */
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
  }

  .main-nav {
    position: fixed;
    top: 0;
    right: -100%;
    /* Hide off-screen */
    width: 80%;
    max-width: 300px;
    height: 100vh;
    background-color: #ffffff !important;
    /* White background for better contrast - !important to override desktop */
    opacity: 1 !important;
    /* Solid, not transparent */
    flex-direction: column;
    padding: 5rem 2rem;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.2);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    /* INCREASED - Below toggle and close-btn but above all content */
    border-left: 1px solid var(--color-border);
  }

  /* Class added by JS to open menu */
  .main-nav.active {
    right: 0;
  }

  /* Show close button on mobile when menu is active */
  .main-nav.active .menu-close-btn {
    display: flex !important;
  }

  .main-nav a {
    font-size: 1.25rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e5e7eb;
    color: #1f2937 !important;
    /* Dark text for white background - !important to override desktop */
  }

  .main-nav a:hover {
    color: var(--color-primary);
  }

  /* Backdrop overlay when menu is open */
  .main-nav.active::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    /* Ensure full width */
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    /* Solid dimming for mobile menu backdrop */
    z-index: -1;
    animation: fadeIn 0.3s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    /* Blur effect to hide page content */
  }

  /* Contact Page Layout Mobile */
  .contact-layout {
    grid-template-columns: 1fr;
  }

  .contact-header {
    padding: 2rem 0;
  }

  h1 {
    font-size: 2rem;
  }

  .section {
    padding: 2.5rem 0;
  }

  /* Ensure TOC doesn't overlap menu */
  .toc,
  .table-of-contents,
  #toc {
    position: relative;
    z-index: 1;
  }
}

/* Utilities */
.text-center {
  text-align: center;
}

.mb-2 {
  margin-bottom: 1rem;
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================
   MOBILE MENU OVERLAY (created by JS)
   ========================================= */
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.05);
  /* Very light dimming - 5% */
  z-index: 9999;
  /* Below nav (10001) */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  /* KEY FIX: Let clicks pass through to menu! */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Prevent article elements from overlapping mobile menu */
@media (max-width: 768px) {

  article,
  article header,
  article h1,
  article h2,
  article h3 {
    z-index: auto !important;
  }
}