* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

@import url("https://fonts.cdnfonts.com/css/helvetica-neue-55");

html,
body {
  width: 100%;
  height: 100%;
  font-family: "Helvetica Neue", sans-serif;
  overflow-x: hidden;
  background: var(--bg, white);
  color: var(--color, black);
}

:root {
  --bg: white;
  --color: black;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 30px;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.85);
  z-index: 1000;
}

nav {
  display: flex;
  gap: 20px;
}

header a {
  color: inherit;
  text-decoration: none;
  text-transform: lowercase;
  font-size: 0.9rem;
}

header a:hover {
  opacity: 0.6;
}

/* open source sits apart from the other tabs, toward the middle */
header a.nav-apart {
  margin-left: 12vw;
}

.viewport {
  position: absolute;
  top: 50px;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: hidden;
}

#canvas {
  position: absolute;
  transform-origin: 0 0;
  will-change: transform;
  background: transparent;
}

.image-box {
  position: absolute;
  width: 240px;
  aspect-ratio: 2.39 / 1;
  cursor: grab;
  overflow: hidden;
  user-select: none;
}

.image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.image-box:active {
  cursor: grabbing;
}

.image-box.highlight {
  box-shadow: 0 0 16px rgba(128, 128, 128, 0.6);
}

/* MODAL BASE */
.modal {
  display: none;
  position: fixed;
  z-index: 3000;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
}

/* close X, top right of the screen while a project is open */
.modal-close {
  position: fixed;
  top: 0;
  right: 16px;
  z-index: 1;
  border: none;
  padding: 0 4px;
  background: none;
  color: #fff;
  font: 300 2rem/1 "Helvetica Neue", sans-serif;
  cursor: pointer;
}

/* Animated modal */
.modal.show {
  display: flex;
  animation: fadeIn 0.3s ease forwards;
}

.modal-content {
  width: 92%;
  max-height: 90vh;
  max-width: 1300px;
  /* padding: 20px; */
  background: transparent;
  border-radius: 0;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: white;
  overflow-y: auto;
  scrollbar-width: none;
  opacity: 0;
  transform: scale(0.95);
  animation: zoomIn 0.3s ease forwards;
}

.modal-content::-webkit-scrollbar {
  display: none;
}

.modal.show .modal-content {
  opacity: 1;
  transform: scale(1);
}

.modal.closing {
  animation: fadeOut 0.3s ease forwards;
}

.modal-content.closing {
  animation: zoomOut 0.3s ease forwards;
}

@keyframes fadeIn {
  from {
    background-color: rgba(0, 0, 0, 0);
  }
  to {
    background-color: rgba(0, 0, 0, 0.4);
  }
}

@keyframes zoomIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    background-color: rgba(0, 0, 0, 0.4);
  }
  to {
    background-color: rgba(0, 0, 0, 0);
  }
}

@keyframes zoomOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.95);
    opacity: 0;
  }
}

.modal-content video {
  width: 100%;
}

#modal-title,
#modal-year,
#modal-tags,
#modal-collab {
  padding: 0 10px;
}

#modal-description {
  padding: 10px;
  font-size: 0.95rem;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: inherit;
}

#modal-image-container {
  display: flex;
  flex-direction: column;
}

#modal-image-container img {
  width: 100%;
  user-select: none;
  pointer-events: none;
}

#tag-filters {
  display: flex;
  gap: 16px;
  align-items: center;
}

.tag-btn {
  background: none;
  border: none;
  color: inherit;
  font-family: "Helvetica Neue", sans-serif;
  font-size: 0.9rem;
  text-transform: lowercase;
  cursor: pointer;
  opacity: 0.35;
  padding: 0;
  transition: opacity 0.2s;
}

.tag-btn:hover {
  opacity: 0.7;
}

.tag-btn.active {
  opacity: 1;
}

.project-grid {
  padding: 90px 30px 60px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 20px;
}

.project-item {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border-radius: 0;
  border: 1px solid transparent;
  aspect-ratio: 20 / 10;
  transition: opacity 0.3s ease, border-color 0.3s ease;
}

@media (max-width: 900px) {
  .project-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 560px) {
  .project-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.project-item:hover {
  border-color: var(--color);
}

.project-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.project-item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.project-item:hover::after {
  opacity: 0.18;
}

.project-item.dimmed {
  opacity: 0.1;
  pointer-events: none;
}

/* left column: title/year/tags/location — right column: description text */
.project-modal-info {
  display: flex;
  gap: 3px;
  margin: 10px 10px 0;
}

.project-modal-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 0 0 auto;
  width: 180px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--color);
  border-radius: 12px;
}

.project-modal-title,
.project-modal-year,
.project-modal-tags,
.project-modal-location,
.project-modal-collab,
.project-modal-text {
  color: #000;
}

.project-modal-title {
  font-size: 1.1rem;
  font-weight: 400;
  text-transform: lowercase;
}

