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

/* === Theme variables === */
:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --fg-secondary: #555555;
  --fg-muted: #888888;
  --code-bg: #f5f5f5;
  --selection: rgba(0, 100, 255, 0.15);
  --max-width: 640px;
  --header-height: 4.5rem;

  /* Default palette: Cobalt */
  --c-l: oklch(0.45 0.20 255);
  --c-d: oklch(0.68 0.18 255);
  --color: var(--c-l);
}

[data-theme="dark"] {
  --bg: #111111;
  --fg: #e5e5e5;
  --fg-secondary: #aaaaaa;
  --fg-muted: #777777;
  --code-bg: #1a1a1a;
  --selection: rgba(100, 180, 255, 0.2);
  --color: var(--c-d);
}

/* === 10 Color Palettes (OKLCH) === */
/* 1 — Cobalt */
[data-palette="1"]  { --c-l: oklch(0.45 0.20 255); --c-d: oklch(0.68 0.18 255); }
/* 2 — Emerald */
[data-palette="2"]  { --c-l: oklch(0.48 0.17 155); --c-d: oklch(0.70 0.16 155); }
/* 3 — Amber */
[data-palette="3"]  { --c-l: oklch(0.58 0.16 75);  --c-d: oklch(0.80 0.16 80);  }
/* 4 — Violet */
[data-palette="4"]  { --c-l: oklch(0.44 0.22 290); --c-d: oklch(0.70 0.20 290); }
/* 5 — Rose */
[data-palette="5"]  { --c-l: oklch(0.50 0.20 15);  --c-d: oklch(0.72 0.18 15);  }
/* 6 — Teal */
[data-palette="6"]  { --c-l: oklch(0.50 0.14 192); --c-d: oklch(0.72 0.13 192); }
/* 7 — Indigo */
[data-palette="7"]  { --c-l: oklch(0.42 0.22 270); --c-d: oklch(0.67 0.20 270); }
/* 8 — Lime */
[data-palette="8"]  { --c-l: oklch(0.50 0.18 130); --c-d: oklch(0.76 0.17 130); }
/* 9 — Crimson */
[data-palette="9"]  { --c-l: oklch(0.48 0.22 25);  --c-d: oklch(0.70 0.20 25);  }
/* 10 — Sky */
[data-palette="10"] { --c-l: oklch(0.52 0.15 215); --c-d: oklch(0.74 0.14 215); }

::selection {
  background: var(--selection);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Header === */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  transition: background 0.2s, transform 0.3s;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-name {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-name:hover { opacity: 0.7; }

/* === Theme toggle === */
.toggle-switch {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.toggle-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: var(--fg-muted);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--bg);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-checkbox:checked + .toggle-track {
  background: var(--fg-secondary);
}

.toggle-checkbox:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}

/* === Page wrapper === */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  flex: 1;
  width: 100%;
  text-align: left;
}

/* === Homepage === */
.hero {
  padding: 5rem 0 3rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.hero-bio {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--fg-secondary);
}

.hero-bio p {
  margin-bottom: 1rem;
}

.hero-bio p:last-child {
  margin-bottom: 0;
}

.section {
  padding: 2.5rem 0;
}

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color);
  margin-bottom: 1rem;
}

.section-list {
  list-style: none;
}

.section-list li {
  margin-bottom: 0.35rem;
}

.section-list a {
  color: var(--fg);
  text-decoration: none;
  font-size: 1rem;
}

.section-list a:hover {
  color: var(--fg-secondary);
}

.section-list .meta {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-left: 0.5rem;
}

/* === Post list (archive) === */
.post-list {
  list-style: none;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0;
}

.post-list a {
  color: var(--fg);
  text-decoration: none;
  font-size: 1rem;
}

.post-list a:hover { color: var(--fg-secondary); }

.post-list time {
  color: var(--fg-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  margin-left: 1rem;
  font-variant-numeric: tabular-nums;
}

/* === Article (single post) === */
.post-header {
  padding: 3rem 0 2rem;
}

.post-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
  margin-bottom: 0.5rem;
}

.post-header time {
  color: var(--fg-muted);
  font-size: 0.9rem;
}

article .content {
  font-size: 1.05rem;
  line-height: 1.75;
}

article .content p { margin-bottom: 1.25rem; }
article .content h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}
article .content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

article .content a {
  color: var(--color);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: color-mix(in oklch, var(--color) 40%, transparent);
}
article .content a:hover {
  text-decoration-color: var(--color);
}

article .content ul, article .content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}
article .content li { margin-bottom: 0.3rem; }

article .content blockquote {
  border-left: 2px solid var(--color);
  padding-left: 1.25rem;
  color: var(--fg-secondary);
  margin: 1.5rem 0;
  font-style: italic;
}

article .content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1.5rem 0;
}

/* === Code === */
code {
  font-family: "SF Mono", "Fira Code", Menlo, monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  padding: 1.25rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

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

/* === Footnotes === */
.footnotes hr {
  display: none;
}

.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  font-size: 0.85rem;
  color: var(--fg-secondary);
}

.footnotes ol {
  padding-left: 1.5rem;
}

.footnotes li {
  margin-bottom: 0.5rem;
}

/* === Tags === */
.tags {
  display: inline-flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tag {
  font-size: 0.75rem;
  color: var(--color);
  padding: 0.15em 0.6em;
  border-radius: 3px;
}

/* === Mermaid === */
.mermaid {
  margin: 1.5rem 0;
  text-align: center;
}

.mermaid svg .flowchart-link,
.mermaid svg .edge-thickness-normal,
.mermaid svg path.path {
  stroke: #444444;
}

.mermaid svg marker path {
  fill: #444444;
  stroke: #444444;
}

[data-theme="dark"] .mermaid svg .flowchart-link,
[data-theme="dark"] .mermaid svg .edge-thickness-normal,
[data-theme="dark"] .mermaid svg path.path {
  stroke: #aaaaaa;
}

[data-theme="dark"] .mermaid svg marker path {
  fill: #aaaaaa;
  stroke: #aaaaaa;
}

/* === Footer === */
.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 2rem;
}

.social-links {
  display: flex;
  gap: 0.5rem;
}

.social-link {
  color: var(--fg-muted);
  text-decoration: none;
  line-height: 1;
  transition: color 0.2s;
}

.social-link:hover { color: var(--fg); }

/* === Color picker (temporary) === */
.color-picker {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  background: var(--bg);
  border: 1px solid var(--fg-muted);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-family: inherit;
  font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.color-picker label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

.color-swatches {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  max-width: 180px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s;
}

.swatch:hover { transform: scale(1.15); }
.swatch.active { border-color: var(--fg); }

/* === Responsive === */
@media (max-width: 600px) {
  .hero h1 { font-size: 2rem; }
  .post-header h1 { font-size: 1.6rem; }
  .hero { padding: 3rem 0 2rem; }
}
