/* ═══ Case study credits — REUSABLE component ═══════════════════════
   Closes a case study: role, year, team, tools, the people who worked on
   it and outside links, under a full-width divider. Three columns on
   desktop, so the short facts (role, year, team) fill the first row and
   the lists (tools, credits, links) the second. Two columns below 1081px.
   Sits after the impact section, inside .case-sections, so it shares the
   page's content edges.
   Used on: peloton-colleges.html, peloton-reviews.html, google-freeletics.html, wone.html, nike.html, virgin-sport.html.

   To add to a case study:
     1. <link rel="stylesheet" href="components/cs-credits.css" /> in <head>
     2. Paste the markup below after the impact section and swap the copy

   <section class="cs-credits" aria-label="Credits">
     <dl class="cs-credits-grid">
       <div class="cs-credits-group">
         <dt class="cs-credits-label">Role</dt>
         <dd class="cs-credits-item">Lead Product Designer<img class="cs-credits-tile" src="Imagery/Self/ben-tile.jpg" alt="" loading="lazy" decoding="async" /></dd>
       </div>
       <div class="cs-credits-group">
         <dt class="cs-credits-label">Year</dt>
         <dd class="cs-credits-item">2023</dd>
       </div>
       <div class="cs-credits-group">
         <dt class="cs-credits-label">Team</dt>
         <dd class="cs-credits-item">Company<img class="cs-credits-tile" src="icons/tiles/….svg" alt="" loading="lazy" decoding="async" /></dd>
       </div>
       <div class="cs-credits-group">
         <dt class="cs-credits-label">Made using</dt>
         <dd class="cs-credits-item">Figma<img class="cs-credits-tile" src="icons/tiles/figma.svg" alt="" loading="lazy" decoding="async" /></dd>
       </div>
       <div class="cs-credits-group cs-credits-group--people">
         <dt class="cs-credits-label">Credits</dt>
         <dd class="cs-credits-item">Name Surname</dd>
       </div>
       <div class="cs-credits-group">
         <dt class="cs-credits-label">Links</dt>
         <dd class="cs-credits-item"><a class="cs-credits-link" href="…" target="_blank" rel="noopener">Press</a></dd>
       </div>
     </dl>
   </section>

   Logo tiles: an <img class="cs-credits-tile"> inside an item pops up beside
   the word on hover (mouse only; hidden on touch screens). For a link, put it
   after the </a>. Square app-style tiles live in icons/tiles/ (figma,
   photoshop, illustrator, after-effects, sketch, jira, miro, usertesting,
   google, google-docs, google-sheets, google-slides, freeletics, peloton,
   instagram, pelobuddy, linkedin, claude, adobe-creative-cloud, quiverai,
   flora, uxtweak, unicorn-studio, wone, zeplin, keynote, indesign, akqa,
   virgin-sport). The role uses Ben's photo tile from the homepage hero
   (Imagery/Self/ben-tile.jpg).

   Groups are optional: leave one out and the rest close up. A group with a
   long list (e.g. Credits) simply runs longer than the others.

   Single row: add .cs-credits--row to the section to give every group its
   own column on desktop, sized to its content and spread edge to edge.
   Below 1081px it falls back to the two-column grid.

   People column: add .cs-credits-group--people to the Credits group and,
   below 1081px, it gets the right-hand column to itself while the other
   groups stack on the left (see the end of this file).
   Used on: peloton-colleges.html, peloton-reviews.html, google-freeletics.html, wone.html, nike.html, virgin-sport.html.
═══════════════════════════════════════════════════════════════════ */

.cs-credits {
  margin-top: clamp(88px, 10vw, 160px);
  padding-top: clamp(36px, 3.6vw, 56px);
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  color: var(--ink);
}

.cs-credits-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(36px, 3.4vw, 64px) clamp(24px, 2.6vw, 48px);
  margin: 0;
}
.cs-credits-group { min-width: 0; }

/* Single row: one column per group, as many as there are. Long names wrap
   onto a second line before anything overflows. */
@media (min-width: 1081px) {
  .cs-credits--row .cs-credits-grid {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: auto;
    justify-content: space-between;
  }
}

