/* samahlstrom.com public homepage. Self-contained: no external fonts, no
   CDN, no JS. System sans + system mono only. Stamp a fresh ?v= on this
   file's <link> whenever it changes (Cloudflare edge-caches css for 4h). */

:root {
  --bg: #fcfcfa;
  --ink: #14141a;
  --muted: #5b5b63;
  --line: #e7e7ea;
  --card-bg: #ffffff;
  --accent: #0f6f6a;
  --accent-ink: #ffffff;
  --accent-wash: rgba(15, 111, 106, 0.08);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-pill: 999px;
  --font-sans: -apple-system, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #101014;
  --ink: #f2f2f5;
  --muted: #9a9aa3;
  --line: #2a2a30;
  --card-bg: #17171c;
  --accent: #5eead4;
  --accent-ink: #0b1f1c;
  --accent-wash: rgba(94, 234, 212, 0.1);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: clamp(1.25rem, 4vw, 2.5rem);
  padding-right: clamp(1.25rem, 4vw, 2.5rem);
}

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

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-md) 0;
}
.skip-link:focus {
  left: 0;
}

/* ---------- nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  min-height: 68px;
  padding-top: 0.6rem;
  padding-bottom: 0.6rem;
}
.nav-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem clamp(0.85rem, 2.5vw, 1.75rem);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  color: var(--ink);
  font-size: 0.95rem;
  text-decoration: none;
}
.nav-links a:hover { color: var(--accent); }
.nav-links .nav-github { color: var(--muted); }
#theme-toggle:hover { color: var(--ink); }

/* ---------- hero ---------- */

.hero {
  padding-top: clamp(2.5rem, 6vw, 5.5rem);
  padding-bottom: clamp(3rem, 6vw, 5.5rem);
}
.hero .wrap {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  align-items: center;
}
@media (min-width: 768px) {
  .hero .wrap {
    grid-template-columns: 1.1fr 0.9fr;
    gap: 3.5rem;
  }
}

.hero h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.4rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}
.hero .subhead {
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  color: var(--muted);
  max-width: 46ch;
  margin: 0 0 1.75rem;
}
.hero .cta {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.98rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-md);
  text-decoration: none;
}
.hero .cta:hover { opacity: 0.9; }

.hero-mark {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(140% 100% at 15% 10%, var(--accent-wash) 0%, transparent 60%),
    var(--card-bg);
  display: grid;
  place-items: center;
  max-width: 320px;
  margin: 0 auto;
}
.hero-mark span {
  font-weight: 800;
  font-size: clamp(4.5rem, 11vw, 6.5rem);
  letter-spacing: -0.03em;
  color: var(--accent);
}

/* ---------- sections ---------- */

section {
  padding-top: clamp(3rem, 6vw, 5rem);
  padding-bottom: clamp(3rem, 6vw, 5rem);
}
section:not(:first-of-type) {
  border-top: 1px solid var(--line);
}
section h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 0 0 1.5rem;
}

.about p {
  font-size: 1.08rem;
  max-width: 65ch;
  color: var(--ink);
}

/* ---------- work (bento) ---------- */

.work-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 768px) {
  .work-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .work-card.featured { grid-column: 1 / -1; }
}

.work-card {
  border: 1px solid var(--line);
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.work-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(17, 17, 20, 0.06);
}
.work-card.featured {
  padding: 2rem;
}
.work-card.featured p.body {
  max-width: 60ch;
  font-size: 1.02rem;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-wash);
  border-radius: var(--radius-pill);
  padding: 0.2rem 0.65rem;
  margin-bottom: 0.75rem;
}

.work-card h3 {
  margin: 0 0 0.6rem;
  font-size: 1.2rem;
}
.work-card p.body {
  color: var(--muted);
  margin: 0 0 0.9rem;
  font-size: 0.96rem;
}
.work-card p.role {
  font-size: 0.9rem;
  margin: 0 0 0.9rem;
}
.work-card a.card-link {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-decoration: none;
}
.work-card a.card-link:hover { text-decoration: underline; }

/* ---------- tooling ---------- */

.tooling-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 768px) {
  .tooling-grid { grid-template-columns: 1fr 1fr; }
}
.tooling-card {
  border: 1px solid var(--line);
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.tooling-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-family: var(--font-mono);
}
.tooling-card p {
  color: var(--muted);
  font-size: 0.96rem;
  margin: 0;
}

/* ---------- contact ---------- */

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.contact-links a {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 0.65rem 1.25rem;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
}
.contact-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--line);
  padding: 1.75rem 0;
}
footer .wrap {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- blog (/blog, /blog/<slug>) ---------- */

.blog-meta {
  color: var(--muted);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  margin: 0 0 2rem;
}

/* Article layout: content column with optional TOC on the right */
.article-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 1024px) {
  .article-layout {
    grid-template-columns: 1fr 220px;
    gap: 3rem;
  }
}

.article-content {
  min-width: 0;
}

/* Rendered post markdown -- headings/paragraphs/lists/code/quotes for
   markdown-it output. Reuses the same tokens as .work-card / .about p rather
   than introducing a second visual language. */
