#portfolio {
  padding-block: clamp(54px, 7vw, 110px);
}
.portfolio-shelf-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 22px;
}
.portfolio-shelf-header .display-heading {
  margin: 10px 0;
  font-size: clamp(35px, 7vw, 90px);
}
.portfolio-shelf-intro {
  margin: 0;
  color: var(--mist);
}
.portfolio-dialog-header button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--white);
  font: 20px var(--mono);
  cursor: pointer;
}
.portfolio-shelf {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 4px 4px 12px;
}
.portfolio-tile {
  flex: 0 0 43%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-margin-inline: 4px;
  display: grid;
  gap: 7px;
}
.portfolio-tile:last-child { scroll-snap-align: end; }
.portfolio-cover {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg);
}
.portfolio-cover img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .3s ease;
}
.portfolio-tile:hover img, .portfolio-tile:focus-visible img { transform: scale(1.045); }
.portfolio-play, .portfolio-duration {
  position: absolute;
  bottom: 10px;
  background: rgba(0,0,0,.8);
  color: #fff;
  border-radius: 99px;
}
.portfolio-play { left: 10px; display: grid; place-items: center; width: 37px; height: 37px; font-size: 13px; }
.portfolio-duration { right: 10px; padding: 5px 8px; font: 12px var(--mono); }
.portfolio-niche { color: var(--cyan); font: 11px var(--mono); text-transform: uppercase; }
.portfolio-tile strong { font-weight: 600; line-height: 1.25; }
.portfolio-shelf:focus-visible, .portfolio-tile:focus-visible,
.portfolio-next:focus-visible, .portfolio-dialog button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.portfolio-dialog {
  position: fixed;
  inset: 0;
  width: min(900px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  margin: auto;
  padding: 14px;
  border: 1px solid var(--line);
  background: #0b1117;
  color: var(--white);
}
.portfolio-dialog::backdrop { background: rgba(0,0,0,.8); }
.portfolio-dialog-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.portfolio-dialog-header h3 { margin: 0; font-size: 16px; }
.portfolio-dialog video { display: block; width: 100%; max-height: 75vh; aspect-ratio: 16 / 9; background: #000; }
@media (max-width: 640px) {
  .portfolio-tile { flex-basis: 82%; }
  .portfolio-shelf-header { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .portfolio-cover img { transition: none; }
}

.portfolio-shelf::-webkit-scrollbar { display: none; }
.portfolio-shelf-frame { position: relative; }
.portfolio-shelf-frame::before,
.portfolio-shelf-frame::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: 4px;
  bottom: 10px;
  width: clamp(14px, 5vw, 76px);
  pointer-events: none;
}
.portfolio-shelf-frame::before {
  left: 0;
  background: linear-gradient(90deg, rgba(9, 15, 19, .82), transparent);
}
.portfolio-shelf-frame::after {
  right: 0;
  background: linear-gradient(270deg, rgba(9, 15, 19, .92), transparent);
}
.portfolio-next {
  position: absolute;
  z-index: 2;
  right: 4px;
  top: 42%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: clamp(46px, 5vw, 62px);
  height: clamp(54px, 7vw, 86px);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 12px;
  color: #fff;
  background: rgba(10,17,22,.38);
  font: 48px/1 system-ui, sans-serif;
  cursor: pointer;
}
.portfolio-next span { animation: portfolio-nudge 1.9s ease-in-out infinite; }
.portfolio-previous {
  left: 4px;
  right: auto;
  --portfolio-nudge-distance: -4px;
}
.portfolio-previous[hidden] { display: none; }
.portfolio-next:hover { background: rgba(10,17,22,.72); }
.portfolio-next:hover span, .portfolio-next:focus-visible span { animation-play-state: paused; }
@keyframes portfolio-nudge {
  0%, 65%, 100% { transform: translateX(0); opacity: .76; }
  34% { transform: translateX(var(--portfolio-nudge-distance, 4px)); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .portfolio-next span { animation: none; }
}
