/* ─── Reset ────────────────────────────────────────────────────────────────── */

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

body {
    margin: 0;
    font-weight: 300;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
}

/* ─── Design tokens ────────────────────────────────────────────────────────── */

:root {
    --font-family: Roboto, sans-serif;
    --font-family-mono: 'Roboto Mono', monospace;
    --bg: #fff;
    --bg-secondary: #f6f8fa;
    --text: #1c1c1e;
    --text-muted: #6e6e73;
    --accent: #0969da;
    --accent-hover: #0550ae;
    --border: #d1d1d6;
    --transition: 150ms ease;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0d1117;
        --bg-secondary: #161b22;
        --text: #e6edf3;
        --text-muted: #8b949e;
        --accent: #58a6ff;
        --accent-hover: #79b8ff;
        --border: #30363d;
    }
}

[data-theme="dark"] {
    --bg: #0d1117;
    --bg-secondary: #161b22;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #79b8ff;
    --border: #30363d;
}

/* ─── Base ──────────────────────────────────────────────────────────────────── */

html {
  background-color: var(--bg);
  color: var(--text);
  font-size: 18px;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition:
    background-color var(--transition),
    color var(--transition);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);

  &:hover {
    color: var(--accent-hover);
  }
}

/* ─── Page layout ───────────────────────────────────────────────────────────── */

.page-body {
  flex: 1;
}

.content-container {
  max-width: 64rem;
  margin-inline: auto;
  padding-inline: 1rem;
  padding-block: 2rem;

  @media (min-width: 640px) {
      padding-inline: 1.5rem;
  }

  @media (min-width: 1024px) {
    padding-inline: 2rem;
    padding-block: 2.5rem;
  }

  @media (min-width: 1280px) {
      padding-inline: 2.5rem;
  }
}

/* ─── Theme picker ──────────────────────────────────────────────────────────── */

.theme-picker {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--transition);

  &:hover {
    border-color: var(--text-muted);
  }
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  width: 2rem;
  max-width: 0;
  overflow: hidden;
  padding: 0;
  background: none;
  border: none;
  border-right: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition:
    max-width var(--transition),
    background-color var(--transition),
    color var(--transition),
    border-color var(--transition);

  &:last-child {
    border-right: none;
  }

  &.active {
    max-width: 2rem;
    color: var(--text);
    background-color: var(--bg);
  }

  &:hover {
    background-color: var(--bg);
    color: var(--text);
  }
}

.theme-picker:hover .theme-option {
  max-width: 2rem;

  &:not(:last-child) {
    border-right-color: var(--border);
  }
}

/* ─── Section nav ───────────────────────────────────────────────────────────── */

.section-nav {
  background-color: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-inline: 1rem;

  @media (min-width: 640px) {
      padding-inline: 1.5rem;
  }
  @media (min-width: 1024px) {
      padding-inline: 2rem;
  }
  @media (min-width: 1280px) {
      padding-inline: 2.5rem;
  }
}

.nav-inner {
  max-width: 64rem;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-end {
    margin-left: auto;
    padding: 0.625rem 0.75rem;
}

.nav-label {
  display: none;

  @media (min-width: 640px) {
      display: inline;
  }
}

.nav-icon {
  font-size: 1.125rem;

  @media (min-width: 640px) {
      font-size: 0.75rem;
  }
}

.section-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition:
    color var(--transition),
    border-color var(--transition);

  &:hover {
    color: var(--text);
    text-decoration: none;
  }

  &.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
  }
}

/* ─── Color utilities ───────────────────────────────────────────────────────── */

.c-text {
  color: var(--text);

  &:hover {
      color: var(--text);
  }
}

.c-muted {
  color: var(--text-muted);

  &:hover {
      color: var(--text-muted);
  }
}

.c-accent {
    color: var(--accent);
}

/* ─── Avatar ────────────────────────────────────────────────────────────────── */

.avatar {
  background-color: var(--accent);
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 2.5rem;
  font-weight: 500;
  user-select: none;
}

/* ─── Social icons ──────────────────────────────────────────────────────────── */

.social-icons {
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 1.5rem;

  a {
    color: var(--text-muted);
    transition: opacity var(--transition);

    &:hover {
      color: var(--text-muted);
      opacity: 0.7;
      text-decoration: none;
    }
  }
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */

footer {
  padding-block: 2rem;
  padding-inline: 1rem;

  @media (min-width: 640px) { padding-inline: 1.5rem; }
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;

  .social-icons { margin-bottom: 1rem; }
}

/* ─── Portfolio ─────────────────────────────────────────────────────────────── */

.portfolio {
  display: flex;
  flex-direction: column;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
}

.portfolio-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
}

.portfolio-avatar {
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  object-fit: cover;
}

.portfolio-name {
  font-size: 2.25rem;
  font-weight: 500;
  line-height: 1.25;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.portfolio-bio {
  font-size: 1.125rem;
  line-height: 1.75;
  max-width: 65ch;
}

.portfolio-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1.5rem;

  a {
      font-size: 0.875rem;
      font-weight: 500;
  }
}

.portfolio .social-icons {
  gap: 1.5rem;
  margin-top: 1.5rem;
}

/* ─── Prose ─────────────────────────────────────────────────────────────────── */

