/* Self-hosted fonts */
@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/inter-tight-500.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter Tight';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/inter-tight-600.woff2') format('woff2');
}

@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/source-serif-4-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Source Serif 4';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/source-serif-4-400-italic.woff2') format('woff2');
}

/* Design tokens */
:root {
  --color-bg: rgb(156, 229, 199);
  --color-text: rgb(51, 52, 61);
  --color-link: rgb(51, 52, 61);
  --color-hover-bg: rgba(72, 73, 85, 0.05);
  --color-border: rgba(72, 73, 85, 0.2);
  --color-text-muted: rgb(30, 60, 45);

  --font-heading: "Inter Tight", system-ui, sans-serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-nav: "Inter Tight", system-ui, sans-serif;
  --font-code: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;

  --max-width: 1200px;
  --spacing: 1.5rem;
  --radius-sm: 4px;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.8;
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* Hoverable list items */
.hoverable-item {
  padding: 0.5rem;
  margin-inline: -0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease;
}

.hoverable-item:hover {
  background-color: var(--color-hover-bg);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-text);
  color: var(--color-bg);
  padding: 8px;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.1;
  margin: 0 0 var(--spacing);
}

h1 {
  font-size: clamp(2.5rem, 8vw, 4.25rem);
}

/* Hero h1 on homepage */
/* Left edge aligns with HR in two-col-section (20% offset) */
.hero h1 {
  font-size: clamp(3rem, 12vw, 5.5rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.05;
  margin-bottom: 2rem;
  margin-inline-start: 20%;
}

/* Section separators */
section {
  margin-bottom: 3rem;
}

section:last-child {
  margin-bottom: 0;
}

section h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
}

/* Two-column section layout (About, Open Source, Speaking intro) */
.two-col-section {
  display: grid;
  grid-template-columns: 20% 22% 13% 1fr;
  gap: 0;
}

.two-col-section .section-header {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: 62% 38%;
  gap: 0;
  align-items: start;
}

.two-col-section .section-content {
  grid-column: 4;
}

.two-col-section .section-header hr {
  border: none;
  border-top: 1px solid var(--color-text);
  margin: 0 0 1rem;
  width: 138px;
  max-width: 100%;
}

.two-col-section .section-title {
  font-family: var(--font-nav);
  font-weight: 600;
  font-size: 1rem;
  margin: 0;
}

.two-col-section .section-content p:first-child {
  margin-top: 0;
}

.two-col-section .section-content p:last-child {
  margin-bottom: 0;
}

.two-col-section .section-content a {
  text-decoration: underline;
  text-decoration-color: rgba(51, 52, 61, 0.4);
}

.two-col-section .section-content a:hover {
  text-decoration-color: var(--color-text);
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
  font-weight: 500;
}

p {
  margin: 0 0 var(--spacing);
}

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

a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

a:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Site header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing);
  max-width: var(--max-width);
  margin: 0 auto;
}

.site-title {
  font-family: var(--font-nav);
  font-weight: 600;
  font-size: 1rem;
}

.site-nav ul {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  font-family: var(--font-nav);
  font-weight: 500;
  font-size: 1rem;
}

.site-nav a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--color-text);
}

.menu-toggle:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

/* Main content */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing) 1rem;
}

/* Article list */
.article-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.article-list li {
  margin-bottom: 0.75rem;
}

.article-list time {
  font-family: var(--font-nav);
  font-size: 1rem;
  margin-inline-end: 0.5rem;
}

.article-list a {
  font-family: var(--font-nav);
  font-size: 1rem;
}

/* Article page */
.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  margin-bottom: 0.5rem;
}

.dek {
  font-weight: 400;
  font-style: italic;
  margin-top: 0;
}

.article-date {
  display: block;
  font-family: var(--font-nav);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  text-align: right;
}

.article-content {
  margin-bottom: 2rem;
}

.article-tags {
  font-family: var(--font-nav);
  font-size: 0.75rem;
  opacity: 0.7;
  margin-bottom: 2rem;
}

.article-tags a:hover {
  text-decoration: underline;
}

.article-tags .separator {
  margin: 0 0.25rem;
}

