:root {
  --bg: #0b0e13;
  --card: rgba(13, 17, 24, 0.86);
  --line: rgba(255, 255, 255, 0.10);
  --text: #e8ebf0;
  --muted: #9aa3b2;
  --accent: #ffb547;      /* trail amber, matches the route layer */
  --accent-2: #5ec2ff;
  --radius: 14px;
  --gutter: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); }
code { font: 0.9em "JetBrains Mono", monospace; color: var(--accent); }

/* ---------- map backdrop ---------- */
#map { position: fixed; inset: 0; z-index: 0; }
.scrim {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, rgba(11,14,19,.75) 0%, rgba(11,14,19,.25) 55%, rgba(11,14,19,0) 100%);
}
main { position: relative; z-index: 2; pointer-events: none; }

/* ---------- sections & cards ---------- */
section {
  min-height: 100vh;
  display: flex; align-items: center;
  padding: 12vh 6vw;
}
.card {
  pointer-events: auto;
  max-width: 560px;
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 40px;
  opacity: .35; transform: translateY(18px);
  transition: opacity .6s ease, transform .6s ease;
}
.card.wide { max-width: 820px; }
section.active .card { opacity: 1; transform: none; }

.eyebrow {
  margin: 0 0 10px;
  font: 500 12px/1 "JetBrains Mono", monospace;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
h1 { font-size: clamp(44px, 7vw, 76px); line-height: 1; margin: 0 0 18px; letter-spacing: -0.03em; }
h2 { font-size: clamp(24px, 3.2vw, 34px); line-height: 1.15; margin: 0 0 16px; letter-spacing: -0.02em; }
h3 { font-size: 17px; margin: 22px 0 6px; }
p { margin: 0 0 14px; color: #cfd5de; }
.lede { font-size: 19px; color: var(--text); }
.role { color: var(--muted); font-size: 15px; }
.note, .hint { color: var(--muted); font-size: 14px; }
.hint { margin: 18px 0 0; }

/* ---------- stats ---------- */
.stats { list-style: none; padding: 0; margin: 26px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stats.small { grid-template-columns: repeat(4, 1fr); margin-bottom: 0; }
.stats li { border-top: 2px solid var(--accent); padding-top: 10px; }
.stats b { display: block; font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; }
.stats.small b { font-size: 22px; }
.stats span { color: var(--muted); font-size: 13px; }

/* ---------- buttons ---------- */
.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 999px;
  background: var(--accent); color: #111; font-weight: 600; text-decoration: none; font-size: 15px;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:hover { filter: brightness(1.1); }

/* ---------- gallery (images dropped into /images/<data-img>.(webp|png|jpg)) ---------- */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 8px 0 18px; }
.gallery figure { margin: 0; }
.gallery .frame {
  aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line);
  background: repeating-linear-gradient(45deg, #151a22 0 10px, #10141b 10px 20px);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font: 12px "JetBrains Mono", monospace;
}
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.35; }

.stack { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.stack span {
  font: 12px "JetBrains Mono", monospace; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}

/* ---------- diagram ---------- */
.diagram { width: 100%; height: auto; margin: 10px 0 14px; }
.diagram rect { fill: #121822; stroke: rgba(255,255,255,.18); }
.diagram .accent rect { stroke: var(--accent); fill: rgba(255,181,71,.06); }
.diagram text { fill: var(--text); font: 600 14px Inter, sans-serif; text-anchor: middle; }
.diagram text.sub { fill: var(--muted); font: 400 12px Inter, sans-serif; }
.diagram text.mono { fill: var(--accent); font: 12.5px "JetBrains Mono", monospace; }
.diagram .hl { fill: var(--accent-2); }
.diagram .edge { stroke: var(--muted); stroke-width: 1.5; fill: none; marker-end: url(#arr); }

/* ---------- case cards ---------- */
.cases { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
.cases article { border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.cases h3 { margin-top: 0; font-size: 15.5px; }
.cases p { font-size: 13.5px; line-height: 1.5; margin-bottom: 8px; }
.cases b { color: var(--accent); font-weight: 600; }

.bullets { padding-left: 18px; margin: 0 0 14px; }
.bullets li { margin-bottom: 8px; color: #cfd5de; }

/* ---------- commit chart ---------- */
.chart { margin: 18px 0 0; }
.chart figcaption { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.legend { display: flex; gap: 12px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
#commit-chart { width: 100%; height: auto; }
#commit-chart text { fill: var(--muted); font: 11px Inter, sans-serif; }

/* ---------- phones: map becomes a fixed header, cards flow below ---------- */
@media (max-width: 760px) {
  #map { height: 38vh; }
  .scrim { height: 38vh; background: linear-gradient(180deg, rgba(11,14,19,0) 60%, var(--bg) 100%); }
  main { padding-top: 34vh; }
  section { min-height: auto; padding: 14px var(--gutter); }
  .card { padding: 24px 20px; background: #10141b; backdrop-filter: none; opacity: 1; transform: none; }
  .gallery, .cases { grid-template-columns: 1fr 1fr; }
  .cases { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr 1fr; }
  .stats.small { grid-template-columns: 1fr 1fr; }
  .stats b { font-size: 22px; }
}

/* ---------- print / PDF: one section per page, no live map ---------- */
@page { size: Letter; margin: 0.55in; }
@media print {
  body { background: #fff; color: #111; font-size: 12.5px; }
  #map, .scrim, .hint { display: none; }
  main { padding: 0; }
  section { min-height: 0; padding: 0; display: block; break-after: page; }
  section:last-child { break-after: auto; }
  .card, section.active .card {
    max-width: none; opacity: 1; transform: none;
    background: none; border: 0; padding: 0; backdrop-filter: none;
  }
  p, .lede, h1, h2, h3, .stats b, .bullets li, .cases p { color: #111; }
  .role, .note, .stats span, .gallery figcaption, .stack span, .chart figcaption { color: #555; }
  .stack span, .cases article, .gallery .frame { border-color: #ccc; }
  .eyebrow, .cases b, code, a { color: #b86e00; }
  .btn { background: none; color: #b86e00; border: 1px solid #b86e00; }
  .btn.ghost { color: #333; border-color: #bbb; }
  .diagram rect { fill: #fafafa; stroke: #bbb; }
  .diagram .accent rect { fill: #fff7ea; stroke: #b86e00; }
  .diagram text { fill: #111; }
  .diagram text.sub { fill: #555; }
  .diagram text.mono { fill: #b86e00; }
  #commit-chart text { fill: #555; }
  .gallery .frame { background: #f2f2f2; }
}

/* ---------- link back to the jwawong portfolio index ---------- */
.home-link {
  position: fixed; top: 16px; left: 16px; z-index: 3;
  font: 500 13px "JetBrains Mono", monospace; color: var(--text); text-decoration: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
}
.home-link:hover { color: var(--accent); }
@media print { .home-link { display: none; } }

/* ---------- live app embed (Try it) ---------- */
/* The iframe is created only on click so the heavy app never loads unasked
   and the page's own scroll isn't captured by the map until the visitor opts in. */
.app-embed {
  position: relative;
  aspect-ratio: 16 / 10;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #11161f url("images/map-overview.png") center / cover no-repeat;
}
.app-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.app-embed-cover {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 0; cursor: pointer;
  background: rgba(11, 14, 19, 0.45);
  color: var(--text); font: inherit;
}
.app-embed-cover:hover { background: rgba(11, 14, 19, 0.3); }
.app-embed-mobile { display: none; }
@media (max-width: 760px) {
  .app-embed { display: none; }
  .app-embed-mobile { display: block; }
}

/* ---------- How it works: demo pins & popups (mirror the app's look) ---------- */
.demo-pin {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px; cursor: pointer;
  background: #fff; border: 3px solid var(--pin, #ef4444);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  transition: transform .15s ease;
}
.demo-pin:hover { transform: scale(1.15); }
.demo-bubble {
  max-width: 180px; padding: 6px 10px; border-radius: 14px 14px 14px 4px;
  background: #2563eb; color: #fff; font: 600 13px/1.3 Inter, sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45); cursor: default;
}
.maplibregl-popup.demo-popup .maplibregl-popup-content {
  padding: 0; width: 280px; border-radius: 12px; overflow: hidden;
  color: #111827; font: 14px/1.45 Inter, sans-serif;
}
.demo-popup .maplibregl-popup-close-button { font-size: 20px; color: #fff; text-shadow: 0 0 4px #000; right: 4px; }
.demo-popup .photo { width: 100%; height: 150px; object-fit: cover; display: block; background: #111; }
.demo-popup .thumbs { display: flex; gap: 6px; padding: 8px 12px 0; overflow: hidden; }
.demo-popup .thumbs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .7; }
.demo-popup .thumbs img.on { opacity: 1; outline: 2px solid #2563eb; }
.demo-popup .body { padding: 10px 14px 14px; }
.demo-popup h4 { margin: 0 0 8px; font-size: 18px; }
.demo-popup .actions { display: flex; gap: 12px; white-space: nowrap; align-items: center; margin-bottom: 8px; font-size: 13px; color: #374151; }
.demo-popup .actions a.primary { background: #2563eb; color: #fff; padding: 5px 10px; border-radius: 6px; text-decoration: none; }
.demo-popup .label { margin: 0; font-weight: 600; font-size: 13px; }
.demo-popup .muted { margin: 0 0 8px; color: #4b5563; font-size: 13px; }
.demo-popup .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-popup .tag { padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #eff6ff; color: #1d4ed8; }
.demo-popup .tag.alt { background: #fdf4ff; color: #a21caf; }
.demo-popup .stats3 { display: flex; gap: 14px; margin: 4px 0 8px; font-size: 13px; }
.demo-popup .stats3 b { display: block; font-size: 16px; }
.demo-popup svg.elev { width: 100%; height: 60px; display: block; }
.paint-legend { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 14px; }
.paint-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 8px; vertical-align: -2px; }

.shot { margin: 16px 0 0; }
.shot img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