.prose {
  line-height: 1.75;

  a:hover {
      text-decoration: underline;
      text-decoration-style: dashed;
      text-underline-offset: 0.3rem;
  }

  p, ul, ol, blockquote, pre, table {
      margin-bottom: 1.25rem;
  }

  h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
  }
  h2 {
      margin-top: 3rem;
  }
  h1 { font-size: 2.25rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.375rem; }
  h4 { font-size: 1.125rem; }

  ul { list-style: disc; padding-left: 1.5rem; }
  ol { list-style: decimal; padding-left: 1.5rem; }
  li { margin-bottom: 0.25rem; }

  code {
      font-family: var(--font-family-mono);
      font-size: 0.875em;
      background-color: var(--bg-secondary);
      padding: 0.15em 0.35em;
      border-radius: 4px;
  }

  pre {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-family: var(--font-family-mono);
    font-size: 0.875rem;
    line-height: 1.6;

    code {
      background: none;
      padding: 0;
      border-radius: 0;
      font-size: inherit;
    }
  }

  .highlight {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1.25rem;

    pre {
      background: none;
      border: none;
      border-radius: 0;
      margin-bottom: 0;
    }
  }

  blockquote {
    border-left: 4px solid var(--border);
    padding-left: 1rem;
    color: var(--text-muted);
    font-style: italic;
  }

  img { max-width: 100%; border-radius: 6px; }

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

  table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;

    th, td {
      padding: 0.5rem 0.75rem;
      border: 1px solid var(--border);
    }
    th {
        background-color: var(--bg-secondary);
        font-weight: 500;
    }
  }
}

/* ─── Stork search ──────────────────────────────────────────────────────────── */

.stork-wrapper {
  position: relative;
}

.stork-input {
  width: 10rem;
  font-size: 0.875rem;
  background-color: var(--bg) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  transition:
    border-color var(--transition),
    background-color var(--transition),
    color var(--transition);

  &:focus {
    border-color: var(--accent) !important;
    outline: none;
    box-shadow: none !important;
  }
}

.stork-output {
  position: absolute !important;
  top: calc(100% + 4px) !important;
  right: 0;
  left: auto !important;
  min-width: 22rem;
  background-color: var(--bg-secondary) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
}

.stork-result {
  border-color: var(--border) !important;

  a, p, em { color: var(--text) !important; }

  &:hover,
  &.stork-selected {
    background-color: var(--bg) !important;
  }
}

.stork-attribution {
  background-color: var(--bg-secondary) !important;
  color: var(--text-muted) !important;
  border-color: var(--border) !important;
}

/* ─── Tag chips ─────────────────────────────────────────────────────────────── */

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-decoration: none;
  transition:
    border-color var(--transition),
    color var(--transition);

  &:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
  }
}

/* ─── Article layout ────────────────────────────────────────────────────────── */

.article-header {
  margin-bottom: 1.5rem;
}

.article-title {
  font-size: 2.25rem;
  font-weight: 500;
  line-height: 1.25;
}

.article-tags {
  margin-top: 1rem;
}

/* ─── Article list ──────────────────────────────────────────────────────────── */

.article-list {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

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

.article-list-title {
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.375;
}

.article-summary {
  font-size: 1rem;
  line-height: 1.625;

  a:hover {
      text-decoration: underline;
      text-decoration-style: dashed;
      text-underline-offset: 0.3rem;
  }
}

.article-footer {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 2rem;
  row-gap: 0.5rem;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
}

/* ─── Article meta ──────────────────────────────────────────────────────────── */

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 1.5rem;
  row-gap: 0.375rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;

  a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
  }
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ─── Pagination ────────────────────────────────────────────────────────────── */

.pagination {
  margin-top: 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;

  a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-weight: 500;
  }
}

/* ─── Tag list ──────────────────────────────────────────────────────────────── */

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

/* ─── Tag index ─────────────────────────────────────────────────────────────── */

.tag-index {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;

  .tag-chip { font-size: 1rem; }
}

.tag-count {
  margin-left: 0.25rem;
  font-size: 0.875rem;
  opacity: 0.7;
}

/* ─── Item list (categories, authors) ───────────────────────────────────────── */

.item-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
  }

  a {
    font-weight: 500;

    i {
        margin-right: 0.25rem;
    }
  }

  .item-count { font-size: 0.875rem; }
}

/* ─── Archive list ──────────────────────────────────────────────────────────── */

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;

  .archive-item {
    display: flex;
    gap: 1rem;
    align-items: baseline;

    dt {
      font-size: 0.875rem;
      flex-shrink: 0;
      margin: 0;
    }

    dd { margin: 0; }
  }
}

/* ─── Page header ───────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 2rem;

  h2 {
    font-size: 1.5rem;
  }

  i {
      margin-right: 0.5rem;
  }
}

/* ─── Pagefind ──────────────────────────────────────────────────────────────── */

:root {
  --pf-text: var(--text);
  --pf-text-secondary: var(--text-muted);
  --pf-text-muted: var(--text-muted);
  --pf-background: var(--bg);
  --pf-border: var(--border);
  --pf-border-focus: var(--accent);
  --pf-hover: var(--bg-secondary);
  --pf-skeleton: var(--bg-secondary);
  --pf-skeleton-shine: var(--border);
  --pf-mark: var(--accent);
  --pf-outline-focus: var(--accent);
  --pf-font: var(--font-family);
  --pf-input-font-size: 1rem;
  --pf-summary-font-size: 0.875rem;
  --pf-result-title-font-size: 0.9rem;
  --pf-result-excerpt-font-size: 0.875rem;
  --pf-border-radius: 4px;
}
