/* ==========================================================================
   Mental Health Productions — the film grid.

   Loaded by that page alone, through {% block head %}, because 225 cards is
   the only place on the site that needs any of it and every other page would
   be paying for the download.

   The component is a poster with a link over it. productions.js replaces the
   link with an <iframe> on click, so the rules below have to hold the frame
   in both states: .prod__frame is the fixed 16/9 box, and whatever sits
   inside it — poster, overlay, player — fills it absolutely.

   The search bar and the pager are plain markup around that grid. Both are
   driven by the view, so there is no hidden/shown state for CSS to manage.
   ========================================================================== */

/* ---------- The grids ----------------------------------------------------- */
/* auto-fill, not auto-fit: a filtered-down result should keep the card width
   the rest of the grid has rather than stretching one card across the row. */
.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 18px;
}
.prod-grid--lead {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* ---------- The card ------------------------------------------------------ */
.prod__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
  overflow: hidden;
  /* The films are phone footage letterboxed into 16/9, so the frame's own
     ground shows at the sides. Matching it to the bars keeps the card from
     reading as a photo floating on a lighter panel. */
  background: #000;
  border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
}
.prod__frame:hover { border-color: var(--g-300); box-shadow: var(--shadow-sm); }

.prod__poster {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* ---------- The overlay --------------------------------------------------- */
/* A real <a> to vimeo.com/<id>, covering the poster so the whole card is the
   target. Without JS it opens the film on Vimeo; with JS the click is
   intercepted and a player lands in this same box. */
.prod__open {
  position: absolute;
  inset: 0;
  display: grid;
  grid-auto-rows: max-content;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  color: #fff;
  text-decoration: none;
  text-align: center;
  background: linear-gradient(180deg, rgba(13, 18, 30, .10) 0%, rgba(13, 18, 30, .62) 100%);
  transition: background .3s var(--ease-out);
}
.prod__open:hover,
.prod__open:focus-visible { background: rgba(13, 18, 30, .52); }
.prod__open:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }

.prod__ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
  border: 1.5px solid rgba(255, 255, 255, .62);
  backdrop-filter: blur(6px);
  transition: transform .3s var(--ease-out), background .3s;
}
.prod__open:hover .prod__ring,
.prod__open:focus-visible .prod__ring {
  transform: scale(1.07);
  background: rgba(255, 255, 255, .26);
}
.prod__ring .ico {
  /* .ico is stroke-only by default; the play glyph is a solid triangle. */
  width: 18px; height: 18px;
  fill: currentColor;
  stroke: none;
  margin-left: 3px;        /* a triangle's visual mass sits left of its box */
}

.prod__open-label {
  font-family: var(--font-display);
  font-size: .92rem;
  font-weight: 550;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 10px rgba(13, 18, 30, .55);
}
.prod--lead .prod__ring { width: 58px; height: 58px; }
.prod--lead .prod__ring .ico { width: 22px; height: 22px; }
.prod--lead .prod__open-label { font-size: 1.04rem; }

/* Bottom right, where a running time goes on every player anyone has used. */
.prod__time {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  background: rgba(13, 18, 30, .72);
  color: #fff;
  font-size: .74rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  pointer-events: none;
}

/* ---------- The player dialog --------------------------------------------- */
/* The .vlb shell — backdrop, panel, frame, close button — is in style.css,
   written for the hero lightbox that has never had anything to open. Only
   what this page adds to it is here: the iframe, and the bar under the
   frame carrying the title and the two arrows.

   Why a dialog and not a player in the card: the films are phone video
   letterboxed into 16:9, so 32% of each frame's width is picture and the
   rest is black. A 212px card gives a 68px-wide person; the 980px panel
   gives about 314px, and the bars land on the near-black backdrop rather
   than in the middle of a white page. */
.vlb__player {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
}

.vlb__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}
/* .vlb__title is centred by style.css and keeps its own margin-top there;
   inside the bar it is the middle column instead. */
.vlb__bar .vlb__title { margin-top: 0; flex: 1 1 auto; }

.vlb__step {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .34);
  transition: background .3s, transform .4s var(--spring), opacity .3s;
}
.vlb__step:hover:not(:disabled) { background: rgba(255, 255, 255, .26); transform: scale(1.08); }
.vlb__step:focus-visible { outline: 3px solid var(--g-400); outline-offset: 3px; }
/* Kept in the layout rather than hidden: the title would jump sideways at
   each end of the list if the arrows came and went. */
.vlb__step:disabled { opacity: .3; cursor: default; }
.vlb__step .ico { width: 18px; height: 18px; }

/* ---------- Search bar ---------------------------------------------------- */
.prod-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
.prod-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.prod-search input {
  flex: 1 1 220px;
  max-width: 300px;
  padding: 10px 15px;
  border-radius: var(--r-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: .9rem;
  transition: border-color .3s, box-shadow .3s;
  outline: none;
}
.prod-search input:focus {
  border-color: var(--g-400);
  box-shadow: 0 0 0 4px rgba(74, 124, 196, .16);
}
.prod-bar__count { margin: 0; }

.prod-empty { margin-top: 24px; }

/* ---------- Pager --------------------------------------------------------- */
/* Real links to ?page=, so they open in a new tab, back works, and the whole
   thing survives JavaScript being off. */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 34px;
}
.pager__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pager__n, .pager__step {
  display: grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  color: var(--body);
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  transition: border-color .2s, background .2s, color .2s;
}
a.pager__n:hover, a.pager__step:hover {
  border-color: var(--g-300);
  background: var(--g-50);
  color: var(--ink);
}
.pager__n.is-on {
  background: var(--g-600);
  border-color: var(--g-600);
  color: #fff;
  font-weight: 550;
}
/* Kept in the flow rather than removed: the row would otherwise shuffle
   sideways every time you reach the first or last page. */
.pager__step.is-off { opacity: .4; }
.pager__gap {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 38px;
  color: var(--body-2);
}

/* ---------- Narrow -------------------------------------------------------- */
/* Two up on a phone rather than one: the posters are legible small, and a
   single column would make 222 of them an unreasonable scroll. */
@media (max-width: 560px) {
  .prod-grid { grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); gap: 12px; }
  /* style.css moves .vlb__close inside the panel at this width, so the bar
     is the only thing under the frame and can take the full row. */
  .vlb__step { width: 36px; height: 36px; }
  .vlb__bar .vlb__title { font-size: .9rem; }
  .prod-grid--lead { grid-template-columns: 1fr; }
  .prod__open-label { font-size: .8rem; }
  .prod__ring { width: 38px; height: 38px; }
  .prod__ring .ico { width: 15px; height: 15px; }
  .prod-bar { justify-content: flex-start; }
  .prod-search input { max-width: none; }
  /* Previous/Next stay; the numbers are a scroll hazard at this width. */
  .pager__list { display: none; }
  .pager { justify-content: space-between; }
}

/* ---------- Print --------------------------------------------------------- */
/* A page of 225 video posters is not a thing to put on paper. */
@media print {
  .prod-grid, .prod-bar, .pager { display: none; }
  .vlb { display: none; }
}
