.portfolio-service-badge {
  color: var(--color-brand-graphite-800);
  text-decoration: none;
}

.portfolio-service-badge:hover {
  border-color: var(--color-brand-orange-300);
  background: var(--color-brand-warm-50);
}

.portfolio-work .service-work__tab-label {
  overflow-wrap: anywhere;
}

/* Compound `.portfolio-detail-hero.service-hero` outranks the global
   `.service-hero` hero rules (max-width 22ch on h1, 620px on the copy column),
   which load after this file. Case-study titles are long sentences and the hero
   image is full-bleed, so the heading should use most of the width. */
.portfolio-detail-hero.service-hero h1 {
  max-width: none;
}

@media (min-width: 921px) {
  .portfolio-detail-hero.service-hero .home-hero__copy {
    grid-column: 1 / span 9;
    max-width: 64rem;
  }
}

.portfolio-story {
  background: var(--gradient-premium-field);
}

.portfolio-story:nth-of-type(2n) {
  background: linear-gradient(180deg, var(--color-brand-steel-50), var(--color-paper));
}

.portfolio-story__media.home-permit__media {
  grid-column: 1 / span 5;
  gap: 0.75rem;
}

.portfolio-story__copy.home-permit__copy {
  grid-column: 7 / -1;
}

.portfolio-story__copy .eyebrow {
  border-left: 3px solid var(--color-brand-orange-500);
  padding-left: 0.75rem;
}

.portfolio-story__copy h2,
.portfolio-text__heading h2 {
  max-width: 16ch;
}

.portfolio-list.home-permit__steps {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: none;
  margin-top: 0.25rem;
}

.portfolio-list.home-permit__steps li {
  min-height: auto;
}

.portfolio-list.home-permit__steps strong {
  color: var(--color-brand-graphite-700);
  font-size: var(--text-body);
  font-weight: 600;
  line-height: 1.45;
}

.portfolio-text {
  background: linear-gradient(180deg, var(--color-paper), var(--color-brand-warm-50), var(--color-paper));
  padding-block: clamp(2rem, 5vw, 4rem);
}

.portfolio-text + .portfolio-text {
  padding-top: 0;
}

.portfolio-text__panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(var(--page-grid-columns), minmax(0, 1fr));
  column-gap: var(--page-grid-gap);
  row-gap: clamp(1rem, 3vw, 1.75rem);
  border-top: 0.3rem solid var(--color-brand-orange-500);
  padding: clamp(1.2rem, 3vw, 2rem);
}

.portfolio-text__heading {
  grid-column: 1 / span 4;
  display: grid;
  align-content: start;
  gap: 0.75rem;
}

.portfolio-text__body {
  grid-column: 6 / -1;
  display: grid;
  gap: 1rem;
}

.portfolio-text__body p {
  margin: 0;
  color: var(--color-brand-graphite-700);
  font-size: var(--text-lede);
  line-height: 1.6;
}

.portfolio-related {
  background: linear-gradient(180deg, var(--color-paper), var(--color-brand-steel-50), var(--color-paper));
}

.portfolio-gallery {
  background: linear-gradient(180deg, var(--color-paper), var(--color-brand-steel-50) 42%, var(--color-paper));
}

.portfolio-gallery__heading {
  margin-bottom: clamp(0.5rem, 2vw, 1rem);
}

.portfolio-gallery__sections {
  grid-column: 1 / -1;
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
}

.portfolio-gallery__section {
  display: grid;
  gap: clamp(1rem, 2.5vw, 1.5rem);
  border-top: 1px solid var(--color-brand-steel-200);
  padding-top: clamp(1.2rem, 3vw, 2rem);
}

.portfolio-gallery__section-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: end;
  justify-content: space-between;
}

.portfolio-gallery__section-heading h3 {
  color: var(--color-brand-graphite-950);
  font-size: var(--text-h3);
}

.portfolio-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.75rem, 1.5vw, 1rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.portfolio-gallery-card {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--color-brand-steel-100);
}

.portfolio-gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms ease;
}

.portfolio-gallery-card:hover img {
  transform: scale(1.055);
}

@media (max-width: 1100px) {
  .portfolio-story__media.home-permit__media,
  .portfolio-story__copy.home-permit__copy,
  .portfolio-text__heading,
  .portfolio-text__body {
    grid-column: 1 / -1;
  }

  .portfolio-story__copy.home-permit__copy {
    order: -1;
  }

  .portfolio-gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .portfolio-detail-hero h1 {
    max-width: none;
  }

  .portfolio-list.home-permit__steps,
  .portfolio-gallery-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-text__panel {
    grid-template-columns: 1fr;
  }

  .portfolio-text__body p {
    font-size: var(--text-body);
  }
}

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

  .portfolio-gallery-card:hover img {
    transform: none;
  }
}

/* ---------- Gallery lightbox ---------- */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, #0e1012 92%, transparent);
  padding: clamp(1rem, 4vw, 3rem);
}

.gallery-lightbox[hidden] {
  display: none;
}

.gallery-lightbox__img {
  max-width: min(100%, 1100px);
  max-height: 86vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
  position: absolute;
  border: 0;
  background: color-mix(in srgb, var(--color-paper) 12%, transparent);
  color: var(--color-paper);
  cursor: pointer;
  line-height: 1;
  transition: color 160ms ease, background 160ms ease;
}

.gallery-lightbox__close {
  top: clamp(0.75rem, 2vw, 1.4rem);
  right: clamp(0.75rem, 2vw, 1.6rem);
  display: grid;
  place-items: center;
  width: 2.85rem;
  height: 2.85rem;
  font-size: 1.9rem;
  background: transparent;
}

.gallery-lightbox__nav {
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  font-size: 1.9rem;
}

.gallery-lightbox__nav--prev {
  left: clamp(0.5rem, 2vw, 1.5rem);
}

.gallery-lightbox__nav--next {
  right: clamp(0.5rem, 2vw, 1.5rem);
}

.gallery-lightbox__close:hover,
.gallery-lightbox__nav:hover,
.gallery-lightbox__close:focus-visible,
.gallery-lightbox__nav:focus-visible {
  color: var(--color-brand-orange-400);
  background: color-mix(in srgb, var(--color-paper) 20%, transparent);
}
