:root {
  --bg: #ffffff;
  --bg-panel: #f4f4f4;
  --ink: #111111;
  --ink-muted: #666666;
  --accent: #2f5f4a;
  --accent-hot: #b85c38;
  --line: #111111;
  --pixel: 4px;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  /* Same face as the “projects & notes” tag under the name */
  --font-body: "IBM Plex Mono", "Courier New", monospace;
  --font-body-size: 0.875rem;
  --font-body-line: 1.55;
  --font-tag-size: 0.72rem;
  --font-tag-line: 1.3;
  --pixel-stretch: 1.28;
  --sidebar-w: 240px;
  --content-width: 40rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  image-rendering: pixelated;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--font-body-size);
  line-height: var(--font-body-line);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(17, 17, 17, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 17, 17, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* Stretch pixel type a bit taller — Press Start 2P reads short/compressed */
.page-title,
.content h2,
.btn,
.back-link {
  font-family: var(--font-pixel);
  transform: scaleY(var(--pixel-stretch));
  transform-origin: left center;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

.shell {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.back-link {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  top: auto;
  right: auto;
  z-index: 50;
  display: inline-block;
  font-size: 0.55rem;
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  border: var(--pixel) solid var(--line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--pixel) var(--pixel) 0 var(--line);
}

.back-link:hover {
  color: var(--ink);
  text-decoration: none;
  transform: translate(2px, 2px) scaleY(var(--pixel-stretch));
  box-shadow: 2px 2px 0 var(--line);
}

/* --- Main --- */
.main {
  box-sizing: border-box;
  width: 100%;
  max-width: calc(var(--content-width) + 4rem);
  margin-left: auto;
  margin-right: auto;
  padding: 2.25rem clamp(1.25rem, 4vw, 2rem) 3rem;
  /* Do not keep a transform after the animation: it would trap
     position:fixed overlays (lightboxes) inside .main instead of the viewport. */
  animation: rise-in 280ms steps(6);
}

body:not([data-page="home"]) .main {
  padding-bottom: 4.5rem;
}

/* Keep inner blocks centered in the column (titles stay left) */
.main .lead,
.main .intro,
.main .content,
.main .cta-row,
.main .collage,
.main .project-list,
.main .video,
.main .video-link,
.main .shot-grid,
.main .pixel-box {
  margin-left: auto;
  margin-right: auto;
}

.main .section-heading {
  margin-left: 0;
  margin-right: auto;
  width: 100%;
}

.main .title-row {
  margin-left: 0;
  margin-right: auto;
  width: 100%;
  max-width: 40rem;
}

.main .page-title {
  margin-left: 0;
  margin-right: auto;
}

.nav__num {
  color: var(--accent-hot);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-body);
  font-weight: 600;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes blink-cursor {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.title-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: var(--pixel) solid var(--line);
  max-width: 40rem;
}

.title-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.title-brand .page-title {
  margin: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.app-icon {
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  display: block;
  image-rendering: auto;
  border: 0;
  background: transparent;
}

.title-row .page-title {
  margin: 0;
  padding-bottom: 0;
  border-bottom: 0;
  width: fit-content;
  flex: 0 1 auto;
  min-width: 0;
}

.title-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.5rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.title-actions .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  font-size: 0.48rem;
  line-height: 1;
  padding: 0.55rem 0.7rem;
  min-height: 2.1rem;
}

.title-actions .btn__apple {
  width: 10px;
  height: 12px;
}

.page-title {
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  line-height: 1.55;
  margin: 0 0 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: var(--pixel) solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  width: fit-content;
  max-width: 100%;
}

.page-title::before {
  content: "#";
  color: var(--accent-hot);
}

.page-title::after {
  content: "";
  display: inline-block;
  width: 0.55rem;
  height: 0.95em;
  margin-left: 0.15rem;
  background: var(--accent);
  animation: blink-cursor 1.1s steps(1) infinite;
  vertical-align: text-bottom;
}

.intro {
  max-width: 40rem;
  margin: 0 0 1.75rem;
  padding: 1rem 1.1rem;
  background: #ffffff;
  border: var(--pixel) solid var(--line);
  box-shadow: var(--pixel) var(--pixel) 0 var(--line);
  color: var(--ink);
}

.intro .lead {
  margin: 0 0 0.85rem;
  color: var(--ink);
}

.intro .platforms {
  color: var(--ink);
}

.intro a {
  color: var(--accent-hot);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.intro a:hover {
  color: var(--accent);
}

.intro .cta-row {
  margin: 1rem 0 0;
}

.cta-row--docs {
  max-width: 40rem;
  margin-top: -0.35rem;
  margin-bottom: 0.85rem;
  gap: 0.4rem;
}

.btn.btn--doc {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.22rem 0.45rem;
  min-height: 0;
  transform: none;
  box-shadow: 2px 2px 0 var(--line);
}

.btn.btn--doc:hover {
  color: var(--ink);
  text-decoration: none;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}

.lead {
  font-family: var(--font-body);
  font-size: var(--font-body-size);
  line-height: var(--font-body-line);
  color: var(--ink-muted);
  margin: 0 0 1.75rem;
  max-width: 40rem;
}

.content {
  width: 100%;
  max-width: var(--content-width);
  font-family: var(--font-body);
  font-size: var(--font-body-size);
  line-height: var(--font-body-line);
}

.content h2 {
  font-size: 0.78rem;
  line-height: 1.5;
  margin: 2rem 0 0.85rem;
  width: fit-content;
  max-width: 100%;
  scroll-margin-top: 1.25rem;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.55rem 0.75rem;
  margin: 2rem 0 0.85rem;
  max-width: 40rem;
}

.section-heading h2 {
  margin: 0;
}

.section-meta {
  font-family: var(--font-body);
  font-size: var(--font-tag-size);
  font-weight: 400;
  line-height: var(--font-tag-line);
  color: var(--ink-muted);
}

.section-meta a {
  font-size: inherit;
}

.content h2::before {
  content: "## ";
  color: var(--accent);
}

.content p {
  margin: 0 0 1rem;
  max-width: 40rem;
}

.content ul {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  max-width: 40rem;
}

.content ol {
  padding-left: 1.5rem;
}

.content img {
  max-width: 100%;
  height: auto;
}

.content .lead p,
.content .platforms p {
  margin-bottom: 0.85rem;
}

.content .project-list {
  padding-left: 0;
}

.content table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.content th,
.content td {
  border: 1px solid var(--line);
  padding: 0.4rem 0.6rem;
}

.content p,
.content li,
.content h2,
.page-title {
  overflow-wrap: anywhere;
}

.content li {
  margin-bottom: 0.35rem;
}

.content li::marker {
  color: var(--accent);
}

.content code {
  font-family: var(--font-body);
  font-size: 0.95em;
  background: var(--bg-panel);
  border: 1px solid rgba(17, 17, 17, 0.2);
  padding: 0.05em 0.35em;
}

.content pre {
  background: #111111;
  color: #ffffff;
  padding: 1rem;
  overflow-x: auto;
  border: var(--pixel) solid var(--line);
  margin: 0 0 1.25rem;
  max-width: 40rem;
}

.content pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
}

.content hr {
  border: 0;
  border-top: 2px dashed var(--ink-muted);
  margin: 2rem 0;
}

.pixel-box {
  border: var(--pixel) solid var(--line);
  background: var(--bg-panel);
  padding: 1rem 1.1rem;
  margin: 1.25rem 0;
  max-width: 40rem;
  box-shadow: var(--pixel) var(--pixel) 0 var(--line);
}

.pixel-box p:last-child {
  margin-bottom: 0;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.content .cta-row {
  justify-content: flex-start;
}

.main .cta-row--docs {
  justify-content: flex-start;
  width: 100%;
  max-width: 40rem;
  margin-left: auto;
  margin-right: auto;
}

.btn {
  display: inline-block;
  font-size: 0.55rem;
  line-height: 1.4;
  padding: 0.75rem 0.9rem;
  border: var(--pixel) solid var(--line);
  background: var(--accent);
  color: var(--bg);
  box-shadow: var(--pixel) var(--pixel) 0 var(--line);
  transition: transform 80ms steps(2), box-shadow 80ms steps(2);
}

.btn:hover {
  color: var(--bg);
  text-decoration: none;
  transform: translate(2px, 2px) scaleY(var(--pixel-stretch));
  box-shadow: 2px 2px 0 var(--line);
}

.btn--ghost {
  background: var(--bg);
  color: var(--ink);
}

.btn--ghost:hover {
  color: var(--ink);
}

.btn--icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn__apple {
  flex-shrink: 0;
  display: block;
  /* Undo the pixel-font vertical stretch applied to .btn */
  transform: scaleY(calc(1 / var(--pixel-stretch)));
  transform-origin: center;
}

.platforms {
  font-family: var(--font-body);
  font-size: var(--font-body-size);
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 0.85rem !important;
  letter-spacing: 0.02em;
}

.video {
  position: relative;
  width: 100%;
  max-width: 40rem;
  margin: 0 0 0.5rem;
  aspect-ratio: 16 / 9;
  border: var(--pixel) solid var(--line);
  background: #111;
  box-shadow: var(--pixel) var(--pixel) 0 var(--line);
  overflow: hidden;
}

.video iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  border: 0;
  display: block;
}

.video-link {
  max-width: 40rem;
  margin: 0 0 1.75rem;
  font-family: var(--font-body);
  font-size: var(--font-tag-size);
  line-height: var(--font-tag-line);
}

.video-link a {
  color: var(--accent-hot);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Project screenshot grids */
.shot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin: 0 0 0.75rem;
  max-width: 40rem;
}

.shot-grid__link {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  text-decoration: none;
  cursor: zoom-in;
}

.shot-grid__link:hover {
  text-decoration: none;
}

.shot-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  object-position: center;
  display: block;
  border: var(--pixel) solid var(--line);
  background: #ffffff;
  cursor: zoom-in;
}

.page-shot {
  display: block;
  width: 100%;
  max-width: 22rem;
  margin: 0 0 1.25rem;
  border: var(--pixel) solid var(--line);
  background: #ffffff;
  box-shadow: var(--pixel) var(--pixel) 0 var(--line);
}

.page-shot img {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: auto;
}

/* Screenshot overlay: Popover API keeps it in the top layer, centered
   in the viewport (not in the page flow, so no scroll-to-hash jump). */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 1.5rem;
  border: 0;
  background: transparent;
  box-sizing: border-box;
  overflow: hidden;
}

.lightbox:popover-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox::backdrop {
  background: rgba(17, 17, 17, 0.82);
}

html:has(.lightbox:popover-open) {
  overflow: hidden;
}

.lightbox__scrim {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-out;
}

.lightbox__img {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1100px);
  max-height: 88dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: var(--pixel) solid #fff;
  background: #111;
  box-shadow: 6px 6px 0 #000;
  pointer-events: none;
}

