:root {
  color-scheme: light;
  --bg: #fafaf9;
  --text: #1c1c1a;
  --muted: #55554f;
  --line: #deded9;
  --accent: #0f766e;
  --on-accent: #ffffff;
  --radius: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark follows the system unless the visitor chose a theme with the toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131312;
    --text: #ecece8;
    --muted: #a8a8a0;
    --line: #2d2d2a;
    --accent: #5eead4;
    --on-accent: #042f2e;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131312;
  --text: #ecece8;
  --muted: #a8a8a0;
  --line: #2d2d2a;
  --accent: #5eead4;
  --on-accent: #042f2e;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }
@media (min-width: 768px) { .wrap { padding: 0 2rem; } }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius); }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: var(--on-accent);
  padding: .5rem 1rem; border-radius: var(--radius);
}
.skip:focus { left: 1rem; top: 1rem; z-index: 20; }

/* Navigation */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  transition: background-color .25s ease, border-color .25s ease;
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.logo { display: block; flex: none; }
.nav nav { display: flex; align-items: center; gap: 1.25rem; font-size: .95rem; }
.nav nav a { text-decoration: none; color: var(--muted); transition: color .2s ease; }
.nav nav a:hover { color: var(--text); }

.theme-toggle {
  font: inherit;
  font-size: .85rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .3rem .75rem;
  cursor: pointer;
  transition: border-color .2s ease, transform .15s ease;
}
.theme-toggle:hover { border-color: var(--muted); }
.theme-toggle:active { transform: translateY(1px); }

@media (max-width: 560px) {
  .nav nav { gap: .9rem; font-size: .85rem; }
  .nav-skills { display: none; }
}

/* Hero */
.hero {
  padding-top: 4rem; padding-bottom: 5rem; min-height: min(70dvh, 640px);
  display: grid; grid-template-columns: 1fr; gap: 2.5rem; align-content: center; align-items: center;
}
.portrait {
  display: block; width: 100%; max-width: 180px; height: auto; aspect-ratio: 1;
  object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line);
}
@media (min-width: 860px) {
  .hero { grid-template-columns: minmax(0, 1fr) 260px; gap: 4rem; }
  .portrait { max-width: none; }
}
h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 650;
  margin: 0 0 1.25rem;
  max-width: 22ch;
  text-wrap: balance;
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 52ch; margin: 0 0 2rem; text-wrap: balance; }
.nowrap { white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.btn {
  display: inline-block;
  padding: .7rem 1.25rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 550;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: transform .15s ease, filter .2s ease, border-color .2s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--muted); }

/* Sections */
.section { padding-top: 4.5rem; padding-bottom: 1rem; scroll-margin-top: 64px; }
h2 { font-size: 1.6rem; letter-spacing: -0.02em; margin: 0 0 1.5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
p { margin: 0 0 1rem; }
.note { color: var(--muted); max-width: 60ch; }

/* Skills: asymmetric grid, collapses to one column on mobile */
.skills { display: grid; grid-template-columns: 1fr; gap: 2rem 3rem; }
.skills p { color: var(--muted); max-width: 60ch; }
@media (min-width: 768px) {
  .skills { grid-template-columns: 2fr 1fr; }
  .skill-wide { grid-column: 1 / -1; padding-top: 1.5rem; border-top: 1px solid var(--line); }
}

/* Projects */
.projects { list-style: none; margin: 0; padding: 0; }
.projects li { padding: 1.5rem 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr; gap: .25rem 2rem; }
.projects li:last-child { border-bottom: 1px solid var(--line); }
.projects p { color: var(--muted); margin: 0; max-width: 62ch; }
.projects .meta { font-size: .9rem; margin-top: .15rem; }
@media (min-width: 768px) { .projects li { grid-template-columns: 1fr 2fr; } }

/* Contact */
.contact { padding-bottom: 4rem; }
.links { list-style: none; padding: 0; margin: 1.25rem 0 0; display: flex; flex-wrap: wrap; gap: 1.5rem; }
.links a { color: var(--accent); text-underline-offset: 4px; }
.links a:hover { text-decoration-thickness: 2px; }

.footer { border-top: 1px solid var(--line); padding-top: 1.5rem; padding-bottom: 2rem; color: var(--muted); font-size: .9rem; }

/* Scroll reveal: only hides content when JavaScript is running. */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s cubic-bezier(.16, 1, .3, 1), transform .6s cubic-bezier(.16, 1, .3, 1); }
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
