:root {
  --ink: #000;
  --paper: #fff;
  --muted: #777;
  --line: #000;
  --block: 300px;
  --gap: 20px;
  --panel-w: clamp(420px, 44vw, 760px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  font-family: Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
}

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--ink); color: var(--paper); }

/* ---------- layout ---------- */

.layout { min-height: 100vh; }

.main {
  padding: 40px 40px 80px 60px;
  transition: margin-right 0.35s var(--ease);
}

body.panel-open .main { margin-right: var(--panel-w); }

/* ---------- header ---------- */

.header {
  display: flex;
  gap: 24px;
  align-items: flex-end; /* text sits on the logo's bottom edge */
  margin-bottom: 40px;
}

.avatar { display: block; color: var(--ink); }
.avatar .logo { display: block; width: 200px; height: 200px; fill: currentColor; }

.intro { padding-bottom: 0; }
.intro .nav { margin-bottom: -3px; } /* drop the text's descender space so the letters land on the line */
.name { font-size: 14px; font-weight: bold; margin: 0; }
.tagline { margin: 6px 0 0; }

.nav { margin-top: 4px; }
.navlink {
  font: inherit;
  font-weight: bold;
  background: none;
  border: 0;
  padding: 10px 0 0;
  color: var(--ink);
  cursor: pointer;
}
.navlink:hover { text-decoration: underline; }
.pipe { margin: 0 6px; }

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

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  /* never more than 4 blocks per row */
  max-width: calc(4 * var(--block) + 3 * var(--gap));
}

.block {
  width: var(--block);
  display: block;
  color: var(--ink);
  text-decoration: none;
  padding: 0 0 4px;
}
.block:hover { text-decoration: none; }

.block-title { display: block; font-weight: bold; min-height: 35px; padding-top: 10px; }
.block-year { display: block; min-height: 35px; padding-top: 8px; }

.block-img {
  display: block;
  width: var(--block);
  height: var(--block);
  object-fit: cover;
  background: #f2f2f2;
  outline: 1px solid transparent;
  outline-offset: 4px;
  transition: outline-color 0.15s, opacity 0.2s;
}

.block:hover .block-img,
.block:focus-visible .block-img { outline-color: var(--ink); }
.block:focus-visible { outline: none; }

.block.is-active .block-img { outline: 2px solid var(--ink); outline-offset: 4px; }
/* right-arrow icon after the open project's title (same drawing as the svg icons) */
.block.is-active .block-title::after {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 6px;
  vertical-align: -0.15em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='square'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%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 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='square'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* svg icons */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: square;
  stroke-linejoin: miter;
  flex: none;
}
.ext-mark .icon { width: 0.9em; height: 0.9em; }
.panel-btn .icon, .book-btn .icon { width: 18px; height: 18px; vertical-align: middle; }
.panel-btn, .book-btn { display: inline-flex; align-items: center; justify-content: center; }
.panel-btn[hidden] { display: none; }
.p-open .icon { width: 1.05em; height: 1.05em; }

body.panel-open .block:not(.is-active) .block-img { opacity: 0.55; }
body.panel-open .block:not(.is-active):hover .block-img { opacity: 1; }

.ext-mark { font-weight: normal; }

/* ---------- side panel ---------- */

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--panel-w);
  background: var(--paper);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform 0.35s var(--ease), visibility 0s linear 0.35s;
  visibility: hidden;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

body.panel-open .panel {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.35s var(--ease), visibility 0s;
}

.panel-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.panel-spacer { flex: 1; }

.panel-btn {
  font: inherit;
  font-size: 18px;
  line-height: 1;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
}
.panel-btn:hover, .panel-btn:focus-visible { border-color: var(--ink); outline: none; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 32px 60px;
}

.p-head { margin-bottom: 20px; }
.p-title { font-size: 15px; font-weight: bold; margin: 0; }
.p-year { margin-top: 2px; }
.p-kind { color: var(--muted); margin-top: 2px; }

