.projects-grid {
  display: grid;
  grid-template-columns: 90%;
  justify-content: center;
  gap: 4.5rem;
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  /* background: rgba(219, 140, 255, 0.04); */
  transform-origin: center;
  /* border-radius: 10px; */
  /* border: 1px solid var(--border); */
  /* border: 1px solid rgba(219, 140, 255, 0.2); */
  /* overflow: hidden; */
}

/* Lift transition (scoped to beat .fade-up's transform/transition in animations.css) */
.projects-grid .project-card {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.4s ease,
              opacity 0.65s ease/* ,
              border-color 0.15s ease */;
  /* Keep the card on its own GPU layer so text doesn't re-snap on hover in/out */
  will-change: transform;
  backface-visibility: hidden;
}

/* Hover: lift off the background — move up, soft shadow. */
.projects-grid .project-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 28px 40px rgba(0, 0, 0, 0.55);
}

/* .project-card:hover { border-color: var(--accent); } */

/* .project-glow {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.project-card:hover .project-glow { opacity: 1; } */

/* ---- Media gallery (the old .project-thumb strip) ---- */

/* Wraps the strip, the arrows beside it, and the dot row below it */
.project-media {
  position: relative;
  z-index: 1;

  /* Width of the chevron box — must match CHEVRON_SVG in render.js */
  --nav-icon: 22px;
  /* Clearance between the image edge and the chevron once it has travelled */
  --nav-gap: 0.6rem;
  /* How far past the image the chevron ends up, and therefore how far the hit
     area has to reach out to meet it — no dead space in between */
  --nav-reach: calc(var(--nav-icon) + var(--nav-gap));

  --dot-size: 10px;
}

/* Same box as the gallery but without its clipping, so the arrows can
   travel out past the image edges */
.gallery-frame {
  position: relative;
}

.project-gallery {
  /* Shape comes from --thumb-mask, ratio from --thumb-ratio (variables.css) */
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: var(--thumb-ratio);
  /* Also what keeps the nav arrows hidden behind the left/right edges */
  overflow: hidden;
  clip-path: var(--thumb-mask);
}

.gallery-track {
  display: flex;
  height: 100%;
  /* Slide order and transform are driven by projectGalleries() in script.js.
     No overshoot here — the curve just decelerates into place. */
  transition: transform 0.45s cubic-bezier(0.33, 0, 0.2, 1);
}

.gallery-slide {
  flex: 0 0 100%;
  height: 100%;
}

.gallery-slide img,
.gallery-slide video,
.gallery-slide iframe {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 0;
  /* object-position: 20% 50%; */
}

/* Edge bands, not halves: the middle stays free so embedded players
   remain clickable. The whole band steps the gallery. */
.gallery-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  /* Spans from inside the image out past where the chevron lands, so moving
     the pointer towards the arrow never leaves the hit area */
  width: calc(clamp(56px, 22%, 140px) + var(--nav-reach));
  z-index: 3;
  display: flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

/* The padding keeps the chevron's resting spot on the image edge even though
   the button now starts outside it */
.gallery-nav--prev {
  left: calc(-1 * var(--nav-reach));
  padding-left: var(--nav-reach);
  justify-content: flex-start;
}

.gallery-nav--next {
  right: calc(-1 * var(--nav-reach));
  padding-right: var(--nav-reach);
  justify-content: flex-end;
}