.lightbox__close {
  position: fixed;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 10;
  font-family: var(--font-pixel);
  font-size: 0.5rem;
  line-height: 1.4;
  padding: 0.65rem 0.75rem;
  border: var(--pixel) solid var(--line);
  background: var(--bg);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--line);
  transform: scaleY(var(--pixel-stretch));
  transform-origin: center;
}

.lightbox__close:hover {
  color: var(--ink);
  text-decoration: none;
  transform: translate(2px, 2px) scaleY(var(--pixel-stretch));
  box-shadow: 2px 2px 0 var(--line);
}

@media (max-width: 700px) {
  .shot-grid {
    grid-template-columns: 1fr;
  }
}

/* Home photo collage */
.collage {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 150px;
  gap: 0.55rem;
  margin: 0 0 1.75rem;
  width: 100%;
  max-width: none;
}

.collage__item {
  position: relative;
  display: block;
  overflow: hidden;
  border: var(--pixel) solid var(--line);
  background: #111;
  color: var(--ink);
  box-shadow: 3px 3px 0 transparent;
  transition: box-shadow 80ms steps(2), transform 80ms steps(2);
  min-height: 0;
}

.collage__item:hover {
  text-decoration: none;
  color: var(--ink);
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0 var(--line);
}

.collage__item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  image-rendering: auto;
}

