/* ===== Global Theme Variables ===== */
:root {
  color-scheme: light dark;
  --fg: #0f1115;
  --bg: #ffffff;
  --muted: #6b7280;
  --link: #2563eb;
  --w: 680px;      /* content max width */
  --lh: 1.65;
  --space: 22px;
}

/* Default: prefers-color-scheme: dark */
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e5e7eb;
    --bg: #0b0d11;
    --muted: #9aa0a6;
    --link: #7aa2ff;
  }
}

/* Forced user toggle */
:root[data-theme="light"] {
  --fg: #0f1115;
  --bg: #ffffff;
  --muted: #6b7280;
  --link: #2563eb;
}
:root[data-theme="dark"] {
  --fg: #e5e7eb;
  --bg: #0b0d11;
  --muted: #9aa0a6;
  --link: #7aa2ff;
}

/* ===== Base Reset ===== */
* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/var(--lh) ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
a:hover { opacity: .9; }

/* ===== Container ===== */
.container {
  max-width: var(--w);
  margin: 0 auto;
  padding-block: calc(var(--space) + 6px) 72px;
  padding-inline: clamp(24px, 8vw, 72px);
}
@media (max-width: 900px) {
  :root { --w: 640px; }
  .container { padding-inline: clamp(28px, 9vw, 80px); }
}
@media (max-width: 640px) {
  :root { --w: 600px; }
  .container { padding-inline: clamp(32px, 11vw, 96px); }
}

/* ===== Navigation ===== */
header.nav {
  display: grid;
  grid-template-columns: 1fr auto; /* left: menu / right: button */
  align-items: center;
  gap: 12px;
  margin-bottom: calc(var(--space) * 1.25);
}
nav a {
  margin-right: 16px;
  color: inherit;
  text-decoration: none;
  opacity: .85;
}
nav a:last-child { margin-right: 0; }
nav a[aria-current="page"] {
  opacity: 1;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ===== Theme Toggle Button ===== */
.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid color-mix(in oklab, var(--fg) 30%, transparent);
  background: transparent;
  color: var(--fg);
  border-radius: 999px;
  cursor: pointer;
  line-height: 1;
  transition: background .2s, border-color .2s, opacity .2s, transform .05s;
}
.theme-btn:hover {
  background: color-mix(in oklab, var(--fg) 8%, transparent);
}
.theme-btn:active { transform: scale(0.98); }
.theme-btn:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--link) 60%, transparent);
  outline-offset: 2px;
}
.theme-btn svg { display: block; width: 18px; height: 18px; stroke: currentColor; fill: none; }

/* Icon toggle depending on theme */
:root[data-theme="dark"]  .icon-sun { display: block; }
:root[data-theme="dark"]  .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }

/* ===== Typography ===== */
h1 { font-size: clamp(28px, 4vw, 36px); line-height: 1.2; margin: 4px 0 10px; }
h2 { font-size: clamp(20px, 3vw, 24px); margin: 28px 0 8px; }
h3 { font-size: clamp(18px, 2.6vw, 20px); margin: 20px 0 6px; }
p { margin: 10px 0; }
ul, ol { padding-left: 20px; margin: 10px 0; }
li { margin: 4px 0; }

hr {
  border: 0;
  height: 1px;
  background: color-mix(in oklab, var(--fg) 12%, transparent);
  margin: 26px 0;
}

footer {
  margin-top: 40px;
  color: var(--muted);
  font-size: 14px;
}

/* ===== About page ===== */
.about-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
  text-align: center;
}
.profile-pic {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--fg) 12%, transparent);
}
@media (max-width: 640px) {
  .about-wrapper {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}