/* Content navigation */
.article-nav,
.speaking-nav,
.project-nav {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.article-nav a,
.speaking-nav a,
.project-nav a {
  flex: 1;
}

.article-nav span,
.speaking-nav span,
.project-nav span {
  display: block;
  font-family: var(--font-nav);
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.article-nav h2,
.speaking-nav h2,
.project-nav h2 {
  font-size: 1.125rem;
  margin: 0;
}

.nav-next {
  text-align: end;
}

/* Code blocks */
pre,
pre[class*="language-"] {
  font-family: var(--font-code);
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0 0 var(--spacing);
  padding: var(--spacing);
  border-radius: var(--radius-sm);
}

code {
  font-family: var(--font-code);
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.07);
  padding: 0.15em 0.35em;
  border-radius: 4px;
}

/* Footer */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem var(--spacing);
  text-align: start;
}

.hex-code {
  font-family: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
}

.social-links {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1.5rem;
}

.social-links a {
  display: inline-flex;
  font-family: var(--font-nav);
}

/* Speaking list section */
.speaking-list-section {
  margin-top: 4rem;
}

.speaking-list-section h2,
.projects-section h2,
.articles-section h2 {
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-style: italic;
  font-weight: 400;
  margin-bottom: 2rem;
}

.speaking-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  margin-bottom: 2rem;
}

.speaking-item {
  margin-bottom: 0;
}

.speaking-item a {
  font-family: var(--font-heading);
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 600;
}

.speaking-item a:hover {
  text-decoration: underline;
}

/* Speaking listing page (2-column grid) */
.speaking-list-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem 3rem;
}

/* Articles section with deks */
.article-items {
  margin-bottom: 1.5rem;
}

.article-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.article-item-content {
  flex: 1;
}

.article-item .article-title {
  font-family: var(--font-nav);
  font-size: 1rem;
  display: block;
  margin-bottom: 0.25rem;
}

.article-item .article-dek {
  font-style: italic;
  margin: 0.25rem 0;
  font-size: 0.9rem;
}

.article-item time {
  font-family: var(--font-nav);
  font-size: 0.875rem;
  color: var(--color-text);
  flex-shrink: 0;
}

/* Page header (Projects, Speaking, Articles list pages) */
.page-header h1 {
  font-size: clamp(3rem, 10vw, 5rem);
  margin-bottom: 2rem;
}

/* Decorative wavy line */
.decorative-line {
  width: 100%;
  height: 80px;
  color: var(--color-text);
  margin-bottom: 3rem;
}

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3rem 2rem;
}

.project-list-item {
  margin-bottom: 1.5rem;
}

.project-list-item a {
  font-family: var(--font-heading);
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 600;
}

.project-list-item a:hover {
  text-decoration: underline;
}

/* Homepage projects (tighter grid, larger titles) */
.projects-section .projects-grid {
  gap: 1.5rem 2rem;
}

.projects-section .project-list-item a {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
}

/* Year headings for grouped listings */
.year-heading {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  color: var(--color-text);
}

.year-heading:first-of-type {
  margin-top: 0;
}

/* Item descriptions (deks) */
.item-dek {
  font-size: 0.9rem;
  color: var(--color-text);
  opacity: 0.8;
  margin: 0.25rem 0 0;
  line-height: 1.5;
}

/* Item tags (listing pages) */
.item-tags {
  font-family: var(--font-nav);
  font-size: 0.8rem;
  margin: 0.25rem 0 0;
  opacity: 0.6;
}

.item-tags a {
  font-size: inherit;
  text-decoration: none;
}

.item-tags a:hover {
  text-decoration: underline;
}

/* Speaking list page */
.speaking-list .speaking-item {
  margin-bottom: 1.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  .site-header {
    flex-wrap: wrap;
  }

  .site-nav {
    order: 3;
    width: 100%;
  }

  .site-nav ul {
    display: none;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1rem;
  }

  .site-nav.is-open ul {
    display: flex;
  }

  .menu-toggle {
    display: block;
    order: 2;
  }

  h1 {
    font-size: 2rem;
  }

  .hero h1 {
    margin-inline-start: 0;
  }

  .two-col-section {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .two-col-section .section-header {
    grid-column: 1;
    grid-template-columns: 1fr;
  }

  .two-col-section .section-content {
    grid-column: 1;
  }

  .speaking-grid,
  .speaking-list-grid,
  .projects-grid {
    grid-template-columns: 1fr;
  }

  .article-nav,
  .speaking-nav,
  .project-nav {
    flex-direction: column;
  }

  .nav-next {
    text-align: start;
  }
}

/* Back link on tag pages */
.back-link {
  margin-top: 2rem;
}

.back-link a {
  font-family: var(--font-nav);
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .hoverable-item {
    transition: none;
  }
}
