/* ============================================================
   jumpin. — Base / Reset / Global
   Global reset, typography, mesh background, core utilities.
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ─── Skip to content ─────────────────────────────────────────── */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 9999;
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary);
  color: var(--color-primary-fg);
  font-weight: 600;
  font-size: var(--text-sm);
  border-radius: var(--r-sm);
  text-decoration: none;
  transition: top var(--duration-fast);
}
.skip-to-content:focus { top: var(--space-4); }

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

.mesh-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at var(--mesh-x1) var(--mesh-y1), hsl(265,60%,18%) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at var(--mesh-x2) var(--mesh-y2), hsl(210,55%,15%) 0%, transparent 55%),
    radial-gradient(ellipse 65% 50% at var(--mesh-x3) var(--mesh-y3), hsl(330,45%,12%) 0%, transparent 55%),
    var(--color-bg);
  animation: mesh-drift 18s ease-in-out infinite alternate;
  will-change: opacity;
}

@keyframes mesh-drift {
  0%   { --mesh-x1: 20%; --mesh-y1: 15%; --mesh-x2: 80%; --mesh-y2: 10%; }
  50%  { --mesh-x1: 25%; --mesh-y1: 20%; --mesh-x2: 75%; --mesh-y2: 15%; }
  100% { --mesh-x1: 18%; --mesh-y1: 12%; --mesh-x2: 82%; --mesh-y2: 8%;  }
}

@supports not (background: radial-gradient(ellipse at var(--mesh-x1) var(--mesh-y1), red, transparent)) {
  /* Fallback: static gradient for browsers without @property support */
  .mesh-bg::before {
    background:
      radial-gradient(ellipse 80% 60% at 20% 15%, hsl(265,60%,18%) 0%, transparent 60%),
      radial-gradient(ellipse 70% 55% at 80% 10%, hsl(210,55%,15%) 0%, transparent 55%),
      radial-gradient(ellipse 65% 50% at 50% 85%, hsl(330,45%,12%) 0%, transparent 55%),
      var(--color-bg);
    animation: none;
  }
}

[data-theme="light"] .mesh-bg::before,
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .mesh-bg::before {
    background:
      radial-gradient(ellipse 80% 60% at 20% 15%, hsl(265,30%,94%) 0%, transparent 60%),
      radial-gradient(ellipse 70% 55% at 80% 10%, hsl(210,35%,93%) 0%, transparent 55%),
      radial-gradient(ellipse 65% 50% at 50% 85%, hsl(30,40%,94%) 0%, transparent 55%),
      var(--color-bg);
  }
}

[data-theme="light"] .mesh-bg::before {
  background:
    radial-gradient(ellipse 80% 60% at 20% 15%, hsl(265,30%,94%) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at 80% 10%, hsl(210,35%,93%) 0%, transparent 55%),
    radial-gradient(ellipse 65% 50% at 50% 85%, hsl(30,40%,94%) 0%, transparent 55%),
    var(--color-bg);
}

@media (prefers-reduced-motion: reduce) {
  .mesh-bg::before { animation: none; }
}

/* God rays (index + organiser only) */
.has-god-rays .mesh-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.05) 0%, transparent 40%),
    linear-gradient(160deg, rgba(255,255,255,0.03) 0%, transparent 35%),
    linear-gradient(130deg, rgba(255,255,255,0.04) 0%, transparent 45%);
  filter: blur(60px);
  pointer-events: none;
}

/* ─── Typography ──────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-snug);
  letter-spacing: -0.02em;
  color: var(--color-text);
}

h1 { font-size: var(--text-3xl); letter-spacing: -0.03em; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { color: var(--color-text-2); }
p + p { margin-top: var(--space-3); }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: opacity var(--duration-fast);
}
a:hover { opacity: 0.8; }

strong { color: var(--color-text); font-weight: 600; }
small { font-size: var(--text-sm); color: var(--color-text-3); }

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-surface-2);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  border: 1px solid var(--color-border);
}

/* ─── Layout containers ───────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

@media (min-width: 768px) {
  .container { padding: 0 var(--space-10); }
}

.container-narrow  { max-width: 560px; }
.container-medium  { max-width: 780px; }

/* ─── Main content area ───────────────────────────────────────── */
main {
  padding-top: calc(var(--nav-height) + var(--space-6));
}

/* bottom padding when bottom nav is visible */
@media (max-width: 767px) {
  body { padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 24px); }
}

/* ─── Focus visible ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* ─── Selection ───────────────────────────────────────────────── */
::selection {
  background: var(--color-primary-dim);
  color: var(--color-text);
}

/* ─── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--r-full); }

/* ─── Entrance animations ─────────────────────────────────────── */
[data-animate] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--duration-slow) var(--ease-out), transform var(--duration-slow) var(--ease-out);
}
[data-animate].animate-in {
  opacity: 1;
  transform: translateY(0);
}
[data-animate][data-delay="1"] { transition-delay: 80ms; }
[data-animate][data-delay="2"] { transition-delay: 160ms; }
[data-animate][data-delay="3"] { transition-delay: 240ms; }
[data-animate][data-delay="4"] { transition-delay: 320ms; }

@media (prefers-reduced-motion: reduce) {
  [data-animate] { opacity: 1; transform: none; transition: none; }
}

/* ─── Utility classes ─────────────────────────────────────────── */
.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;
}
.text-primary  { color: var(--color-primary); }
.text-muted    { color: var(--color-text-3); }
.text-success  { color: var(--color-success); }
.text-error    { color: var(--color-error); }
.text-mono     { font-family: var(--font-mono); }
.text-display  { font-family: var(--font-display); font-weight: 700; }
.text-center   { text-align: center; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.gap-2  { gap: var(--space-2); }
.gap-3  { gap: var(--space-3); }
.gap-4  { gap: var(--space-4); }

/* ─── Section headings ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.section-header h2 { font-size: var(--text-xl); }
.section-header a  { font-size: var(--text-sm); color: var(--color-primary); font-weight: 500; }
