/* ============================================================
   SafeSpace — main.css
   Design tokens, resets, typography, layout utilities
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  /* Background layers */
  --bg-0: #060a14;
  --bg-1: #0a0e1e;
  --bg-2: #0e1428;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.075);
  --bg-glass: rgba(14, 20, 40, 0.7);

  /* Borders */
  --border: rgba(255, 255, 255, 0.07);
  --border-accent: rgba(0, 212, 170, 0.35);
  --border-purple: rgba(139, 92, 246, 0.35);

  /* Accent colours */
  --teal: #00d4aa;
  --teal-bright: #00f5c4;
  --teal-dim: rgba(0, 212, 170, 0.12);
  --teal-glow: rgba(0, 212, 170, 0.25);

  --purple: #8b5cf6;
  --purple-bright: #a78bfa;
  --purple-dim: rgba(139, 92, 246, 0.12);
  --purple-glow: rgba(139, 92, 246, 0.25);

  --coral: #f87171;
  --coral-dim: rgba(248, 113, 113, 0.12);

  --amber: #fbbf24;
  --amber-dim: rgba(251, 191, 36, 0.12);

  /* Text */
  --text-primary: #e2e8f8;
  --text-secondary: #8892b0;
  --text-muted: #4a5580;
  --text-on-accent: #060a14;

  /* Gradients */
  --gradient-hero: linear-gradient(135deg, #060a14 0%, #0a0e1e 60%, #0a1230 100%);
  --gradient-teal: linear-gradient(135deg, var(--teal) 0%, #0891b2 100%);
  --gradient-purple: linear-gradient(135deg, var(--purple) 0%, #6366f1 100%);
  --gradient-card: linear-gradient(145deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-accent);
  --shadow-teal: 0 0 30px var(--teal-glow);
  --shadow-purple: 0 0 30px var(--purple-glow);

  /* Typography */
  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;
  --text-5xl:  3rem;
  --text-6xl:  3.75rem;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Border radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --container-max: 1240px;
  --nav-height: 72px;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-0);
  background-image: var(--gradient-hero);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--teal);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--teal-bright); }

ul, ol { list-style: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

p { color: var(--text-secondary); }

/* ── Layout Utilities ───────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.section {
  padding-block: var(--space-20);
}

.section-sm {
  padding-block: var(--space-12);
}

/* Flexbox */
.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; }
.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); }
.flex-wrap { flex-wrap: wrap; }

/* Grid */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Text utilities */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-teal { color: var(--teal); }
.text-purple { color: var(--purple); }

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

/* ── Background Mesh ────────────────────────────────────────── */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.bg-mesh::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse at center, rgba(0, 212, 170, 0.07) 0%, transparent 70%);
  border-radius: 50%;
  animation: float-slow 20s ease-in-out infinite alternate;
}

.bg-mesh::after {
  content: '';
  position: absolute;
  bottom: -20%;
  right: -10%;
  width: 55%;
  height: 55%;
  background: radial-gradient(ellipse at center, rgba(139, 92, 246, 0.07) 0%, transparent 70%);
  border-radius: 50%;
  animation: float-slow 25s ease-in-out infinite alternate-reverse;
}

@keyframes float-slow {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(3%, 5%) scale(1.05); }
}

/* ── Noise Texture Overlay ──────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  background-size: 200px;
  pointer-events: none;
  opacity: 0.4;
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 170, 0.3);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(0, 212, 170, 0.5); }

/* ── Responsive breakpoints ─────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  :root { --container-max: 100%; }
}

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

  :root {
    --text-5xl: 2.25rem;
    --text-6xl: 2.75rem;
    --space-20: 3.5rem;
  }

  .section { padding-block: var(--space-12); }
  .container { padding-inline: var(--space-4); }
}

@media (max-width: 480px) {
  :root {
    --text-4xl: 1.875rem;
    --text-5xl: 2rem;
  }
}
