:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #6e6e6e;
  --line: rgba(0, 0, 0, 0.08);
  --cell: #f5f5f5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --fg: #ffffff;
    --muted: #8e8e8e;
    --line: rgba(255, 255, 255, 0.12);
    --cell: #121212;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 0; }

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

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h2, h3, p { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }

/* Header: one row with name, app icons, and links. */
.bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.wordmark { font-weight: 600; font-size: 15px; white-space: nowrap; }

.shelf { display: flex; gap: 22px; }
.shelf a {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  white-space: nowrap;
  color: var(--muted);
  transition: color 0.2s;
}
.shelf a:hover { color: var(--fg); }
.icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.shelf a:hover .icon { transform: scale(1.08); }
.icon-placeholder {
  display: grid;
  place-items: center;
  background: var(--fg);
  color: var(--bg);
  font-weight: 700;
  font-size: 11px;
}
/* Foldspell's icon ships with its own transparent margin. */
.icon-inset { border-radius: 0; transform: scale(1.12); }
.shelf a:hover .icon-inset { transform: scale(1.2); }

/* Mosaic: soft rounded cells. */
.mosaic {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}
.cell {
  background: var(--cell);
  border-radius: 28px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 72px 32px;
}
.cell-feature { grid-column: span 4; grid-row: span 2; padding-bottom: 0; justify-content: flex-start; }
.cell-side { grid-column: span 2; }
.cell-half { grid-column: span 3; padding: 64px 32px; }

.cell h2 {
  font-size: clamp(32px, 3.4vw, 44px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
}
.cell-feature h2 { font-size: clamp(44px, 5.4vw, 72px); letter-spacing: -0.04em; }
.cell p {
  margin-top: 10px;
  font-size: 17px;
  color: var(--muted);
}
.cell-feature p { font-size: clamp(19px, 2vw, 24px); letter-spacing: -0.015em; }
.cell h3 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }

.cell-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 20px;
  border-radius: 15px;
  font-size: 26px;
}
.cell-feature .cell-icon { width: 80px; height: 80px; border-radius: 18px; }
.cell-half .cell-icon { width: 56px; height: 56px; border-radius: 13px; margin-bottom: 16px; }
.cell-icon.icon-inset { border-radius: 0; }
@media (prefers-color-scheme: dark) {
  .icon-inset { filter: drop-shadow(0 0 0.6px rgba(255, 255, 255, 0.4)); }
}

.ctas {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
  margin-top: 24px;
}
.btn {
  padding: 11px 22px;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font-size: 15px;
  font-weight: 500;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.8; }
.more { font-size: 15px; font-weight: 500; }
.more::after { content: " ›"; }
.more:hover { text-decoration: underline; text-underline-offset: 4px; }
.ext-link { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 500; }
.ext-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.ext { width: 11px; height: 11px; opacity: 0.6; }

/* Screenshots already include the device frame. */
.phones {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  margin-top: 56px;
  max-height: 440px;
  overflow: hidden;
}
.phones img { width: 200px; }
.phones img:nth-child(2) { width: 226px; }

/* Shared section heading for Work, Tinkering, Patents */
.section-title { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; }

