/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;

  /* light mode (default) */
  --bg: #faf6ec;
  --bg-soft: #f3ecd8;
  --ink: #2a2722;
  --ink-soft: #4a443a;
  --muted: #8a7f6e;
  --rule: #e6dec9;
  --rule-strong: #d4c8a8;
  --accent: #8a3a2c;
  --accent-soft: #b85a48;

  --serif: 'Outfit', ui-serif, Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Courier New', monospace;

  --max: 38rem;
  --sidebar: 16rem;
}

/* When no explicit data-theme is set, follow OS preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1c1a16;
    --bg-soft: #25221c;
    --ink: #e8e2d4;
    --ink-soft: #b8af9e;
    --muted: #786e5a;
    --rule: #2e2922;
    --rule-strong: #3a3429;
    --accent: #e89373;
    --accent-soft: #f0a888;
  }
}

/* Explicit dark mode (data-theme="dark") */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1a16;
  --bg-soft: #25221c;
  --ink: #e8e2d4;
  --ink-soft: #b8af9e;
  --muted: #786e5a;
  --rule: #2e2922;
  --rule-strong: #3a3429;
  --accent: #e89373;
  --accent-soft: #f0a888;
}

:root[data-theme="light"] { color-scheme: light; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
img, svg { display: block; max-width: 100%; }

/* ---------- base ---------- */
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.65;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color .15s, text-decoration-color .15s;
}
a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

/* ---------- layout ---------- */
.page {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  gap: 4rem;
  max-width: 64rem;
  margin: 0 auto;
  padding: 4rem 2rem 2rem;
}

@media (max-width: 760px) {
  .page {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    padding: 2rem 1.25rem;
  }
}

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky;
  top: 4rem;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

@media (max-width: 760px) {
  .sidebar { position: static; }
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.brand-mark {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform .15s;
}
.brand-mark:hover {
  transform: rotate(-6deg) scale(1.05);
  text-decoration: none;
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
}
.brand-name:hover { color: var(--accent); text-decoration: none; }

.brand-tag {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 300;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.75rem 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.55rem;
  margin: 0 -0.55rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--ink-soft);
  border-radius: 4px;
  transition: background .12s, color .12s;
}
.nav-link svg { color: var(--muted); transition: color .12s; flex-shrink: 0; }
.nav-link:hover {
  background: var(--bg-soft);
  color: var(--accent);
  text-decoration: none;
}
.nav-link:hover svg { color: var(--accent); }

.links {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.links a:hover { color: var(--accent); }
.links svg { flex-shrink: 0; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background .12s, border-color .12s, color .12s;
  width: fit-content;
}
.theme-toggle:hover {
  background: var(--bg-soft);
  border-color: var(--rule-strong);
  color: var(--accent);
}
.theme-toggle .theme-icon-light,
.theme-toggle .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-light,
:root:not([data-theme="light"]):not([data-theme="dark"]) .theme-toggle .theme-icon-dark { display: inline-block; }
:root[data-theme="light"] .theme-toggle .theme-icon-dark,
:root:not([data-theme="light"]):not([data-theme="dark"]) .theme-toggle .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-light { display: inline-block; }
:root[data-theme="light"] .theme-toggle .theme-icon-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .theme-icon-light { display: inline-block; }
  :root:not([data-theme]) .theme-toggle .theme-icon-dark { display: none; }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .theme-icon-dark { display: inline-block; }
  :root:not([data-theme]) .theme-toggle .theme-icon-light { display: none; }
}

/* ---------- content ---------- */
.content { max-width: var(--max); }

.intro { padding-bottom: 1rem; }

.hello {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
  line-height: 1.25;
}
.hello .wave {
  display: inline-block;
  font-size: 1.4rem;
  margin-left: 0.25rem;
  animation: wave 2.5s ease-in-out 1;
  transform-origin: 70% 70%;
}
@keyframes wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  10%, 30% { transform: rotate(14deg); }
  20%, 40% { transform: rotate(-8deg); }
  50% { transform: rotate(10deg); }
}