.gallery-nav-icon {
  position: relative;
  display: flex;
  opacity: 0;
  /* The chevron overflows the button and sits off the image, so it would
     otherwise extend the hit area past the artwork. Only the band counts. */
  pointer-events: none;
  transition: opacity 0.25s ease,
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Rest tucked against the image edge, then travel outwards on hover — the
   chevron never sits over the artwork, so it needs no scrim behind it. */
.gallery-nav--prev .gallery-nav-icon { transform: translateX(0) scaleX(-1); }
.gallery-nav--next .gallery-nav-icon { transform: translateX(0); }

.gallery-nav--prev:hover .gallery-nav-icon,
.gallery-nav--prev:focus-visible .gallery-nav-icon {
  opacity: 1;
  transform: translateX(calc(-100% - var(--nav-gap))) scaleX(-1);
}

.gallery-nav--next:hover .gallery-nav-icon,
.gallery-nav--next:focus-visible .gallery-nav-icon {
  opacity: 1;
  transform: translateX(calc(100% + var(--nav-gap)));
}

.gallery-nav:focus { outline: none; }

/* Below the strip in normal flow, not over the artwork — so no scrim needed.
   Right-aligned, then inset by one dot so the row never sits on the card's
   perceived edge while the card is lifted on hover. */
.gallery-dots {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.7rem;
  padding-right: var(--dot-size);
}

.gallery-dot {
  width: var(--dot-size);
  height: var(--dot-size);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--muted);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.gallery-dot:hover { background: var(--accent); }

.gallery-dot.is-active { background: var(--accent); }

/* Hover arrows are unreachable on touch — dots and swipe carry navigation */
@media (hover: none) {
  .gallery-nav { display: none; }
}

/* Below 769px the card fills the container, so the only room outside the image
   is the container padding — the chevron travels half-way out instead, and the
   hit area shrinks with it via --nav-reach. */
@media (max-width: 768px) {
  .project-media {
    --nav-gap: 0px;
    --nav-reach: calc(var(--nav-icon) / 2);
  }

  .gallery-nav--prev:hover .gallery-nav-icon,
  .gallery-nav--prev:focus-visible .gallery-nav-icon { transform: translateX(-50%) scaleX(-1); }

  .gallery-nav--next:hover .gallery-nav-icon,
  .gallery-nav--next:focus-visible .gallery-nav-icon { transform: translateX(50%); }
}

.project-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 2rem;
}

.project-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 0.9rem;
}

.project-name {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text);
  transition: transform 0.25s ease;
}

.project-card:hover .project-name { transform: translateX(32px); }

.project-arrow {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(calc(-50%)) translateX(-35px);
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.25s, color 0.25s,
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.project-card:hover .project-arrow {
  opacity: 1;
  color: var(--accent);
  transform: translateY(calc(-50%)) translateX(0);
}

.project-desc {
  font-size: 1rem;
  line-height: 1.4;
  color: var(--muted);
  margin-bottom: 1.25rem;
  /* margin-right: 2rem; */
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
}

.tag {
  font-family: var(--mono);
  font-size: .9rem;
  letter-spacing: 0.07em;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--purple);
  
  border-radius: 15px;

  color: var(--orange);
  /* background-color: var(--red); */
  transition: border-color 0.2s, color 0.2s;
}

/* .tag:hover { border-color: rgba(244,229,184,0.35); color: var(--text); } */
.tag:hover { border-color: var(--yellow); color: var(--yellow); }

.project-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.btn {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.09em;
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.15s ease;
}

.btn:hover { background: var(--accent); color: var(--bg); }

/* The live button behaves like the card border used to: neutral by default,
   accent border + text when hovering anywhere on the card. */
.project-card:hover .btn:not(.btn--ghost) {
  border-color: var(--accent);
  color: var(--accent);
}

/* Direct hover on the button: solid fill must beat the card-hover text color
   (extra :hover ups specificity past the rule above) */
.project-card:hover .btn:not(.btn--ghost):hover {
  color: var(--bg);
}

.btn--ghost {
  border-color: var(--border);
  color: var(--muted);
}

.btn--ghost:hover { background: rgba(244,229,184,0.08); color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .projects-grid .project-card { transition: opacity 0.65s ease; }
  .projects-grid .project-card:hover { transform: none; }

  /* Jump between slides, and fade the chevrons in rather than sliding them */
  .gallery-track { transition: none; }

  .gallery-nav-icon { transition: opacity 0.25s ease; }
  .gallery-nav--prev .gallery-nav-icon { transform: translateX(0) scaleX(-1); }
  .gallery-nav--next .gallery-nav-icon { transform: translateX(0); }
}
