/* ==========================================================================
   Collection pages (e.g. projects/website-collection/): many short pieces of
   work on one page. Loaded after case-study.css, which provides the shell
   (bar, hero, byline, facts, contents rail, Up next) and the article column.

   Blocks, used directly inside a <section> of the article:
     ol.cl-index        numbered list of everything in the collection
     p.cl-summary       one-line summary under a piece's heading
     dl.cl-meta         small facts for one piece (time, status, role…)
     .cl-key            the one design idea worth remembering
     a.cl-visit         "Visit site" button

   Visual compositions (wide, centred, image-first):
     figure.cl-hero     a laptop mockup with a phone screen overlapping it
     figure.cl-iso      an isometric wall of many screens, with a call to action
     figure.cl-bento    rows of tiles (.cl-row > .cl-tile / .cl-stack), each keeping its image's proportions
   Per piece colours on the section: --stage (dark backdrop), --wall (light backdrop).
   ========================================================================== */

.cl-page .cs-article > section {
  --stage: #2a1024;   /* solid backdrop for mockups: set per site from its own colours */
  --wall: #FFD2DB;    /* solid backdrop for the screen wall */
}

/* Bring the first project preview into view below the byline. */
.cl-page[data-project="website-collection"] .cs-hero,
.cl-page[data-project="website-collection"] .cs-layout { padding-top: clamp(20px, 3vw, 36px); }

#allbuddy > .cl-iso { margin-top: 16px; }

/* index of the collection */
.cl-index { margin: 22px 0 0; padding: 0; list-style: none; counter-reset: cl; border-top: 1px solid var(--cs-line); }
.cl-index li { counter-increment: cl; display: flex; align-items: baseline; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--cs-line); font: 600 1.02rem/1.4 var(--f-body); }
.cl-index li::before { content: counter(cl, decimal-leading-zero); min-width: 26px; font-size: 0.78rem; font-weight: 700; color: var(--cs-accent); }
.cl-index a { color: var(--cs-text); text-decoration: none; }
.cl-index a:hover { color: var(--cs-accent); }
.cl-index span { margin-left: auto; font-weight: 500; font-size: 0.85rem; color: var(--cs-muted); }

/* one piece */
.cl-summary { font-size: 1.12em; color: var(--cs-text); }
.cl-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 22px; margin: 22px 0 0; padding: 18px 0; border-block: 1px solid var(--cs-line); }
.cl-meta div { min-width: 0; }
.cl-meta dt { font: 600 0.78rem/1.3 var(--f-body); color: var(--cs-muted); }
.cl-meta dd { margin: 4px 0 0; font: 600 0.95rem/1.4 var(--f-body); color: var(--cs-text); }
.cl-meta a { color: var(--cs-accent); }

.cl-key { margin-top: 26px; padding: 18px 20px 18px 22px; border-left: 4px solid var(--cs-accent); border-radius: 0 12px 12px 0; background: var(--cs-tint); }
.cl-key b { display: block; margin-bottom: 4px; font: 700 1rem/1.35 var(--f-body); color: var(--cs-accent); }
.cl-key p { margin: 0; }