.prose {
  font-size: 1.05rem;
}
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3 {
  line-height: 1.25;
  margin: 2rem 0 0.75rem;
  scroll-margin-top: 5rem;
}
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0 0 1.1rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
}
.prose code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--accent-wash);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}
.prose pre {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
  overflow-x: auto;
}
.prose pre code { background: none; padding: 0; }
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}
.prose hr { border: none; border-top: 1px solid var(--line); margin: 1.75rem 0; }
.prose mark { background: #fef08a; color: inherit; padding: 0.1em 0.2em; border-radius: 2px; }
.prose mark[data-color] { background: attr(data-color); }
.prose mark[style*="background"] { padding: 0.1em 0.2em; border-radius: 2px; }
html[data-theme="dark"] .prose mark:not([data-color]):not([style*="background"]) { background: #854d0e; }

/* Tables */
.prose table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 1.25rem 0; font-size: 0.95em; table-layout: fixed; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.prose th, .prose td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0.6rem 0.85rem; text-align: left; }
.prose th:last-child, .prose td:last-child { border-right: 0; }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--card-bg); font-weight: 600; }
.prose tr:nth-child(even) td { background: color-mix(in srgb, var(--card-bg) 60%, transparent); }

/* Column layouts */
.prose div[data-column-block="true"] {
  display: grid;
  gap: 1.5rem;
  margin: 1.5rem 0;
}
.prose div[data-column-block="true"][data-columns="1"] { grid-template-columns: 1fr; }
.prose div[data-column-block="true"][data-columns="2"] { grid-template-columns: 1fr 1fr; }
.prose div[data-column-block="true"][data-columns="3"] { grid-template-columns: 1fr 1fr 1fr; }
.prose div[data-column="true"] {
  min-width: 0;
}
.prose div[data-column="true"] > :first-child { margin-top: 0; }
.prose div[data-column="true"] > :last-child { margin-bottom: 0; }
@media (max-width: 640px) {
  .prose div[data-column-block="true"][data-columns="2"],
  .prose div[data-column-block="true"][data-columns="3"] {
    grid-template-columns: 1fr;
  }
}

/* Callouts */
.prose .callout,
.prose div[data-callout="true"] { border-radius: var(--radius-md); padding: 1rem 1.25rem; margin: 1.25rem 0; border-left: 4px solid; }
.prose .callout > :first-child,
.prose div[data-callout="true"] > :first-child { margin-top: 0; }
.prose .callout > :last-child,
.prose div[data-callout="true"] > :last-child { margin-bottom: 0; }
.prose .callout-note,
.prose div[data-type="note"] { background: color-mix(in srgb, #3b82f6 8%, transparent); border-color: #3b82f6; }
.prose .callout-warning,
.prose div[data-type="warning"] { background: color-mix(in srgb, #f59e0b 8%, transparent); border-color: #f59e0b; }
.prose .callout-tip,
.prose div[data-type="tip"] { background: color-mix(in srgb, #10b981 8%, transparent); border-color: #10b981; }
html[data-theme="dark"] .prose .callout-note, html[data-theme="dark"] .prose div[data-type="note"] { background: color-mix(in srgb, #3b82f6 12%, transparent); }
html[data-theme="dark"] .prose .callout-warning, html[data-theme="dark"] .prose div[data-type="warning"] { background: color-mix(in srgb, #f59e0b 12%, transparent); }
html[data-theme="dark"] .prose .callout-tip, html[data-theme="dark"] .prose div[data-type="tip"] { background: color-mix(in srgb, #10b981 12%, transparent); }

/* Video embeds */
.prose iframe { width: 100%; max-width: 640px; aspect-ratio: 16/9; height: auto; border-radius: var(--radius-md); margin: 1.25rem 0; border: none; }
.prose div[data-youtube-video] { margin: 1.25rem 0; }
.prose div[data-youtube-video] iframe { margin: 0; }

/* Figures */
.prose figure { margin: 1.5rem 0; }
.prose figure img { margin: 0; }
.prose figcaption { font-size: 0.9em; color: var(--muted); text-align: center; margin-top: 0.5rem; }

/* ---------- blog hero / preview ---------- */

.blog-hero {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
}

.preview-banner {
  background: var(--accent-wash);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1.5rem;
}

/* ---------- table of contents ---------- */

.article-toc {
  display: none;
}
@media (min-width: 1024px) {
  .article-toc {
    display: block;
    position: sticky;
    top: 5.5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    padding-bottom: 2rem;
  }
}

.article-toc-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin: 0 0 0.75rem;
}

.article-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-toc-list li {
  margin: 0;
}

.article-toc-list a {
  display: block;
  padding: 0.35rem 0;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  line-height: 1.4;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  margin-left: -0.75rem;
  transition: color 0.15s, border-color 0.15s;
}

.article-toc-list a:hover {
  color: var(--ink);
  border-left-color: var(--line);
}

.article-toc-list a.toc-h2 {
  padding-left: 0.75rem;
}

.article-toc-list a.toc-h3 {
  padding-left: 1.5rem;
  font-size: 0.825rem;
}

/* ---------- comments section ---------- */

.comments-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.comments-section h2 {
  font-size: 1.4rem;
  margin: 0 0 1rem;
}

.comments-discuss {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}

.comments-list {
  margin-bottom: 2rem;
}

.comments-empty {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.comment {
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.comment:last-child {
  border-bottom: none;
}

.comment-meta {
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.comment-author {
  font-weight: 600;
  color: var(--ink);
}

.comment-date {
  color: var(--muted);
  margin-left: 0.5rem;
}

.comment-body {
  margin: 0;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-form {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.form-field {
  margin-bottom: 1rem;
}
.form-field:last-of-type {
  margin-bottom: 1.25rem;
}

.form-field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-field textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hp {
  position: absolute;
  left: -9999px;
  opacity: 0;
  height: 0;
  overflow: hidden;
}

.comments-form button {
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.3rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.comments-form button:hover {
  opacity: 0.9;
}
