:root {
  --background: #f6f3ec;
  --foreground: #1c1b19;
  --muted-foreground: #75716a;
  --border: #e0dbcf;
  --accent: #ece8dd;
  --card: #faf8f2;
  --green: #16a34a;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23n)'/%3E%3C/svg%3E");
  --cursor: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2024%2024%27%20width%3D%2718%27%20height%3D%2718%27%20fill%3D%27none%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M22%2010.2069L3%203L10.2069%2022L13.4828%2013.4828L22%2010.2069Z%27%20fill%3D%27none%27%20stroke%3D%27%23000000%27%20stroke-width%3D%272.2%27%2F%3E%3C%2Fsvg%3E") 2 2, auto;
  --cursor-hover: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2024%2024%27%20width%3D%2718%27%20height%3D%2718%27%20fill%3D%27none%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M22%2010.2069L3%203L10.2069%2022L13.4828%2013.4828L22%2010.2069Z%27%20fill%3D%27%23000000%27%20stroke%3D%27%23000000%27%20stroke-width%3D%272.2%27%2F%3E%3C%2Fsvg%3E") 2 2, auto;
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #141311;
    --foreground: #f0ede6;
    --muted-foreground: #9d988e;
    --border: #f0e6d21a;
    --accent: #232120;
    --card: #1b1a18;
    --green: #22c55e;
    --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23n)'/%3E%3C/svg%3E");
    --cursor: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2024%2024%27%20width%3D%2718%27%20height%3D%2718%27%20fill%3D%27none%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M22%2010.2069L3%203L10.2069%2022L13.4828%2013.4828L22%2010.2069Z%27%20fill%3D%27none%27%20stroke%3D%27%23ffffff%27%20stroke-width%3D%272.2%27%2F%3E%3C%2Fsvg%3E") 2 2, auto;
    --cursor-hover: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2024%2024%27%20width%3D%2718%27%20height%3D%2718%27%20fill%3D%27none%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M22%2010.2069L3%203L10.2069%2022L13.4828%2013.4828L22%2010.2069Z%27%20fill%3D%27%23ffffff%27%20stroke%3D%27%23ffffff%27%20stroke-width%3D%272.2%27%2F%3E%3C%2Fsvg%3E") 2 2, auto;
  }
}
:root[data-theme="dark"] {
  --background: #141311;
  --foreground: #f0ede6;
  --muted-foreground: #9d988e;
  --border: #f0e6d21a;
  --accent: #232120;
  --card: #1b1a18;
  --green: #22c55e;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='100%' height='100%' filter='url(%23n)'/%3E%3C/svg%3E");
  --cursor: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2024%2024%27%20width%3D%2718%27%20height%3D%2718%27%20fill%3D%27none%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M22%2010.2069L3%203L10.2069%2022L13.4828%2013.4828L22%2010.2069Z%27%20fill%3D%27none%27%20stroke%3D%27%23ffffff%27%20stroke-width%3D%272.2%27%2F%3E%3C%2Fsvg%3E") 2 2, auto;
  --cursor-hover: url("data:image/svg+xml,%3Csvg%20viewBox%3D%270%200%2024%2024%27%20width%3D%2718%27%20height%3D%2718%27%20fill%3D%27none%27%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%3E%3Cpath%20d%3D%27M22%2010.2069L3%203L10.2069%2022L13.4828%2013.4828L22%2010.2069Z%27%20fill%3D%27%23ffffff%27%20stroke%3D%27%23ffffff%27%20stroke-width%3D%272.2%27%2F%3E%3C%2Fsvg%3E") 2 2, auto;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  overflow-x: clip;
  background-color: var(--background);
  background-image: var(--grain);
  background-size: 180px 180px;
  cursor: var(--cursor);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, dl, dd, dt { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; cursor: var(--cursor-hover); }
button { font: inherit; color: inherit; cursor: var(--cursor-hover); background: none; border: 0; padding: 0; text-align: left; }
::selection { background: var(--foreground); color: var(--background); }

:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  max-width: 48rem;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

.muted { color: var(--muted-foreground); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--font-mono); font-size: 0.8125rem; }

.ico {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.ico.sm { width: 0.875rem; height: 0.875rem; }

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
}
/* full-bleed, paper-coloured bar so it blends into the page instead of showing as a box */
.nav::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%);
  background-color: color-mix(in srgb, var(--background) 88%, transparent);
  background-image: var(--grain);
  background-size: 180px 180px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.nav-name { font-weight: 600; }
.nav-links { display: flex; align-items: center; gap: 1rem; }
.nav-links > a { font-size: 0.875rem; transition: opacity 0.2s; }
.nav-links > a:hover { opacity: 0.6; }
.theme-toggle {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  transition: opacity 0.2s;
}
.theme-toggle:hover { opacity: 0.6; }
.theme-toggle .ico-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ico-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .ico-moon { display: block; }
}
@media (max-width: 26rem) {
  .nav-links { gap: 0.75rem; }
}

/* ---------- Hero ---------- */
.hero { padding: 3rem 1rem 1.25rem; }
.hero-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 2.5rem;
}
.hero-name { padding: 0.5rem 0; }
h1 {
  font-size: 1.375rem;
  line-height: 1.33;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.avatar {
  position: relative;
  width: 5rem;
  height: 5rem;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--accent);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 1.375rem;
  letter-spacing: -0.04em;
  user-select: none;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.bio { max-width: 42rem; }

.term { position: relative; display: inline-block; outline-offset: 2px; }
@media (min-width: 40rem) {
  .term {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-decoration-color: var(--muted-foreground);
    text-underline-offset: 4px;
    cursor: var(--cursor-hover);
  }
  .term::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translate(-50%, 4px);
    width: max-content;
    max-width: 16rem;
    padding: 0.375rem 0.625rem;
    border-radius: 8px;
    background: var(--foreground);
    color: var(--background);
    font-size: 0.75rem;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 10;
  }
  .term:hover::after, .term:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
}

