/* ======================================================================
   DESIGN TOKENS
   Concept: AI/tech newsletter — cool, technical, signal-not-noise.
   Palette: deep ink background, electric violet accent (Nurple's namesake),
   minty signal-green for "ship" highlights.
   ====================================================================== */

:root,
[data-theme="light"] {
  /* Type scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);
  --text-hero: clamp(2.75rem, 0.5rem + 6vw, 6rem);

  /* Spacing (4px base) */
  --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;
  --space-32: 8rem;

  /* Light surface palette — soft cream so it's not stark white */
  --color-bg: #faf9f7;
  --color-surface: #ffffff;
  --color-surface-2: #f3f1ec;
  --color-surface-offset: #ebe8e1;
  --color-divider: #e3e0d9;
  --color-border: #d4d0c6;

  --color-text: #14121a;
  --color-text-muted: #5a5764;
  --color-text-faint: #908d99;
  --color-text-inverse: #faf9f7;

  /* Electric violet — "Nurple" */
  --color-primary: #6b3df5;
  --color-primary-hover: #5a2de0;
  --color-primary-active: #4a22be;
  --color-primary-soft: #ede7ff;

  /* Signal mint */
  --color-signal: #16a47a;
  --color-signal-soft: #d6f3e8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition-interactive: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  --shadow-sm: 0 1px 2px rgba(20, 18, 26, 0.06);
  --shadow-md: 0 8px 20px -8px rgba(20, 18, 26, 0.12);
  --shadow-lg: 0 24px 50px -16px rgba(20, 18, 26, 0.18);
  --shadow-glow: 0 10px 40px -10px rgba(107, 61, 245, 0.45);

  --content-narrow: 640px;
  --content-default: 1080px;
  --content-wide: 1280px;

  --font-body: "Inter", -apple-system, "Helvetica Neue", sans-serif;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --color-bg: #0c0a14;
  --color-surface: #131022;
  --color-surface-2: #1a1730;
  --color-surface-offset: #221d3d;
  --color-divider: #1f1b35;
  --color-border: #2c2747;

  --color-text: #ece9f6;
  --color-text-muted: #a6a1c4;
  --color-text-faint: #6f6a8c;
  --color-text-inverse: #0c0a14;

  --color-primary: #8a5cff;
  --color-primary-hover: #9b71ff;
  --color-primary-active: #7846ee;
  --color-primary-soft: #221945;

  --color-signal: #2dd4a0;
  --color-signal-soft: #14342a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 50px -16px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 10px 50px -8px rgba(138, 92, 255, 0.55);
}

/* System dark fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #0c0a14;
    --color-surface: #131022;
    --color-surface-2: #1a1730;
    --color-surface-offset: #221d3d;
    --color-divider: #1f1b35;
    --color-border: #2c2747;
    --color-text: #ece9f6;
    --color-text-muted: #a6a1c4;
    --color-text-faint: #6f6a8c;
    --color-text-inverse: #0c0a14;
    --color-primary: #8a5cff;
    --color-primary-hover: #9b71ff;
    --color-primary-active: #7846ee;
    --color-primary-soft: #221945;
    --color-signal: #2dd4a0;
    --color-signal-soft: #14342a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 20px -8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 50px -16px rgba(0, 0, 0, 0.7);
    --shadow-glow: 0 10px 50px -8px rgba(138, 92, 255, 0.55);
  }
}

/* ======================================================================
   RESET
   ====================================================================== */

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

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.55;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

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

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  text-wrap: balance;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
}

a,
button,
input,
[role="button"] {
  transition:
    color var(--transition-interactive),
    background var(--transition-interactive),
    border-color var(--transition-interactive),
    box-shadow var(--transition-interactive),
    transform var(--transition-interactive);
}

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

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

.container {
  width: 100%;
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: clamp(var(--space-4), 4vw, var(--space-10));
}