.cl-visit { display: inline-flex; align-items: center; gap: 8px; margin-top: 28px; padding: 12px 20px; border-radius: 99px; background: var(--cs-accent); color: #fff; font: 700 0.95rem var(--f-body); text-decoration: none; }
.cl-visit:hover { filter: brightness(1.08); }
.cl-soon { margin-top: 18px; color: var(--cs-muted); }

/* ---- compositions: wide and centred -------------------------------------- */
.cs-article > section > :is(.cl-hero, .cl-iso, .cl-bento, .cl-full) {
  --w: min(1600px, 100vw - 2 * var(--gutter));
  width: var(--w);
  max-width: none;
  margin: clamp(30px, 4vw, 48px) calc((100% - var(--w)) / 2) 0;
}
:is(.cl-hero, .cl-iso, .cl-bento, .cl-full) img { display: block; max-width: 100%; height: auto; }
:is(.cl-hero, .cl-iso, .cl-bento, .cl-full) figcaption { max-width: var(--cs-measure); margin: 12px auto 0; font: 400 0.9rem/1.5 var(--f-body); color: var(--cs-muted); text-align: center; }

/* single full mockup (the solid backdrop is baked into the image) */
.cl-full img { border-radius: 20px; background: var(--stage); }

/* laptop + phone */
.cl-hero__stage { position: relative; padding: clamp(22px, 5vw, 76px) clamp(14px, 7vw, 120px) clamp(30px, 6vw, 90px); border-radius: 20px; background: var(--stage); overflow: hidden; }
.cl-hero__laptop { position: relative; width: 88%; }
.cl-phone { position: absolute; right: clamp(10px, 5vw, 90px); bottom: clamp(14px, 4vw, 64px); width: 19%; padding: 0.55%; border-radius: 13% / 6%; background: #0e0b0d; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.12), -24px 30px 60px -20px rgb(0 0 0 / 0.7); transform: rotate(4deg); }
.cl-phone img { width: 100%; border-radius: 12% / 5.4%; }

/* isometric wall of screens */
.cl-iso__stage { position: relative; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 20px; background: var(--wall); isolation: isolate; }
.cl-iso__plane {
  position: absolute; left: 50%; top: 50%; width: 172%;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3%;
  transform: translate(-43%, -47%) rotateX(52deg) rotateZ(-34deg);
  transform-style: preserve-3d;
}
.cl-iso__col { display: flex; flex-direction: column; gap: 3.2vw; }
.cl-iso__col:nth-child(2) { transform: translateY(-12%); }
.cl-iso__col:nth-child(3) { transform: translateY(-3%); }
.cl-iso__col:nth-child(4) { transform: translateY(-16%); }
.cl-iso__col img { width: 100%; border-radius: 1vw; box-shadow: 0 2px 0 rgb(255 255 255 / 0.6) inset, -1.4vw 2.2vw 3vw -1vw rgb(90 30 70 / 0.35); }
.cl-iso__cta { position: absolute; inset: auto 0 0 0; display: flex; justify-content: center; padding: 9% 16px clamp(16px, 3vw, 36px); background: linear-gradient(to top, var(--wall) 20%, transparent); }
.cs-article .cl-iso__cta a { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; border-radius: 99px; background: #1e1712; color: #fff; font: 700 0.95rem var(--f-body); text-decoration: none; box-shadow: 0 12px 30px -12px rgb(30 23 18 / 0.6); }
.cs-article .cl-iso__cta a:hover { background: var(--cs-accent); color: #fff; }

/* Watch: a denser wall of twelve full-width sections on the brand blue */
.cl-iso--watch .cl-iso__plane { width: 158%; gap: 2.4%; transform: translate(-45%, -50%) rotateX(52deg) rotateZ(-34deg); }
.cl-iso--watch .cl-iso__col { gap: 2.2vw; }
.cl-iso--watch .cl-iso__col img { border-radius: 0.7vw; box-shadow: 0 0 0 1px rgb(255 255 255 / 0.4), -1.4vw 2.2vw 3vw -0.8vw rgb(2 22 90 / 0.55); }
.cl-iso--watch .cl-iso__cta a { background: #fff; color: #0650d5; }

/* bento: rows of tiles that keep every image's own proportions, so nothing is ever cropped.
   .cl-row is a flex row; each .cl-tile (or .cl-stack of two tiles) carries --ar, the image's
   width / height. flex-grow = --ar makes every tile in a row the same height.
   A stack's --ar = 1 / (1/ar1 + 1/ar2). Tiles with a baked solid backdrop set --tile to that colour. */
.cl-bento figure, .cl-bento .cl-rows { display: grid; gap: clamp(10px, 1.4vw, 20px); }
.cl-row { display: flex; gap: clamp(10px, 1.4vw, 20px); }
.cl-row > * { flex: var(--ar, 1) 1 0; min-width: 0; }
.cl-tile { position: relative; overflow: hidden; border-radius: 18px; background: var(--tile, #f4ecef); box-shadow: 0 0 0 1px var(--cs-line); aspect-ratio: var(--ar, auto); }
.cl-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cl-stack { display: flex; flex-direction: column; gap: clamp(10px, 1.4vw, 20px); }
.cl-stack > .cl-tile { flex: calc(1 / var(--ar, 1)) 1 0; aspect-ratio: auto; }   /* in a column, height follows 1 / ratio */
.cl-tile--solid { box-shadow: none; }

/* short stories: a paragraph after a bento gets room */
.cl-bento + p { margin-top: clamp(26px, 3vw, 36px); }

/* the one decision per story, as a pull quote */
.cl-decision { margin: 24px 0 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--cs-accent); }
.cl-decision span { display: block; margin-bottom: 6px; font: 700 0.78rem/1.3 var(--f-body); letter-spacing: 0.04em; text-transform: uppercase; color: var(--cs-accent); }
.cl-decision p { margin: 0; font: italic 400 clamp(1.15rem, 1.05rem + 0.45vw, 1.4rem)/1.45 'Source Serif 4', Georgia, serif; color: var(--cs-text); text-wrap: pretty; }
.cl-decision + p { margin-top: 22px; }

@media (max-width: 640px) {
  .cl-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl-phone { width: 24%; right: 10px; bottom: 12px; }
  .cl-hero__laptop { width: 92%; }
  .cl-iso__stage { aspect-ratio: 4 / 5; }
  .cl-iso__plane { width: 230%; }
  .cl-row { flex-direction: column; }
  .cl-row > *, .cl-stack > .cl-tile { flex: none; }
  .cl-stack > .cl-tile { aspect-ratio: var(--ar, auto); }
  .cl-stack { gap: 10px; }
}
@media (prefers-reduced-motion: no-preference) {
  .cl-iso__col img { transition: transform 0.4s ease; }
}

/* Gallery: a wall of posters in 4 staggered columns. Every image keeps its own shape (no cropping);
   the stagger gives the irregular, photo-wall feel. Wall colour per section: --wall. */
.cs-article > section > .cl-gallery {
  --w: min(1600px, 100vw - 2 * var(--gutter));
  width: var(--w);
  max-width: none;
  margin: clamp(26px, 4vw, 44px) calc((100% - var(--w)) / 2) 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 20px);
  padding: clamp(14px, 3vw, 44px);
  border-radius: 24px;
  background: var(--wall);
  overflow: hidden;
}
.cl-gallery__col { display: grid; gap: clamp(10px, 1.4vw, 20px); align-content: start; }
.cl-gallery__col:nth-child(2) { margin-top: 9%; }
.cl-gallery__col:nth-child(3) { margin-top: -4%; }
.cl-gallery__col:nth-child(4) { margin-top: 14%; }
.cl-gallery img { display: block; width: 100%; height: auto; border-radius: 10px; box-shadow: 0 18px 36px -22px rgb(0 0 0 / 0.55); transition: transform 0.35s ease; }
@media (hover: hover) { .cl-gallery img:hover { transform: translateY(-4px) scale(1.015); } }

@media (max-width: 640px) {
  /* phones: one two-column masonry flow, so no column leaves a gap */
  .cs-article > section > .cl-gallery { display: block; columns: 2; column-gap: 10px; }
  .cl-gallery__col { display: contents; }
  .cl-gallery img { margin-bottom: 10px; break-inside: avoid; }
}

/* Collection of posters: the gallery sits right under the heading, with its story line after it */
.cl-gallery + .cl-summary { max-width: var(--cs-measure); margin: 22px auto 0; }
.cl-page[data-project="social-media"] .cs-hero__lede { max-width: 56ch; }
/* Social media collection: posters come first, so the author line is skipped and the hero stays tight */
.cl-page[data-project="social-media"] [data-cs-byline] { display: none; }
.cl-page[data-project="social-media"] .cs-hero { padding-bottom: 0; }
.cl-page[data-project="social-media"] .cs-article > section:first-child > h2 { margin-bottom: 0; }
