/* =====================================================
   CSS custom properties — light mode defaults
   ===================================================== */
:root {
  --color-bg:       oklch(96% 0.005 298);
  --color-surface:  oklch(100% 0 0);
  --color-heading:  oklch(25% 0.005 298);
  --color-body:     oklch(40% 0.005 298);
  --color-muted:    oklch(60% 0.005 298);
  --color-border:   oklch(92% 0.004 298);
  --color-accent:   oklch(50% 0.18 265);
  --color-tag-bg:   oklch(91% 0.008 298);
  --color-tag-text: oklch(40% 0.01 298);

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  --max-width: 42rem;
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:       oklch(18% 0.005 298);
    --color-surface:  oklch(22% 0.005 298);
    --color-heading:  oklch(93% 0.005 298);
    --color-body:     oklch(78% 0.005 298);
    --color-muted:    oklch(55% 0.005 298);
    --color-border:   oklch(26% 0.005 298);
    --color-accent:   oklch(72% 0.14 265);
    --color-tag-bg:   oklch(26% 0.008 298);
    --color-tag-text: oklch(75% 0.01 298);
  }
}

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

html { font-size: 17px; min-height: 100%; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-body);
  line-height: 1.7;
  padding: 0 1rem;
  min-height: 100vh;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* =====================================================
   Layout
   ===================================================== */
nav, main {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* =====================================================
   Nav
   ===================================================== */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 2.5rem;
}

nav .site-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-heading);
  text-decoration: none;
}

nav ul {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

nav ul a {
  color: var(--color-muted);
  font-size: 0.9rem;
}
nav ul a:hover { color: var(--color-heading); text-decoration: none; }

/* =====================================================
   Post list (home + tag pages)
   ===================================================== */
.post-list { display: flex; flex-direction: column; gap: 0.1rem; }

.post-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
}

.post-item a {
  color: var(--color-heading);
  font-size: 0.975rem;
}
.post-item a:hover { text-decoration: underline; }

.post-item time {
  font-size: 0.8rem;
  color: var(--color-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* =====================================================
   Individual post
   ===================================================== */
.post { max-width: var(--max-width); }

.post-header { margin-bottom: 2rem; }

.post-header h1 {
  font-size: 1.75rem;
  color: var(--color-heading);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--color-muted);
}

.post-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.tag {
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  text-decoration: none;
}
.tag:hover { text-decoration: none; color: var(--color-accent); }

/* =====================================================
   Post content typography
   ===================================================== */
.post-content > * + * { margin-top: 1.25rem; }

.post-content h2 {
  font-size: 1.3rem;
  color: var(--color-heading);
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

.post-content h3 {
  font-size: 1.1rem;
  color: var(--color-heading);
  margin-top: 1.5rem;
  margin-bottom: 0.35rem;
}

.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
}

.post-content li + li { margin-top: 0.25rem; }

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-tag-bg);
  padding: 0.1em 0.35em;
  border-radius: var(--radius);
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
}

.post-content pre {
  position: relative;
  background: oklch(15% 0.005 298);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

@media (prefers-color-scheme: dark) {
  .post-content pre { background: oklch(13% 0.005 298); }
}

.post-content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: oklch(85% 0.01 298);
}

.post-content blockquote {
  border-left: 3px solid var(--color-border);
  padding-left: 1rem;
  color: var(--color-muted);
  font-style: italic;
}

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

/* =====================================================
   Tags index page
   ===================================================== */
.tag-list h1 {
  color: var(--color-heading);
  font-size: 1.4rem;
  margin-bottom: 1.25rem;
}

.tag-list ul { list-style: none; display: flex; flex-wrap: wrap; gap: 0.6rem; }

.tag-list li { display: flex; align-items: center; gap: 0.35rem; }

.tag-list .tag-count {
  font-size: 0.75rem;
  color: var(--color-muted);
}

/* =====================================================
   About / misc pages
   ===================================================== */
main h1 {
  color: var(--color-heading);
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

main p { margin-top: 0.75rem; }

.back-link { margin-top: 2rem; font-size: 0.85rem; }

/* =====================================================
   Post prev/next navigation
   ===================================================== */
.post-nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
  gap: 1rem;
  font-size: 0.875rem;
}

.post-nav-newer { flex: 1; }
.post-nav-older { flex: 1; text-align: right; }

.post-nav a { color: var(--color-muted); }
.post-nav a:hover { color: var(--color-heading); text-decoration: none; }

/* =====================================================
   Footer breathing room
   ===================================================== */
main { padding-bottom: 4rem; }

/* =====================================================
   Copy code button
   ===================================================== */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 3.2rem;
  padding: 0.2rem 0;
  text-align: center;
  font-family: var(--font);
  font-size: 0.75rem;
  line-height: 1.6;
  background: oklch(28% 0.005 298);
  color: oklch(70% 0.005 298);
  border: 1px solid oklch(35% 0.005 298);
  border-radius: var(--radius);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}

.post-content pre:hover .copy-btn,
.copy-btn:focus { opacity: 1; }

.copy-btn.copied {
  opacity: 1;
}

.copy-btn .check {
  color: oklch(65% 0.18 145);
  font-weight: 700;
}

/* =====================================================
   Syntax highlighting — light (Solarized Light)
   ===================================================== */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #93a1a1; }
.token.punctuation                                           { color: #586e75; }
.token.namespace                                             { opacity: .7; }
.token.property, .token.tag, .token.boolean, .token.number,
.token.constant, .token.symbol, .token.deleted              { color: #268bd2; }
.token.selector, .token.attr-name, .token.string, .token.char,
.token.builtin, .token.url, .token.inserted                 { color: #2aa198; }
.token.atrule, .token.attr-value, .token.keyword            { color: #859900; }
.token.function, .token.class-name                          { color: #b58900; }
.token.regex, .token.important, .token.variable             { color: #cb4b16; }
.token.important, .token.bold                               { font-weight: bold; }
.token.italic                                               { font-style: italic; }
.token.entity                                               { cursor: help; }

/* =====================================================
   Syntax highlighting — dark (Okaidia)
   ===================================================== */
@media (prefers-color-scheme: dark) {
  .token.comment, .token.prolog, .token.doctype, .token.cdata { color: #8292a2; }
  .token.punctuation                                           { color: #f8f8f2; }
  .token.property, .token.tag, .token.constant,
  .token.symbol, .token.deleted                               { color: #f92672; }
  .token.boolean, .token.number                               { color: #ae81ff; }
  .token.selector, .token.attr-name, .token.string, .token.char,
  .token.builtin, .token.inserted                             { color: #a6e22e; }
  .token.operator, .token.entity, .token.url,
  .token.variable                                             { color: #f8f8f2; }
  .token.atrule, .token.attr-value, .token.function,
  .token.class-name                                           { color: #e6db74; }
  .token.keyword                                              { color: #66d9ef; }
  .token.regex, .token.important                              { color: #fd971f; }
  .token.important, .token.bold                               { font-weight: bold; }
  .token.italic                                               { font-style: italic; }
}
