/*
 * base.css — Design tokens and element reset.
 * Load first. All other stylesheets depend on the custom properties defined here.
 */

/* ── Design tokens ─────────────────────────────────────────────────────── */

:root {
    /* Colour — backgrounds */
    --color-bg-base:     #080d1a;
    --color-bg-surface:  #0d1321;
    --color-bg-elevated: #131c2e;
    --color-bg-overlay:  #1a2540;
    --color-bg-card:     #111827;

    /* Colour — brand */
    --color-brand:       #1f8fff;
    --color-brand-hover: #3b9fff;
    --color-brand-dim:   rgba(31, 143, 255, 0.12);
    --color-accent:      #2dd4bf;
    --color-accent-dim:  rgba(45, 212, 191, 0.12);

    /* Colour — semantic */
    --color-success:     #22c55e;
    --color-success-dim: rgba(34, 197, 94, 0.12);
    --color-warning:     #f59e0b;
    --color-warning-dim: rgba(245, 158, 11, 0.12);
    --color-danger:      #ef4444;
    --color-danger-dim:  rgba(239, 68, 68, 0.12);

    /* Colour — text */
    --color-text-primary:   #f1f5f9;
    --color-text-secondary: #94a3b8;
    --color-text-muted:     #64748b;
    --color-text-inverse:   #080d1a;
    --color-text-brand:     #1f8fff;
    --color-text-accent:    #2dd4bf;

    /* Colour — borders */
    --color-border:       rgba(255, 255, 255, 0.08);
    --color-border-mid:   rgba(255, 255, 255, 0.12);
    --color-border-strong:rgba(255, 255, 255, 0.20);
    --color-border-brand: rgba(31, 143, 255, 0.30);

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Scale — fluid type via clamp() */
    --text-xs:   0.75rem;        /* 12px */
    --text-sm:   0.875rem;       /* 14px */
    --text-base: 1rem;           /* 16px */
    --text-lg:   1.125rem;       /* 18px */
    --text-xl:   1.25rem;        /* 20px */
    --text-2xl:  clamp(1.375rem, 2vw, 1.5rem);
    --text-3xl:  clamp(1.625rem, 3vw, 1.875rem);
    --text-4xl:  clamp(2rem,     4vw, 2.5rem);
    --text-5xl:  clamp(2.5rem,   5vw, 3.25rem);
    --text-6xl:  clamp(3rem,     6vw, 4rem);

    /* Weights */
    --font-normal:    400;
    --font-medium:    500;
    --font-semibold:  600;
    --font-bold:      700;
    --font-extrabold: 800;

    /* Leading */
    --leading-none:    1;
    --leading-tight:   1.25;
    --leading-snug:    1.375;
    --leading-normal:  1.5;
    --leading-relaxed: 1.625;

    /* Tracking */
    --tracking-tight:  -0.025em;
    --tracking-snug:   -0.015em;
    --tracking-normal:  0;
    --tracking-wide:    0.025em;
    --tracking-wider:   0.05em;

    /* Spacing scale (multiples of 4px) */
    --space-1:  0.25rem;   /* 4px  */
    --space-2:  0.5rem;    /* 8px  */
    --space-3:  0.75rem;   /* 12px */
    --space-4:  1rem;      /* 16px */
    --space-5:  1.25rem;   /* 20px */
    --space-6:  1.5rem;    /* 24px */
    --space-8:  2rem;      /* 32px */
    --space-10: 2.5rem;    /* 40px */
    --space-12: 3rem;      /* 48px */
    --space-16: 4rem;      /* 64px */
    --space-20: 5rem;      /* 80px */
    --space-24: 6rem;      /* 96px */
    --space-32: 8rem;      /* 128px */

    /* Border radius */
    --radius-sm:   4px;
    --radius-md:   8px;
    --radius-lg:   12px;
    --radius-xl:   16px;
    --radius-2xl:  24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md:    0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg:    0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl:    0 20px 60px rgba(0, 0, 0, 0.7);
    --shadow-brand: 0 4px 20px rgba(31, 143, 255, 0.25);
    --shadow-card:  0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--color-border);

    /* Transitions */
    --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base:   250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow:   400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index scale */
    --z-below:    -1;
    --z-base:      0;
    --z-raised:   10;
    --z-dropdown: 100;
    --z-sticky:   200;
    --z-overlay:  300;
    --z-modal:    400;
    --z-toast:    500;

    /* Layout */
    --container-max:    1280px;
    --container-narrow: 768px;
    --container-wide:   1440px;
    --nav-height:       64px;
    --section-gap:      clamp(var(--space-16), 8vw, var(--space-24));
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

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

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

body {
    font-family:      var(--font-sans);
    font-size:        var(--text-base);
    font-weight:      var(--font-normal);
    line-height:      var(--leading-normal);
    color:            var(--color-text-primary);
    background-color: var(--color-bg-base);
    min-height:       100dvh;
    -webkit-font-smoothing:  antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ─────────────────────────────────────────────────────────── */

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

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl);  font-weight: var(--font-semibold); }
h5 { font-size: var(--text-lg);  font-weight: var(--font-semibold); }
h6 { font-size: var(--text-base);font-weight: var(--font-semibold); }

p {
    line-height: var(--leading-relaxed);
    color:       var(--color-text-secondary);
}

p + p { margin-top: var(--space-4); }

a {
    color:           var(--color-brand);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition:      color var(--transition-fast);
}

a:hover {
    color:           var(--color-brand-hover);
}

a:focus-visible {
    outline:        2px solid var(--color-brand);
    outline-offset: 3px;
    border-radius:  var(--radius-sm);
}

strong { font-weight: var(--font-semibold); color: var(--color-text-primary); }
em     { font-style: italic; }
small  { font-size: var(--text-sm); color: var(--color-text-muted); }

code, kbd, pre {
    font-family: var(--font-mono);
    font-size:   0.9em;
}

code {
    background:    var(--color-bg-elevated);
    border:        1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding:       0.1em 0.4em;
    color:         var(--color-accent);
}

pre {
    background:    var(--color-bg-elevated);
    border:        1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding:       var(--space-6);
    overflow-x:    auto;
    line-height:   var(--leading-relaxed);
}

pre code {
    background: none;
    border:     none;
    padding:    0;
    color:      var(--color-text-primary);
}

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

ul, ol {
    padding-left: var(--space-6);
}

li {
    line-height: var(--leading-relaxed);
    color: var(--color-text-secondary);
}

hr {
    border: none;
    border-top: 1px solid var(--color-border);
}

/* ── Accessibility ──────────────────────────────────────────────────────── */

.skip-nav {
    position:        absolute;
    top:             var(--space-2);
    left:            var(--space-2);
    padding:         var(--space-2) var(--space-4);
    background:      var(--color-brand);
    color:           var(--color-text-inverse);
    font-weight:     var(--font-semibold);
    font-size:       var(--text-sm);
    border-radius:   var(--radius-md);
    text-decoration: none;
    z-index:         var(--z-toast);
    transform:       translateY(-120%);
    transition:      transform var(--transition-fast);
}

.skip-nav:focus {
    transform: translateY(0);
}

.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;
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration:        0.01ms !important;
        animation-iteration-count: 1      !important;
        transition-duration:       0.01ms !important;
        scroll-behavior:           auto   !important;
    }
}
