/**
 * Layout core: page background (main layout), container, section, stack, grid.
 * Mobile-first. Breakpoints: 560, 640, 768, 860, 980, 1024px.
 * Loaded for every view. Utilities live in layout-utilities.css.
 * Page background (starfield, neural-bg) lives here because main.php outputs it.
 */

/* ===== PAGE BACKGROUND (main layout: body pseudo-elements + .neural-bg) ===== */
/* Simplified for Firefox performance: no SVG filters, no SMIL. Static gradients only. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -4;
  /* Desktop: fewer star layers than before — less style/paint cost, same vibe */
  background:
    radial-gradient(1px 1px at 22% 28%, #ffffff 1px, transparent 1px),
    radial-gradient(1px 1px at 72% 72%, #079CFF 1px, transparent 1px),
    radial-gradient(1px 1px at 88% 38%, #00E6FF 1px, transparent 1px),
    radial-gradient(2px 2px at 12% 82%, rgba(255, 255, 255, 0.85) 1px, transparent 1px),
    var(--bg-900);
  background-size: 480px 480px, 420px 420px, 360px 360px, 520px 520px, auto;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  opacity: 0.38;
  pointer-events: none;
  background: radial-gradient(ellipse 85% 55% at 50% 0%, rgba(7, 156, 255, 0.07) 0%, transparent 52%);
}

.neural-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  opacity: 0.28;
  pointer-events: none;
  contain: layout style paint;
  background: radial-gradient(ellipse 100% 80% at 32% 22%, rgba(7, 156, 255, 0.09) 0%, transparent 48%);
}

.neural-bg::before {
  content: none;
}

/* Light theme: subtle page background (keep depth without dark starfield) */
html[data-theme="light"] body::before {
  background:
    radial-gradient(1px 1px at 22% 32%, rgba(37, 99, 235, 0.35) 1px, transparent 1px),
    radial-gradient(1px 1px at 78% 64%, rgba(8, 145, 178, 0.3) 1px, transparent 1px),
    radial-gradient(2px 2px at 12% 78%, rgba(15, 23, 42, 0.08) 1px, transparent 1px),
    var(--bg-900);
  background-size: 420px 420px, 380px 380px, 500px 500px, auto;
  opacity: 1;
}

html[data-theme="light"] body::after {
  opacity: 0.35;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(37, 99, 235, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(8, 145, 178, 0.05) 0%, transparent 50%);
}

html[data-theme="light"] .neural-bg {
  opacity: 0.25;
  background: radial-gradient(ellipse 100% 80% at 30% 20%, rgba(37, 99, 235, 0.06) 0%, transparent 45%),
    radial-gradient(ellipse 80% 60% at 70% 80%, rgba(8, 145, 178, 0.04) 0%, transparent 45%);
}

html[data-theme="light"] .neural-bg::before {
  background: radial-gradient(circle at 20% 30%, rgba(37, 99, 235, 0.05) 0%, transparent 25%);
}

/* Mobile LCP: cheaper first paint — solid theme background only (tokens already set on html[data-theme]). */
@media (max-width: 1023px) {
  body::before {
    background: var(--bg-900);
    background-size: auto;
  }

  body::after {
    opacity: 0;
    background: none;
  }

  .neural-bg {
    opacity: 0;
    background: none;
  }

  .neural-bg::before {
    content: none;
  }

  html[data-theme="light"] body::before {
    background: var(--bg-900);
    background-size: auto;
    opacity: 1;
  }

  html[data-theme="light"] body::after {
    opacity: 0;
    background: none;
  }

  html[data-theme="light"] .neural-bg {
    opacity: 0;
    background: none;
  }

  html[data-theme="light"] .neural-bg::before {
    content: none;
  }
}

/* Animations removed for Firefox performance (no SVG filters/SMIL). Backgrounds are static gradients. */

/* ===== CONTAINER ===== */
.container {
  width: 100%;
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-5);
  padding-right: var(--space-5);
}

@media (min-width: 640px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

/* Desktop .container padding in layout-core.desktop.css */

/* ===== SECTION ===== */
.section {
  padding-top: var(--space-12);
  padding-bottom: var(--space-12);
  /* content-visibility:auto + intrinsic 200px caused large CLS when real section height applied (e.g. tools grid, marketing sections). */
}

.section--tight {
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
}

.section--loose {
  padding-top: var(--space-16);
  padding-bottom: var(--space-16);
}

/* Mobile .section padding in layout-core.mobile.css */

/* ===== SECTION LABEL (eyebrow above section headings) ===== */
.section-label {
  display: block;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-2);
}

/* ===== STACK (flex column with gap) ===== */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack--sm { gap: var(--space-2); }
.stack--md { gap: var(--space-4); }
.stack--lg { gap: var(--space-6); }
.stack--xl { gap: var(--space-8); }

.stack--center {
  align-items: center;
}

.stack--inline {
  flex-direction: row;
  flex-wrap: wrap;
}

/* ===== GRID ===== */
.grid {
  display: grid;
  gap: var(--space-4);
  width: 100%;
}

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

.grid--gap-sm { gap: var(--space-2); }
.grid--gap-md { gap: var(--space-4); }
.grid--gap-lg { gap: var(--space-6); }
.grid--gap-xl { gap: var(--space-8); }

/* Responsive grid: 1 col default, then 2 at sm, 4 at lg */
.grid--responsive {
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .grid--responsive-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

/* Desktop grid in layout-core.desktop.css */

/* Full-width layout default */
.layout-full {
  width: 100%;
  min-height: 100%;
}