.socials-row {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.socials { display: flex; gap: 0.5rem; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: color-mix(in srgb, var(--foreground) 80%, transparent);
  transition: background 0.2s, color 0.2s;
}
.icon-btn .ico { width: 1.125rem; height: 1.125rem; }
.icon-btn:hover { background: color-mix(in srgb, var(--accent) 40%, transparent); color: var(--foreground); }

/* ---------- Sections ---------- */
.section { padding: 2.5rem 1rem; scroll-margin-top: 2.5rem; }
h2 {
  font-size: 1.25rem;
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 1.5rem;
}
h3, .title { font-weight: 500; font-size: 1rem; line-height: 1.5; }
.sub { font-size: 0.875rem; color: var(--muted-foreground); line-height: 1.5; }
.desc { font-size: 0.875rem; color: var(--muted-foreground); }

.list { display: flex; flex-direction: column; gap: 2rem; }

.entry { display: flex; gap: 1rem; }
.entry-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.125rem 1rem;
}
.entry-head .date { white-space: nowrap; }
.entry-body.collapsible { gap: 0; }
.entry-body.collapsible > .lead-desc { margin-top: 0.5rem; }
.entry-body.collapsible > .chips { margin-top: 0.5rem; }
/* bullets sit after the always-visible paragraph, so no extra top padding on a bare list */
.entry-body.collapsible .proj-inner > .dots { padding-top: 1rem; }

/* logo placeholder (initials until a real image is dropped in) */
.logo {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--muted-foreground);
  user-select: none;
}
.logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
/* a real logo loaded: no box, no background, no border, no placeholder initial */
.logo.has-img { border: 0; background: none; border-radius: 0; overflow: visible; }
.logo.has-img > span { display: none; }

.dots {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.375rem 1.5rem;
}
@media (min-width: 40rem) {
  .dots { grid-template-columns: 1fr 1fr; }
  .dots.one { grid-template-columns: 1fr; }
}
.dots li { position: relative; padding-left: 0.875rem; font-size: 0.875rem; line-height: 1.5; }
.dots li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted-foreground);
}
.dots strong { font-weight: 500; }

/* small bordered chips, as on project cards */
.chips { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.chips li, .chips > span {
  font-size: 0.75rem;
  line-height: 1.33;
  padding: 0.125rem 0.375rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* ---------- Projects (collapsible) ---------- */
.project { display: block; }
.proj-toggle { display: flex; flex-direction: column; gap: 0.5rem; width: 100%; border-radius: 6px; }
.proj-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.proj-head .title { display: block; transition: text-decoration-color 0.2s; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; }
.proj-toggle:hover .title { text-decoration-color: var(--foreground); }
.proj-head .sub { display: block; }
.more {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding-top: 0.125rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  transition: color 0.2s;
  white-space: nowrap;
}
.proj-toggle:hover .more { color: var(--foreground); }
.more .ico { transition: transform 0.25s ease; }
.proj-toggle[aria-expanded="true"] .more .ico { transform: rotate(180deg); }

.proj-more { display: block; }
.js .proj-more {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.3s ease, visibility 0.3s;
}
.js .proj-more.open { grid-template-rows: 1fr; visibility: visible; }
.proj-inner { overflow: hidden; min-height: 0; }
.proj-inner > .desc { padding-top: 1rem; }
.proj-inner > .dots { padding: 1rem 0 0.25rem; }
.proj-inner > .dots + .desc.tail { padding-top: 0.75rem; }
.side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.125rem; flex-shrink: 0; }
.side .sub { display: block; white-space: nowrap; }
.side .more { padding-top: 0; }

/* ---------- Stack ---------- */
.stack-grid { display: flex; flex-direction: column; gap: 1.5rem; }
.stack-grid .row { display: grid; gap: 0.5rem; }
@media (min-width: 40rem) {
  .stack-grid .row { grid-template-columns: 140px 1fr; }
}
.label { font-size: 0.875rem; color: var(--muted-foreground); line-height: 1.5rem; }
.pills { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.pills li {
  display: flex;
  align-items: center;
  height: 1.5rem;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: nowrap;
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 2.5rem 1rem 2rem;
}
.footer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.125rem 1rem;
}
.footer-name { font-weight: 600; }
.footer-meta { margin-top: 1rem; align-items: center; }

/* ---------- Reveal ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .js .proj-more, .more .ico { transition: none; }
}

/* ---------- Theme switch animation ---------- */
/* View Transitions: the new theme is revealed by a circle (clip-path set in script.js) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) { z-index: 2; }

/* Fallback: cross-fade colours */
html.theme-fade *:not(.reveal),
html.theme-fade *:not(.reveal)::after {
  transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, fill 0.4s ease, stroke 0.4s ease !important;
}

/* Sun/moon icon spins in after a toggle */
@keyframes icon-in {
  from { transform: rotate(-90deg) scale(0.4); opacity: 0; }
  to { transform: none; opacity: 1; }
}
html.theme-changed .theme-toggle .ico { animation: icon-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }

@media (prefers-reduced-motion: reduce) {
  html.theme-changed .theme-toggle .ico { animation: none; }
}

/* Details control is hidden when a panel has nothing to reveal yet */
.proj-toggle.no-details { cursor: default; pointer-events: none; }
.proj-toggle.no-details .more { display: none; }
