/* =========================================================
   WORKS — YOUTUBE / VIDEO LIBRARY
   Three landscape films per desktop row. This file loads
   after style.css and mobile.css so it is isolated to Works.
   ========================================================= */

body[data-page="works"] .page-head {
  padding-bottom: clamp(46px, 6vh, 70px);
}

/* The approved treatment keeps the page introduction concise. The CMS text
   remains in the DOM and can be restored later without losing its content. */
body[data-page="works"] #worksPageDescription {
  display: none;
}

body[data-page="works"] #worksDynamicList {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: clamp(16px, 1.7vw, 30px);
  row-gap: clamp(44px, 6vw, 78px);
  width: 100%;
  max-width: 1844px;
  margin: 0 auto;
  padding: 0 var(--pad) clamp(110px, 15vh, 190px);
  border: 0;
}

body[data-page="works"] .work-film-card {
  display: block;
  min-width: 0;
  padding: 0;
  border: 0;
}

body[data-page="works"] .work-film-trigger {
  display: block;
  width: 100%;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}
body.has-cursor[data-page="works"] .work-film-trigger {
  cursor: none;
}

body[data-page="works"] .fb-watchtag {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000000;
  display: none;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font: 600 10px Inter, system-ui, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

body[data-page="works"] .fb-watchtag.show {
  display: block;
}
body[data-page="works"] .work-film-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: clamp(14px, 1.2vw, 20px);
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.09), transparent 36%),
    #111;
  box-shadow: 0 24px 65px rgba(0, 0, 0, 0.3);
  transform: translateZ(0);
}

body[data-page="works"] .work-film-frame::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.2));
  content: "";
  pointer-events: none;
}

body[data-page="works"] .work-film-poster {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.002);
  transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-page="works"] .work-film-play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: grid;
  width: clamp(48px, 3.5vw, 62px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  background: rgba(5, 5, 5, 0.46);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.36);
  color: #fff;
  transform: translate(-50%, -50%);
  transition: background 350ms ease, transform 500ms cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  pointer-events: none;
}

body[data-page="works"] .work-film-play svg {
  width: 18px;
  height: 18px;
  margin-left: 2px;
  fill: currentColor;
}

body[data-page="works"] .work-film-meta {
  display: block;
  margin-top: 15px;
}

body[data-page="works"] #worksDynamicList .work-film-title {
  display: block;
  width: 100%;
  margin: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.88);
  font-family: "Inter", "Archivo", Arial, sans-serif;
  font-size: clamp(13px, 0.95vw, 15px);
  font-weight: 500;
  letter-spacing: 0.025em;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body[data-page="works"] #worksDynamicList .work-film-description {
  display: -webkit-box;
  width: 100%;
  min-height: 3em;
  margin: 7px 0 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.5);
  font-family: "Inter", "Archivo", Arial, sans-serif;
  font-size: clamp(12px, 0.82vw, 14px);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.5;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

body[data-page="works"] #worksDynamicList .work-film-description:empty {
  display: none;
}

body[data-page="works"] #worksDynamicList .work-film-card.work-piece .work-film-description:empty {
  display: -webkit-box;
}
body[data-page="works"] .work-film-editor-source {
  display: none !important;
}

/* mobile.js adds its legacy “Tap to watch” pill to .work-media elements. The
   new cards already have the approved circular play control. */
body[data-page="works"] .work-film-frame .fbm-watch-label,
body[data-page="works"] .work-film-frame .fbm-card-index {
  display: none !important;
}

body[data-page="works"] .work-film-trigger:focus-visible {
  outline: none;
}

body[data-page="works"] .work-film-trigger:focus-visible .work-film-frame {
  outline: 2px solid rgba(255, 255, 255, 0.72);
  outline-offset: 5px;
}

@media (hover: hover) and (pointer: fine) {
  body[data-page="works"] .work-film-trigger:hover .work-film-poster {
    filter: brightness(1.06);
    transform: scale(1.045);
  }

  body[data-page="works"] .work-film-trigger:hover .work-film-play {
    background: rgba(5, 5, 5, 0.7);
    transform: translate(-50%, -50%) scale(1.08);
  }
}

/* Scroll-triggered entrance approved in the preview: centre card first,
   then both outer cards. The renderer adds data-work-reveal only after JS is
   ready, so a script failure never leaves the library invisible. */
