/* ==========================================================================
   High Elm Studio — work
   Grouped by client. Posters are drop-in slots; only the pieces with a
   video ID are playable.
   ========================================================================== */

.library {
  max-width: var(--container);
  margin: 0 auto;
  padding: 168px var(--side-pad) 120px;
  display: flex;
  flex-direction: column;
  gap: 104px;
}

.library__head {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 32px 88px;
  align-items: end;
}

.library__head > div { display: flex; flex-direction: column; gap: 20px; }

.library__head h1 {
  margin: 0;
  font-family: var(--hd);
  font-weight: var(--hdw);
  font-size: clamp(30px, 3.4vw, 52px);
  line-height: 1.08;
  letter-spacing: var(--hdls);
  text-wrap: balance;
}

.library__head p {
  margin: 0;
  font-size: 15px;
  line-height: 1.8;
  color: var(--body);
  max-width: 500px;
  text-wrap: pretty;
}

/* --- A client group ----------------------------------------------------- */

.group { display: flex; flex-direction: column; gap: 28px; }

.group__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 18px;
  flex-wrap: wrap;
}

.group__head h2 {
  margin: 0;
  font-family: var(--hd);
  font-weight: var(--hdw);
  font-size: clamp(22px, 1.9vw, 30px);
}

.group__sector { font-size: 13px; color: var(--muted); }

.group__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-min, 240px)), 1fr));
  gap: 32px 24px;
}

/* One reel per screen is too much on a phone; pair them up. Landscape
   films stay full width, where they still read. */
@media (max-width: 599px) {
  .group__grid[data-shape="tall"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- A piece ------------------------------------------------------------ */
/* <button> when it plays, <div> when it is only a still. */

.piece {
  all: unset;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

button.piece { cursor: pointer; }
button.piece:hover { opacity: 0.92; }
button.piece:focus-visible { outline: 2px solid var(--muted); outline-offset: 4px; }

.piece__frame {
  position: relative;
  aspect-ratio: var(--ratio, 9 / 16);
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.piece__play {
  position: absolute;
  z-index: 2;
  left: 14px;
  bottom: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(12, 21, 32, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bone);
  font-size: 12px;
  pointer-events: none;
}

.piece__meta { display: flex; flex-direction: column; gap: 4px; }
.piece__meta b { font-size: 15px; font-weight: 400; color: var(--ink); }
.piece__meta span { font-size: 13px; color: var(--muted); }

/* --- Tail CTA ----------------------------------------------------------- */

.library__foot {
  border-top: 1px solid var(--hair);
  padding-top: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.library__foot span {
  font-family: var(--hd);
  font-size: clamp(22px, 1.9vw, 30px);
}

.btn-ink {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 28px;
  background: var(--ink);
  color: var(--bone);
  font-size: 14px;
  border-radius: var(--radius);
  transition: background 200ms ease;
}
.btn-ink:hover { background: #1A2633; color: var(--bone); }

/* --- Reel player -------------------------------------------------------- */

.reel {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(12, 21, 32, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.reel[hidden] { display: none; }

.reel__frame {
  position: relative;
  max-width: 100%;
  background: var(--ink);
}
.reel__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.reel__close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(250, 248, 244, 0.4);
  background: none;
  color: var(--bone);
  font-size: 18px;
  cursor: pointer;
  transition: border-color 200ms ease;
}
.reel__close:hover { border-color: var(--bone); }

/* --- Show more ----------------------------------------------------------- */

.work__more {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

.work__more-btn { cursor: pointer; font-family: inherit; background: none; }

.group__grid--more[hidden],
.group[hidden] { display: none; }

/* The extra pieces arrive rather than appear. */
@media (prefers-reduced-motion: no-preference) {
  .group__grid--more:not([hidden]) > .piece {
    animation: workReveal 600ms var(--ease) both;
  }
  .group__grid--more:not([hidden]) > .piece:nth-child(n+5) { animation-delay: 60ms; }
  .group__grid--more:not([hidden]) > .piece:nth-child(n+9) { animation-delay: 120ms; }
}

@keyframes workReveal {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Phones: smaller, calmer type and tighter groups.
   -------------------------------------------------------------------------- */
@media (max-width: 599px) {
  .library { padding: 120px var(--side-pad) 80px; gap: 72px; }
  .library__head h1 { font-size: 26px; }
  .library__head p { font-size: 14px; line-height: 1.75; }
  .group { gap: 22px; }
  .group__grid { gap: 28px 16px; }
  .piece__meta b { font-size: 14px; }
  .library__foot span { font-size: 20px; }
  .reel { padding: 24px; }
}

.library__head p a { color: var(--ink); border-bottom: 1px solid var(--hair); }

/* Optional intro under a group heading, with the names worked with */
.group__intro { display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin-top: -8px; }
.group__intro p { margin: 0; font-size: 14px; line-height: 1.75; color: var(--body); text-wrap: pretty; }
.group__voices { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.group__voices li { font-size: 13px; line-height: 1; padding: 8px 12px; border: 1px solid var(--hair); border-radius: 999px; color: var(--ink); }
