/* ============================================================
   PROJECT ACCORDION — expanding panels, one per project.
   Each panel shows the project title and opens that project's
   own photo gallery in the lightbox.
   ============================================================ */

.pacc {
  margin-top: clamp(26px, 3.4vw, 40px);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Panels wrap onto several rows, so each carries its own height.
   The basis gives 6 per row at desktop width. */
.pacc__panel {
  flex: 1 1 calc(16.666% - 10px);
  min-width: 0;
  height: clamp(250px, 24vw, 330px);
  display: flex;
  transition: flex-grow 0.7s var(--ease);
}

/* Extra photos only exist so the lightbox can group a project's full set.
   Kept out of the layout with CSS, NOT the hidden attribute, because
   initLightbox() skips [hidden] elements. */
.pacc__extra {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* ---- Panel ---- */
.pacc__item {
  position: relative;
  flex: 1;
  min-width: 0;
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background-size: cover;
  background-position: center;
  cursor: pointer;
}

/* legibility scrim */
.pacc__item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.14) 52%, transparent 100%);
  transition: opacity 0.5s var(--ease);
  opacity: 0.86;
}

/* ---- Open icon, centred like the reference ---- */
.pacc__open {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  transform: translate(-50%, -50%) scale(0.7);
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  color: #fff;
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease), background 0.35s var(--ease);
}
.pacc__item:hover .pacc__open { background: var(--red); border-color: var(--red); }

/* ---- Caption ---- */
.pacc__cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: clamp(16px, 2vw, 26px);
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
}
.pacc__name {
  font-size: clamp(0.95rem, 1.15vw, 1.2rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  /* panels are narrow now that all 11 projects are shown, so names wrap
     onto a second line instead of being cut off with an ellipsis */
  overflow-wrap: anywhere;
}
.pacc__count {
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--red);
}

/* red rule under the open panel */
.pacc__item::before {
  content: "";
  position: absolute;
  left: clamp(16px, 2vw, 26px);
  bottom: 0;
  z-index: 3;
  width: 52px;
  height: 3px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s var(--ease);
}

/* ---- Open state ---- */
.pacc__panel.is-open { flex-grow: 2.6; }
.pacc__panel.is-open .pacc__item::after { opacity: 1; }
.pacc__panel.is-open .pacc__cap { opacity: 1; transform: translateY(0); }
.pacc__panel.is-open .pacc__open { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pacc__panel.is-open .pacc__item::before { transform: scaleX(1); }

.pacc__item:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

/* ---- Mobile: stack, every title visible ---- */
@media (max-width: 860px) {
  /* stay in row direction and wrap: in column direction flex-basis would
     set the panel HEIGHT against an auto-height container and collapse it */
  .pacc {
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
    gap: 10px;
  }
  .pacc__panel { flex: 1 1 calc(50% - 10px); height: 190px; }
  .pacc__panel.is-open { flex-grow: 1; }
  .pacc__cap { opacity: 1; transform: none; }
  .pacc__open { opacity: 1; transform: translate(-50%, -50%) scale(1); width: 46px; height: 46px; }
  .pacc__item::before { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  .pacc__panel, .pacc__cap, .pacc__open { transition: none; }
}

@media (max-width: 520px) {
  .pacc__panel { flex: 1 1 100%; height: 200px; }
}