.project-modal-year,
.project-modal-tags,
.project-modal-location,
.project-modal-collab {
  font-size: 0.8rem;
  text-transform: lowercase;
  opacity: 0.6;
}

.project-modal-text {
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-line;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--color);
  border-radius: 12px;
}

.project-modal-title:empty,
.project-modal-year:empty,
.project-modal-tags:empty,
.project-modal-location:empty,
.project-modal-collab:empty,
.project-modal-text:empty {
  display: none;
}

@media (max-width: 768px) {
  .project-modal-info {
    flex-direction: column;
  }

  .project-modal-meta {
    width: auto;
  }
}

#project-modal-images {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  margin: 0 10px 10px;
  padding: 0;
  height: 48vh;
  /* keep full height when long text makes the popup scroll (mobile) */
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--color);
  border-radius: 12px;
}

.gallery-wrap {
  position: relative;
  flex-shrink: 0;
}

/* blinking outline arrows: hint that the gallery scrolls sideways.
   white on dark pictures, black on light/transparent ones (set in studio.js) */
.gallery-arrow {
  position: absolute;
  top: calc(50% - 5px);
  width: 18px;
  height: 22px;
  border: none;
  padding: 0;
  background: none;
  color: #000;
  transform: translateY(-50%);
  cursor: pointer;
  animation: gallery-blink 1.6s ease-in-out infinite;
}

.gallery-arrow.on-dark {
  color: #fff;
}

.gallery-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.gallery-next {
  right: 24px;
}

.gallery-prev {
  left: 24px;
}

.gallery-prev svg {
  transform: scaleX(-1);
}

.gallery-arrow[hidden] {
  display: none;
}

@keyframes gallery-blink {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.25; }
}

#project-modal-images::-webkit-scrollbar {
  display: none;
}

#project-modal-images img,
#project-modal-images video {
  flex: 0 0 auto;
  box-sizing: border-box;
  height: 100%;
  width: auto;
  max-width: none;
  object-fit: contain;
  display: block;
  border-right: 0.5px solid var(--color);
  user-select: none;
}

#project-modal-images img,
#project-modal-images video {
  cursor: zoom-in;
}

#project-modal-images img:last-child,
#project-modal-images video:last-child {
  border-right: none;
}

/* ── Lightbox: click a gallery image to enlarge it ────────────────── */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(0, 0, 0, 0.85);
  opacity: 0;
  cursor: zoom-out;
  transition: opacity 0.25s ease;
}

.image-lightbox.show {
  display: flex;
  opacity: 1;
}

.image-lightbox img,
.image-lightbox video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
  transform: scale(0.96);
  transition: transform 0.25s ease;
}

.image-lightbox.show img,
.image-lightbox.show video {
  transform: scale(1);
}

/* ── Custom cursor (shared with landing page, see cursor.js) ─────── */
.mercury-cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border: 1px solid color-mix(in srgb, var(--color) 70%, transparent);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: width 120ms ease, height 120ms ease, opacity 0.6s ease;
  z-index: 4000;
  opacity: 1;
}

.mercury-cursor::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--color) 90%, transparent);
}

.mercury-cursor.down {
  width: 56px;
  height: 56px;
}

.mercury-cursor.hidden {
  opacity: 0;
}

@media (hover: none) {
  .mercury-cursor { display: none; }
}

.image-box {
  transition: opacity 0.3s ease;
}

.image-box.dimmed {
  opacity: 0.1;
  pointer-events: none;
}


@media (max-width: 768px) {
  /* Header: nav on row 1, tag-filters on row 2 */
  header {
    flex-wrap: wrap;
    height: auto;
    min-height: 50px;
    padding: 12px 20px 0;
    gap: 0;
    align-items: center;
  }

  nav {
    flex: 1;
    gap: 16px;
  }

  header a {
    font-size: 0.85rem;
  }

  header a.nav-apart {
    margin-left: 0;
  }

  /* Tag filters: full-width second row, horizontally scrollable */
  #tag-filters {
    flex-basis: 100%;
    order: 3;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
    gap: 16px;
    padding: 12px 0 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    /* prevent body overflow-x: hidden from clipping this scroll */
    position: relative;
  }

  #tag-filters::-webkit-scrollbar {
    display: none;
  }

  .tag-btn {
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  body {
    overflow-x: visible;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  /* gallery: pictures stacked full width, scroll down instead of sideways */
  #project-modal-images {
    flex-direction: column;
    height: auto;
    overflow: hidden;
  }

  #project-modal-images img,
  #project-modal-images video {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 0.5px solid var(--color);
  }

  #project-modal-images > :last-child {
    border-bottom: none;
  }

  .gallery-arrow {
    display: none;
  }

  /* enlarged picture: use the full screen width */
  .image-lightbox {
    padding: 40px 0;
  }
}

/* rotated phone: enlarged picture/video uses the full screen height */
@media (max-height: 500px) {
  .image-lightbox {
    padding: 0;
  }
}
