/* ------------------------------------------------------------------ *
 *  jruddell.com — styles
 *  Clean, modern, responsive. Light + dark theme via [data-theme].
 * ------------------------------------------------------------------ */

:root {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --surface-2: #eef1f5;
  --text: #16191d;
  --muted: #5b6675;
  --border: #e4e7ec;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-contrast: #ffffff;
  --code-bg: #f6f8fa;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.10);

  /* syntax */
  --code-text: #24292f;
  --code-comment: #6e7781;
  --code-kw: #cf222e;
  --code-str: #0a3069;
  --code-num: #0550ae;
  --code-fn: #8250df;
  --code-var: #953800;
  --code-type: #116329;
  --code-meta: #6e7781;

  --maxw: 1080px;
  --prose: 720px;
  --radius: 14px;
  --radius-sm: 9px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono",
    monospace;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2330;
  --text: #e7edf3;
  --muted: #9aa6b2;
  --border: #232c38;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-contrast: #0d1117;
  --code-bg: #161b22;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.5);

  --code-text: #c9d1d9;
  --code-comment: #8b949e;
  --code-kw: #ff7b72;
  --code-str: #a5d6ff;
  --code-num: #79c0ff;
  --code-fn: #d2a8ff;
  --code-var: #ffa657;
  --code-type: #7ee787;
  --code-meta: #8b949e;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 90px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

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

img { max-width: 100%; height: auto; }

h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.02em; font-weight: 700; }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---- Header / nav ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.brand .mono {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.96rem;
  font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-links a.active { color: var(--text); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

.nav-toggle { display: none; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.97rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); }

/* ---- Hero ---- */
.hero { padding: 40px 0 40px; }
.hero .eyebrow {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  margin-bottom: 14px;
}
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); margin: 0 0 18px; }
.hero p.lead {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 640px;
  margin: 0 0 28px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- Sections ---- */
.section { padding: 44px 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.section-head h2 { font-size: 1.6rem; margin: 0; }
.section-head .link { color: var(--muted); font-weight: 500; font-size: 0.95rem; }
.section-head .link:hover { color: var(--accent); }

/* ---- Project cards ---- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.card {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.card h3 { font-size: 1.18rem; margin: 0 0 10px; }
.card p { margin: 0 0 14px; color: var(--muted); font-size: 0.98rem; }
.card .tech { font-size: 0.83rem; line-height: 1.55; color: var(--muted); margin: 0 0 18px; }
.card .tech .tech-label {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
  margin-right: 8px;
}
.card .spacer { flex: 1; }
.card-links { display: flex; flex-wrap: wrap; gap: 14px; }
.card-links a { font-weight: 600; font-size: 0.92rem; display: inline-flex; align-items: center; gap: 5px; }
.card-links a svg { width: 14px; height: 14px; }
.badge-soon {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 4px 11px;
  border-radius: 999px;
}

.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.tag {
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
}

/* ---- Post list ---- */
.post-list { display: flex; flex-direction: column; }
.post-item {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}
.post-item:first-child { padding-top: 4px; }
.post-item .meta { color: var(--muted); font-size: 0.86rem; margin-bottom: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.post-item h3 { font-size: 1.3rem; margin: 0 0 8px; }
.post-item h3 a { color: var(--text); }
.post-item h3 a:hover { color: var(--accent); text-decoration: none; }
.post-item p { margin: 0 0 12px; color: var(--muted); }
.post-item .readmore { font-weight: 600; font-size: 0.92rem; }

/* ---- Article / prose ---- */
.article { padding: 56px 0 40px; }
.article-header { max-width: var(--prose); margin: 0 auto 30px; }
.article-header .meta { color: var(--muted); font-size: 0.9rem; margin-bottom: 14px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.article-header h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); margin: 0 0 12px; }
.article-header .subtitle { font-size: 1.2rem; color: var(--muted); margin: 0 0 18px; }
.back-link { color: var(--muted); font-weight: 500; font-size: 0.92rem; }
.republished { font-size: 0.9rem; color: var(--muted); margin: 14px 0 0; }
.republished a { color: var(--accent); font-weight: 500; }
.republished a svg { width: 13px; height: 13px; vertical-align: -1px; }

.prose { max-width: var(--prose); margin: 0 auto; }
.prose > * + * { margin-top: 1.15em; }
.prose h2 { font-size: 1.6rem; margin-top: 2em; padding-top: 0.2em; }
.prose h3 { font-size: 1.28rem; margin-top: 1.7em; }
.prose h4 { font-size: 1.08rem; margin-top: 1.5em; }
.prose p { margin: 0; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0; }
.prose li + li { margin-top: 0.4em; }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; margin: 1.5em auto 0.4em; }
.prose img + em { display: block; text-align: center; color: var(--muted); font-size: 0.88rem; margin-top: 0; }
.prose a { font-weight: 500; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 2px; }
.prose blockquote {
  margin: 1.4em 0;
  padding: 2px 18px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
}
.prose blockquote p { margin: 0.7em 0; }
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td { border: 1px solid var(--border); padding: 9px 13px; text-align: left; }
.prose th { background: var(--surface); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
}
.prose :not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.12em 0.4em;
  border-radius: 6px;
  white-space: nowrap;
}
.prose pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.55;
}
.prose pre code { background: none; border: none; padding: 0; font-size: inherit; white-space: pre; color: var(--code-text); }

