/* Recent projects gallery (gallery.html) */

.mg2p {
  --mg2p-orange: #db5815;
  --mg2p-navy: #111f28;
  --mg2p-muted: #5c5c5c;
  --mg2p-line: #e3e3e3;
  --mg2p-soft: #f4f4f4;
  --mg2p-cols: 3;
  --mg2p-gap: 1rem;
  padding: 7rem 5% 0;
  color: #000;
  font-family: Montserrat, sans-serif;
}

.mg2p_inner {
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
}

/* ---------- Section heading ---------- */

.mg2p_head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 27rem);
  align-items: end;
  gap: 1.5rem 4rem;
  margin-bottom: 3.5rem;
}

.mg2p_eyebrow {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.mg2p_title {
  margin: 0;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
}

.mg2p_lede {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.5;
}

/* ---------- Board: project list + photos ---------- */

.mg2p_board {
  display: grid;
  grid-template-columns: 17.5rem minmax(0, 1fr);
  align-items: start;
  gap: 3.5rem;
}

.mg2p_rail {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
}

/* Without JS every project is shown in sequence, so the list has nothing to switch. */
.mg2p_board:not(.is-ready) {
  grid-template-columns: minmax(0, 1fr);
}

.mg2p_board:not(.is-ready) .mg2p_rail {
  display: none;
}

.mg2p_rail-label {
  margin: 0 0 .875rem;
  color: var(--mg2p-muted);
  font-size: .875rem;
  font-weight: 600;
}

.mg2p_tab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: .75rem;
  width: 100%;
  padding: .9375rem 1rem;
  border: 0;
  border-left: 3px solid var(--mg2p-line);
  border-radius: 0 10px 10px 0;
  background: transparent;
  color: #3d3d3d;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.mg2p_tab:hover {
  border-left-color: #c4c4c4;
  color: #000;
}

.mg2p_tab[aria-selected="true"] {
  border-left-color: var(--mg2p-orange);
  background: var(--mg2p-soft);
  color: #000;
}

.mg2p_tab-count {
  color: var(--mg2p-muted);
  font-size: .8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mg2p_tab[aria-selected="true"] .mg2p_tab-count {
  color: var(--mg2p-orange);
}

.mg2p_tab:focus-visible,
.mg2p_tile:focus-visible,
.mg2p_lb-btn:focus-visible {
  outline: 2px solid var(--mg2p-orange);
  outline-offset: 2px;
}

.mg2p_stage {
  min-width: 0;
}

.mg2p_panel[hidden] {
  display: none;
}

.mg2p_panel + .mg2p_panel {
  margin-top: 4rem;
}

.mg2p_board.is-ready .mg2p_panel + .mg2p_panel {
  margin-top: 0;
}

.mg2p_panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .375rem 2rem;
}

.mg2p_name {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.mg2p_note {
  grid-column: 1;
  margin: 0;
  color: var(--mg2p-muted);
  font-size: 1.0625rem;
  font-weight: 500;
}

.mg2p_count {
  grid-column: 2;
  grid-row: 1 / span 2;
  margin: 0;
  color: var(--mg2p-muted);
  font-size: .875rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.mg2p_count b {
  display: block;
  color: #000;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* Tape-measure rule: short ticks every 8px, an orange mark every 80px. */
.mg2p_rule {
  height: 14px;
  margin: 1.25rem 0 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, .28);
  background-image:
    repeating-linear-gradient(90deg, var(--mg2p-orange) 0 2px, transparent 2px 80px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .28) 0 1px, transparent 1px 8px);
  background-repeat: no-repeat;
  background-position: left bottom;
  background-size: 100% 100%, 100% 45%;
}

/* ---------- Photo grid ---------- */

/* Masonry: every photo keeps its original aspect ratio (--ar, set per item).
   Plain CSS columns by default; project-gallery.js upgrades it to a grid
   (.is-masonry) so photos read left to right in the order they were sent. */
.mg2p_grid {
  column-count: var(--mg2p-cols);
  column-gap: var(--mg2p-gap);
  margin: 0 0 calc(-1 * var(--mg2p-gap));
  padding: 0;
  list-style: none;
}

.mg2p_item {
  position: relative;
  margin: 0 0 var(--mg2p-gap);
  aspect-ratio: var(--ar, 4 / 3);
  break-inside: avoid;
}

.mg2p_grid.is-masonry {
  display: grid;
  grid-template-columns: repeat(var(--mg2p-cols), minmax(0, 1fr));
  grid-auto-rows: 4px; /* row unit; each item spans as many as its height needs */
  column-gap: var(--mg2p-gap);
  row-gap: 0;
}

.mg2p_grid.is-masonry .mg2p_item {
  margin: 0;
  aspect-ratio: auto;
}

.mg2p_tile {
  position: absolute;
  inset: 0;
  display: block;
  border-radius: 16px;
  background: var(--mg2p-soft);
  overflow: hidden;
}

.mg2p_grid.is-masonry .mg2p_tile {
  bottom: var(--mg2p-gap);
}

.mg2p_tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .45s cubic-bezier(.2, .7, .2, 1);
}