.p-block { margin: 0 0 28px; }
.p-block img,
.p-block video { display: block; width: 100%; height: auto; background: #f2f2f2; }
.p-text { font-size: 13px; }
.p-text a, .p-caption a, .p-credit a { text-decoration: underline; }

.p-embed { position: relative; width: 100%; background: #000; }
.p-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.p-caption { margin-top: 8px; }

.p-credit { margin-top: 10px; padding-top: 14px; border-top: 1px solid #ddd; }

/* external project */
.p-preview { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: #f2f2f2; margin-bottom: 18px; }

.p-open {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: bold;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  padding: 12px 18px;
  text-decoration: none;
}
.p-open:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.p-url { display: block; color: var(--muted); margin-top: 10px; word-break: break-all; }
.p-open-archive { margin-top: 22px; color: var(--ink); background: var(--paper); }

/* list of link buttons (made in fields) */
.p-links { display: flex; flex-wrap: wrap; gap: 8px; }
.p-links .p-link { margin-top: 0; font-weight: normal; padding: 9px 14px; }
.p-links .p-link.is-active { background: var(--ink); color: var(--paper); }

/* window above the buttons that shows the chosen page */
.p-viewer { background: #f2f2f2; border: 1px solid var(--ink); margin-bottom: 8px; }
.p-viewer iframe[hidden], .p-viewer-empty[hidden], .p-viewer-newtab[hidden] { display: none; }
.p-viewer-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.p-viewer-newtab { display: inline-block; margin: 0 0 16px; color: var(--muted); text-decoration: underline; }

/* block with no image yet */
.block-img-blank { background: #f2f2f2; }
.p-open-archive:hover { color: var(--paper); background: var(--ink); }
.p-desc { font-size: 13px; margin: 0 0 18px; }

/* collapsible sections (two images series) */
.p-section { border-top: 1px solid var(--ink); }
.p-block:has(> .p-section) { margin-bottom: 0; }
.p-block:has(> .p-section) + .p-block:not(:has(> .p-section)) { margin-top: 28px; }
.p-section-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 0;
  cursor: pointer;
  list-style: none;
  font-size: 13px;
}
.p-section-head::-webkit-details-marker { display: none; }
.p-section-mark { flex: none; width: 14px; font-size: 16px; line-height: 1.1; }
.p-section-head:hover .p-section-mark { text-decoration: none; }
.p-section-head:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
.p-section-title { flex: 1; min-width: 0; }
.p-section-title a { text-decoration: underline; }
.p-block .p-section-cover {
  flex: none;
  align-self: center;
  width: auto;
  height: 64px;
  max-width: 40%;
  object-fit: contain;
  background: none;
}
.p-block .p-section[open] .p-section-cover { display: none; }
.p-section-body { padding: 4px 0 24px; }
.p-section-body > .p-block:last-child { margin-bottom: 0; }

/* image galleries (vhs ghosts, broke image) */
.p-gallery { columns: var(--cols, 3); column-gap: 8px; }
.p-block .p-gallery img { margin: 0 0 8px; break-inside: avoid; }
/* row-order grid: reads left to right, top to bottom */
.p-gallery.is-rows { columns: auto; display: grid; grid-template-columns: repeat(var(--cols, 3), 1fr); gap: 8px; }
.p-block .p-gallery.is-rows img { margin: 0; }

/* gallery items with a caption (still life) */
.p-gallery-item { margin: 0; break-inside: avoid; }
.p-gallery.is-rows:has(.p-gallery-caption) { row-gap: 18px; }
.p-block .p-gallery-item video { cursor: pointer; }
.p-gallery-caption { margin-top: 6px; font-size: 11px; line-height: 1.35; }
.p-block img.is-small { width: auto; max-width: 100%; }

/* 3d booklet (images zine) */
.book { padding: 28px 0 8px; perspective: 2200px; perspective-origin: 50% 30%; user-select: none; }
.book-tilt {
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 14deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.5s ease-out;
}
.book-stage {
  position: relative;
  width: 100%;
  aspect-ratio: calc(var(--page-ratio) * 2);
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.45, 0.05, 0.25, 1);
  cursor: pointer;
  outline: none;
}
.book[data-state="front"] .book-stage { transform: translateX(-25%); }
.book[data-state="back"] .book-stage { transform: translateX(25%); }

.book-leaf {
  position: absolute;
  top: 0;
  left: 50%;
  width: 50%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transform: translateZ(var(--z, 0)) rotateY(0deg);
  transition: transform 0.9s cubic-bezier(0.45, 0.05, 0.25, 1);
}
.book-leaf.is-turned { transform: translateZ(var(--z, 0)) rotateY(-180deg); }

.book-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.06);
}
.book-back { transform: rotateY(180deg); }
.book-face.is-blank { background: #fbfbf8; }
.book-face img { display: block; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
/* shading toward the spine */
.book-face::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.book-front::after { background: linear-gradient(to right, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0) 5%); }
.book-back::after { background: linear-gradient(to left, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0) 5%); }

.book-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 26px; }
.book-label { min-width: 150px; text-align: center; }
.book-btn {
  font: inherit;
  font-size: 18px;
  line-height: 1;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
}
.book-btn:hover:not(:disabled), .book-btn:focus-visible { border-color: var(--ink); outline: none; }
.book-btn:disabled { opacity: 0.25; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .book-leaf, .book-stage, .book-tilt { transition: none; }
}

/* early work toggle block (a button styled like the other blocks) */
.block-toggle {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.toggle-mark { font-weight: normal; margin-left: 4px; }
.block-toggle.is-open .block-img { outline: 1px solid var(--ink); }

/* early work section in the grid */
.section-title {
  font-size: 14px;
  font-weight: bold;
  margin: 60px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--ink);
}
.section-title span { font-weight: normal; margin-left: 8px; }

/* header pages (cv / nft / links) */
.navlink.is-active { text-decoration: underline; }

.pg { font-size: 13px; max-width: 560px; }
.pg a { text-decoration: underline; }
.pg p { margin: 0 0 10px; }
.pg-section { margin: 0 0 30px; }
.pg-section h3 { font-size: 13px; font-weight: bold; margin: 0 0 10px; }
.pg-muted { color: var(--muted); }
.pg-sep { margin: 0 4px; }

.pg-list { list-style: none; margin: 0; padding: 0; }
.pg-list li { margin: 0 0 4px; }

.pg-projects { list-style: none; margin: 0; padding: 0; }
.pg-projects li { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.pg-projects img { display: block; width: 40px; height: 40px; object-fit: cover; }
.pg-projects img.pg-wide-logo { width: 115px; height: 20px; object-fit: contain; object-position: left; }

.pg-years { margin: 0; }
.pg-years dt { font-weight: bold; margin: 18px 0 6px; }
.pg-years dt:first-child { margin-top: 0; }
.pg-years dd { margin: 0 0 10px; padding-left: 12px; border-left: 1px solid var(--ink); }

.pg-form { border: 1px solid var(--ink); margin-bottom: 10px; }
.pg-form iframe { display: block; width: 100%; height: min(1100px, 80vh); border: 0; }

/* ---------- small screens: panel becomes a full-screen sheet ---------- */

@media (max-width: 900px) {
  :root { --block: calc(50vw - 30px); --gap: 16px; }

  .main { padding: 20px 16px 80px; }
  body.panel-open .main { margin-right: 0; }
  body.panel-open { overflow: hidden; }

  .header { flex-direction: column; gap: 12px; margin-bottom: 24px; }
  .header { align-items: flex-start; }
  .avatar .logo { width: 120px; height: 120px; }
  .intro { padding-top: 0; }

  .panel {
    width: 100%;
    border-left: 0;
    transform: translateY(100%);
  }
  body.panel-open .panel { transform: translateY(0); }
  .panel-body { padding: 20px 16px 60px; }

  body.panel-open .block:not(.is-active) .block-img { opacity: 1; }
}

@media (max-width: 420px) {
  :root { --block: calc(100vw - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  .main, .panel, body.panel-open .panel { transition: none; }
}
