/* 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-Bold.woff2") format("woff2");
  font-weight: 700;
  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;
}

/* theme tokens */
:root {
  --font: "JetBrains Mono", ui-monospace, "Cascadia Code", "Source Code Pro",
    Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --max-width: 65ch;
  --line-height: 1.6;
}

/* light (default) */
:root,
[data-theme="light"] {
  --bg: #f5f5f0;
  --fg: #1a1a1a;
  --fg-muted: #6b6b6b;
  --accent: #4a4a4a;
  --link: #1a1a1a;
  --link-hover: #555;
  --border: #ccc;
  --code-bg: #e8e8e3;
  --selection-bg: #1a1a1a;
  --selection-fg: #f5f5f0;
}

/* dark */
[data-theme="dark"] {
  --bg: #0d0d0d;
  --fg: #d4d4d4;
  --fg-muted: #777;
  --accent: #999;
  --link: #d4d4d4;
  --link-hover: #aaa;
  --border: #333;
  --code-bg: #1a1a1a;
  --selection-bg: #d4d4d4;
  --selection-fg: #0d0d0d;
}

/* os preference fallback (before js loads) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0d;
    --fg: #d4d4d4;
    --fg-muted: #777;
    --accent: #999;
    --link: #d4d4d4;
    --link-hover: #aaa;
    --border: #333;
    --code-bg: #1a1a1a;
    --selection-bg: #d4d4d4;
    --selection-fg: #0d0d0d;
  }
}

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

/* base */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 0.875rem;
  line-height: var(--line-height);
  color: var(--fg);
  background: var(--bg);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-fg);
}

/* typography */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 1.1rem;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

p {
  margin-bottom: 1em;
}

/* animations */
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* page fade-in */
main {
  animation: fade-in 0.2s ease-out;
}

/* terminal cursor blink on site title */
.site-title a::after {
  content: "_";
  animation: blink 1s step-end infinite;
  color: var(--fg-muted);
}

/* link underline slide */
a {
  color: var(--link);
  text-decoration: none;
  background-image: linear-gradient(var(--fg-muted), var(--fg-muted));
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.2s ease;
}

a:hover {
  color: var(--link-hover);
  background-size: 100% 1px;
}

/* respect motion preferences */
@media (prefers-reduced-motion: reduce) {
  main {
    animation: none;
  }

  .site-title a::after {
    animation: none;
    opacity: 1;
  }

  a {
    transition: none;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
    background-image: none;
  }
}

/* header / nav */
.site-header {
  margin-bottom: 2.5rem;
}

.site-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
}

.site-title a {
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--fg-muted);
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--fg);
}

.site-nav .sep {
  color: var(--border);
  user-select: none;
}

.theme-toggle {
  margin-left: auto;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--fg);
}

/* horizontal rule */
hr {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 1.5rem 0;
}

/* lists */
ul,
ol {
  padding-left: 2ch;
  margin-bottom: 1em;
}

li {
  margin-bottom: 0.25em;
}

li::marker {
  color: var(--fg-muted);
}

/* code */
code {
  font-family: var(--font);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

pre {
  background: var(--code-bg);
  padding: 1em;
  overflow-x: auto;
  margin-bottom: 1em;
  border-radius: 2px;
}

pre code {
  background: none;
  padding: 0;
}

/* blockquote */
blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1em;
  color: var(--fg-muted);
  margin-bottom: 1em;
}

/* post list */
.post-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  margin-bottom: 0.75em;
}

.post-date {
  color: var(--fg-muted);
  font-size: 0.8rem;
}

/* project list */
.project-list {
  list-style: none;
  padding: 0;
}

.project-list li {
  margin-bottom: 1em;
}

.project-desc {
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* link list */
.link-list {
  list-style: none;
  padding: 0;
}

.link-list li {
  margin-bottom: 0.75em;
}

.link-desc {
  color: var(--fg-muted);
  font-size: 0.85rem;
}

/* footer */
.site-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
  text-align: right;
  font-size: 0.8rem;
  display: flex;
  justify-content: flex-end;
  gap: 1.5ch;
}

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

.post-header h1 {
  margin-top: 0;
  margin-bottom: 0.25em;
}

.post-meta {
  color: var(--fg-muted);
  font-size: 0.8rem;
}

.post-content h2 {
  margin-top: 2em;
}

/* page heading */
.page-title {
  margin-top: 0;
  margin-bottom: 1rem;
}

/* responsive */
@media (max-width: 600px) {
  body {
    font-size: 0.8125rem;
    padding: 1.5rem 1rem;
  }
}
