/* Case-study hub groups, case-page gallery ("Inside the build") and its lightbox.
   Loaded on case-studies/ and every case page (build/content/pages.py CASE_EXTRA); behavior in cases.js.
   Colors come from the --pg-* tokens, so it follows variation A light, A dark and B. */

/* ---------- Hub: ad-data cases first, other builds in their own group ---------- */
.cs-groups { display: grid; gap: clamp(48px, 7vw, 80px); }
.cs-group[hidden] { display: none; }
.cs-group-head { margin-bottom: 26px; }
.cs-group-other { padding-top: clamp(36px, 5vw, 56px); border-top: 1px solid var(--pg-line); }
.cs-group[hidden] + .cs-group-other { padding-top: 0; border-top: 0; }
.cs-group .pg-cards.vx-filtered > :not([hidden]) { animation: cs-fin .5s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes cs-fin { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Case hero cover (builds outside ad data) ---------- */
.cs-cover-fig { margin: 0; width: 100%; display: grid; place-items: center; }
.cs-cover-fig .case-cover { display: block; background: var(--pg-panel); animation: cs-rise .9s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes cs-rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }

/* ---------- Gallery ---------- */
.cs-gal { display: grid; gap: 18px; }
.cs-shot { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.cs-open { position: relative; display: block; overflow: hidden; border-radius: 20px; border: 1px solid var(--pg-line); background: var(--pg-panel); box-shadow: var(--pg-shadow); color: inherit; cursor: zoom-in; isolation: isolate; }
.cs-open img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 11; object-fit: cover; transition: transform .7s cubic-bezier(.22, 1, .36, 1), filter .4s ease; }
.cs-open::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .28)); opacity: 0; transition: opacity .35s ease; pointer-events: none; }
.cs-zoom { position: absolute; right: 14px; bottom: 14px; z-index: 1; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--pg-surface); color: var(--pg-text); border: 1px solid var(--pg-line); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .3s ease, transform .3s ease; }
.cs-zoom svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cs-open:hover img, .cs-open:focus-visible img { transform: scale(1.035); }
.cs-open:hover::after, .cs-open:focus-visible::after { opacity: 1; }
.cs-open:hover .cs-zoom, .cs-open:focus-visible .cs-zoom { opacity: 1; transform: none; }
.cs-open:focus-visible { outline: 3px solid var(--pg-hl); outline-offset: 3px; }
.cs-shot figcaption { display: grid; gap: 4px; padding: 0 4px; }
.cs-shot figcaption b { font-family: var(--pg-head); font-size: 1rem; line-height: 1.3; color: var(--pg-text); }
.cs-cap { color: var(--pg-muted); font-size: .9rem; line-height: 1.5; }
.cs-n { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: .72rem; font-weight: 700; letter-spacing: .08em; color: var(--pg-accent); }

/* Lead image: large, with its caption beside it */
.cs-lead { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: clamp(18px, 3vw, 36px); align-items: center; }
.cs-lead .cs-open { border-radius: 26px; }
.cs-lead .cs-open img { aspect-ratio: auto; }
.cs-lead figcaption { gap: 10px; padding: 0; }
.cs-lead figcaption b { font-size: clamp(1.25rem, 2vw, 1.6rem); letter-spacing: -.01em; }
.cs-lead .cs-cap { font-size: 1rem; }
.cs-hint { display: none; color: var(--pg-muted); font-size: .85rem; line-height: 1.5; padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--pg-line); }
.cs-js .cs-hint { display: block; }
.cs-lead .cs-zoom { opacity: 1; transform: none; }

/* Thumbnails: six-column grid, each row of two or three filled (spans set in the HTML) */
.cs-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px; margin-top: 10px; }
.cs-grid > .cs-shot { grid-column: span var(--span, 2); }

@media (max-width: 900px) {
  .cs-lead { grid-template-columns: 1fr; }
  .cs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cs-grid > .cs-shot { grid-column: auto; }
  .cs-grid > .cs-shot:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .cs-zoom { opacity: 1; transform: none; }
}
@media (max-width: 560px) {
  .cs-grid { grid-template-columns: 1fr; gap: 22px; }
  .cs-open, .cs-lead .cs-open { border-radius: 16px; }
}

