:root {
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #5c6370;
  --accent: #2f6feb;
  --border: #e3e6ea;
  --maxw: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --fg: #e6e8ec;
    --muted: #9aa2ad;
    --accent: #6ea8ff;
    --border: #262a31;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main, .site-header, .site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 600; text-decoration: none; color: var(--fg); }
nav a { margin-left: 1.25rem; color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--accent); }

.hero { padding-block: 4rem 2rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.25rem); margin: 0 0 .5rem; }
.tagline { color: var(--muted); font-size: 1.125rem; margin: 0; }

.muted { color: var(--muted); }

.site-footer {
  margin-top: 4rem;
  padding-block: 2rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .9rem;
}

/* ---- Project grid ------------------------------------------------------ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1.25rem;
  padding: 0;
  margin: 1.5rem 0 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
  transition: border-color .15s;
}

.card:hover { border-color: var(--accent); }

.card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: var(--border);
}

.card-body { padding: 1rem 1.1rem 1.2rem; }
.card-body h3 { margin: 0 0 .35rem; font-size: 1.05rem; }
.card-body h3 a { color: var(--fg); text-decoration: none; }
.card:hover h3 a { color: var(--accent); }
.card-body p { margin: 0; color: var(--muted); font-size: .95rem; }

.tags { margin-top: .75rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.tag {
  font-size: .75rem;
  padding: .15rem .5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
}

/* ---- Click-to-load YouTube --------------------------------------------- */
/* The iframe is only injected on click. Embedding it directly would pull
   ~1MB of Google JS into every page load, before the visitor asks to watch. */

.video {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 1.5rem 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}

.video iframe { width: 100%; height: 100%; border: 0; display: block; }

.video-poster {
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
}

.video-poster::after {
  content: "";
  width: 4.5rem;
  height: 3.2rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, .75);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  box-shadow: 0 0 0 99rem rgba(0, 0, 0, .15) inset;
}

.video-poster::before {
  content: "";
  position: absolute;
  z-index: 1;
  border-style: solid;
  border-width: .7rem 0 .7rem 1.15rem;
  border-color: transparent transparent transparent #fff;
}

.video-poster:hover::after { background: #c00; }

.video-note { margin: -.75rem 0 1.5rem; font-size: .9rem; color: var(--muted); }

/* ---- Prose ------------------------------------------------------------- */

/* Text stays in a readable column; media is free to use the full width. */
.prose > p,
.prose > ul,
.prose > h2,
.prose > .hero,
.prose > .video-note,
.prose > .back { max-width: 42rem; }

.prose > h2 { margin-top: 3rem; }
.prose a { color: var(--accent); }
.prose > ul { padding-left: 1.2rem; }
.prose > ul li { margin-bottom: .3rem; }

.back { display: inline-block; margin-top: 3rem; color: var(--muted); }

/* ---- Split hero (two images side by side) ------------------------------ */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin: 1.5rem 0;
}

.split img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  background: var(--border);
}

.split figure { margin: 0; }
.split figcaption { margin-top: .4rem; font-size: .8rem; color: var(--muted); }

@media (max-width: 34rem) {
  .split { grid-template-columns: 1fr; }
}

/* ---- Buttons ----------------------------------------------------------- */

.button {
  display: inline-block;
  padding: .6rem 1.1rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.button:hover { filter: brightness(1.08); }

.button-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.button-row { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.5rem 0; }

/* ---- Screenshot gallery ------------------------------------------------ */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: .75rem;
  margin: 1.25rem 0;
}

.gallery img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: var(--border);
}

/* ---- Small meta text --------------------------------------------------- */

.meta { font-size: .85rem; color: var(--muted); }
.when { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.links { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.links a { color: var(--accent); }

/* Placeholder state for a video whose id has not been filled in yet. */
.video-todo {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: .9rem;
  background: var(--border);
}
