/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #8a8a86;
  --hair: #111111;
  --hair-soft: #e3e3df;
  --veil: rgba(255, 255, 255, 0.72);
  --gutter: clamp(20px, 2.2vw, 36px);
  --header-h: 72px;
  --foot-h: 64px;
  --tools-h: 48px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: "Courier Prime", "Courier New", Courier, monospace;
  color-scheme: light;
}
html.dark {
  --bg: #111111;
  --ink: #e8e8e4;
  --muted: #8d8d88;
  --hair: #3a3a38;
  --hair-soft: #2a2a28;
  --veil: rgba(17, 17, 17, 0.7);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--ink); }
html { overflow-x: clip; }
/* No grey/black tap flash on iOS / Android when tapping links and buttons */
* { -webkit-tap-highlight-color: transparent; }
a, button { touch-action: manipulation; }
html.theme-anim, html.theme-anim * { transition: background-color .45s var(--ease), color .45s var(--ease), border-color .45s var(--ease) !important; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
:focus-visible { outline: 1px dashed var(--ink); outline-offset: 4px; }

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; background: var(--bg); padding: .5rem 1rem; z-index: 100; }

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--hair);
}
.logo { font-size: 22px; letter-spacing: .01em; margin-right: auto; }
.nav { display: flex; gap: 36px; font-size: 15px; }
.nav a { position: relative; padding: 4px 0; }
.nav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform .35s var(--ease);
}
.nav a:hover::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }
.contact-icons { display: flex; gap: 16px; }
.icon-link { display: inline-grid; place-items: center; padding: 6px; transition: opacity .3s var(--ease); }
.icon-link:hover { opacity: .5; }

/* ---------- Email card (top-right envelope) ---------- */
.mail-pop {
  position: fixed; top: calc(var(--header-h) - 1px); right: var(--gutter); z-index: 45;
  min-width: 260px; padding: 18px 20px 16px;
  background: var(--bg); border: 1px solid var(--hair);
  font-size: 13px;
  animation: popIn .35s var(--ease) both;
}
.mail-pop[hidden] { display: none; }
.mail-pop .addr { font-size: 14px; user-select: text; }
.mail-pop .row { display: flex; gap: 22px; align-items: baseline; margin-top: 14px; font-size: 12px; }
.mail-pop .row button, .mail-pop .row a { color: var(--muted); transition: color .25s; }
.mail-pop .row button:hover, .mail-pop .row a:hover { color: var(--ink); }
@keyframes popIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.theme-toggle { display: inline-flex; align-items: center; gap: 10px; padding: 6px; margin-right: -6px; }
.theme-toggle svg { transition: transform .6s var(--ease); }
html.dark .theme-toggle svg { transform: rotate(180deg); }

.menu-toggle { display: none; width: 32px; height: 32px; position: relative; margin-right: -4px; }
.menu-toggle span {
  position: absolute; left: 5px; right: 5px; height: 1px; background: currentColor;
  transition: transform .35s var(--ease), top .35s var(--ease);
}
.menu-toggle span:nth-child(1) { top: 12px; }
.menu-toggle span:nth-child(2) { top: 19px; }
.menu-open .menu-toggle span:nth-child(1) { top: 16px; transform: rotate(45deg); }
.menu-open .menu-toggle span:nth-child(2) { top: 16px; transform: rotate(-45deg); }

/* ---------- Mobile menu ---------- */
.mobile-menu {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 39;
  background: var(--bg);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 36px var(--gutter) calc(28px + env(safe-area-inset-bottom));
  opacity: 0; transform: translateY(-8px);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.mobile-menu[hidden] { display: none; }
.mobile-menu:not(.is-open) { pointer-events: none; }
.mobile-menu.is-open { opacity: 1; transform: none; }
.mobile-menu nav { display: flex; flex-direction: column; gap: 18px; font-size: 26px; }
.mobile-menu nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 1px; }
.mobile-menu-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }

/* ---------- Main / views ---------- */
main { padding-top: var(--header-h); min-height: 100vh; outline: none; }
.view { animation: viewIn .6s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; } to { opacity: 1; } }

.page-foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: var(--foot-h);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 var(--gutter);
  font-size: 12px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.page-foot .muted, .muted { color: var(--muted); }
