:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #2b3138;
  --text: #e6e8ea;
  --muted: #9aa4af;
  --accent: #4dd4ac;
  --accent-strong: #2bbf93;
  --max-width: 60rem;
  color-scheme: dark;
}

/* Light palette: applies when the OS prefers light (and no manual
   override is set), or when the visitor picks light with the toggle. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #fafafa;
    --surface: #ffffff;
    --border: #e2e5e9;
    --text: #1c2128;
    --muted: #5b6570;
    --accent: #0e9373;
    --accent-strong: #0b7a60;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e2e5e9;
  --text: #1c2128;
  --muted: #5b6570;
  --accent: #0e9373;
  --accent-strong: #0b7a60;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.site-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 3.5rem;
}

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

.nav-links { display: flex; gap: 1.25rem; }
.nav-links a { color: var(--muted); font-size: 0.95rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-right { display: flex; align-items: center; gap: 1.25rem; }
.brand { white-space: nowrap; }
@media (max-width: 30rem) {
  /* Not enough room for brand, anchors and toggle: the home page is one scroll
     and project pages have a back link, so drop the anchors on phones. */
  .nav-links { display: none; }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 1rem; height: 1rem; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* Hero */
.hero { padding: 5rem 1rem 2.5rem; }

.kicker {
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(2rem, 5.5vw, 3.25rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}

.lede {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 38rem;
  margin: 0 0 2rem;
}

.cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b0f14;
}
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

/* Sections */
main section { padding: 1.5rem 1rem; }

h2 {
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

.section-intro { color: var(--muted); margin-top: 0; }

/* Project cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.card h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.card p { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.95rem; }

.tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tags span {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 0.35rem;
  padding: 0.15rem 0.5rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 1.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Clickable cards */
a.card {
  display: flex;
  flex-direction: column;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
a.card:hover, a.card:focus-visible {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--bg) 60%, transparent);
}
a.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.card .tags { margin-top: auto; }

.card-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.card-head h3 { margin: 0; }
.card-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.6rem;
  flex: none;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* Project pages */
.project-hero { padding-top: 3.5rem; }

.back-link {
  display: inline-block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
.back-link:hover { color: var(--text); }

.project-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.project-head h1 { margin: 0; }
.project-head .kicker { margin-bottom: 0.25rem; }
.project-icon {
  width: 6rem;
  height: 6rem;
  border-radius: 1.25rem;
  flex: none;
  object-fit: cover;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--bg) 70%, transparent);
}
.project-hero .lede { margin-bottom: 1.25rem; }
.project-hero .tags span { font-size: 0.85rem; }

.feature-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: grid;
  gap: 0.75rem;
}
.feature-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  color: var(--muted);
}
.feature-list li strong { color: var(--text); display: block; margin-bottom: 0.2rem; }

.project-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.project-nav a {
  flex: 1 1 14rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  color: var(--text);
}
.project-nav a:hover { text-decoration: none; border-color: var(--accent); }
.project-nav a.next { text-align: right; }
.project-nav small { display: block; color: var(--muted); font-size: 0.8rem; margin-bottom: 0.2rem; }

@media (max-width: 30rem) {
  .project-head { flex-direction: column; align-items: flex-start; }
}