/* Work: cells like the apps, a step down in scale */
.work { max-width: 1240px; margin: 0 auto; padding: 72px 20px 0; }
.work .section-title { margin-bottom: 20px; }
.work-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.work-cell { padding: 48px 28px 40px; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.work-cell:hover { transform: scale(1.012); }
.work-cell:hover .more { text-decoration: underline; text-underline-offset: 4px; }
.work-cell h3 { font-size: 26px; }
.work-cell p { margin-top: 4px; font-size: 15px; }
.work-cell .work-platforms {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.work-cell .more { margin-top: 20px; }
.work-icons { display: flex; gap: 10px; margin-bottom: 20px; }
.work-icons .cell-icon { width: 56px; height: 56px; margin: 0; border-radius: 13px; }
.logo-tile {
  display: grid;
  place-items: center;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.logo-tile img { width: 64%; }

/* Tinkering and Patents: compact lists side by side */
.lists {
  max-width: 1240px;
  margin: 0 auto;
  padding: 72px 20px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px 56px;
}
.list .section-title { font-size: 20px; letter-spacing: -0.02em; margin-bottom: 10px; }
.list li { border-top: 1px solid var(--line); }
.list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 11px 0;
  font-size: 14px;
}
.list a:hover span { text-decoration: underline; text-underline-offset: 3px; }
.list em { font-style: normal; font-size: 13px; color: var(--muted); white-space: nowrap; }

/* About */
.about {
  margin: 88px max(20px, calc((100% - 1200px) / 2)) 0;
  padding: 48px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 48px;
  align-items: center;
  background: var(--cell);
  border-radius: 28px;
}
.about > img {
  width: 168px;
  height: 168px;
  object-fit: cover;
  border-radius: 38px;
}
.about-copy p {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.4;
  max-width: 40ch;
  text-wrap: pretty;
}
.about-copy .about-aside { margin-top: 12px; font-size: 17px; color: var(--muted); }
.about-aside a { color: var(--fg); }
.about-aside a:hover { text-decoration: underline; text-underline-offset: 4px; }
.about-links { display: flex; gap: 20px; margin-top: 24px; color: var(--muted); }
.about-links a { display: grid; place-items: center; margin: -6px; padding: 6px; transition: color 0.2s; }
.about-links a:hover { color: var(--fg); }
.about-links svg { width: 20px; height: 20px; }

.footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 40px 48px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 1080px) {
  .shelf-name { display: none; }
  .shelf { gap: 14px; }
}

@media (max-width: 900px) {
  .mosaic { grid-template-columns: repeat(2, 1fr); }
  .cell-feature { grid-column: span 2; grid-row: auto; }
  .cell-side, .cell-half { grid-column: span 1; }
  .lists { grid-template-columns: 1fr; }
  .work-grid { grid-template-columns: 1fr; gap: 12px; }
  /* Work cells turn into compact rows: icons left, text right. */
  .work-cell {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto auto;
    column-gap: 16px;
    align-items: center;
    justify-items: start;
    text-align: left;
  }
  .work-grid .work-cell { padding: 20px; border-radius: 22px; }
  .work-icons { grid-row: span 3; margin: 0; }
  .work-icons .cell-icon { width: 48px; height: 48px; border-radius: 11px; }
  .work-cell h3 { font-size: 19px; align-self: end; }
  .work-cell p { margin: 0; }
  .work-cell .work-platforms { margin-top: 2px; }
  .work-cell .more { display: none; }
}

@media (max-width: 700px) {
  .bar { grid-template-columns: auto 1fr auto; }
  .shelf { justify-content: center; gap: 10px; }
  .mosaic { padding: 12px; gap: 12px; }
  .cell { padding: 56px 20px; border-radius: 22px; }
  .cell-feature { padding-bottom: 0; }
  .phones img:nth-child(1), .phones img:nth-child(3) { display: none; }
  .work, .lists { padding-left: 12px; padding-right: 12px; }
  .work { padding-top: 56px; }
  .lists { padding-top: 56px; gap: 40px; }
  .work .section-title { font-size: 24px; }
  .about { margin: 64px 12px 0; padding: 32px 24px; grid-template-columns: 1fr; gap: 24px; border-radius: 22px; }
  .about > img { width: 112px; height: 112px; border-radius: 26px; }
  .about-copy p { font-size: 19px; }
  .footer { padding: 24px 24px 40px; }
}

@media (max-width: 520px) {
  .cell-side { grid-column: span 2; }
  .cell-half { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  html { scroll-behavior: auto; }
}

/* Detail pages: same palette and cells as the home page, set as a reading column. */
:root { --surface: var(--cell); }

.article {
  max-width: 760px;
  margin: 0 auto;
  padding: 72px 20px 0;
}

/* Header */
.project-header { margin-bottom: 40px; }
.project-title {
  margin: 0;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.04;
  text-wrap: balance;
}
.project-actions { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 16px; }
.project-actions a { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; font-weight: 500; }
.project-actions a[target="_blank"]::after {
  content: "";
  width: 11px;
  height: 11px;
  opacity: 0.6;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4 2.5h5.5V8M9.5 2.5 2.5 9.5' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4 2.5h5.5V8M9.5 2.5 2.5 9.5' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.project-actions a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* Galleries */
.project-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 56px;
}
.project-gallery-wide { grid-template-columns: 1fr; }
.project-shot { margin: 0; display: grid; gap: 10px; }
.project-frame {
  min-height: 160px; /* gives lazy images without dimensions a box to load into */
  overflow: hidden;
  border-radius: 22px;
  background: var(--cell);
}
.project-frame img { width: 100%; height: auto; }
.project-gallery-wide .project-frame { aspect-ratio: 16 / 10; }
.project-gallery-wide .project-frame img { height: 100%; object-fit: cover; object-position: center top; }
.device-gallery .project-frame { background: none; border-radius: 0; overflow: visible; }
.project-gallery-wide .project-frame, .photo-gallery-wall .project-frame { min-height: 0; }

.project-shot figcaption,
.article-diagram-figure figcaption,
.tp-figure figcaption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Showcase: product window shots, wider than the reading column and without a frame. */
.showcase {
  grid-template-columns: 1fr;
  gap: 40px;
  width: min(calc(100vw - 40px), 1040px);
  margin-left: 50%;
  transform: translateX(-50%);
}
.showcase .project-frame { min-height: 0; background: none; border-radius: 0; overflow: visible; }
.showcase .project-frame-window { border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.14), 0 0 0 1px var(--line); }

/* Kitesurfing photo wall breaks out of the reading column. */
.photo-gallery-breakout {
  width: min(calc(100vw - 40px), 1200px);
  margin-left: 50%;
  transform: translateX(-50%);
}
.photo-gallery-wall { display: block; columns: 3 280px; column-gap: 16px; }
.photo-gallery-wall .project-shot { display: block; break-inside: avoid; margin: 0 0 16px; }

/* Hero image on long-form articles */
.article-hero-figure { margin: 0 0 56px; }
.article-hero-figure img { width: 100%; height: auto; border-radius: 22px; }

/* Prose */
.project-sections { display: grid; gap: 48px; }
/* Grid children default to min-width: auto, which lets wide code blocks push the page sideways. */
.project-sections > *, .project-prose { min-width: 0; }
.article-section-title {
  margin: 0 0 14px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.article-subsection-title { margin: 32px 0 14px; font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.project-prose p {
  margin: 0 0 18px;
  font-size: 18px;
  line-height: 1.65;
  letter-spacing: -0.005em;
  text-wrap: pretty;
}
.project-prose ul { margin: 8px 0 18px; padding: 0; list-style: none; display: grid; gap: 12px; }
.project-prose li {
  position: relative;
  padding-left: 22px;
  font-size: 17px;
  line-height: 1.55;
  text-wrap: pretty;
}
.project-prose li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.68em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.project-prose a,
.text-link { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--fg) 35%, transparent); }
.project-prose a:hover,
.text-link:hover { text-decoration-color: currentColor; }

/* Diagrams and figures that expand in a lightbox */
.article-diagram-stack { display: grid; gap: 32px; margin: 8px 0 32px; }
.article-diagram-figure { margin: 0; display: grid; gap: 10px; }
.article-diagram-frame {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 22px;
  overflow: hidden;
  background: var(--cell);
  cursor: zoom-in;
}
.article-diagram-frame img { width: 100%; height: auto; }

/* Next page */
.next-project {
  margin: 72px 0 0;
  padding: 32px;
  border-radius: 28px;
  background: var(--cell);
}
.next-project p { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.next-project a { font-size: 26px; font-weight: 700; letter-spacing: -0.025em; }
.next-project a::after { content: " ›"; }
.next-project a:hover { text-decoration: underline; text-underline-offset: 5px; }

.article + .footer { margin-top: 88px; }

/* Lightbox (created by ../../script.js) */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.image-lightbox[hidden] { display: none; }
.image-lightbox-figure { margin: 0; display: grid; gap: 12px; max-width: min(1400px, 100%); }
.image-lightbox-image { max-height: 82vh; width: auto; margin: 0 auto; border-radius: 16px; }
.image-lightbox-caption { font-size: 13px; color: var(--muted); text-align: center; }
.image-lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--fg);
  color: var(--bg);
  font: 500 13px/1 "Inter", system-ui, sans-serif;
  cursor: pointer;
}
body.has-lightbox { overflow: hidden; }

@media (max-width: 700px) {
  .article { padding-top: 48px; }
  /* Screenshot galleries become a swipeable row that runs edge to edge. */
  .project-gallery:not(.project-gallery-wide):not(.photo-gallery-wall):not(.showcase) {
    display: flex;
    gap: 12px;
    margin-inline: -20px;
    padding-inline: 20px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 20px;
    scrollbar-width: none;
  }
  .project-gallery:not(.project-gallery-wide):not(.photo-gallery-wall):not(.showcase)::-webkit-scrollbar { display: none; }
  .project-gallery:not(.project-gallery-wide):not(.photo-gallery-wall):not(.showcase) .project-shot {
    flex: 0 0 62%;
    scroll-snap-align: start;
  }
  .project-prose p { font-size: 17px; }
  .next-project { padding: 24px; border-radius: 22px; }
}
