/* ============================================================
   WildGuard Society — Layout System (css/layout.css)
   Grid, container, section spacing, responsive breakpoints
   ============================================================ */

/* ── Container ── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

/* ── Page content clears the fixed floating header ── */
main:not(.portal-main) {
  padding-top: calc(var(--header-height) + 1rem);
}

.container--narrow { max-width: 800px; }
.container--wide { max-width: 1400px; }

/* ── Section Spacing ── */
.section {
  padding: var(--space-3xl) 0;
  position: relative;
}

.section--sm { padding: var(--space-2xl) 0; }
.section--lg { padding: 6rem 0; }

/* ── Content overlay (dark glass background for readability) ── */
.content-overlay {
  background: var(--overlay-mid);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ── Section header (centered title + subtitle + accent line) ── */
.section-header {
  text-align: center;
  margin-bottom: var(--space-2xl);
}

.section-header h2 {
  color: var(--lighter);
  margin-bottom: 0.8rem;
  display: inline-block;
  position: relative;
}

.section-header h2::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -0.6rem;
  transform: translateX(-50%);
  width: 48px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.section-header p {
  color: var(--text-dim);
  max-width: 560px;
  margin: 1.2rem auto 0;
}

/* ── Grid System ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-xl);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-xl);
  margin-top: var(--space-xl);
}

.card-grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

/* ── Vertical rhythm helpers ── */
.stack > * + * { margin-top: var(--space-lg); }
.stack--sm > * + * { margin-top: var(--space-sm); }
.stack--xl > * + * { margin-top: var(--space-2xl); }

/* ── Flex helpers ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

/* ── Text helpers ── */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }

/* ── Visibility ── */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ⊜Accessibility: Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-md);
  background: var(--accent);
  color: var(--darker);
  padding: 0.5rem 1rem;
  border-radius: 0 0 var(--radius) var(--radius);
  z-index: var(--z-toast);
  font-weight: 600;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ░Focus-visible for keyboard only (pollyfill) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ═ Navigation skip hint */
.skip-to-main {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--darker);
  padding: 0.5rem 1.5rem;
  border-radius: 0 0 8px 8px;
  z-index: 10000;
  font-weight: 600;
  transition: top 0.3s ease;
  text-decoration: none;
}

.skip-to-main:focus {
  top: 0;
}

/* ── Spacing utilities ── */
.mt-2 { margin-top: var(--space-xl); }
.mt-3 { margin-top: var(--space-2xl); }
.mb-2 { margin-bottom: var(--space-xl); }
.mb-3 { margin-bottom: var(--space-2xl); }
.p-2 { padding: var(--space-xl); }

/* ── Responsive Breakpoints ── */

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

@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .section { padding: var(--space-2xl) 0; }
}

@media (max-width: 768px) {
  .container { padding: 0 1.25rem; }
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section { padding: 2.5rem 0; }
  .section-header h2 { font-size: 1.8rem; }
}

@media (max-width: 480px) {
  .container { padding: 0 1rem; }
  .section-header p { font-size: 0.9rem; }
}