/* ==========================================================================
   Portfolio hero: "the loupe".
   A dim, drifting wall of client sites sits behind the heading. A real lemon slice follows the
   cursor like a magnifying glass; inside it the same wall shows in full colour, tinted lemon
   through the slice's translucent flesh. Decorative only (aria-hidden); the page reads the same
   without it. Loaded by portfolio.html alone.
   ========================================================================== */

.phead--loupe { position: relative; overflow: hidden; isolation: isolate; }
.phead--loupe > .wrap { position: relative; z-index: 3; }
.phead--loupe .d-hero, .phead--loupe .lead { text-shadow: 0 2px 36px rgba(11, 11, 9, .7), 0 0 2px rgba(11, 11, 9, .35); }

.pfh {
  --tw: clamp(168px, 20vw, 308px);   /* tile width */
  --gap: 14px;
  --r: 190px;                        /* lens radius, set by script from the hero's width */
  position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; contain: layout paint;
}

/* the wall: three rows, tilted a little, drifting in opposite directions */
.pfh__layer { position: absolute; inset: 0; }
.pfh__wall {
  position: absolute; left: -12%; top: 50%; width: 124%; display: grid; gap: var(--gap);
  transform: translate3d(0, calc(-50% + var(--py, 0px)), 0) rotate(-6deg); transform-origin: 50% 50%;
}
.pfh__row { display: flex; gap: var(--gap); width: max-content; will-change: transform; }
.pfh__tile { flex: none; display: block; width: var(--tw); aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: #181814; }
.pfh__tile img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* dim: the same wall, grey and low */
.pfh__dim { filter: grayscale(1) brightness(.36) contrast(1.08); }
/* where the text sits the wall is almost gone */
.pfh__shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(11, 11, 9, .96) 0%, rgba(11, 11, 9, .9) 36%, rgba(11, 11, 9, .3) 64%, rgba(11, 11, 9, 0) 100%),
    linear-gradient(0deg, #0b0b09 0%, rgba(11, 11, 9, 0) 20%),
    linear-gradient(180deg, rgba(11, 11, 9, .55) 0%, rgba(11, 11, 9, 0) 22%);
}
/* lit: full colour, only inside the lens (clip-path is set by script, in pixels) */
.pfh__lit { clip-path: circle(0 at 50% 50%); filter: brightness(1) saturate(1.1); visibility: hidden; }
.pfh.is-ready .pfh__lit { visibility: visible; }

.pfh__lens {
  position: absolute; left: 0; top: 0; z-index: 2; width: calc(var(--r) * 2 * 1.2); height: calc(var(--r) * 2 * 1.2);
  margin: calc(var(--r) * -1.2) 0 0 calc(var(--r) * -1.2); max-width: none; opacity: 0;
  transform: translate3d(70vw, 40%, 0); will-change: transform; transition: opacity .8s cubic-bezier(.16, 1, .3, 1);
}
.pfh.is-ready .pfh__lens { opacity: 1; }

/* a small label for whichever site is under the lens */
.pfh__tag {
  position: absolute; left: 0; top: 0; z-index: 2; margin: 0; padding: .5rem .8rem; border-radius: 999px; white-space: nowrap;
  font: 500 .68rem/1 "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; text-transform: uppercase;
  color: #f3f1e7; background: rgba(11, 11, 9, .82); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  opacity: 0; transform: translate3d(0, 0, 0); transition: opacity .3s;
}
.pfh__tag b { color: #efe91b; font-weight: 500; margin-left: .55em; }
.pfh__tag.is-on { opacity: 1; }

/* without script the wall is a still backdrop and the lens is not shown */
.pfh:not(.is-ready) .pfh__lens, .pfh:not(.is-ready) .pfh__tag { display: none; }
.pfh:not(.is-ready) .pfh__row { transform: translate3d(calc(var(--tw) * -.5), 0, 0); }

@media (max-width: 899px) {
  .pfh { --tw: clamp(150px, 42vw, 230px); --gap: 10px; }
  .pfh__shade {
    background:
      linear-gradient(180deg, rgba(11, 11, 9, .86) 0%, rgba(11, 11, 9, .5) 55%, rgba(11, 11, 9, .22) 100%),
      linear-gradient(0deg, #0b0b09 0%, rgba(11, 11, 9, 0) 16%);
  }
  .pfh__tag { font-size: .6rem; padding: .42rem .65rem; }
}
@media (prefers-reduced-motion: reduce) {
  .pfh__lens { transition: none; }
}
@media print { .pfh { display: none !important; } }
