:root {
  --bg: #fafaf9;
  --fg: #111111;
  --text: #3a3a3a;
  --muted: #5c5c5c;
  --accent: #0f766e;
  --rule: rgba(0, 0, 0, 0.14);
  --shadow: rgba(17, 17, 17, 0.18);
  --chart: #0d9488;
  color-scheme: light;
}

/* dark palette: used when the system is dark (unless the visitor picked light), or when they picked dark */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111;
    --fg: #f2f2f2;
    --text: #c8c8c8;
    --muted: #9a9a9a;
    --accent: #5eead4;
    --rule: rgba(255, 255, 255, 0.16);
    --shadow: rgba(0, 0, 0, 0.5);
    --chart: #11a596;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111111;
  --fg: #f2f2f2;
  --text: #c8c8c8;
  --muted: #9a9a9a;
  --accent: #5eead4;
  --rule: rgba(255, 255, 255, 0.16);
  --shadow: rgba(0, 0, 0, 0.5);
  --chart: #11a596;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

main {
  position: relative;
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 56px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

/* header */
header { display: flex; flex-direction: column; gap: 10px; }

#avatar {
  width: 88px;
  height: 88px;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 4px 16px var(--shadow);
  /* not clickable, selectable or draggable; no "save image" on right-click or long-press */
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; color: var(--fg); line-height: 1.2; }
.role { font-weight: 500; color: var(--fg); }
.bio { max-width: 560px; }
.meta { font-size: 14px; color: var(--muted); }
.status { color: var(--accent); }

nav { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; color: var(--fg); margin-top: 4px; }
nav a { text-decoration: underline; text-decoration-color: var(--muted); text-decoration-thickness: 1px; text-underline-offset: 4px; }
nav a:hover { text-decoration-color: var(--accent); }

/* sections */
section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px dashed var(--rule);
}
h2 { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 22px; }
.entry { display: flex; flex-direction: column; gap: 4px; }

.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.title { font-weight: 500; color: var(--fg); }
/* linked titles get a quiet underline so they read as links on touch screens, where there's no hover */
a.title { text-decoration: underline; text-decoration-color: var(--muted); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a.title:hover { text-decoration-color: var(--accent); }
.date { font-size: 13px; color: var(--muted); white-space: nowrap; }
.desc { font-size: 14px; }
.tech { font-size: 13px; color: var(--muted); }

ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }
li { display: flex; gap: 8px; font-size: 14px; }
li::before { content: "–"; color: var(--muted); flex-shrink: 0; }

.skills { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; font-size: 14px; }
.skills dt { color: var(--muted); }
.skills dd { color: var(--fg); }
.nowrap { white-space: nowrap; }
.sep { color: var(--muted); }

footer { font-size: 14px; color: var(--muted); padding-top: 24px; border-top: 1px dashed var(--rule); }
footer a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

/* theme toggle: system → light → dark, top-right on the same row as the photo */
.header-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.theme-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 16px; height: 16px; }

.load-error { display: flex; flex-direction: column; gap: 8px; font-size: 14px; padding: 16px; border: 1px dashed var(--rule); border-radius: 6px; }
.load-error strong { color: var(--fg); }

/* ---------- stats page ---------- */
.back { font-size: 14px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.tile { padding: 12px 14px; border: 1px solid var(--rule); border-radius: 8px; min-width: 0; }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-size: 24px; font-weight: 600; color: var(--fg); line-height: 1.3; }
.tile-value.text { font-size: 16px; line-height: 1.95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-note { font-size: 12px; color: var(--muted); }

.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .bar { fill: var(--chart); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.active { fill: var(--rule); opacity: 0.5; }
.chart-tooltip {
  position: absolute;
  top: -6px;
  transform: translate(-50%, -100%);
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  color: var(--bg);
  background: var(--fg);
  border-radius: 6px;
  pointer-events: none;
}
.chart-table summary { font-size: 13px; color: var(--muted); cursor: pointer; }
.chart-table table { margin-top: 8px; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-table th, .chart-table td { padding: 2px 16px 2px 0; text-align: left; }
.chart-table th { color: var(--muted); font-weight: 500; }

.bar-list { gap: 10px; }
.bar-list li { display: block; font-size: 14px; }
.bar-list li::before { content: none; }
.bar-row { display: flex; justify-content: space-between; gap: 12px; }
.bar-name { color: var(--fg); overflow-wrap: anywhere; }
.bar-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 4px; margin-top: 4px; }
.bar-fill { height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.empty { font-size: 14px; color: var(--muted); }

@media (max-width: 480px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  main { padding-top: 20px; }
  .skills { grid-template-columns: 1fr; gap: 0; }
  .skills dt { font-size: 13px; }
  .skills dd { margin: 2px 0 14px; line-height: 1.7; }
  .skills dd:last-child { margin-bottom: 0; }
}
