/* ---------- Fonts ---------- */
@font-face {
  font-family: "Space Grotesk Variable";
  src: url("/assets/fonts/space-grotesk-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter Variable";
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Design tokens ---------- */
:root[data-theme="dark"] {
  --bg: #0d0d12;
  --bg-elevated: #16161d;
  --text: #f2f1ec;
  --text-muted: #9a99a2;
  --accent: #6e56cf;
  --accent-contrast: #ffffff;
  --border: rgba(255, 255, 255, 0.08);
  --code-bg: #1b1b24;
  --shadow: rgba(0, 0, 0, 0.4);
}

:root[data-theme="light"] {
  --bg: #faf9f7;
  --bg-elevated: #ffffff;
  --text: #16161d;
  --text-muted: #5d5c66;
  --accent: #6e56cf;
  --accent-contrast: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --code-bg: #f1f0f5;
  --shadow: rgba(0, 0, 0, 0.08);
}

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

html {
  color-scheme: dark light;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter Variable", ui-sans-serif, system-ui, sans-serif;
  font-size: 1.125rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  font-family: "Space Grotesk Variable", ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 0.5em;
}

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

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

.wrap {
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
  padding-inline: 1.5rem;
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 1.25rem;
}

.site-header__brand {
  font-family: "Space Grotesk Variable", sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--text);
  text-decoration: none;
}

.site-header__nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-header__nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

.site-header__nav a:hover {
  color: var(--text);
}

.theme-toggle {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
}

.theme-toggle__icon::before {
  content: "☀️";
}

:root[data-theme="dark"] .theme-toggle__icon::before {
  content: "🌙";
}

/* ---------- Hero / home ---------- */
.hero {
  padding-block: 3.5rem 2.5rem;
}

.hero h1 {
  font-size: clamp(2.5rem, 5vw + 1rem, 4.5rem);
  font-weight: 800;
  max-width: 16ch;
}

.hero p {
  color: var(--text-muted);
  max-width: 50ch;
  font-size: 1.15rem;
}

/* ---------- Post list ---------- */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-bottom: 3rem;
}

.post-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.75rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px var(--shadow);
}

.post-card__title {
  font-size: 1.5rem;
  margin-bottom: 0.35rem;
}

.post-card__title a {
  color: var(--text);
  text-decoration: none;
}

.post-card__meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.post-card__desc {
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.tag-pill {
  display: inline-block;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  text-decoration: none;
  margin-right: 0.4rem;
}

/* ---------- Post page ---------- */
.post {
  padding-block: 2.5rem 4rem;
  max-width: 65ch;
  margin-inline: auto;
}

.post__title {
  font-size: clamp(2rem, 4vw + 1rem, 3rem);
}

.post__meta {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}

.post__tags {
  margin-bottom: 2rem;
}

.post__body p,
.post__body ul,
.post__body ol {
  margin-bottom: 1.25em;
}

.post__body blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.5em 0;
  padding: 0.25em 1.25em;
  color: var(--text-muted);
}

.post__body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.9rem;
}

.post__body code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.post__body :not(pre) > code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 0.3rem;
}

.post__footer {
  margin-top: 3rem;
  border-top: 1px solid var(--border);
  padding-top: 1.5rem;
}

.post__nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.post__nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
}

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

/* ---------- Tags index ---------- */
.tag-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 3rem;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-footer__inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-footer__nav a {
  color: var(--text-muted);
  margin-left: 1rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-header__inner {
    flex-wrap: wrap;
    row-gap: 0.75rem;
  }

  .site-header__nav {
    gap: 0.85rem;
    font-size: 0.9rem;
  }
}

@media (min-width: 960px) {
  .post-card {
    padding: 2rem 2.25rem;
  }
}
