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

/* ============================================
   CUSTOM PROPERTIES — Dark mode default
   ============================================ */
:root {
  /* Colors */
  --bg:      #0d0d0d;
  --surface: #161616;
  --border:  #2a2a2a;
  --text:    #e8e8e8;
  --muted:   #888;
  --accent:  #60a5fa;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", Consolas,
               "Courier New", monospace;

  /* Type scale */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  /* Spacing scale */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-24: 6rem;

  /* Layout */
  --max-w:  720px;
  --radius: 3px;
}

/* Light mode via system preference */
@media (prefers-color-scheme: light) {
  :root {
    --bg:      #f8f8f8;
    --surface: #efefef;
    --border:  #d0d0d0;
    --text:    #111;
    --muted:   #666;
    --accent:  #2563eb;
  }
}

/* ============================================
   BASE
   ============================================ */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--sp-4);
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent);
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
  z-index: 9999;
  transition: top 0.1s;
}

.skip-link:focus {
  top: var(--sp-4);
}

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

/* ============================================
   LAYOUT
   ============================================ */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: var(--sp-6);
}

main {
  flex: 1;
  padding-block: var(--sp-16);
}

/* ============================================
   HEADER & NAV
   ============================================ */
header {
  border-bottom: 1px solid var(--border);
  padding-block: var(--sp-4);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.site-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color 0.15s;
}

.site-name:hover {
  color: var(--accent);
}

nav {
  display: flex;
  gap: var(--sp-6);
  flex-wrap: wrap;
}

nav a {
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

nav a:hover {
  color: var(--text);
}

nav a[aria-current="page"] {
  color: var(--accent);
}

/* ============================================
   FOOTER
   ============================================ */
footer {
  border-top: 1px solid var(--border);
  padding-block: var(--sp-6);
}

footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

footer p,
footer a {
  font-size: var(--text-sm);
  color: var(--muted);
}

footer a {
  text-decoration: none;
  transition: color 0.15s;
}

footer a:hover {
  color: var(--accent);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }

p {
  color: var(--text);
  max-width: 68ch;
}

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

a:hover {
  text-decoration: none;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1em 0.45em;
  border-radius: var(--radius);
}

/* ============================================
   HOME — HERO
   ============================================ */
.hero {
  padding-top: var(--sp-24);
  padding-bottom: var(--sp-16);
}

.hero h1 {
  font-size: clamp(2rem, 6vw, 3.25rem);
  margin-bottom: var(--sp-3);
}

.hero .tagline {
  font-size: var(--text-xl);
  color: var(--muted);
  margin-bottom: var(--sp-8);
}

.hero .intro {
  font-size: var(--text-lg);
  color: var(--muted);
  margin-bottom: var(--sp-12);
  max-width: 55ch;
}

/* Nav cards */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-4);
}

.nav-card {
  display: block;
  padding: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s;
}

.nav-card:hover {
  border-color: var(--accent);
}

.nav-card .card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--accent);
  margin-bottom: var(--sp-1);
}

.nav-card .card-desc {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ============================================
   PAGE HEADER (shared across interior pages)
   ============================================ */
.page-header {
  margin-bottom: var(--sp-12);
  padding-bottom: var(--sp-8);
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--sp-2);
}

.page-header p {
  color: var(--muted);
  font-size: var(--text-base);
}

/* ============================================
   ABOUT
   ============================================ */
.section {
  margin-bottom: var(--sp-12);
}

/* Small-caps label style section headings */
.section h2 {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-6);
}

.section p + p {
  margin-top: var(--sp-4);
}

/* Stack definition list */
dl.stack {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--sp-3) var(--sp-8);
  align-items: baseline;
}

dl.stack dt {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent);
  white-space: nowrap;
}

dl.stack dd {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ============================================
   PROJECTS
   ============================================ */
.project-list {
  display: flex;
  flex-direction: column;
}

.project-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--sp-4) var(--sp-8);
  align-items: start;
  padding-block: var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.project-list .project-row:first-child {
  border-top: 1px solid var(--border);
}

.project-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: block;
  margin-bottom: var(--sp-1);
  transition: color 0.15s;
  font-family: var(--font-mono);
}

.project-name:hover {
  color: var(--accent);
}

.project-desc {
  font-size: var(--text-sm);
  color: var(--muted);
  max-width: 52ch;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
  padding-top: var(--sp-1);
}

.tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius);
  white-space: nowrap;
}

/* ============================================
   BLOG LIST
   ============================================ */
.post-list {
  display: flex;
  flex-direction: column;
}

.post-item {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--sp-6);
  align-items: baseline;
  padding-block: var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.post-list .post-item:first-child {
  border-top: 1px solid var(--border);
}

.post-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  padding-top: 3px;
}

.post-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  display: block;
  margin-bottom: var(--sp-1);
  transition: color 0.15s;
}

.post-title:hover {
  color: var(--accent);
}

.post-summary {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* ============================================
   BLOG POST (article page)
   ============================================ */
.post-header {
  margin-bottom: var(--sp-12);
  padding-bottom: var(--sp-8);
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  margin-bottom: var(--sp-3);
}

.post-meta {
  font-size: var(--text-sm);
  color: var(--muted);
}

.post-content {
  max-width: 66ch;
}

.post-content h2 {
  font-size: var(--text-xl);
  margin-top: var(--sp-8);
  margin-bottom: var(--sp-4);
}

.post-content h3 {
  font-size: var(--text-lg);
  margin-top: var(--sp-6);
  margin-bottom: var(--sp-3);
}

.post-content p {
  margin-bottom: var(--sp-4);
  max-width: 66ch;
}

.post-content ul,
.post-content ol {
  margin-bottom: var(--sp-4);
  padding-left: var(--sp-6);
}

.post-content li {
  margin-bottom: var(--sp-2);
  color: var(--text);
  font-size: var(--text-base);
}

.post-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-6);
  overflow-x: auto;
  margin-bottom: var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.back-link {
  display: inline-block;
  margin-top: var(--sp-12);
  font-size: var(--text-sm);
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--accent);
}

/* ============================================
   CONTACT
   ============================================ */
.contact-links {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin-top: var(--sp-8);
  max-width: 480px;
}

.contact-link {
  display: flex;
  flex-direction: column;
  padding: var(--sp-6);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s;
}

.contact-link:hover {
  border-color: var(--accent);
}

.contact-link-label {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-1);
}

.contact-link-value {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--accent);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 540px) {
  main {
    padding-block: var(--sp-12);
  }

  .hero {
    padding-top: var(--sp-16);
    padding-bottom: var(--sp-12);
  }

  .project-row {
    grid-template-columns: 1fr;
  }

  .project-tags {
    justify-content: flex-start;
  }

  .post-item {
    grid-template-columns: 1fr;
    gap: var(--sp-2);
  }

  dl.stack {
    grid-template-columns: 1fr;
    gap: var(--sp-1) 0;
  }

  dl.stack dt {
    margin-top: var(--sp-3);
  }

  dl.stack dt:first-child {
    margin-top: 0;
  }
}