/* ---------- About the project ---------- */
.cs-about-body { display: grid; gap: 14px; }
.cs-about-body p { margin: 0; color: var(--pg-muted); font-size: 1.02rem; line-height: 1.65; }
.cs-about-body .cs-about-lead { color: var(--pg-text); font-family: var(--pg-head); font-size: clamp(1.1rem, 1.7vw, 1.3rem); line-height: 1.45; }
.cs-facts { margin: 10px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border: 1px solid var(--pg-line); border-radius: 18px; overflow: hidden; background: var(--pg-surface); }
.cs-facts div { padding: 14px 18px; border-bottom: 1px solid var(--pg-line); }
.cs-facts div:nth-child(odd) { border-right: 1px solid var(--pg-line); }
.cs-facts div:nth-last-child(-n + 2):nth-child(odd), .cs-facts div:last-child { border-bottom: 0; }
.cs-facts div:last-child:nth-child(odd) { grid-column: 1 / -1; border-right: 0; }
.cs-facts dt { font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pg-accent); margin-bottom: 4px; }
.cs-facts dd { margin: 0; color: var(--pg-text); font-size: .95rem; }
.case-detail .cs-approach { color: var(--pg-text); margin: 0 0 12px; }
@media (max-width: 560px) {
  .cs-facts { grid-template-columns: 1fr; }
  .cs-facts div, .cs-facts div:nth-child(odd) { border-right: 0; border-bottom: 1px solid var(--pg-line); }
  .cs-facts div:last-child { border-bottom: 0; }
}

/* ---------- Lightbox (built by cases.js) ---------- */
.cs-lb { position: fixed; inset: 0; z-index: 1000; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; padding: clamp(12px, 3vw, 32px) clamp(12px, 5vw, 88px); opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility 0s linear .3s; }
.cs-lb[hidden] { display: none; }
.cs-lb.is-open { opacity: 1; visibility: visible; transition: opacity .3s ease; }
.cs-lb-bg { position: absolute; inset: 0; background: rgba(8, 8, 10, .86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.cs-lb-stage { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; min-height: 0; min-width: 0; touch-action: pan-y; }
.cs-lb-img { max-width: 100%; max-height: calc(100vh - 210px); max-height: calc(100dvh - 210px); width: auto; height: auto; object-fit: contain; border-radius: 14px; box-shadow: 0 30px 90px rgba(0, 0, 0, .55); background: var(--pg-panel); transform: scale(.96); opacity: 0; transition: transform .45s cubic-bezier(.22, 1, .36, 1), opacity .3s ease; }
.cs-lb.is-open .cs-lb-img.is-ready { transform: none; opacity: 1; }
.cs-lb-img.is-leaving-l { transform: translateX(-28px); opacity: 0; }
.cs-lb-img.is-leaving-r { transform: translateX(28px); opacity: 0; }
.cs-lb-cap { position: relative; justify-self: center; width: min(760px, 100%); margin-top: 14px; padding: 14px 18px; border-radius: 16px; background: var(--pg-surface); color: var(--pg-text); border: 1px solid var(--pg-line); display: grid; gap: 4px; text-align: left; }
.cs-lb-cap b { font-family: var(--pg-head); font-size: 1.02rem; }
.cs-lb-cap span { color: var(--pg-muted); font-size: .9rem; line-height: 1.5; }
.cs-lb-cap span:empty { display: none; }
.cs-lb-btn { position: absolute; z-index: 2; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .22); background: rgba(20, 20, 24, .7); color: #fff; cursor: pointer; transition: background .2s ease, transform .2s ease; }
.cs-lb-btn:hover { background: rgba(255, 255, 255, .18); }
.cs-lb-btn:focus-visible { outline: 3px solid var(--pg-hl); outline-offset: 3px; }
.cs-lb-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cs-lb-close { top: clamp(10px, 2vw, 20px); right: clamp(10px, 2vw, 20px); }
.cs-lb-prev, .cs-lb-next { top: 50%; margin-top: -24px; }
.cs-lb-prev { left: clamp(8px, 1.5vw, 20px); }
.cs-lb-next { right: clamp(8px, 1.5vw, 20px); }
.cs-lb-prev:hover { transform: translateX(-2px); }
.cs-lb-next:hover { transform: translateX(2px); }
.cs-lb-count { position: absolute; z-index: 2; top: clamp(18px, 2.6vw, 30px); left: clamp(14px, 3vw, 28px); color: rgba(255, 255, 255, .85); font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: .8rem; letter-spacing: .08em; }
html.cs-lb-lock { overflow: hidden; }
@media (max-width: 600px) {
  .cs-lb { padding: 64px 10px 12px; }
  .cs-lb-img { max-height: calc(100vh - 230px); max-height: calc(100dvh - 230px); border-radius: 10px; }
  .cs-lb-prev, .cs-lb-next { top: auto; bottom: 14px; margin-top: 0; width: 44px; height: 44px; }
  .cs-lb-cap { margin-top: 10px; padding: 12px 64px; text-align: center; min-height: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  .cs-open img, .cs-open::after, .cs-zoom, .cs-lb, .cs-lb-img, .cs-lb-btn { transition: none !important; }
  .cs-open:hover img, .cs-open:focus-visible img { transform: none; }
  .cs-cover-fig .case-cover, .cs-group .pg-cards.vx-filtered > * { animation: none !important; }
  .cs-lb-img, .cs-lb-img.is-leaving-l, .cs-lb-img.is-leaving-r { transform: none; }
}
