/* --- Portfolio: full-width, continuously auto-scrolling wall that's also
   manually scrollable ---
   4 real overflow:scroll columns (not a CSS-animation illusion), each with
   3 stacked copies of its projects. portfolio-wall.js nudges scrollTop every
   frame for the continuous auto-motion AND silently wraps scrollTop between
   the buffer copies so it loops forever — but because it's a genuine
   scrollable element, the visitor's own mouse wheel/trackpad scrolls it too,
   for free, via native browser behavior. No card chrome, badges, or titles
   on the tiles — just the work, clickable through to its own page. */

.portfolio-wall {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  width: 100vw;
  margin-left: calc(50% - 50vw);
  height: 100vh;
  height: 100dvh;
  padding-inline: var(--space-md);
  /* 100vw includes the vertical scrollbar's own width, so this can run a
     few pixels wider than the actual viewport content area — clipped here,
     scoped to just this element, instead of on body/html (which breaks
     position:sticky site-wide, including the header and home hero). */
  overflow-x: hidden;
}

.portfolio-wall__col {
  position: relative;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.portfolio-wall__col::-webkit-scrollbar {
  display: none;
}

.portfolio-wall__track {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
}

.portfolio-wall__item {
  position: relative;
  flex: none;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: var(--color-gradient-brand);
}

/* A <button>, not an <a> — the tile opens the details modal only, it never
   navigates to a separate page (see portfolio-modal.js) — so it needs the
   usual button resets to look and lay out exactly like the block-level
   link it replaced. */
.portfolio-wall__link {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.portfolio-wall__item img,
.portfolio-wall__video,
.portfolio-wall__placeholder {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-base) var(--ease-out);
}

/* The placeholder briefcase mark gets a slow, continuous float+pulse so an
   empty tile still reads as "alive" rather than a frozen static graphic —
   distinct from (and independent of) the item's own hover-scale below. */
.portfolio-wall__icon {
  transform-origin: center;
  transform-box: fill-box;
  animation: portfolio-wall-icon-float 4s ease-in-out infinite;
}

@keyframes portfolio-wall-icon-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3%) scale(1.04); }
}

.portfolio-wall__title {
  position: absolute;
  inset: auto 0 0 0;
  padding: var(--space-lg) var(--space-sm) var(--space-sm);
  background: linear-gradient(transparent, rgba(10, 15, 26, 0.8));
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  text-wrap: balance;
}

.portfolio-wall__item:hover img,
.portfolio-wall__item:hover .portfolio-wall__video,
.portfolio-wall__link:focus-visible img,
.portfolio-wall__link:focus-visible .portfolio-wall__video {
  transform: scale(1.05);
}

/* "View Details" — hidden until hover/focus, when the video (if any) is
   also paused by portfolio-modal.js so the button reads clearly against a
   still frame instead of competing with motion underneath it. */
.portfolio-wall__item::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0);
  transition: background var(--duration-base) var(--ease-out);
  pointer-events: none;
}

.portfolio-wall__item:hover::after,
.portfolio-wall__item:focus-within::after {
  background: rgba(6, 10, 18, 0.45);
}

.portfolio-wall__view-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 0.5rem));
  z-index: 1;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(10, 15, 26, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #ffffff;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.portfolio-wall__item:hover .portfolio-wall__view-btn,
.portfolio-wall__item:focus-within .portfolio-wall__view-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

.portfolio-wall__view-btn:hover,
.portfolio-wall__view-btn:focus-visible {
  background: var(--color-accent-blue);
  border-color: var(--color-accent-blue);
}

@media (hover: none) {
  /* Touch devices have no hover state to reveal the button on — keep it
     centered but always visible (its own blurred pill background already
     reads clearly over the video/title without needing the dark scrim). */
  .portfolio-wall__view-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 63.99rem) {
  .portfolio-wall {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-wall__item img {
    transition: none;
  }

  .portfolio-wall__icon {
    animation: none;
  }
}

/* --- Project detail modal ---
   Same open/close mechanics as .cookie-modal (components.css): hidden
   attribute toggle, backdrop-click-to-close, Escape-to-close, z-index:
   var(--z-modal) — see portfolio-modal.js. Content is cloned per-project
   from a <template> rather than fetched, so the modal never needs a
   network round-trip or a JSON API. */
.portfolio-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-md);
  background: rgba(3, 8, 16, 0.72);
}

.portfolio-modal[hidden] {
  display: none;
}

.portfolio-modal__panel {
  position: relative;
  width: min(100%, 44rem);
  max-height: 88vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-lg);
  animation: portfolio-modal-in var(--duration-base) var(--ease-out);
}

@keyframes portfolio-modal-in {
  from {
    opacity: 0;
    transform: translateY(1rem) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.portfolio-modal__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: none;
  background: rgba(10, 15, 26, 0.55);
  color: #ffffff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.portfolio-modal__close:hover {
  background: rgba(10, 15, 26, 0.75);
}

.portfolio-modal__media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
}

.portfolio-modal__media video,
.portfolio-modal__media img,
.portfolio-modal__media .portfolio-wall__placeholder {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000000;
}

.portfolio-modal__body {
  padding: var(--space-lg);
}

.portfolio-modal__body h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  margin-top: var(--space-2xs);
  margin-bottom: var(--space-sm);
}

.portfolio-modal__summary {
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
}

.portfolio-modal__table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.portfolio-modal__table tr:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}

.portfolio-modal__table th,
.portfolio-modal__table td {
  padding: var(--space-xs) var(--space-sm);
  text-align: left;
  font-size: var(--fs-sm);
  vertical-align: top;
}

.portfolio-modal__table th {
  width: 9rem;
  background: var(--color-bg-surface);
  color: var(--color-text-faint);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.portfolio-modal__table td {
  color: var(--color-text);
}

.portfolio-modal__desc {
  color: var(--color-text-muted);
  font-size: var(--fs-sm);
  line-height: 1.7;
}

@media (max-width: 30rem) {
  .portfolio-modal__table th {
    width: 6.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio-modal__panel {
    animation: none;
  }
}