/* Matches the site's other small labels: 600, uppercase, +0.14em. */
.cs-credits-label {
  margin: 0 0 clamp(16px, 1.6vw, 22px);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-light);
}
.cs-credits-item {
  margin: 0;
  font-size: clamp(16px, 1.25vw, 19px);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.cs-credits-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  transition: text-decoration-color 0.25s ease;
}
.cs-credits-link:hover { text-decoration-color: currentColor; }
.cs-credits-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

/* ── Logo tile: hugs the word, then bounces in to its right on hover ──
   It starts small, low and tipped over, and a springy curve overshoots it
   past upright before it settles. Alternate items tip opposite ways.
   Leaving uses a quick plain fade so it never wobbles on the way out. */
.cs-credits-item:has(.cs-credits-tile) { position: relative; width: fit-content; }
.cs-credits-tile {
  --tip: -24deg;
  position: absolute; left: calc(100% + 12px); top: 50%; z-index: 1;
  width: 32px; height: 32px; border-radius: 6px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  opacity: 0; pointer-events: none;
  transform: translate3d(-6px, -10%, 0) scale(0.3) rotate(var(--tip));
  transition: opacity 0.15s ease, transform 0.25s ease;
}
.cs-credits-item:nth-of-type(even) .cs-credits-tile { --tip: 24deg; }
@media (hover: hover) and (pointer: fine) {
  .cs-credits-item:hover .cs-credits-tile {
    opacity: 1; transform: translate3d(0, -50%, 0) scale(1) rotate(0deg);
    transition: opacity 0.12s ease, transform 0.55s cubic-bezier(0.34, 1.8, 0.5, 1);
  }
}
@media (hover: none), (pointer: coarse) {
  .cs-credits-tile { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cs-credits-tile,
  .cs-credits-item:hover .cs-credits-tile { transform: translate3d(0, -50%, 0); transition: opacity 0.2s ease; }
}

/* Tablet + mobile: the body loses its side padding, so the block takes the gutter itself. */
@media (max-width: 1080px) {
  .cs-credits { margin: clamp(64px, 10vw, 96px) var(--case-gutter, 24px) 0; }
  .cs-credits-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* People column: mark the Credits group .cs-credits-group--people and it takes the right-hand
     column to itself, the longest list running down one side while every other group stacks
     in order on the left. One auto row per left-hand group plus a last 1fr row, so a long list
     runs on past the stack without spreading the stack's rows apart. Margins stand in for the
     row gap, or the empty last row would add a gap of its own under a short list. */
  .cs-credits-grid:has(> .cs-credits-group--people) {
    --cs-credits-rows: 1;
    grid-template-rows: repeat(var(--cs-credits-rows), auto) 1fr;
    row-gap: 0;
  }
  .cs-credits-grid:has(> .cs-credits-group--people):has(> :nth-child(3)) { --cs-credits-rows: 2; }
  .cs-credits-grid:has(> .cs-credits-group--people):has(> :nth-child(4)) { --cs-credits-rows: 3; }
  .cs-credits-grid:has(> .cs-credits-group--people):has(> :nth-child(5)) { --cs-credits-rows: 4; }
  .cs-credits-grid:has(> .cs-credits-group--people):has(> :nth-child(6)) { --cs-credits-rows: 5; }
  .cs-credits-grid:has(> .cs-credits-group--people):has(> :nth-child(7)) { --cs-credits-rows: 6; }
  .cs-credits-grid:has(> .cs-credits-group--people) > .cs-credits-group { grid-column: 1; margin-bottom: clamp(36px, 3.4vw, 64px); }
  .cs-credits-grid:has(> .cs-credits-group--people) > .cs-credits-group:last-child,
  .cs-credits-grid:has(> .cs-credits-group--people) > .cs-credits-group:has(+ .cs-credits-group--people:last-child) { margin-bottom: 0; }
  .cs-credits-grid:has(> .cs-credits-group--people) > .cs-credits-group--people { grid-column: 2; grid-row: 1 / -1; margin-bottom: 0; }
}