body[data-page="works"] .work-film-card[data-work-reveal] {
  opacity: 0;
  transform: translate3d(0, 56px, 0) scale(0.985);
  transition:
    opacity 760ms cubic-bezier(0.22, 1, 0.36, 1) var(--work-reveal-delay, 0ms),
    transform 900ms cubic-bezier(0.22, 1, 0.36, 1) var(--work-reveal-delay, 0ms);
  will-change: opacity, transform;
}

body[data-page="works"] .work-film-card[data-work-reveal].is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

/* The on-page editor still identifies Works projects by .work-piece. Its old
   preview motion must not override this compact card layout. */
body[data-page="works"] .work-film-card.work-piece,
body[data-page="works"] .work-film-card.work-piece .work-media,
body[data-page="works"] .work-film-card.work-piece .work-meta > * {
  opacity: 1 !important;
  transform: none !important;
}

/* =========================================================
   IN-SITE FILM PLAYER
   ========================================================= */
body.works-video-open {
  overflow: hidden;
}

.works-video-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483200;
  display: grid;
  visibility: hidden;
  padding: clamp(20px, 4vw, 68px);
  place-items: center;
  opacity: 0;
  transition: visibility 0s linear 420ms, opacity 420ms ease;
}

.works-video-modal.is-open {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

.works-video-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(0, 0, 0, 0.87);
  cursor: pointer;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.works-video-dialog {
  position: relative;
  z-index: 1;
  width: min(1220px, 100%);
  opacity: 0;
  transform: translateY(22px) scale(0.975);
  transition: opacity 340ms ease, transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.works-video-modal.is-open .works-video-dialog {
  opacity: 1;
  transform: none;
}

.works-video-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: clamp(14px, 1.5vw, 24px);
  background: #000;
  box-shadow: 0 38px 120px rgba(0, 0, 0, 0.74);
}

.works-video-shell::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  animation: works-player-spin 0.8s linear infinite;
  content: "";
}

.works-video-shell iframe,
.works-video-shell video {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.works-video-shell video {
  object-fit: contain;
}

.works-video-close {
  position: absolute;
  right: 0;
  bottom: calc(100% + 14px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(13, 13, 13, 0.64);
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  font-family: "Inter", Arial, sans-serif;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.works-video-close span {
  font-size: 17px;
  font-weight: 300;
  line-height: 0.7;
}

body.has-cursor .works-video-modal,
body.has-cursor .works-video-modal * {
  cursor: auto;
}

body.has-cursor .works-video-backdrop,
body.has-cursor .works-video-close {
  cursor: pointer;
}

body.works-video-open .fb-cursor,
body.works-video-open .fb-watchtag {
  display: none !important;
}

@keyframes works-player-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1060px) {
  body[data-page="works"] #worksDynamicList {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  body[data-page="works"] .page-head {
    padding-bottom: 54px !important;
  }
  
body[data-page="works"] #worksDynamicList .work-film-description {
  min-height: 3em;
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
}

  body[data-page="works"] #worksDynamicList {
    grid-template-columns: 1fr;
    row-gap: 44px;
    padding: 0 var(--fbm-pad, 18px) 96px !important;
  }

  body[data-page="works"] .work-film-card {
    padding: 0 !important;
  }

  body[data-page="works"] .work-film-frame,
  body[data-page="works"] .work-film-card:nth-child(even) .work-film-frame {
    width: 100%;
    aspect-ratio: 16 / 9 !important;
    border-radius: 14px !important;
  }

  body[data-page="works"] .work-film-meta {
    margin-top: 13px !important;
  }

  body[data-page="works"] #worksDynamicList .work-film-title {
    max-width: 100%;
    margin: 0 !important;
    font-family: "Inter", "Archivo", Arial, sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: 0.025em !important;
    line-height: 1.35 !important;
    white-space: nowrap;
  }

  body[data-page="works"] .work-film-card[data-work-reveal] {
    --work-reveal-delay: 0ms !important;
    transform: translate3d(0, 42px, 0) scale(0.99);
  }

  body[data-page="works"] .work-film-card[data-work-reveal].is-visible {
    transform: translate3d(0, 0, 0) scale(1);
  }

  .works-video-modal {
    padding: 54px 14px 20px;
  }

  .works-video-close {
    right: 4px;
    bottom: calc(100% + 11px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-page="works"] .work-film-card[data-work-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .works-video-dialog,
  .work-film-poster,
  .work-film-play {
    transition: none !important;
  }
}
