:root {
  /* Each page has its own theme, picked by <body data-page="...">.
     Default (About page): creamy off-white. */
  color-scheme: light;
  --bg: #f5eedf;
  --surface: #fffaf0;
  --text: #2b2519;
  --muted: #6e6553;
  --border: #e3d8c2;
  --accent: #1d4ed8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 45, 20, 0.05), 0 8px 24px rgba(60, 45, 20, 0.08);
  --max: 1040px;
}

/* Projects grid + project pages: dark blue over the binary-code image. */
body[data-page="projects"],
body[data-page="project"] {
  color-scheme: dark;
  --bg: #050c2c;
  --surface: rgba(8, 16, 48, 0.78);
  --text: #eef2ff;
  --muted: #a9b4d6;
  --border: rgba(120, 150, 255, 0.2);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}
/* Not set on project pages: there each project's own accent (set on <html> by site.js) is used. */
body[data-page="projects"] { --accent: #60a5fa; }

/* Hobbies: dark military green. */
body[data-page="hobbies"] {
  color-scheme: dark;
  --bg: #262e1b;
  --surface: #323c25;
  --text: #eef0e0;
  --muted: #b9bfa2;
  --border: rgba(190, 205, 150, 0.18);
  --accent: #a8bd6e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* Projects pages: fixed full-screen background image (a pseudo-element, because
   background-attachment: fixed doesn't work on iOS). */
body[data-page="projects"]::before,
body[data-page="project"]::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(3, 8, 30, 0.35), rgba(3, 8, 30, 0.55)),
    url("../assets/img/bg.jpg") center / cover no-repeat,
    var(--bg);
}

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

a { color: inherit; }

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--border); }
.nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.card, .project-card { backdrop-filter: blur(6px); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: 0.88; }
.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* Hero */
.hero { padding: 72px 0 40px; }
.hero h1 {
  font-size: clamp(2.2rem, 6vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}
.hero .title { font-size: 1.2rem; color: var(--muted); margin: 0 0 20px; }
.hero .summary { max-width: 640px; font-size: 1.05rem; margin: 0 0 28px; }
.meta { color: var(--muted); font-size: 0.95rem; margin-bottom: 24px; }
.meta span + span::before { content: "·"; margin: 0 8px; }

/* Sections */
section { padding: 32px 0; }
section h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 12px; }

.entry-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.entry-head h3 { margin: 0; font-size: 1.05rem; }
.entry-head .dates { color: var(--muted); font-size: 0.9rem; }
.entry-org { color: var(--muted); margin: 2px 0 8px; }
.entry ul { margin: 0; padding-left: 20px; }

.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.skills h3 { margin: 0 0 10px; font-size: 0.95rem; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }
.tags li {
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Project grid */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.project-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--muted); }
.project-cover {
  aspect-ratio: 16 / 9;
  background: var(--accent);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.project-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.project-body h3 { margin: 0; font-size: 1.2rem; }
.project-body p { margin: 0; color: var(--muted); }
.project-body .tags { margin-top: auto; }
.status {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.status.live { color: #16a34a; }
.card-labels { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 9px;
}
.detail-hero .category { margin-bottom: 10px; }

/* Project detail */
.back { display: inline-block; margin: 28px 0 0; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }
.detail-hero { padding: 24px 0 8px; }
.detail-hero h1 { font-size: clamp(2rem, 5vw, 2.8rem); margin: 0 0 6px; letter-spacing: -0.02em; }
.detail-hero .tagline { color: var(--muted); font-size: 1.15rem; margin: 0 0 20px; }
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
@media (max-width: 760px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-grid ul { margin: 0; padding-left: 20px; }

.demo-frame {
  width: 100%;
  height: 70vh;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.demo-empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 24px;
}

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

/* ---------- Hobbies: overview tiles + one section per hobby ---------- */
.hobby-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.hobby-tile {
  position: relative;
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  color: #fff;
  text-decoration: none;
  box-shadow: var(--shadow);
  background: var(--tile-accent);
}
.hobby-tile-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 25%;
  transition: transform 0.3s ease;
}
.hobby-tile:hover .hobby-tile-img { transform: scale(1.04); }
.hobby-tile-body {
  position: absolute;
  inset: auto 0 0 0;
  padding: 40px 16px 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
}
.hobby-tile-body h3 { margin: 0; font-size: 1.3rem; }
.hobby-tile-body span { font-size: 0.85rem; opacity: 0.85; }

.hobby { scroll-margin-top: 80px; }
.hobby-head { border-left: 4px solid var(--accent); padding-left: 14px; margin-bottom: 16px; }
.hobby .hobby-head h2 { margin: 0 0 4px; font-size: 1.6rem; text-transform: none; letter-spacing: -0.01em; color: var(--text); }
.hobby-head p { margin: 0 0 10px; color: var(--muted); max-width: 680px; }

/* ---------- Gallery grid (hobbies and project pages) ---------- */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.media-item {
  margin: 0;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--border);
}
.media-item img,
.media-item video { width: 100%; height: 100%; object-fit: cover; object-position: center 30%; display: block; }
.media-item video { background: #000; }
.media-open { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.media-open:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.media-open img { transition: transform 0.25s ease; }
.media-open:hover img { transform: scale(1.04); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.9);
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: min(1200px, 100%); text-align: center; }
.lightbox img { max-width: 100%; max-height: 82vh; border-radius: 8px; }
.lightbox figcaption { color: #ddd; margin-top: 10px; font-size: 0.95rem; }
.lightbox button {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 0;
  border-radius: 999px;
  width: 44px;
  height: 44px;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  flex: none;
}
.lightbox button:hover { background: rgba(255, 255, 255, 0.25); }
.lightbox button[hidden] { display: none; }
.lb-close { position: absolute; top: 16px; right: 16px; }
@media (max-width: 640px) {
  .hobby-overview { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .hobby-tile { aspect-ratio: 3 / 4; }
  .hobby-tile-body { padding: 24px 8px 8px; }
  .hobby-tile-body h3 { font-size: 0.95rem; }
  .hobby-tile-body span { display: none; }
  .media-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .lb-prev, .lb-next { position: absolute; bottom: 24px; }
  .lb-prev { left: calc(50% - 56px); }
  .lb-next { right: calc(50% - 56px); }
}

/* ---------- Embedded video (e.g. PitchEye field test) ---------- */
.field-test p { margin-top: 0; max-width: 680px; }
.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 0 0 16px;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- About page: headshot next to the name ---------- */
.hero-top { display: flex; align-items: center; gap: 24px; margin-bottom: 8px; }
.hero-top h1 { margin-bottom: 4px; }
.hero-top .title { margin-bottom: 0; }
.avatar {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow);
}
@media (max-width: 640px) {
  .hero-top { gap: 16px; }
  .avatar { width: 88px; height: 88px; border-width: 3px; }
}
