/* Layout System */

.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-6);
  padding-right: var(--space-6);
}

section {
  padding-top: var(--space-20);
  padding-bottom: var(--space-20);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.grid { display: grid; }

.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.gap-12 { gap: var(--space-12); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }
.mb-16 { margin-bottom: var(--space-16); }

.w-full { width: 100%; }

/* Specific Components */
.hero-buttons {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 320px;
}

/* Display Utilities */
.hidden { display: none; }

/* Base Grids (Mobile First) */
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Medium Screens (>= 768px) */
@media (min-width: 768px) {
  .md\:flex { display: flex !important; }
  .md\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .md\:flex-col { flex-direction: column; }
  .md\:col-span-1 { grid-column: span 1 / span 1; }
  .md\:w-auto { width: auto; }
  .md\:hidden { display: none !important; }
  
  .hero-buttons {
    flex-direction: row;
    max-width: none;
    width: auto;
  }
}

/* Large Screens (>= 1024px) */
@media (min-width: 1024px) {
  .lg\:flex { display: flex !important; }
  .lg\:grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
  .lg\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .lg\:flex-col { flex-direction: column; }
}

/* Mobile adjustments */
@media (max-width: 767px) {
  section {
    padding-top: var(--space-12);
    padding-bottom: var(--space-12);
  }
}

/* Glassmorphism Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background-color: rgba(248, 250, 252, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color 350ms cubic-bezier(0.4, 0, 0.2, 1),
              border-color     350ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: background-color;
}

:root[data-theme="dark"] .site-header {
  background-color: rgba(10, 14, 26, 0.85);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
}

/* Mobile Menu */
.mobile-menu {
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-body);
  z-index: 40;
  padding: var(--space-8) var(--space-6);
  display: flex;
  flex-direction: column;
  /* Slide in from top with a smooth spring curve */
  transform: translateY(-8px);
  opacity: 0;
  visibility: hidden;
  transition:
    transform   380ms cubic-bezier(0.32, 0.72, 0, 1),
    opacity     300ms cubic-bezier(0.4, 0, 0.2, 1),
    visibility  380ms cubic-bezier(0.32, 0.72, 0, 1),
    background-color 350ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  will-change: transform, opacity;
  /* Prevent scroll chaining on iOS */
  touch-action: pan-y;
}

.mobile-menu.is-open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  /* Slightly different easing for open vs close feels more natural */
  transition:
    transform   300ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity     250ms cubic-bezier(0.4, 0, 0.2, 1),
    visibility  300ms cubic-bezier(0.22, 1, 0.36, 1),
    background-color 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-nav-link {
  color: var(--text-main);
  text-decoration: none;
  width: 100%;
  text-align: center;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-color);
  transition: color var(--transition-fast);
}

.mobile-nav-link:hover {
  color: var(--color-blue-500);
}

/* Documentation Layout */
.docs-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  margin-top: var(--space-8);
  margin-bottom: var(--space-16);
}

@media (min-width: 768px) {
  .docs-layout {
    grid-template-columns: 280px 1fr;
    gap: var(--space-12);
  }
}

.docs-sidebar {
  position: sticky;
  top: 100px;
  height: max-content;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  padding-right: var(--space-6);
  display: none;
}

@media (min-width: 768px) {
  .docs-sidebar {
    display: block;
  }
}

.docs-nav-link {
  display: block;
  padding: var(--space-2) 0;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--transition-fast);
}

.docs-nav-link:hover, .docs-nav-link.active {
  color: var(--color-blue-500);
  font-weight: 600;
}

.docs-nav-group {
  margin-bottom: var(--space-6);
}

.docs-nav-group-title {
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

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

.docs-section {
  margin-bottom: var(--space-12);
  padding-top: 0;
  padding-bottom: 0;
}

.docs-section h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: var(--space-4);
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-2);
}

.docs-section h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: var(--space-8);
  margin-bottom: var(--space-3);
  color: var(--text-main);
}

.docs-section p {
  color: var(--text-muted);
  margin-bottom: var(--space-4);
  line-height: 1.7;
}

.docs-section ul, .docs-section ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-6);
  color: var(--text-muted);
}

.docs-section li {
  margin-bottom: var(--space-2);
}

.docs-code-block {
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.9rem;
  margin-bottom: var(--space-4);
  color: var(--text-main);
  white-space: pre-wrap;
  word-break: break-word;
}
