/* ── Fonts ── */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/JetBrainsMono-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Variables ── */
:root {
  --bg:     #f5f5f0;
  --fg:     #0f0f0f;
  --dim:    #767672;
  --border: #d0d0cc;
  --link:   #0f0f0f;

  --c-red:    #c0392b;
  --c-green:  #27ae60;
  --c-yellow: #b8860b;
  --c-blue:   #2471a3;

  --bg-alt:   #ebebе6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:     #161614;
    --fg:     #b8b8b3;
    --dim:    #666662;
    --border: #2a2a28;
    --link:   #b8b8b3;

    --c-red:    #e06c75;
    --c-green:  #98c379;
    --c-yellow: #e5c07b;
    --c-blue:   #61afef;

    --bg-alt:   #1a1a18;
  }
}

.c-red    { color: var(--c-red); }
.c-green  { color: var(--c-green); }
.c-yellow { color: var(--c-yellow); }
.c-blue   { color: var(--c-blue); }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

/* ── Base ── */
body {
  font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--fg);
  max-width: 74ch;
  margin: 2.5rem auto;
  padding: 0 1.25rem;
  min-height: calc(100vh - 5rem);
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

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

p { margin: 1rem 0; }

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  margin: 2rem 0 0.5rem;
}
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

ul, ol { padding-left: 1.5em; margin: 1rem 0; }
li { margin: 0.25rem 0; }

blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1rem;
  color: var(--dim);
  margin: 1rem 0;
}

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

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

/* ── Code ── */
code {
  font-family: inherit;
  font-size: 0.9em;
  border: 1px solid var(--border);
  padding: 0.1em 0.35em;
}

pre {
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
pre code {
  border: none;
  padding: 0;
  font-size: 0.875em;
}

/* ── Navigation ── */
header {
  margin-bottom: 3rem;
}
header nav {
  display: flex;
  align-items: baseline;
  gap: 0 2ch;
  flex-wrap: wrap;
}
header nav a {
  text-decoration: none;
  color: var(--fg);
}
header nav a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.site-name {
  font-weight: 700;
  padding-right: 2ch;
  margin-right: 1ch;
  border-right: 1px solid var(--border);
}

header nav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Post list ── */
.post-list {
  list-style: none;
  padding: 0;
}
.post-list li {
  display: flex;
  gap: 2ch;
  margin: 0.4rem 0;
}
.post-list time {
  color: var(--dim);
  flex-shrink: 0;
}

/* ── Post header ── */
.post-header h1 {
  margin-top: 0;
}
.post-header time {
  display: block;
  color: var(--dim);
  margin-bottom: 1.5rem;
}
.post-header + .content {
  margin-top: 1.5rem;
}

/* ── Tags ── */
.tags {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1ch;
  margin: 0.5rem 0 0;
}
.tags li::before {
  content: '#';
  color: var(--dim);
}

/* ── Post nav ── */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 2ch;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.875em;
}
.post-nav a { text-decoration: none; }
.post-nav a:hover { text-decoration: underline; }

/* ── Homepage intro ── */
.intro {
  margin-bottom: 2.5rem;
}
.intro p {
  margin-top: 0;
}

/* ── Footer ── */
footer {
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--dim);
  font-size: 0.875em;
}

/* ── Search ── */
.search-wrap {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.search-wrap summary {
  cursor: pointer;
  color: var(--dim);
  font-size: 0.875em;
  user-select: none;
}
.search-wrap summary:focus-visible { outline: 1px solid var(--fg); }
#search-input {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  margin-top: 0.75rem;
  border-radius: 0;
  -webkit-appearance: none;
}
#search-input:focus {
  outline: 1px solid var(--fg);
  outline-offset: 0;
}
#search-results {
  list-style: none;
  padding: 0;
  margin-top: 0.75rem;
}
#search-results li {
  margin: 0.4rem 0;
  display: flex;
  gap: 2ch;
}
#search-results .result-date {
  color: var(--dim);
  flex-shrink: 0;
}

/* ── Post content ── */
.content h2,
.content h3 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.25rem;
}

.content a {
  color: var(--c-blue);
  text-decoration-color: var(--c-blue);
}

/* ── Tables ── */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.25rem 0;
  font-size: 0.9em;
}
th, td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  text-align: left;
}
thead th {
  background: var(--bg-alt);
}
tbody tr:nth-child(even) td {
  background: var(--bg-alt);
}
