/* ============================================
   CASE STUDY BLOCKS
   All repeatable block types rendered by case-parser.js.
   Re-uses .block, .label, .h1, .h2, .h3, etc. from global.css.
   ============================================ */

/* ----------------------------------------
   FRAME MODIFIER — tighter gap for case pages
   ---------------------------------------- */
.frame--case {
  gap: 80px;
}

/* Text elements: 800px centered — images stay full width */
.frame--case .hero__content,
.frame--case .section-head,
.frame--case .case__split {
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Hero content: collapse gap, set explicit spacing */
.frame--case .hero__content {
  gap: 0;
}
.frame--case .hero__content > * + * {
  margin-top: var(--sp-16);
}
.frame--case .case__hero-meta {
  margin-top: var(--sp-32);
}

/* Blocks inside a case page: no border, vertical stack with 48px gap */
.frame--case .block {
  border: none;
  display: flex;
  flex-direction: column;
  gap: 60px;
}

/* Padding: 80px top, 64px bottom — defines header height */
.site-header--case > .container {
  padding-top: 80px;
  padding-bottom: 48px;
}

.case__header-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-img);
}

/* ----------------------------------------
   HERO META  — horizontal row of meta items
   inside the .site-header hero (mirrors about__metrics)
   ---------------------------------------- */
.case__hero-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-32);
}

.case__hero-meta-item {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.case__hero-meta-item dd {
  font-size: 24px;
    font-weight: 500;
    font-family: var(--font-title);
    color: var(--color-accent);
}

/* ----------------------------------------
   COVER IMAGE  — first item in main frame
   ---------------------------------------- */
.case__cover {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-img);
}

.case__cover img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

/* ----------------------------------------
   FIGURE + CAPTION  — wraps each [image] item
   ---------------------------------------- */
.case__figure {
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

/* FULL-WIDTH IMAGE BLOCK  — [image] item */
.case__image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  box-shadow: var(--shadow-img);
  cursor: zoom-in;
}

.case__caption {
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--color-ink-label);
  text-align: left;
  letter-spacing: 0px;
}

/* ----------------------------------------
   LIGHTBOX
   ---------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background-color: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

.lightbox.is-open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-12);
  max-width: min(1400px, 100%);
  transform: scale(0.94);
  transition: transform 260ms ease;
}

.lightbox.is-open .lightbox__figure {
  transform: scale(1);
}

.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox__caption {
    font-family: var(--font-body);
    font-size: 15px;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    letter-spacing: 0;
}

.lightbox__close {
  position: absolute;
  top: var(--sp-24);
  right: var(--sp-24);
  color: #fff;
  opacity: 0.55;
  padding: var(--sp-8);
  transition: opacity 150ms ease;
}

.lightbox__close:hover { opacity: 1; }

/* ----------------------------------------
   SPLIT LAYOUT  — vertical stack, 700px wide
   Used by [split-title] and [split-text]
   ---------------------------------------- */
.case__split {
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
}

.case__split-right {
  font-size: var(--fs-text);
  line-height: var(--lh-text);
  color: var(--color-ink-secondary);
  width: 100%;
}

/* 16px between any consecutive block children in text content areas */
.case__split-right > * + *,
.hero__desc > * + * {
  margin-top: var(--sp-16);
}

/* ----------------------------------------
   RICH TEXT — bullet list
   ---------------------------------------- */
.case__list {
  display: grid;
  grid-template-columns: 1fr; /* default: single column */
  gap: var(--sp-16);
}

.case__list--cols-2 { grid-template-columns: repeat(2, 1fr); }
.case__list--cols-3 { grid-template-columns: repeat(3, 1fr); }

.case__list li {
  background-color: color-mix(in srgb, var(--color-accent) 13%, var(--color-bg));
  padding: 12px;
  border-radius: 4px;
  font-size: var(--fs-text);
  line-height: var(--lh-text);
}

/* ----------------------------------------
   FLOATING TOC
   Lives as first child of <main>.
   On wide viewports: <main> becomes a 3-col grid —
   TOC in left col (sticky), container in center col.
   Hidden on narrow screens.
   ---------------------------------------- */

/* Default: hidden */
.case-toc { display: none; }

@media (min-width: 1480px) {
  /* Make <main> a 3-column grid when TOC is present.
     Side columns keep a minimum so the TOC never clips; the centre
     content flexes down to fit rather than forcing a fixed width. */
  main.has-toc {
    display: grid;
    grid-template-columns: minmax(300px, 1fr) minmax(0, var(--container-md)) minmax(300px, 1fr);
  }

  /* Keep the content container in the center column */
  main.has-toc > .container {
    grid-column: 2;
  }

  /* TOC: sticky, anchored to the right edge of the left column */
  .case-toc {
    display: block;
    grid-column: 1;
    justify-self: end;
    position: sticky;
    top: 48px;
    height: fit-content;
    align-self: start;
    width: 300px;
    padding-left: 24px;
    padding-right: 24px;
    padding-top: 64px; /* align with .frame padding */
  }
}

.case-toc__list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-24);
}

.case-toc__link {
  display: block;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 400;
  color: var(--color-ink-label);
  line-height: 1.3;
  transition: color 150ms ease;
}

.case-toc__link:hover {
  color: var(--color-ink);
}

.case-toc__link.is-active {
  color: var(--color-accent);
  font-weight: 700;
}

/* ----------------------------------------
   BACK LINK — bottom of case pages
   Uses the .project__cta button style; this only centres it
   and flips the arrow (points left, tilts 45° on hover).
   ---------------------------------------- */
.case__back {
  display: flex;
  width: fit-content;
  margin: var(--sp-64) auto var(--sp-48);
}

.case__back:hover svg,
.case__back:focus-visible svg {
  transform: rotate(45deg);
}

/* ----------------------------------------
   RESPONSIVE
   ---------------------------------------- */
@media (max-width: 820px) {
  .case__cover img { aspect-ratio: 4 / 3; }
  

  .site-header--case > .container {
      padding-bottom: 32px;
  }

  .frame--case .block {
      gap: 48px;
  }
}

@media (max-width: 560px) {

  .site-header--case > .container {
      padding-bottom: 16px;
  }
    .frame--case .case__hero-meta {
      display: flex;
      flex-direction: column;
      gap: var(--sp-16);
  }

  .frame--case .block {
      gap: 32px;
  }

  .case__list--cols-2, .case__list--cols-3 {
      display: flex;
      flex-direction: column;
      gap: var(--sp-16);
  }
}