/* highlight.js (self-themed via variables; degrades gracefully if hljs absent) */
.hljs { color: var(--code-text); background: transparent; }
.hljs-comment, .hljs-quote { color: var(--code-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-name, .hljs-tag, .hljs-meta-keyword { color: var(--code-kw); }
.hljs-string, .hljs-attr, .hljs-template-tag, .hljs-addition, .hljs-regexp { color: var(--code-str); }
.hljs-number, .hljs-literal, .hljs-bullet { color: var(--code-num); }
.hljs-title, .hljs-section, .hljs-selector-id { color: var(--code-fn); }
.hljs-variable, .hljs-template-variable, .hljs-attribute { color: var(--code-var); }
.hljs-type, .hljs-class .hljs-title, .hljs-selector-class { color: var(--code-type); }
.hljs-symbol, .hljs-link, .hljs-meta { color: var(--code-meta); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* post nav (prev/next) */
.post-nav {
  max-width: var(--prose);
  margin: 40px auto 0;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.post-nav a { max-width: 48%; }
.post-nav .dir { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 3px; }
.post-nav .ttl { font-weight: 600; color: var(--text); }
.post-nav a:hover .ttl { color: var(--accent); }
.post-nav .next { margin-left: auto; text-align: right; }

/* ---- Contact form ---- */
.form-wrap { max-width: var(--prose); margin: 0 auto; }
.form {
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.field { display: grid; gap: 7px; }
.field label { font-weight: 600; font-size: 0.92rem; }
.field input, .field textarea {
  width: 100%;
  font: inherit;
  font-size: 0.97rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.field textarea { resize: vertical; min-height: 150px; }
.field .err { color: #e5484d; font-size: 0.84rem; min-height: 1em; }
[data-theme="dark"] .field .err { color: #ff6369; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-status { font-weight: 600; font-size: 0.95rem; min-height: 1.2em; }
.form-status.ok { color: #1a7f37; }
.form-status.bad { color: #e5484d; }
[data-theme="dark"] .form-status.ok { color: #57ab5a; }
[data-theme="dark"] .form-status.bad { color: #ff6369; }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 36px 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.socials { display: flex; gap: 8px; }
.socials a {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
}
.socials a:hover { color: var(--text); border-color: var(--accent); }
.socials svg { width: 18px; height: 18px; fill: currentColor; }

/* ---- Utilities ---- */
.center { text-align: center; }
.muted { color: var(--muted); }
.cta-band {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
}
.cta-band h2 { margin: 0 0 10px; font-size: 1.7rem; }
.cta-band p { margin: 0 auto 22px; color: var(--muted); max-width: 480px; }

/* ---- Responsive ---- */
@media (max-width: 720px) {
  body { font-size: 16px; }
  .nav-links {
    position: fixed;
    inset: 64px 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px 18px;
    box-shadow: var(--shadow);
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px; font-size: 1rem; }
  .nav-toggle { display: inline-grid; }
  .hero { padding: 28px 0 24px; }
  .cta-band { padding: 30px 22px; }
  .post-nav { flex-direction: column; }
  .post-nav a, .post-nav .next { max-width: 100%; text-align: left; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