.page-foot .links { display: flex; gap: 30px; }
.page-foot button { font-size: 12px; color: var(--muted); padding: 6px 0; transition: color .25s; }
.page-foot button:hover, .page-foot button[aria-pressed="true"] { color: var(--ink); }
.page-foot button[aria-pressed="true"] { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Gallery (Artwork / Commercial) ---------- */
.gallery {
  --g-gap: clamp(14px, 1.2vw, 24px);
  position: relative; overflow: hidden;
  height: calc(100vh - var(--header-h));
  height: calc(100svh - var(--header-h));
  touch-action: pan-y; user-select: none; cursor: grab;
}
.gallery.is-dragging { cursor: grabbing; }
.g-track { position: absolute; inset: 0; }
.g-item {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 40px 0 60px;
  opacity: .18;
  transition: transform .9s var(--ease), opacity .9s var(--ease);
  -webkit-user-drag: none;
}
.g-item.is-near { opacity: .9; }
.g-item.is-near img { filter: grayscale(1); }
.g-item.is-active { opacity: 1; }
.gallery.is-dragging .g-item { transition: opacity .9s var(--ease); }
.g-item img {
  width: auto; height: auto; max-width: min(62vw, 1100px);
  max-height: calc(100svh - var(--header-h) - 180px);
  object-fit: contain; pointer-events: none;
  transition: transform 1.2s var(--ease), filter .9s var(--ease);
}
.g-item.is-active:hover img { transform: scale(1.012); }
.g-cap { font-size: 12px; color: var(--muted); opacity: 0; transition: opacity .6s var(--ease), color .3s; }
.g-item.is-near .g-cap { opacity: .7; }
.g-item.is-active .g-cap { opacity: 1; }
.g-item.is-active:hover .g-cap { color: var(--ink); }

/* Image fade-in once loaded */
.fade { opacity: 0; transition: opacity .7s var(--ease); }
.fade.is-loaded { opacity: 1; }

/* ---------- Project: slideshow ---------- */
.project { position: relative; }
.slides {
  position: relative;
  height: calc(100vh - var(--header-h) - var(--tools-h));
  height: calc(100svh - var(--header-h) - var(--tools-h));
  padding: 10px var(--gutter) var(--foot-h);
  display: flex; align-items: center; justify-content: center;
  touch-action: pan-y;
  user-select: none;
}
.slide-stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.slide-img {
  position: absolute;
  max-width: min(70vw, 1180px);
  max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity .55s var(--ease), transform .55s var(--ease);
}
.slide-img.is-active { opacity: 1; }
.slide-img.from-right { transform: translateX(14px); }
.slide-img.from-left { transform: translateX(-14px); }
.slide-img.is-active.from-right, .slide-img.is-active.from-left { transform: none; }

.slide-hit { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 2; }
.slide-hit.prev { left: 0; cursor: w-resize; }
.slide-hit.next { right: 0; cursor: e-resize; }
.chev {
  position: absolute; top: 50%; z-index: 3; transform: translateY(-50%);
  font-size: 22px; padding: 14px 10px; line-height: 1;
  transition: transform .3s var(--ease), opacity .3s;
}
.chev.prev { left: calc(var(--gutter) - 10px); }
.chev.next { right: calc(var(--gutter) - 10px); }
.chev.prev:hover { transform: translate(-4px, -50%); }
.chev.next:hover { transform: translate(4px, -50%); }
.slides.at-start .prev, .slides.at-end .next { visibility: hidden; pointer-events: none; }

/* Top-right view switch: counter + grid / single icon */
.view-tools {
  position: relative; z-index: 15;
  height: var(--tools-h);
  padding: 0 calc(var(--gutter) - 6px) 0 var(--gutter);
  display: flex; align-items: center; justify-content: flex-end; gap: 14px;
}
.view-count { font-size: 12px; color: var(--muted); padding: 6px 0; letter-spacing: .02em; transition: color .25s; }
.view-count:hover { color: var(--ink); }
.view-count[hidden] { display: none; }

/* ---------- Project: full-screen viewer ---------- */
html.viewer-open, html.viewer-open body { overflow: hidden; }
.viewer {
  position: fixed; inset: 0; z-index: 50;
  overscroll-behavior: contain;
  background: var(--bg);
  overflow: hidden;
  opacity: 0; transition: opacity .3s var(--ease);
}
.viewer[hidden] { display: none; }
.viewer.is-open { opacity: 1; }
.viewer-bar {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  height: var(--header-h);
  padding: env(safe-area-inset-top) var(--gutter) 0;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
}
.viewer-close { font-size: 12px; color: var(--ink); padding: 10px 0 10px 16px; }
.viewer-track {
  position: absolute; inset: 0;
  display: flex;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.viewer-track::-webkit-scrollbar { display: none; }
.viewer-slide {
  flex: 0 0 100%; min-width: 0; height: 100%;
  scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  padding: var(--header-h) var(--gutter) calc(var(--header-h) - 10px);
}
.viewer-slide img {
  background: var(--hair-soft);
  max-width: min(100%, 1400px); max-height: 100%;
  width: auto; height: auto; object-fit: contain;
  pointer-events: none; -webkit-user-drag: none;
}
.viewer .chev[hidden] { display: none; }

/* ---------- Project: thumbnails ---------- */
.thumbs {
  padding: 24px var(--gutter) calc(var(--foot-h) + 40px);
  display: flex; justify-content: center;
}
.thumb-grid {
  width: min(78vw, 1240px);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(18px, 2.6vw, 42px) clamp(16px, 2.2vw, 36px);
}
.thumb {
  min-width: 0;
  aspect-ratio: 4 / 3.1;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .35s var(--ease);
  animation: rise .6s var(--ease) both;
}
.thumb img { max-width: 100%; max-height: 100%; width: auto; height: auto; transition: transform .45s var(--ease); }
@media (hover: hover) { .thumb-grid:hover .thumb { opacity: .38; } }
.thumb-grid .thumb:hover, .thumb-grid .thumb:focus-visible { opacity: 1; }
.thumb:hover img { transform: scale(1.03); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Info panel ---------- */
.info-veil {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 20;
  background: var(--veil);
  opacity: 0; pointer-events: none; transition: opacity .45s var(--ease);
}
.info {
  position: fixed; top: var(--header-h); right: 0; bottom: 0; z-index: 21;
  width: min(38vw, 560px);
  background: var(--bg);
  border-left: 1px solid var(--hair);
  padding: 30px 44px 48px;
  overflow-y: auto;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform .55s var(--ease), visibility 0s linear .55s;
}
.info-open .info { transform: none; visibility: visible; transition: transform .55s var(--ease), visibility 0s; }
.info-open .info-veil { opacity: 1; pointer-events: auto; }
.info-close { display: block; margin-left: auto; font-size: 12px; padding: 4px 0; }
.info h1 { font-size: 24px; font-weight: 400; line-height: 1.3; margin: 34px 0 18px; }
.info .meta { font-size: 12px; color: var(--muted); line-height: 1.75; margin-bottom: 30px; }
.info .body p { font-size: 13px; line-height: 1.85; margin-bottom: 1.2em; }
.info .more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .6s var(--ease); }
.info .more > div { overflow: hidden; }
.info.is-expanded .more { grid-template-rows: 1fr; }
.link-btn { font-size: 13px; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; padding: 2px 0; }

/* ---------- About ---------- */
.about {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 6vw; padding: 48px var(--gutter) 140px;
  max-width: 1500px;
}
.about h1 { font-size: 18px; font-weight: 700; margin-bottom: 22px; }
.about p { font-size: clamp(15px, 1.25vw, 18px); line-height: 1.8; max-width: 62ch; }
.about figure { padding-top: 60px; justify-self: center; width: min(100%, 420px); }
.about figure img { width: 100%; height: auto; }

.u { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }

/* ---------- Site footer (static pages) ---------- */
.site-foot { padding: 0 var(--gutter) 28px; font-size: 12px; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 60;
  transform: translate(-50%, 10px); opacity: 0;
  background: var(--ink); color: var(--bg); font-size: 12px; padding: 9px 16px;
  transition: opacity .3s, transform .3s var(--ease); pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 404 ---------- */
.notfound { min-height: calc(100vh - var(--header-h)); display: grid; place-items: center; text-align: center; font-size: 14px; }
.notfound a { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  :root { --header-h: 60px; --foot-h: 56px; }
  .nav, .site-header > .theme-toggle { display: none; }
  .menu-toggle { display: block; }
  .logo { font-size: 20px; }

  .slide-img { max-width: calc(100vw - 2 * var(--gutter)); }
  .chev { display: none; }
  .gallery { --g-gap: 10px; }
  .g-item img { max-width: 82vw; }
  .page-foot { font-size: 11px; }
  .page-foot .links { gap: 18px; }

  .thumb-grid { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

  .info { width: 100%; padding: 22px var(--gutter) 40px; border-left: 0; }


  .about { grid-template-columns: 1fr; gap: 44px; padding-top: 34px; }
  .about figure { padding-top: 0; justify-self: start; width: min(100%, 360px); }
}
@media (max-width: 480px) {
  .thumb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 860px) {
  .page-foot > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .page-foot .links { flex-shrink: 0; }
}

/* ---------- Commercial ---------- */
.commercial { padding: 48px var(--gutter) 120px; }
.masonry { columns: 4 260px; column-gap: clamp(18px, 2vw, 32px); }
.tile {
  display: block; break-inside: avoid; margin-bottom: clamp(18px, 2vw, 32px);
  transition: opacity .35s var(--ease);
  animation: rise .6s var(--ease) both;
}
.tile img { width: 100%; height: auto; background: var(--hair-soft); transition: transform .6s var(--ease); }
@media (hover: hover) { .masonry:hover .tile { opacity: .4; } }
.masonry .tile:hover, .masonry .tile:focus-visible { opacity: 1; }
.tile:hover img { transform: scale(1.015); }

.lightbox {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 35;
  background: var(--bg);
  padding: 30px var(--gutter) var(--foot-h);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .35s var(--ease);
  touch-action: pan-y; user-select: none;
}
.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }
.lb-stage { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.lightbox .slide-img { max-width: min(80vw, 1400px); }
.lightbox .page-foot { position: absolute; }
.lb-close { font-size: 12px; color: var(--muted); }
.lb-close:hover { color: var(--ink); }

@media (max-width: 860px) {
  .masonry { columns: 2; column-gap: 12px; }
  .tile { margin-bottom: 12px; }
  .lightbox .slide-img { max-width: calc(100vw - 2 * var(--gutter)); }
}
