/* Video wall: clip tiles, the strip on the directory page, the masonry wall on a company page,
   image and post tiles, and the player pop-up. Needs styles.css and news.css (tokens, .news-tag).

   MEMBER UPLOAD FLOW (not built here, for the programmer):
   Members would upload from the Members' Area. Suggested rules: video as MP4 (H.264 + AAC), max 60 seconds and
   100 MB each, portrait or landscape; images as JPG/PNG/WebP up to 5 MB; a poster is made from the first frame if
   none is given. Transcode on the server to 720p MP4 (plus a poster JPG) and host it on the site, not a third-party
   player. Every upload sits in a "pending" state until a BFREPA editor approves it, with a report link on live tiles.
   Store: company id, type (video /
   image / post), title, caption, poster, file, duration, link, created date, status. */

/* ---------- Clip tile (a button, so it works with the keyboard) ---------- */
.dir-vtile {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  text-align: left;
  color: var(--paper);
  background: var(--field-deep);
  border-radius: 0.55rem;
  transition: transform 180ms var(--ease), box-shadow 180ms var(--ease);
}

.dir-vtile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-soft);
}

.dir-vtile__poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dir-vtile--tall {
  aspect-ratio: 9 / 14;
}

.dir-vtile--wide {
  aspect-ratio: 16 / 9;
}

.dir-vtile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(20, 28, 17, 0.88), rgba(20, 28, 17, 0) 55%);
  pointer-events: none;
}

/* Full video wall page: the tile keeps the shape of its poster (portrait or landscape), only poster, play button and length */
.dir-vtile--auto {
  aspect-ratio: auto;
  min-height: 9rem;
}

.dir-vtile--auto .dir-vtile__poster {
  display: block;
  height: auto;
}

.dir-vtile--auto::after {
  background: linear-gradient(to top, rgba(20, 28, 17, 0.35), rgba(20, 28, 17, 0) 45%);
}

/* Round cream play button, centred */
.dir-vtile__play {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 3.4rem;
  height: 3.4rem;
  margin: -1.7rem 0 0 -1.7rem;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 4px 16px rgba(20, 28, 17, 0.4);
}

.dir-vtile__play::before {
  content: "";
  position: absolute;
  left: 1.3rem;
  top: 1rem;
  border: 0.7rem solid transparent;
  border-left: 1.1rem solid var(--field);
  border-right: 0;
}

.dir-vtile:hover .dir-vtile__play {
  background: var(--feed);
}

/* Duration: yolk pill, same as .news-tag */
.dir-vtile__dur {
  position: absolute;
  z-index: 1;
  right: 0.75rem;
  top: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--yolk) 16%, var(--paper));
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  color: color-mix(in srgb, var(--yolk) 70%, var(--ink));
}

.dir-vtile__cap {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 0.2rem;
  padding: 0.95rem 1.05rem;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
}

.dir-vtile__cap b {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(245, 241, 228, 0.72);   /* softer than the white title, so the title leads */
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

/* Screen-reader-only text */
.dir-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Strip on the directory page ---------- */
.dir-teaser {
  background: var(--feed);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  margin-top: var(--space-lg);
  padding: var(--space-lg) 0 var(--space-md);
}

.dir-teaser__inner {
  width: min(100% - 2rem, var(--content-wide));
  margin-inline: auto;
}

.dir-teaser__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.dir-teaser__head h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.dir-teaser__head .text-link {
  margin-top: 0;
  white-space: nowrap;
}

/* No sideways scrolling: the strip is a grid that shows only as many tiles as fit. 2 on phones, 3 on tablets, 5 on desktop. */
.dir-teaser__strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 0.3rem 0 1rem;
}

.dir-teaser__strip li:nth-child(n + 3) {
  display: none;
}

@media (min-width: 640px) {
  .dir-teaser__strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dir-teaser__strip li:nth-child(n + 3) {
    display: block;
  }

  .dir-teaser__strip li:nth-child(n + 4) {
    display: none;
  }
}

@media (min-width: 960px) {
  .dir-teaser__strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .dir-teaser__strip li:nth-child(n + 4) {
    display: block;
  }

  .dir-teaser__strip li:nth-child(n + 6) {
    display: none;
  }
}

/* ---------- Masonry wall on the company page: CSS columns, tiles keep their own height ---------- */
.dir-wall {
  columns: 1;
  column-gap: 1.25rem;
}

@media (min-width: 36rem) {
  .dir-wall {
    columns: 2;
  }
}

@media (min-width: 62rem) {
  .dir-wall {
    columns: 3;
  }
}

.dir-wall > * {
  display: block;
  width: 100%;
  margin: 0 0 1.25rem;
  break-inside: avoid;
}

.dir-wall .dir-vtile--tall {
  aspect-ratio: 9 / 13;
}

@media (max-width: 35.99rem) {
  .dir-wall .dir-vtile--tall {
    aspect-ratio: 4 / 5;
  }
}

/* Image tile and post tile: the same white card as the news cards */
.dir-tile {
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: 0.55rem;
}

.dir-tile__media {
  margin: 0;
  background: var(--feed);
}

.dir-tile__media img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
}

.dir-tile__body {
  padding: 1.1rem 1.25rem 1.3rem;
}

.dir-tile h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.32;
  letter-spacing: -0.01em;
}

.dir-tile p {
  margin: 0.45rem 0 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}

/* Post: avatar, handle and relative date, text, optional photo */
.dir-post {
  padding: 1.15rem 1.25rem;
}

.dir-post__who {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
}

.dir-post__who .dir-co__mono {
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  font-size: 0.9rem;
}

.dir-post__who b {
  display: block;
  font-size: 0.92rem;
  line-height: 1.2;
}

.dir-post__who small {
  font-size: 0.78rem;
  color: var(--muted);
}

.dir-post p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* ---------- Player pop-up (a native <dialog>) ---------- */
.dir-player {
  width: min(56rem, 94vw);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0.55rem;
  background: #000;
  color: var(--paper);
  font-family: var(--font-body);
}

.dir-player::backdrop {
  background: rgba(20, 28, 17, 0.8);
}

.dir-player video {
  display: block;
  width: 100%;
  max-height: 78vh;
  background: #000;
}

.dir-player__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1rem;
  background: var(--field-deep);
  font-size: 0.92rem;
}

.dir-player__bar button {
  min-height: 2.4rem;
  padding: 0.3rem 1.1rem;
  font-weight: 600;
  color: var(--field);
  background: var(--paper);
  border-radius: var(--radius);
}

.dir-player__note {
  margin: 0;
  padding: 1rem;
  font-size: 0.92rem;
  background: var(--field-deep);
}

.dir-player__note[hidden] {
  display: none;
}

/* A comment on the wall keeps its line breaks */
.dir-post p {
  white-space: pre-line;
}
