/**
 * Visual Fantasy — portfolio masonry + lightbox
 * Neutrals: #F5F5F5, #141414, #707070
 */

body.pf-modal-open {
  overflow: hidden;
}

/* ── Category filters — outline pills, flat active (no gradient fills) ── */
.pf-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: 0 auto clamp(32px, 5.5vw, 56px);
  max-width: min(960px, 100%);
  padding: 0 16px;
}

.pf-filter {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  margin: 0;
  padding: 16px 32px;
  min-height: 56px;
  box-sizing: border-box;
  font-family: 'Barlow', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--vf-grey, #707070);
  background: transparent;
  border: 1px solid rgb(from var(--vf-white, #f5f5f5) r g b / 0.28);
  border-radius: 999px;
  line-height: 1.25;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.pf-filter:hover {
  color: var(--vf-white, #f5f5f5);
  background: transparent;
  border-color: rgb(from var(--vf-white, #f5f5f5) r g b / 0.55);
  transform: translateY(-1px);
}

.pf-filter:active {
  transform: translateY(0);
}

.pf-filter.is-active {
  color: var(--vf-black, #141414);
  background: var(--vf-white, #f5f5f5);
  border-color: var(--vf-white, #f5f5f5);
  transform: none;
}

.pf-filter.is-active:hover {
  color: var(--vf-black, #141414);
  background: var(--vf-white, #f5f5f5);
  border-color: var(--vf-white, #f5f5f5);
}

.pf-filter.is-active:active {
  background: rgb(from var(--vf-white, #f5f5f5) r g b / 0.92);
}

.pf-filter:focus-visible {
  outline: 2px solid rgb(from var(--vf-white, #f5f5f5) r g b / 0.5);
  outline-offset: 4px;
}

.pf-filter.is-active:focus-visible {
  outline-color: rgb(from var(--vf-white, #f5f5f5) r g b / 0.65);
}

@media (prefers-reduced-motion: reduce) {
  .pf-filter {
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  }

  .pf-filter:hover,
  .pf-filter.is-active,
  .pf-filter:active,
  .pf-filter.is-active:hover,
  .pf-filter.is-active:active {
    transform: none;
  }
}

.pf-item--filter-hidden {
  display: none !important;
}

@media (max-width: 639px) {
  .pf-filters {
    gap: 10px;
    margin-bottom: clamp(22px, 5vw, 36px);
    padding: 0 12px;
  }

  .pf-filter {
    font-size: 11px;
    letter-spacing: 0.1em;
    padding: 14px 22px;
    min-height: 50px;
    flex: 1 1 auto;
    min-width: min(100%, 168px);
  }
}

/* ── Grid: fixed column system so landscape is exactly 2× portrait width (same row fraction) ──
   Narrow (<768px): 2 columns → portrait span 1, landscape span 2 (50% vs 100%).
   Wide: 12 columns → portrait span 3, landscape span 6 (25% vs 50%).
   Breakpoint is 768px so phones and small tablets keep two portrait columns; 480px was too low
   and matched “mobile” devtools widths, switching to 4-across too early. */
.pf-masonry {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 3vw, 24px);
  padding-bottom: 8px;
  align-items: start;
}

@media (min-width: 768px) {
  .pf-masonry {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
}

/* JS masonry (portfolio-masonry.js): absolute packing; no-JS keeps grid above */
.pf-masonry--masonry {
  display: block;
  position: relative;
  width: 100%;
}

.pf-masonry--masonry .pf-item,
.pf-masonry--masonry .pf-item--landscape {
  display: block;
  grid-column: unset;
  max-width: none;
}

/* Tile: button reset + white stroke */
.pf-item {
  -webkit-appearance: none;
  appearance: none;
  border: 2px solid var(--vf-white, #f5f5f5);
  border-radius: 10px;
  background: rgb(from var(--vf-white, #f5f5f5) r g b / 0.04);
  padding: 0;
  margin: 0;
  width: auto;
  min-width: 0;
  max-width: 100%;
  grid-column: span 1; /* portrait unit: half row on 2-col grid */
  cursor: pointer;
  display: block;
  overflow: hidden;
  text-align: left;
  color: inherit;
  font: inherit;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.pf-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgb(from var(--vf-black, #141414) r g b / 0.45);
  border-color: rgb(from var(--vf-white, #f5f5f5) r g b / 0.95);
}

.pf-item:focus-visible {
  outline: 2px solid rgb(from var(--vf-white, #f5f5f5) r g b / 0.55);
  outline-offset: 3px;
}

.pf-item__inner {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  /* Placeholder until portfolio-grid-previews.js sets intrinsic aspect from video metadata */
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(
      145deg,
      rgb(from var(--vf-white, #f5f5f5) r g b / 0.08) 0%,
      rgb(from var(--vf-grey, #707070) r g b / 0.12) 48%,
      rgb(from var(--vf-black, #141414) r g b / 0.5) 100%
    ),
    rgb(from var(--vf-black, #141414) r g b / 0.35);
}

/* Per-tile loading (matches modal: title + % + bar; sits above video) */
.pf-item__loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2.5vw, 16px);
  box-sizing: border-box;
  background: rgb(from var(--vf-black, #141414) r g b / 0.68);
  pointer-events: none;
  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
}

.pf-item__loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.pf-item__loading-box {
  width: 100%;
  max-width: min(280px, 94%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(6px, 1.5vw, 10px);
}

.pf-item__loading-title {
  margin: 0;
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(18px, 4.2vw, 28px);
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  color: var(--vf-white, #f5f5f5);
  line-height: 1;
}

.pf-item__loading-pct {
  margin: 0;
  font-family: 'Barlow', sans-serif;
  font-size: clamp(22px, 5vw, 36px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--vf-white, #f5f5f5);
  line-height: 1;
}

.pf-item__loading-track {
  width: 100%;
  height: clamp(8px, 1.8vw, 12px);
  border-radius: 999px;
  background: rgb(from var(--vf-white, #f5f5f5) r g b / 0.14);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgb(from var(--vf-white, #f5f5f5) r g b / 0.08);
}

.pf-item__loading-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgb(from var(--vf-white, #f5f5f5) r g b / 0.85),
    var(--vf-white, #f5f5f5)
  );
  transition: none;
}

/* Inline preview: frame matches video aspect ratio; full frame visible (letterboxing on inner bg) */
.pf-item__video {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  z-index: 0;
  pointer-events: none;
  display: block;
  background: transparent;
}

@media (min-width: 768px) {
  .pf-item {
    grid-column: span 3; /* portrait unit: 3/12 row */
  }
}

/* Landscape (w > h): exactly 2× portrait width (half row vs quarter row) */
.pf-item--landscape {
  grid-column: span 2;
}

@media (min-width: 768px) {
  .pf-item--landscape {
    grid-column: span 6;
  }
}

.pf-item__meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 12px 14px 14px;
  background: linear-gradient(transparent, rgb(from var(--vf-black, #141414) r g b / 0.82));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.pf-item__title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--vf-white, #f5f5f5);
  line-height: 1.25;
}

@media (max-width: 639px) {
  .pf-masonry {
    gap: clamp(10px, 2.5vw, 14px);
  }

  .pf-item {
    border-radius: 8px;
    border-width: 1.5px;
  }

  .pf-item__meta {
    padding: 10px 10px 12px;
  }

  .pf-item__title {
    font-size: 13px;
    letter-spacing: 0.05em;
    line-height: 1.2;
  }
}

/* ── Modal ── */
.pf-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.28s ease,
    visibility 0.28s ease;
}

.pf-modal.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.pf-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(from var(--vf-black, #141414) r g b / 0.88);
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
}

.pf-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: min(960px, 100%);
  max-height: min(92vh, 100%);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--page-bg, #141414);
  border: 1px solid rgb(from var(--vf-white, #f5f5f5) r g b / 0.12);
  border-radius: 14px;
  box-shadow: 0 28px 80px rgb(0 0 0 / 0.55);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pf-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: rgb(from var(--vf-white, #f5f5f5) r g b / 0.1);
  color: var(--vf-white, #f5f5f5);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.pf-modal__close:hover {
  background: rgb(from var(--vf-white, #f5f5f5) r g b / 0.18);
}

.pf-modal__close:focus-visible {
  outline: 2px solid rgb(from var(--vf-white, #f5f5f5) r g b / 0.45);
  outline-offset: 2px;
}

.pf-modal__media {
  position: relative;
  width: 100%;
  background: rgb(from var(--vf-black, #141414) r g b / 0.6);
}

.pf-modal__loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 5vw, 48px);
  box-sizing: border-box;
  pointer-events: none;
  background: rgb(from var(--vf-black, #141414) r g b / 0.72);
}

.pf-modal__loading[hidden] {
  display: none !important;
}

.pf-modal__loading-inner {
  width: 100%;
  max-width: min(560px, 94%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(14px, 3vw, 22px);
}

.pf-modal__loading-title {
  margin: 0;
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(32px, 6vw, 52px);
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
  color: var(--vf-white, #f5f5f5);
  line-height: 1.05;
}

.pf-modal__loading-pct {
  margin: 0;
  font-family: 'Barlow', sans-serif;
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--vf-white, #f5f5f5);
  line-height: 1;
}

.pf-modal__loading-track {
  width: 100%;
  height: clamp(14px, 2.4vw, 22px);
  border-radius: 999px;
  background: rgb(from var(--vf-white, #f5f5f5) r g b / 0.14);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgb(from var(--vf-white, #f5f5f5) r g b / 0.08);
}

.pf-modal__loading-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgb(from var(--vf-white, #f5f5f5) r g b / 0.85),
    var(--vf-white, #f5f5f5)
  );
  transition: none;
}

.pf-modal__video {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  max-height: min(62vh, 720px);
  object-fit: contain;
  vertical-align: top;
  background: #000;
}

.pf-modal__video--buffering {
  opacity: 0;
  pointer-events: none;
}

.pf-modal__video.is-hidden {
  display: none;
}

/* Grid preview <video> hoisted into lightbox — layout matches modal player, not tile absolute fill */
.pf-modal__media > .pf-item__video.pf-modal__video--from-tile {
  position: relative;
  left: auto;
  top: auto;
  width: 100%;
  max-height: min(62vh, 720px);
  height: auto;
  object-fit: contain;
  object-position: center;
  z-index: 1;
  pointer-events: auto;
  background: #000;
}

.pf-modal__placeholder {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(42vh, 360px);
  padding: 32px 20px;
  text-align: center;
  color: var(--vf-grey, #707070);
  font-size: 15px;
  line-height: 1.55;
  border-bottom: 1px solid rgb(from var(--vf-white, #f5f5f5) r g b / 0.08);
}

.pf-modal__placeholder.is-hidden {
  display: none;
}

.pf-modal__body {
  padding: 20px 22px 24px;
  padding-inline-end: max(22px, calc(44px + 8px));
}

.pf-modal__category {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--vf-grey, #707070);
  margin: 0 0 8px;
  line-height: 1.3;
}

.pf-modal__category[hidden] {
  display: none;
}

.pf-modal__title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(28px, 4vw, 40px);
  letter-spacing: 0.05em;
  color: var(--vf-white, #f5f5f5);
  line-height: 1.1;
  margin-bottom: 10px;
}

.pf-modal__desc {
  font-size: 15px;
  line-height: 1.65;
  color: var(--vf-grey, #707070);
  font-weight: 400;
}

body.is-rtl .pf-modal__close {
  right: auto;
  left: 10px;
}

body.is-rtl .pf-modal__body {
  padding-inline-end: 22px;
  padding-inline-start: max(22px, calc(44px + 8px));
}

body.is-rtl .pf-item {
  text-align: right;
}

body.is-rtl .pf-item__meta {
  align-items: flex-end;
}

@media (max-width: 639px) {
  .pf-modal__body {
    padding: 16px 18px 20px;
    padding-inline-end: max(18px, calc(44px + 8px));
  }

  .pf-modal__title {
    font-size: clamp(24px, 6vw, 32px);
  }

  .pf-modal__desc {
    font-size: 14px;
    line-height: 1.6;
  }

  body.is-rtl .pf-modal__body {
    padding-inline-end: 18px;
    padding-inline-start: max(18px, calc(44px + 8px));
  }
}

/* ── Portfolio CTA band (below grid, light surface) ── */
/* Full-bleed: .pf-main is max-width centered; negative --h-pad margins only clear
   main padding — use viewport width so the band reaches the left/right screen edges on desktop. */
.pf-cta {
  margin-top: clamp(40px, 6vw, 72px);
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  box-sizing: border-box;
  padding: clamp(48px, 7vw, 96px) max(var(--h-pad, 16px), env(safe-area-inset-right, 0px))
    clamp(56px, 9vw, 112px) max(var(--h-pad, 16px), env(safe-area-inset-left, 0px));
  background: var(--vf-white, #f5f5f5);
  color: var(--vf-black, #141414);
}

.pf-cta__inner {
  max-width: min(960px, 100%);
  margin: 0 auto;
  text-align: center;
}

.pf-cta__title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(40px, 5.5vw + 8px, 76px);
  letter-spacing: 0.05em;
  color: var(--vf-black, #141414);
  line-height: 1.08;
  margin: 0 0 clamp(18px, 3vw, 28px);
}

.pf-cta__lead {
  font-family: 'Barlow', sans-serif;
  font-size: clamp(17px, 2.2vw + 4px, 24px);
  font-weight: 400;
  line-height: 1.55;
  color: var(--vf-black, #141414);
  margin: 0 auto clamp(28px, 4vw, 40px);
  max-width: 52em;
}

.pf-cta__note {
  font-family: 'Barlow', sans-serif;
  font-size: clamp(15px, 1.5vw + 6px, 20px);
  line-height: 1.55;
  color: var(--vf-grey, #707070);
  margin: clamp(36px, 5vw, 52px) auto clamp(18px, 2.5vw, 24px);
  max-width: 42em;
}

.pf-cta__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 16px 36px;
  font-family: 'Barlow', sans-serif;
  font-size: clamp(14px, 1.1vw + 10px, 17px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 999px;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

@media (min-width: 900px) {
  .pf-cta {
    padding-left: max(clamp(24px, 4vw, 48px), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(24px, 4vw, 48px), env(safe-area-inset-right, 0px));
  }

  .pf-cta__btn {
    min-height: 60px;
    padding: 18px 44px;
  }
}

.pf-cta__btn--primary {
  background: var(--vf-black, #141414);
  color: var(--vf-white, #f5f5f5);
  border: 2px solid var(--vf-black, #141414);
}

.pf-cta__btn--primary:hover {
  background: rgb(from var(--vf-black, #141414) r g b / 0.88);
  transform: translateY(-1px);
}

.pf-cta__btn--secondary {
  background: transparent;
  color: var(--vf-black, #141414);
  border: 2px solid var(--vf-black, #141414);
}

.pf-cta__btn--secondary:hover {
  background: rgb(from var(--vf-black, #141414) r g b / 0.06);
  transform: translateY(-1px);
}

.pf-cta__btn:focus-visible {
  outline: 2px solid var(--vf-black, #141414);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .pf-cta__btn--primary:hover,
  .pf-cta__btn--secondary:hover {
    transform: none;
  }
}