.mg2p_tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 0 var(--mg2p-orange);
  transition: box-shadow .2s ease;
  pointer-events: none;
}

.mg2p_tile:hover img {
  transform: scale(1.05);
}

.mg2p_tile:hover::after {
  box-shadow: inset 0 0 0 3px var(--mg2p-orange);
}

.mg2p_board.is-ready .mg2p_panel.is-entering .mg2p_item {
  animation: mg2p-rise .5s cubic-bezier(.2, .7, .2, 1) both;
  animation-delay: calc(min(var(--i, 0), 14) * 28ms);
}

@keyframes mg2p-rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

/* ---------- Photo viewer ---------- */

.mg2p_lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, .94);
  color: #fff;
  font-family: Montserrat, sans-serif;
  overflow: hidden;
}

.mg2p_lightbox::backdrop {
  background: rgba(0, 0, 0, .94);
}

.mg2p_lb-frame {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) 4.5rem;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.mg2p_lb-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
}

.mg2p_lb-caption {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.mg2p_lb-caption span {
  margin-left: .875rem;
  color: #b5b5b5;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.mg2p_lb-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}

.mg2p_lb-btn:hover {
  border-color: #db5815;
  background: #db5815;
}

.mg2p_lb-btn svg {
  width: 1.125rem;
  height: 1.125rem;
}

.mg2p_lb-prev,
.mg2p_lb-next {
  align-self: center;
  justify-self: center;
}

.mg2p_lb-figure {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 0 2rem;
}

/* Sized by project-gallery.js to fit the viewer without stretching small originals. */
.mg2p_lb-img {
  display: block;
  max-width: 100%;
  border-radius: 6px;
  background: #1c1c1c;
}

/* ---------- Responsive ---------- */

@media screen and (max-width: 991px) {
  .mg2p {
    padding-top: 5rem;
  }

  .mg2p_head {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 2.5rem;
  }

  .mg2p_title {
    font-size: 2.75rem;
  }

  .mg2p_board,
  .mg2p_board:not(.is-ready) {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }

  .mg2p_rail {
    position: static;
    flex-direction: row;
    gap: .5rem;
    /* Bleed to the screen edges: the section's 5% gutter is 1/18 of this column's width. */
    margin: 0 calc(-100% / 18);
    padding: 0 calc(100% / 18) .25rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .mg2p_rail::-webkit-scrollbar {
    display: none;
  }

  .mg2p_rail-label {
    display: none;
  }

  .mg2p_tab {
    flex: 0 0 auto;
    width: auto;
    padding: .6875rem 1rem;
    border: 1px solid #c9c9c9;
    border-radius: 5px;
    font-size: .9375rem;
    white-space: nowrap;
  }

  .mg2p_tab:hover {
    border-color: #9a9a9a;
  }

  .mg2p_tab[aria-selected="true"] {
    border-color: var(--mg2p-orange);
    background: var(--mg2p-orange);
    color: #fff;
  }

  .mg2p_tab[aria-selected="true"] .mg2p_tab-count {
    color: #fff;
  }
}

@media screen and (max-width: 767px) {
  .mg2p {
    --mg2p-cols: 2;
    --mg2p-gap: .75rem;
    padding-top: 4rem;
  }

  .mg2p_title {
    font-size: 2.25rem;
  }

  .mg2p_name {
    font-size: 1.5rem;
  }

  .mg2p_lb-frame {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .mg2p_lb-figure {
    grid-column: 1 / -1;
    grid-row: 2;
    padding: 0 .75rem;
  }

  .mg2p_lb-prev,
  .mg2p_lb-next {
    grid-row: 3;
    margin: 1rem 0 1.5rem;
  }

  .mg2p_lb-prev {
    justify-self: end;
    margin-right: .5rem;
  }

  .mg2p_lb-next {
    justify-self: start;
    margin-left: .5rem;
  }
}

@media screen and (max-width: 479px) {
  .mg2p {
    --mg2p-gap: .5rem;
  }

  .mg2p_count b {
    font-size: 1.5rem;
  }

  .mg2p_tile {
    border-radius: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mg2p_tab,
  .mg2p_tile img,
  .mg2p_tile::after,
  .mg2p_lb-btn {
    transition: none;
  }

  .mg2p_board.is-ready .mg2p_panel.is-entering .mg2p_item {
    animation: none;
  }
}