.collage__caption {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1;
  padding: 0.35rem 0.45rem;
  font-family: var(--font-body);
  font-size: var(--font-tag-size);
  font-weight: 600;
  line-height: var(--font-tag-line);
  background: rgba(17, 17, 17, 0.82);
  color: #ffffff;
}

/* Home grid of project links */
.title-row--home {
  max-width: none;
  width: 100%;
}

.title-row--home .archive-link {
  margin: 0;
  flex: 0 0 auto;
  margin-left: auto;
}

.archive-link {
  margin: 0;
}

.archive-link a {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem;
  border: var(--pixel) solid var(--line);
  background: var(--bg-panel);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--font-tag-size);
  line-height: var(--font-tag-line);
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--line);
}

.archive-link a:hover {
  color: var(--ink);
  text-decoration: none;
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--line);
}

.archive-link .nav__num {
  margin-right: 0;
}

.project-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 40rem;
}

.project-list a {
  display: grid;
  grid-template-columns: 2.4rem 1fr;
  gap: 0.65rem;
  align-items: baseline;
  padding: 0.65rem 0.75rem;
  border: var(--pixel) solid var(--line);
  background: var(--bg-panel);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--font-body-size);
  line-height: var(--font-body-line);
  box-shadow: 3px 3px 0 transparent;
  transition: box-shadow 80ms steps(2), transform 80ms steps(2);
}

.project-list .nav__num {
  color: var(--accent-hot);
}

.project-list.project-list--archive a {
  display: flex;
  flex-wrap: nowrap;
  align-items: baseline;
  gap: 1.5rem;
}

.project-list.project-list--archive a .nav__num {
  flex: 0 0 auto;
  white-space: nowrap;
  min-width: 4.5em;
  margin-right: 0.5rem;
}

.project-list a:hover {
  text-decoration: none;
  transform: translate(-2px, -2px);
  box-shadow: 3px 3px 0 var(--line);
}

.project-list .soon {
  color: var(--ink-muted);
  font-size: 0.85em;
}

.project-list .soon::before {
  content: "· ";
}

.project-list__text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  min-width: 0;
}

.project-list__name {
  display: inline;
}

.project-list__desc {
  display: inline;
  color: var(--ink-muted);
  font-size: var(--font-tag-size);
  line-height: var(--font-tag-line);
  font-weight: 400;
}

.project-list__desc::before {
  content: "— ";
}

@media (max-width: 760px) {
  .title-row {
    flex-wrap: wrap;
  }

  .collage {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 110px;
  }
}

@media (max-width: 420px) {
  .collage {
    grid-template-columns: 1fr;
    grid-auto-rows: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
