/* CASE STUDY */
.case-study {
  padding-top: 8vh;
}

.case-study-grid {
  align-items: start;
}


/* GALLERY — left column, drives the page's scroll length */
.case-study-gallery {
  grid-column: 1 / span 8;
  display: flex;
  flex-direction: column;
  row-gap: var(--spacing-24);
}

.case-study-gallery-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: var(--gutter);
}

.case-study-figure {
  display: flex;
  flex-direction: column;
  row-gap: var(--spacing-8);
}

.case-study-image {
  width: 100%;
  height: auto;
  background-color: var(--color-bg-light-gray);
}

.case-study-caption {
  font-family: var(--font-family);
  font-size: var(--text-caption-13);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-caption);
  color: var(--color-text-secondary-on-light);
}




/* CONTENT */
.case-study-content {
  grid-column: 9 / span 4;
  align-self: stretch;
  min-height: 0;
  padding-left: var(--spacing-24);
  display: grid;
  grid-template-rows: 1fr auto;
}

.case-study-content-inner {
  align-self: start;
  min-height: 0;
  position: sticky;
  top: 8vh;
}

.case-study-title {
  font-family: var(--font-family);
  font-size: var(--text-title);
  font-weight: var(--font-weight-regular);
  letter-spacing: var(--letter-spacing-heading);
  line-height: var(--line-height-heading);
  color: var(--color-text-primary-on-light);
}

.case-study-subtitle {
  margin-top: var(--spacing-16);
  font-family: var(--font-family);
  font-size: var(--text-body-16);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
  letter-spacing: var(--letter-spacing-body);
  color: var( --color-text-secondary-on-light);
  max-width: var(--text-max-width);
}

.nda-note {
  font-size: var(--text-body-16);
  letter-spacing: var(--letter-spacing-body);
  line-height: var(--line-height-body);
  color: var(--color-text-secondary-on-light);
  font-style: italic;
  margin-top: var(--spacing-12);
}

/* META — domain / timeline */
.case-study-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: var(--gutter);
  margin-top: var(--spacing-32);
  margin-bottom: var(--spacing-32);
  padding-block: var(--spacing-16);
}

.case-study-meta-item {
  grid-column: span 2;
}

.case-study-meta-item dt {
  font-family: var(--font-family);
  font-size: var(--text-caps);
  font-weight: var(--font-weight-regular);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--color-text-secondary-on-light);
}

.case-study-meta-item dd {
  margin-top: var(--spacing-4);
  font-family: var(--font-family);
  font-size: var(--text-body-14);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
  color: var(--color-text-primary-on-light);
}


/* Accordion sections */
.accordion {
  border-top: 1px solid var(--color-border);
}

.accordion:last-of-type {
  border-bottom: 1px solid var(--color-border);
}

.accordion-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  column-gap: var(--spacing-16);
  padding-block: var(--spacing-16);
  font-family: var(--font-family);
  font-size: var(--text-heading-16);
  font-weight: var(--font-weight-regular);
  letter-spacing: var(--letter-spacing-heading-sm);
  color: var(--color-text-primary-on-light);
  cursor: pointer;
  list-style: none;
}

.accordion-label::-webkit-details-marker {
  display: none;
}

.accordion-label::marker {
  content: "";
}

.accordion-icon {
  position: relative;
  flex-shrink: 0;
  width: var(--text-heading-24); /* 24px target area */
  height: var(--text-heading-24);
  color: var(--color-text-primary-on-light);
}

.accordion-icon::before,
.accordion-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.875rem;
  height: 1px;
  background-color: currentColor;
  transform: translate(-50%, -50%) rotate(0deg);
  /* Longer duration + a standard smooth ease-in-out — at 0.3s the rotation
     read as a snap rather than a motion; 0.45s gives the eye time to
     actually track the bars turning. */
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-icon::after {
  transform: translate(-50%, -50%) rotate(90deg);
}


.accordion.is-open .accordion-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.accordion.is-open .accordion-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.accordion-body {
  height: 0;
  overflow: hidden;
  font-family: var(--font-family);
  font-size: var(--text-body-16);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body);
  color: var(--color-text-secondary-on-light);
  max-width: var(--text-max-width);
  text-wrap: pretty;
}

.accordion.is-open .accordion-body {
  height: auto;
}

.accordion-body p {
  /* Bottom spacing lives here as margin, not as padding-bottom on
     .accordion-body — padding is part of an element's own box and can't
     be clipped to nothing by its own overflow:hidden, which left a
     permanent ~16px gap at height:0. A child's margin, on the other hand,
     does get clipped away along with the rest of the content. */
  margin-bottom: var(--spacing-16);
}


/* Next project card */
.case-study-next {
  display: flex;
  align-items: flex-end;
  column-gap: var(--spacing-16);
  padding-top: var(--spacing-80);
  /* padding-bottom is set in px by main.js, measured from the gallery's
     last figcaption — its height isn't fixed (captions can wrap onto a
     second line at narrower widths), so it can't be reliably guessed with
     a static calc(). This keeps this card's visible content lined up with
     the last image, not the caption beneath it, at any viewport width. */
  padding-bottom: 0;
}

.case-study-next-media {
  flex: 0 0 auto;
  width: 30%;
  max-width: 11rem;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.case-study-next-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-study-next-info {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-16);
  padding-block: var(--spacing-8);
}

.case-study-next-label {
  font-family: var(--font-family);
  font-size: var(--text-caps);
  font-weight: var(--font-weight-regular);
  letter-spacing: var(--letter-spacing-caps);
  text-transform: uppercase;
  color: var(--color-text-secondary-on-light);

}

.case-study-next-title {
  font-family: var(--font-family);
  font-size: var(--text-heading-18);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-heading);
  letter-spacing: var(--letter-spacing-heading);
  color: var(--color-text-primary-on-light);
  transition: color var(--transition-fast);
}

.case-study-next:hover .case-study-next-title {
  color: var(--color-text-secondary-on-light);
}




@media (max-width: 768px) {
  .case-study {
    padding-top: 15vh;
  }

  .case-study-gallery,
  .case-study-content-inner,
  .case-study-next {
    grid-column: 1 / -1;
  }

  /* Drops its own grid box so .case-study-content-inner and .case-study-next
     become direct items of .case-study-grid — letting the gallery's `order`
     slot between them instead of being stuck after the whole content block. */
  .case-study-content {
    display: contents;
  }

  .case-study-content-inner {
    position: static;
    order: 1;
  }

  .case-study-gallery {
    order: 2;
    margin-top: var(--spacing-48);
  }

  .case-study-gallery-row {
    grid-template-columns: 1fr;
    row-gap: var(--spacing-32);
  }

  .accordion-icon {
    width: 2.75rem; /* 44px touch target */
    height: 2.75rem;
    margin-right: calc(-1 * (2.75rem - var(--text-heading-24)) / 2);
  }

  .case-study-next {
    order: 3;
    flex-direction: column;
    align-items: flex-start;
    row-gap: var(--spacing-16);
    margin-top: var(--spacing-48);
  }

  .case-study-next-media {
    width: 50%;
  }
}
