/* base.css — universal reset + design tokens */

:root {
  /* Type scale (fluid) */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.82rem + 0.3vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.125rem);
  --text-2xl: clamp(2rem, 1.4rem + 2.4vw, 3.25rem);
  --text-3xl: clamp(2.5rem, 1.4rem + 4vw, 4.5rem);
  --text-hero: clamp(2.75rem, 1.4rem + 5.5vw, 6rem);

  /* 4px spacing system */
  --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;

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-prose: 68ch;
  --content-wide: 1200px;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 140ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-interactive: 240ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-slow: 480ms cubic-bezier(0.22, 1, 0.36, 1);

  /* Fonts */
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  --font-display: "Inter Display", "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* LIGHT MODE (default) — Apple-inspired soft whites, near-black text, blue accent */
:root,
[data-theme="light"] {
  --color-bg: #fbfbfd;
  --color-surface: #ffffff;
  --color-surface-2: #f5f5f7;
  --color-surface-offset: #f0f0f3;
  --color-divider: rgba(0, 0, 0, 0.07);
  --color-border: rgba(0, 0, 0, 0.12);

  --color-text: #1d1d1f;
  --color-text-muted: #6e6e73;
  --color-text-faint: #a1a1a6;
  --color-text-inverse: #f5f5f7;

  --color-primary: #0071e3;
  --color-primary-hover: #0077ed;
  --color-primary-active: #0058b0;
  --color-primary-highlight: rgba(0, 113, 227, 0.12);

  --color-accent-soft: rgba(0, 113, 227, 0.08);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.10);

  --backdrop: rgba(251, 251, 253, 0.72);
}

/* DARK MODE */
[data-theme="dark"] {
  --color-bg: #000000;
  --color-surface: #0f0f10;
  --color-surface-2: #141416;
  --color-surface-offset: #1c1c1e;
  --color-divider: rgba(255, 255, 255, 0.08);
  --color-border: rgba(255, 255, 255, 0.14);

  --color-text: #f5f5f7;
  --color-text-muted: #a1a1a6;
  --color-text-faint: #6e6e73;
  --color-text-inverse: #1d1d1f;

  --color-primary: #2997ff;
  --color-primary-hover: #4ba8ff;
  --color-primary-active: #1d7fdc;
  --color-primary-highlight: rgba(41, 151, 255, 0.18);

  --color-accent-soft: rgba(41, 151, 255, 0.10);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.6);

  --backdrop: rgba(0, 0, 0, 0.72);
}

/* System fallback when no data-theme set */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #000000;
    --color-surface: #0f0f10;
    --color-surface-2: #141416;
    --color-surface-offset: #1c1c1e;
    --color-divider: rgba(255, 255, 255, 0.08);
    --color-border: rgba(255, 255, 255, 0.14);
    --color-text: #f5f5f7;
    --color-text-muted: #a1a1a6;
    --color-text-faint: #6e6e73;
    --color-text-inverse: #1d1d1f;
    --color-primary: #2997ff;
    --color-primary-hover: #4ba8ff;
    --color-primary-active: #1d7fdc;
    --color-primary-highlight: rgba(41, 151, 255, 0.18);
    --color-accent-soft: rgba(41, 151, 255, 0.10);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.6);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.6);
    --backdrop: rgba(0, 0, 0, 0.72);
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
  scroll-padding-top: 7rem;
  font-feature-settings: "ss01", "cv11";
}

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);
  letter-spacing: -0.011em;
}

@supports (font-variation-settings: normal) {
  html {
    font-family: "Inter var", var(--font-body);
  }
}

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

a {
  color: var(--color-primary);
  text-decoration: none;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

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

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

h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
  line-height: 1.12;
  font-family: var(--font-display);
  letter-spacing: -0.022em;
  font-weight: 600;
}

p,
li,
figcaption,
blockquote p {
  text-wrap: pretty;
}

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

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

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

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

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

.skip {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  z-index: 100;
}

.skip:focus {
  top: var(--space-3);
}