.intro p {
  font-size: 1.0625rem;
  color: var(--ink-soft);
}

.kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}

/* ---------- blocks ---------- */
.block { margin-top: 3rem; }

.block-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.block-title svg { color: var(--muted); }

.now {
  font-size: 0.95rem;
  color: var(--ink-soft);
  background: var(--bg-soft);
  padding: 1rem 1.25rem;
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

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

.post-item {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.5rem 1.25rem;
  padding: 1rem 0;
  border-bottom: 1px dotted var(--rule);
}
.post-item:last-child { border-bottom: 0; }

.post-item time {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding-top: 0.25rem;
}

.post-body p {
  margin: 0.3rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.post-title {
  font-weight: 500;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--ink);
}
.post-title:hover { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent); }

/* ---------- project list ---------- */
.project-item {
  padding: 1rem 0;
  border-bottom: 1px dotted var(--rule);
}
.project-item:last-child { border-bottom: 0; }

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 0.85rem;
  margin-bottom: 0.25rem;
}

.project-name {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
}

.project-tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
}

.project-item p {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.muted { color: var(--muted); font-style: italic; }

/* ---------- post detail ---------- */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--rule);
}
.post-header .kicker { margin-bottom: 1.25rem; }
.post-header .kicker a { color: var(--muted); text-decoration: none; }
.post-header .kicker a:hover { color: var(--accent); }

.post-h1 {
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

.post-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.post-body-prose {
  font-size: 1.0625rem;
  color: var(--ink-soft);
}
.post-body-prose p { margin: 0 0 1.1rem; }
.post-body-prose strong, .post-body-prose b {
  color: var(--ink);
  font-weight: 600;
}
.post-body-prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
}
.post-body-prose a:hover { text-decoration-color: var(--accent); }
.post-body-prose h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.post-body-prose h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.75rem 0 0.5rem;
  color: var(--ink);
}
.post-body-prose ul, .post-body-prose ol {
  margin: 0 0 1.1rem 1.25rem;
  padding: 0;
}
.post-body-prose li { margin: 0.25rem 0; }
.post-body-prose ul li::marker { color: var(--muted); }
.post-body-prose blockquote {
  margin: 1.25rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-style: italic;
}
.post-body-prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-soft);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: var(--accent);
}
.post-body-prose pre {
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1.25rem 0;
}
.post-body-prose pre code { background: transparent; padding: 0; color: var(--ink); }
.post-body-prose hr { border: 0; border-top: 1px dotted var(--rule); margin: 2rem 0; }
.post-body-prose img { margin: 1.25rem 0; border-radius: 4px; }

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.post-footer .kicker {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.post-footer .kicker:hover { color: var(--accent); }

/* ---------- pixel icons (Tania Rascia's MIT-licensed nav PNGs) ---------- */
.pixel {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  flex-shrink: 0;
  display: inline-block;
}

.brand-mark .pixel { width: 32px; height: 32px; }
.nav-link .pixel { width: 20px; height: 20px; }
.links a .pixel { width: 16px; height: 16px; }
.block-title .pixel { width: 20px; height: 20px; }

/* slight lift for dark mode so pixel icons read */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pixel { filter: brightness(1.1) contrast(0.95); }
}
:root[data-theme="dark"] .pixel { filter: brightness(1.1) contrast(0.95); }

/* ---------- footer ---------- */
.footer {
  max-width: 64rem;
  margin: 4rem auto 2rem;
  padding: 1.5rem 2rem 0;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.footer .dot { opacity: 0.4; }

@media (max-width: 760px) {
  .footer { padding: 1.5rem 1.25rem 0; }
}

/* ---------- selection ---------- */
::selection {
  background: var(--accent);
  color: var(--bg);
}
