/* ============================================
   Portfolio page styles
   - Bauhaus-inspired irregular masonry grid
   - Offset colored frame (primary colors) with stitched border
   - Hover: front image crossfades to hover image
   ============================================ */

/* Override default subpage padding — portfolio goes edge-to-edge */
.portfolio-main {
  position: relative;
  z-index: 2;
  max-width: 1400px;
  margin: 2rem auto 5rem;
  padding: 2rem 3rem;
}

/* Grid — 4 columns on desktop, irregular row heights via span */
.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 180px;  /* base row height; tall items span 2 */
  gap: 5rem 2.5rem;
  align-items: start;
}

/* ========== Individual piece ========== */

.piece {
  position: relative;
  margin: 0;
   height: 100%;
  transform: translateY(var(--offset, 0)) rotate(var(--rot, 0deg));
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: transform;
}

/* Size variants — Bauhaus irregular rhythm */
.piece--square { grid-row: span 2; }
.piece--tall   { grid-row: span 3; }

/* The colored offset frame (sits behind image) */
.piece__frame {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 14px;  /* this is the visible colored border */
  background: var(--frame-bg);
  border-radius: 2px;
  transition:
    transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1),
    box-shadow 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow:
    0 1px 0 rgba(0,0,0,0.05),
    0 12px 30px -18px rgba(0,0,0,0.25);
}

/* Stitched dashed border on the frame (not the image) */
.piece__frame::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px dashed rgba(243, 236, 225, 0.6);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}

/* Image container */
.piece__images {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);  /* shows while images load */
}

.piece__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.35s ease;
}

.piece__img--front { opacity: 1; z-index: 1; }
.piece__img--hover { opacity: 0; z-index: 2; }

/* Hover: crossfade to hover image and lift slightly */
.piece:hover {
  transform: translateY(calc(var(--offset, 0) - 6px)) rotate(0deg);
  z-index: 5;
}

.piece:hover .piece__frame {
  box-shadow:
    0 2px 0 rgba(0,0,0,0.08),
    0 24px 40px -18px rgba(0,0,0,0.35);
}

.piece:hover .piece__img--front { opacity: 0; }
.piece:hover .piece__img--hover { opacity: 1; }

/* ========== Color variants ========== */

.piece--blue   { --frame-bg: var(--blue); }
.piece--red    { --frame-bg: var(--red); }
.piece--yellow { --frame-bg: var(--yellow); }

/* Yellow frame needs a darker stitch to read */
.piece--yellow .piece__frame::before {
  border-color: rgba(20, 20, 20, 0.4);
}

/* ========== Title ========== */

.piece__title {
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 400;
  font-size: 0.78rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 1rem 0 0;
  text-align: center;
  /* Counter-rotate so title reads level even if piece is tilted */
  transform: rotate(calc(var(--rot, 0deg) * -1));
}

/* ========== Responsive ========== */

@media (max-width: 1100px) {
  .portfolio-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4rem 2rem;
  }
}

@media (max-width: 768px) {
  .portfolio-main {
    padding: 1rem 1.25rem 2rem;
  }
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 140px;
    gap: 3rem 1rem;
  }
  /* Flatten the rotations on mobile for a cleaner read */
  .piece {
    transform: translateY(0) rotate(0deg) !important;
  }
  .piece__title {
    transform: rotate(0deg);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
  }
  .piece__frame {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 260px;
  }
  .piece--tall { grid-row: span 2; }  /* keep singles from getting too tall */
}
