@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ================================================================
   Design Tokens — Warm minimalism
   Strict spacing scale, modular type, single accent
   ================================================================ */

:root {
  /* Backgrounds */
  --bg: #fafaf9;
  --bg-elevated: #f5f5f4;
  --bg-inset: #e7e5e4;

  /* Text */
  --text: #1c1917;
  --text-secondary: #44403c;
  --muted: #78716c;

  /* Accent — royal blue */
  --accent: #2563eb;
  --accent-subtle: rgba(37, 99, 235, 0.08);

  /* Links */
  --link: #57534e;
  --link-hover: #1c1917;

  /* Borders & dividers */
  --border: #e7e5e4;
  --border-subtle: rgba(231, 229, 228, 0.5);

  /* Code */
  --code-bg: #1c1917;
  --code-text: #e7e5e4;

  /* Spacing scale — 4px base */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.5rem;    /* 24px */
  --space-6: 2rem;      /* 32px */
  --space-7: 3rem;      /* 48px */
  --space-8: 4rem;      /* 64px */
  --space-9: 6rem;      /* 96px */

  /* Typography scale — Minor Third (1.2) */
  --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: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  --text-5xl: 3rem;      /* 48px */

  /* Radius */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Typography families */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;

  /* Layout */
  --max-width: 720px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition: 250ms cubic-bezier(0.25, 0.1, 0.25, 1);
  --transition-slow: 350ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0a09;
    --bg-elevated: #1c1917;
    --bg-inset: #292524;

    --text: #e7e5e4;
    --text-secondary: #d6d3d1;
    --muted: #a8a29e;

    --accent: #60a5fa;
    --accent-subtle: rgba(96, 165, 250, 0.12);

    --link: #d6d3d1;
    --link-hover: #fafaf9;

    --border: #292524;
    --border-subtle: rgba(41, 37, 36, 0.5);

    --code-bg: #1c1917;
    --code-text: #e7e5e4;
  }
}

/* ================================================================
   Base
   ================================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: var(--text-base);
  font-weight: 400;
  text-rendering: optimizeLegibility;
}

/* Selection */
::selection {
  background: var(--accent-subtle);
  color: var(--text);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Static — no page-load animations */

/* ================================================================
   Typography
   ================================================================ */

h1 {
  font-size: clamp(var(--text-4xl), 5vw, var(--text-5xl));
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: var(--space-4);
}

h2 {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--text);
  margin: var(--space-7) 0 var(--space-3);
}

h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
  margin: var(--space-6) 0 var(--space-2);
}

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

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

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

ul, ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}

li {
  margin-bottom: var(--space-2);
  color: var(--text-secondary);
}

/* ================================================================
   Labels & Meta
   ================================================================ */

.label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-3);
}

/* ================================================================
   Code
   ================================================================ */

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-inset);
  color: var(--text);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

pre {
  position: relative;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--code-bg);
  color: var(--code-text);
  padding: var(--space-4);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.6;
  margin: var(--space-5) 0;
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  border-radius: 0;
}

.copy-code {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--muted);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

pre:hover .copy-code { opacity: 1; }
.copy-code:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.copy-code.copied { color: #22c55e; border-color: #22c55e; background: rgba(255,255,255,0.06); }

/* ================================================================
   Images & Blockquotes
   ================================================================ */

article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: var(--space-5) 0;
}

article blockquote {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  border-left: 2px solid var(--accent);
  background: var(--accent-subtle);
  color: var(--text-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--text-lg);
}

article blockquote p:last-child { margin-bottom: 0; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-7) 0;
}

/* ================================================================
   Layout
   ================================================================ */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-8) var(--space-5) var(--space-6);
}

@media (max-width: 640px) {
  body { font-size: var(--text-base); }
  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-xl); }
  .container { padding: var(--space-6) var(--space-4) var(--space-5); }
  .copy-code { opacity: 1; }
}

/* ================================================================
   Buttons
   ================================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--text);
  color: var(--bg);
}
.btn-primary:hover {
  background: var(--muted);
  color: var(--bg);
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--text);
  color: var(--text);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: var(--space-1) 0;
}
.btn-ghost:hover {
  color: var(--text);
  text-decoration: none;
}

/* ================================================================
   Social Buttons
   ================================================================ */

.social-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}
.social-btn:hover {
  color: var(--text);
}

/* ================================================================
   Cards
   ================================================================ */

.card {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

/* ================================================================
   Tags / Pills
   ================================================================ */

.tag {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted);
  background: var(--bg-inset);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.tag:hover {
  background: var(--border);
  color: var(--text);
  text-decoration: none;
}

/* ================================================================
   Header scroll indicator
   ================================================================ */

header.scrolled {
  border-bottom-color: var(--border);
}
