/* ============================================================
   Colors
   Light is the default. Dark applies when the visitor picks it,
   or when their device is in dark mode and they haven't chosen.
   ============================================================ */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1f2023;
  --muted: #5d6066;
  --accent: #0f766e;
  --border: #e4e4e7;
  --code-bg: #f1f1f3;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1b1c1e;
  --surface: #222326;
  --text: #dcdcdd;
  --muted: #9c9da1;
  --accent: #5eead4;
  --border: #323337;
  --code-bg: #2a2b2f;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1c1e;
    --surface: #222326;
    --text: #dcdcdd;
    --muted: #9c9da1;
    --accent: #5eead4;
    --border: #323337;
    --code-bg: #2a2b2f;
    color-scheme: dark;
  }
}

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.7 var(--sans);
}

.wrap { max-width: 720px; margin: 0 auto; padding: 0 20px; }

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

h1 { margin: 0 0 6px; font-size: 34px; line-height: 1.2; letter-spacing: -0.01em; }
h2 { margin: 48px 0 12px; font-size: 22px; line-height: 1.3; }
h3 { margin: 28px 0 8px; font-size: 18px; }
p  { margin: 0 0 14px; }
ul { padding-left: 22px; margin: 0 0 14px; }
li { margin-bottom: 6px; }

.muted { color: var(--muted); }
.mono  { font-family: var(--mono); }

/* ============================================================
   Header
   ============================================================ */
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 24px;
  font-family: var(--mono);
  font-size: 15px;
}
.logo { color: var(--text); font-weight: 700; text-decoration: none; }
.logo span { color: var(--accent); }

.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--accent); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-left: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.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; }

/* ============================================================
   "GET /about  200 OK" line above page titles
   ============================================================ */
.request {
  margin: 32px 0 10px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
}
.request .method { color: var(--accent); font-weight: 700; }
.request .status { margin-left: 8px; }

.tagline { margin: 0 0 28px; font-family: var(--mono); font-size: 15px; color: var(--muted); }

/* ============================================================
   Skills and topics: label + value rows
   ============================================================ */
.rows { margin: 0; display: grid; grid-template-columns: 170px 1fr; gap: 10px 20px; }
.rows dt { font-family: var(--mono); font-size: 14px; color: var(--muted); padding-top: 2px; }
.rows dd { margin: 0; }

/* ============================================================
   Cards (featured project, project list)
   ============================================================ */
.card {
  display: block;
  padding: 20px 22px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
a.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 6px; color: var(--accent); }
.card p { margin: 0 0 12px; }
.card .more { font-family: var(--mono); font-size: 14px; color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.tags li {
  margin: 0;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* ============================================================
   Links row
   ============================================================ */
.links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0; padding: 0; list-style: none; font-family: var(--mono); font-size: 15px; }
.links li { margin: 0; }

/* ============================================================
   Case study
   ============================================================ */
.facts { margin: 24px 0 0; display: grid; grid-template-columns: 110px 1fr; gap: 8px 18px; font-size: 15px; }
.facts dt { font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 3px; }
.facts dd { margin: 0; }

.media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 28px 0 0;
  aspect-ratio: 16 / 9;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}
video { width: 100%; border-radius: 10px; margin-top: 28px; }

.diagram {
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow-x: auto;
  text-align: center;
}
.diagram pre.mermaid { margin: 0; background: none; border: 0; padding: 0; font-family: var(--sans); }

.decisions li strong { color: var(--text); }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.gallery .shot {
  aspect-ratio: 9 / 19;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}
.gallery img { width: 100%; border-radius: 14px; border: 1px solid var(--border); }

/* ============================================================
   Posts list
   ============================================================ */
.post-item { padding: 18px 0; border-bottom: 1px solid var(--border); }
.post-item h3 { margin: 0 0 4px; }
.post-item p { margin: 0; }
.post-meta { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ============================================================
   Code, tables, quotes, images (articles)
   ============================================================ */
code { font-family: var(--mono); font-size: 0.88em; background: var(--code-bg); padding: 2px 5px; border-radius: 4px; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.5;
  tab-size: 4;
}
pre code { background: none; padding: 0; font-size: 14px; }
img { max-width: 100%; height: auto; border-radius: 8px; }
.table-wrap { overflow-x: auto; margin-bottom: 14px; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--code-bg); }
blockquote { margin: 20px 0; padding: 4px 16px; border-left: 3px solid var(--accent); color: var(--muted); }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  margin-top: 72px;
  padding-top: 24px;
  padding-bottom: 40px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* ============================================================
   Phones
   ============================================================ */
@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 28px; }
  .rows, .facts { grid-template-columns: 1fr; gap: 2px; }
  .rows dd, .facts dd { margin-bottom: 12px; }
  .site-nav a { padding: 8px 6px; }
}

/* Diagrams can be wider than the text column on large screens */
@media (min-width: 900px) {
  .diagram {
    width: min(1000px, calc(100vw - 40px));
    margin-left: 50%;
    transform: translateX(-50%);
  }
}

/* ============================================================
   Project header: summary on the left, demo video on the right
   ============================================================ */
.project-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 40px;
  align-items: center;
}
.project-hero .facts { grid-template-columns: 80px 1fr; }

.demo { margin: 0; }

.demo-video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 19.5;
  object-fit: contain;
  /* Hide the white margin baked into the video around the phone frame */
  clip-path: inset(5% 2.4% 5.6% 2.4% round 12% / 5.6%);
}

.demo figcaption {
  margin-top: -18px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
}

@media (max-width: 640px) {
  .project-hero { grid-template-columns: 1fr; gap: 8px; }
  .demo { max-width: 300px; margin: 20px auto 0; }
}