:root {
  color-scheme: light;

  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #5f5f5c;
  --border: #e4e3df;
  --border-strong: #d6d5d0;
  --shadow: rgba(26, 26, 26, 0.07);
  --accent: #1f6f4a;
  --accent-soft: #eef4f0;
  --amber: #8a6100;
  --amber-soft: #fbf3e0;

  --space-1: 0.375rem;
  --space-2: 0.75rem;
  --space-3: 1.25rem;
  --space-4: 2rem;
  --space-5: 3.5rem;
  --space-6: 5rem;

  --radius: 12px;
  --radius-sm: 6px;
  --maxw: 720px;
}

/* Dark palette. The two blocks below must stay in sync: the first covers an
   explicit choice, the second the system preference when no script has run. */

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131312;
  --surface: #1b1b1a;
  --text: #ededea;
  --text-muted: #a2a19c;
  --border: #2f2f2c;
  --border-strong: #43423e;
  --shadow: rgba(0, 0, 0, 0.4);
  --accent: #6fc493;
  --accent-soft: #17281f;
  --amber: #e0b35f;
  --amber-soft: #2b2317;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;

    --bg: #131312;
    --surface: #1b1b1a;
    --text: #ededea;
    --text-muted: #a2a19c;
    --border: #2f2f2c;
    --border-strong: #43423e;
    --shadow: rgba(0, 0, 0, 0.4);
    --accent: #6fc493;
    --accent-soft: #17281f;
    --amber: #e0b35f;
    --amber-soft: #2b2317;
  }
}

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

body,
h1, h2, h3,
p, ul, figure, figcaption {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  z-index: 10;
}

.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

/* ---------- Header ---------- */

.site-header {
  padding: var(--space-6) 0 var(--space-5);
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  position: relative;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  /* Only useful with scripting: the inline head script adds .js to <html>. */
  display: none;
  position: absolute;
  top: 0;
  right: var(--space-3);
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

:root.js .theme-toggle {
  display: inline-flex;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--border-strong);
}

.theme-toggle svg {
  flex: none;
}

/* Show the icon for the theme the button switches to. */
.theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.site-header h1 {
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 600;
}

.tagline {
  color: var(--text-muted);
  font-size: 1.125rem;
  margin-top: var(--space-1);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-4);
  font-size: 0.95rem;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav a:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---------- Sections ---------- */

.section {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border);
}

.section:last-of-type {
  border-bottom: none;
}

.section h2 {
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.section p + p {
  margin-top: var(--space-2);
}

/* ---------- Projects ---------- */

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-top: var(--space-3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.project-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 6px 24px var(--shadow);
}

.project-card-media {
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
}

.project-body {
  flex: 1 1 auto;
  min-width: 0;
}

.project-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.project-head h3 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.badge {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 0.2em 0.6em;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-live {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-wip {
  background: var(--amber-soft);
  color: var(--amber);
}

.feature-list {
  margin-top: var(--space-2);
  display: grid;
  gap: var(--space-1);
  font-size: 0.95rem;
  color: var(--text-muted);
}

.feature-list li {
  padding-left: 1.1em;
  position: relative;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-3);
}

.tags li {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15em 0.55em;
}

.project-links {
  margin-top: var(--space-3);
}

.link-external {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-weight: 500;
}

.icon-arrow {
  flex: none;
}

/* Wide, landscape screenshots: full card width, below the text. */
.project-media-wide {
  margin-top: var(--space-3);
}

.project-media-wide img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Portrait phone screenshots: narrow column beside the text. */
.project-media {
  flex: 0 0 auto;
  width: 200px;
  max-width: 40%;
}

.project-media img {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8rem;
}

.project-media figcaption {
  margin-top: var(--space-1);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Contact ---------- */

.contact-list {
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.contact-list a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.contact-list a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.contact-list svg {
  flex: none;
  color: var(--text-muted);
}

.contact-list a:hover svg {
  color: var(--accent);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-4) 0 var(--space-5);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Reveal on scroll ---------- */

.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .site-header {
    padding: var(--space-4) 0 var(--space-4);
  }

  .project-card {
    padding: var(--space-3);
  }

  .project-card-media {
    flex-direction: column;
  }

  .project-media {
    width: 100%;
    max-width: 220px;
    margin: 0 auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
