/* PuzzleX — the portfolio, laid out like Behance: the work page's cards, a project over the grid (or on its own
   page) as a column of blocks up to 1400px wide on the project's own background, a rail of actions beside it, and
   the details, files and more projects under it. The blocks are drawn by lib/blocks.js; portfolio.js runs them. */

/* ---------- the work page: Behance's grid of covers ---------- */
.work-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr)); gap: 30px 24px; }
.work-item.is-hidden { display: none; }
.pf-card { min-width: 0; }
.pf-card-cover {
  position: relative; display: block; overflow: hidden; border-radius: 6px; aspect-ratio: 808 / 632;
  background: var(--ink-2); isolation: isolate;
}
.pf-card-cover .cover { display: block; width: 100%; height: 100%; object-fit: cover; }
.pf-card-shade {
  position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .72), rgba(0, 0, 0, 0) 55%);
  opacity: 0; transition: opacity .2s ease;
}
.pf-card-title {
  position: absolute; inset: auto 0 0 0; padding: 0 16px 14px; color: #fff; font-weight: 700; font-size: 15px; line-height: 1.35;
  opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pf-card-cover:hover .pf-card-shade, .pf-card-cover:focus-visible .pf-card-shade,
.pf-card-cover:hover .pf-card-title, .pf-card-cover:focus-visible .pf-card-title { opacity: 1; transform: none; }
.pf-card-cover:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
/* a phone has no hover: the title is always there */
@media (hover: none) { .pf-card-shade, .pf-card-title { opacity: 1; transform: none; } }
.pf-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13.5px; }
.pf-card-owner { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; }
.pf-card-owner span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-card-logo { flex: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; object-fit: contain; padding: 2px; }
.pf-card-sector { flex: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- the overlay over the grid ---------- */
.pf-modal { position: fixed; inset: 0; z-index: 500; background: rgba(8, 8, 9, .93); opacity: 0; transition: opacity .2s ease; }
.pf-modal.is-open { opacity: 1; }
.pf-modal[hidden] { display: none; }
.pf-modal-scroll { position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; padding: 30px clamp(12px, 5.5vw, 84px) 0; scrollbar-color: rgba(255, 255, 255, .25) transparent; }
.pf-modal-body { min-height: 100%; }
.pf-modal-close, .pf-modal-nav {
  position: fixed; z-index: 2; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: #fff; transition: background .15s;
}
.pf-modal-close { top: 10px; inset-inline-end: 10px; width: 44px; height: 44px; }
.pf-modal-nav { top: 50%; width: 48px; height: 48px; margin-top: -24px; background: rgba(255, 255, 255, .06); }
.pf-modal-nav.prev { inset-inline-start: 12px; }
.pf-modal-nav.next { inset-inline-end: 12px; }
.pf-modal-nav[hidden] { display: none; }
.pf-modal-close:hover, .pf-modal-nav:hover { background: rgba(255, 255, 255, .14); }
.pf-modal-close:focus-visible, .pf-modal-nav:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.pf-modal-close svg, .pf-modal-nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pf-modal-wait { display: grid; place-items: center; min-height: 70vh; }
.pf-modal-wait span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .18); border-top-color: #fff; animation: pf-spin .8s linear infinite; }
@keyframes pf-spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) { .pf-modal-nav { display: none; } .pf-modal-scroll { padding-top: 56px; } }

/* ---------- a project's own page ---------- */
.pf-page { padding-top: 104px; }
.pf-page .pf { padding: 0 clamp(14px, 4vw, 64px); }

/* ---------- the project: head, canvas and rail ---------- */
.pf { --pf-w: 1400px; --pf-rail: 70px; }
.pf-head, .pf-stage, .pf-info, .pf-more { max-width: calc(var(--pf-w) + var(--pf-rail) + 24px); margin-inline: auto; }
.pf-head { display: flex; align-items: center; gap: 14px; padding-inline-end: calc(var(--pf-rail) + 24px); margin-bottom: 18px; }
.pf-head-logo, .pf-rail-logo, .pf-info-logo { flex: none; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #fff; }
.pf-head-logo { width: 40px; height: 40px; }
.pf-head-logo img, .pf-rail-logo img, .pf-info-logo img { width: 80%; height: 80%; object-fit: contain; }
.pf-head-text { min-width: 0; }
.pf-title { font-size: clamp(17px, 1.5vw, 21px); font-weight: 800; line-height: 1.3; color: #fff; }
.pf-owner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; font-size: 14px; color: var(--muted); }
.pf-owner span:first-child { color: var(--text); font-weight: 600; }
.pf-owner a:hover { color: var(--text); text-decoration: underline; }

.pf-stage { display: grid; grid-template-columns: minmax(0, var(--pf-w)) var(--pf-rail); justify-content: center; gap: 24px; align-items: start; }
.pf-canvas {
  display: flex; flex-direction: column; gap: var(--pf-gap, 0px); min-width: 0; overflow: hidden;
  background: var(--pf-bg, #fff); color: var(--pf-fg, #191919);
}
.pf-rail { position: sticky; top: 30px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.pf-rail-logo { width: 48px; height: 48px; box-shadow: 0 0 0 3px rgba(255, 255, 255, .1); transition: box-shadow .15s; }
.pf-rail-logo:hover { box-shadow: 0 0 0 3px var(--lime); }
.pf-rail-btn {
  display: grid; justify-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 11.5px; font-weight: 600; text-align: center; cursor: pointer;
}
.pf-rail-btn svg {
  box-sizing: content-box; width: 20px; height: 20px; padding: 12px; border-radius: 50%; background: rgba(255, 255, 255, .1);
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: background .15s, color .15s;
}
.pf-rail-btn:hover svg { background: rgba(255, 255, 255, .2); }
.pf-rail-hire svg { background: var(--lime); color: var(--ink); }
.pf-rail-hire:hover svg { background: #e6ff4d; }
.pf-rail-btn.is-done svg { background: #2fbf71; color: #fff; }
.pf-rail-btn:focus-visible, .pf-rail-logo:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; border-radius: 12px; }
@media (max-width: 900px) {
  .pf-head { padding-inline-end: 0; }
  .pf-stage { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .pf-rail { position: static; flex-direction: row; justify-content: center; gap: 26px; }
  .pf-rail-logo { display: none; }
}

/* ---------- the blocks ---------- */
.pf-block { margin: 0; min-width: 0; }
.pf-media { display: block; max-width: 100%; height: auto; }
.pf-image .pf-media, .pf-video .pf-media { margin-inline: auto; }
.pf-video video.pf-media { width: 100%; background: #000; max-height: 90vh; }
.pf-video video.pf-loop { width: auto; background: none; max-height: none; }
.pf-caption { padding: 12px clamp(18px, 6%, 90px) 4px; font-size: 14px; line-height: 1.6; opacity: .78; }
.pf-voice { display: grid; gap: 8px; padding: 14px clamp(18px, 6%, 90px); font-size: 13px; opacity: .85; }
.pf-voice audio, .pf-audio audio { display: block; width: 100%; min-height: 44px; }
.pf-error { padding: 24px; font-size: 14px; opacity: .75; text-align: center; }

/* text */
.pf-text { padding: clamp(28px, 4.5vw, 72px) clamp(20px, 9%, 150px); font-size: clamp(16px, 1.2vw, 19px); line-height: 1.75; overflow-wrap: anywhere; }
.pf-text > * + * { margin-top: .8em; }
.pf-text h2 { font-size: 1.9em; line-height: 1.25; font-weight: 800; }
.pf-text h3 { font-size: 1.35em; line-height: 1.35; font-weight: 700; }
.pf-text blockquote { padding-inline-start: 1em; border-inline-start: 3px solid currentColor; font-size: 1.15em; opacity: .9; }
.pf-text ul, .pf-text ol { padding-inline-start: 1.4em; }
.pf-text li + li { margin-top: .3em; }
.pf-text a { text-decoration: underline; text-underline-offset: 3px; }
.pf-text .a-start { text-align: start; } .pf-text .a-center { text-align: center; } .pf-text .a-end { text-align: end; } .pf-text .a-justify { text-align: justify; }
.pf-text .fs-s { font-size: .82em; } .pf-text .fs-l { font-size: 1.3em; } .pf-text .fs-xl { font-size: 1.75em; line-height: 1.3; }

/* photo grid: rows of the same height, each photo as wide as its shape asks */
.pf-grid { display: flex; flex-direction: column; gap: var(--pf-gap, 0px); }
.pf-row { display: flex; gap: var(--pf-gap, 0px); }
.pf-cell { flex-basis: 0; min-width: 0; overflow: hidden; }
.pf-cell .pf-media { width: 100%; height: 100%; object-fit: cover; }

/* frames: video, audio, embeds, prototypes, 3D from Sketchfab */
.pf-frame { width: 100%; background: rgba(0, 0, 0, .04); }
.pf-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.pf-audio-box { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px 16px; padding: clamp(22px, 3vw, 40px) clamp(18px, 6%, 90px); }
.pf-audio-box audio { grid-column: 1 / -1; }
.pf-audio-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: currentColor; }
.pf-audio-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--pf-bg, #fff); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pf-audio-name { font-weight: 700; font-size: 1.05em; }
.pf-audio .pf-frame { background: none; padding: 16px clamp(18px, 6%, 90px); }
.pf-proto { padding: clamp(22px, 3.5vw, 56px) clamp(14px, 5%, 80px); }
.pf-device { border-radius: 14px; overflow: hidden; box-shadow: 0 18px 50px rgba(0, 0, 0, .22), 0 0 0 1px rgba(0, 0, 0, .08); background: #fff; }
.pf-proto-open { display: table; margin: 16px auto 0; font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* 3D */
.pf-model-box { position: relative; aspect-ratio: 16 / 10; background: var(--pf-model-bg, transparent); }
.pf-model-box model-viewer { position: absolute; inset: 0; width: 100%; height: 100%; --poster-color: transparent; }
.pf-model-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pf-model-box.is-live .pf-model-poster { display: none; }
.pf-model-hint {
  position: absolute; z-index: 1; inset: auto 0 14px; margin: auto; width: max-content; max-width: calc(100% - 28px);
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; pointer-events: none;
  background: rgba(0, 0, 0, .62); color: #fff; font-size: 12.5px;
}
.pf-model-hint svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

/* the photo set (Lightroom's place): one photo at a time, arrows, thumbnails, full screen */
.pf-lr-stage { position: relative; background: #0d0d0e; }
.pf-lr-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; list-style: none; outline: none; }
.pf-lr-track::-webkit-scrollbar { display: none; }
.pf-lr-track:focus-visible { box-shadow: inset 0 0 0 2px var(--lime); }
.pf-lr-slide { flex: 0 0 100%; scroll-snap-align: center; aspect-ratio: 3 / 2; display: grid; place-items: center; }
.pf-lr-slide .pf-media { width: 100%; height: 100%; object-fit: contain; }
.pf-lr-btn, .pf-lr-full {
  position: absolute; display: grid; place-items: center; border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(0, 0, 0, .5); color: #fff; transition: background .15s, opacity .15s;
}
.pf-lr-btn { top: 50%; width: 44px; height: 44px; margin-top: -22px; }
.pf-lr-btn.prev { inset-inline-start: 14px; }
.pf-lr-btn.next { inset-inline-end: 14px; }
[dir="rtl"] .pf-lr-btn svg { transform: scaleX(-1); }
.pf-lr-btn:disabled { opacity: 0; pointer-events: none; }
.pf-lr-full { top: 14px; inset-inline-end: 14px; width: 38px; height: 38px; }
.pf-lr-btn:hover, .pf-lr-full:hover { background: rgba(0, 0, 0, .78); }
.pf-lr-btn svg, .pf-lr-full svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pf-lr-count { position: absolute; bottom: 14px; inset-inline-start: 14px; padding: 4px 11px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-family: var(--lat); font-size: 12.5px; direction: ltr; }
.pf-lr-thumbs { display: flex; gap: 6px; padding: 10px; overflow-x: auto; scrollbar-width: thin; background: #0d0d0e; }
.pf-lr-thumb { flex: none; width: 66px; height: 48px; padding: 0; border: 0; border-radius: 3px; overflow: hidden; background: #222; cursor: pointer; opacity: .5; transition: opacity .15s; }
.pf-lr-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-lr-thumb:hover, .pf-lr-thumb[aria-current] { opacity: 1; }
.pf-lr-thumb[aria-current] { box-shadow: inset 0 0 0 2px #fff; }
.pf-lr .pf-caption { background: #0d0d0e; color: #eee; margin: 0; padding-bottom: 14px; }
.pf-lr-stage:fullscreen { background: #000; display: flex; align-items: center; }
.pf-lr-stage:fullscreen .pf-lr-track { width: 100%; height: 100%; }
.pf-lr-stage:fullscreen .pf-lr-slide { aspect-ratio: auto; height: 100%; }

/* PDF */
.pf-pdf iframe { display: block; width: 100%; height: clamp(420px, 80vh, 900px); border: 0; background: #fff; }
.pf-pdf-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px clamp(18px, 4%, 40px); }
.pf-pdf-mark { font-family: var(--lat); font-weight: 900; letter-spacing: .08em; direction: ltr; }

/* ---------- under the project: its details, then more projects ---------- */
.pf-info { padding: 60px 0 30px; }
.pf-info-top { display: grid; justify-items: center; gap: 10px; text-align: center; }
.pf-info-title { font-size: clamp(22px, 2.2vw, 30px); font-weight: 800; color: #fff; max-width: 32ch; }
.pf-info-cta { display: grid; place-items: center; width: 78px; height: 78px; margin-top: 14px; border-radius: 50%; background: var(--lime); color: var(--ink); transition: transform .2s ease, box-shadow .2s; }
.pf-info-cta:hover { transform: scale(1.06); box-shadow: 0 0 0 8px rgba(215, 255, 0, .14); }
.pf-info-cta:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.pf-info-cta svg { width: 32px; height: 32px; fill: currentColor; }
.pf-info-cta-label { font-size: 14px; font-weight: 700; }
.pf-published { font-size: 13px; color: var(--muted); }
.pf-info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 46px; }
.pf-info-owner, .pf-info-meta { padding: 26px; border-radius: 8px; background: var(--ink-2); border: 1px solid var(--line); }
.pf-info-meta:empty, .pf-info-meta:not(:has(.pf-meta-part)) { display: none; }
.pf-info-grid:not(:has(.pf-meta-part)) { grid-template-columns: minmax(0, 1fr); max-width: 760px; margin-inline: auto; }
.pf-info-who { display: flex; align-items: center; gap: 14px; }
.pf-info-logo { width: 60px; height: 60px; }
.pf-info-client { font-size: 18px; font-weight: 800; }
.pf-info-sector { margin-top: 2px; font-size: 13.5px; color: var(--muted); }
.pf-info-summary { margin-top: 18px; font-size: 15px; line-height: 1.8; color: var(--muted); white-space: pre-line; }
.pf-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; list-style: none; }
.pf-chips li > * { display: inline-block; padding: 6px 13px; border-radius: 999px; background: rgba(255, 255, 255, .07); font-size: 13px; }
.pf-chips a:hover { background: rgba(255, 255, 255, .14); }
.pf-meta-part + .pf-meta-part { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.pf-meta-part h3 { font-size: 12.5px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.pf-meta-part .pf-chips { margin-top: 12px; }
.pf-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; list-style: none; }
.pf-tools li { padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.pf-credits { display: grid; gap: 10px; margin-top: 12px; list-style: none; }
.pf-credits li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.pf-credit-name { font-weight: 700; }
.pf-credit-role { font-size: 13px; color: var(--muted); }
.pf-assets { display: grid; gap: 8px; margin-top: 12px; list-style: none; }
.pf-asset { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 8px; background: rgba(255, 255, 255, .05); transition: background .15s; }
.pf-asset:hover { background: rgba(255, 255, 255, .1); }
.pf-asset svg { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pf-asset-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-asset-size { flex: none; font-size: 12px; color: var(--muted); direction: ltr; }
@media (max-width: 760px) { .pf-info-grid { grid-template-columns: minmax(0, 1fr); } }

.pf-more { padding: 30px 0 70px; }
.pf-more-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.pf-more-head h2 { font-size: 18px; font-weight: 800; }
.pf-more-head a { font-size: 14px; color: var(--muted); }
.pf-more-head a:hover { color: var(--text); }
.pf-more-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; list-style: none; }
@media (max-width: 1100px) { .pf-more-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .pf-more-grid { grid-template-columns: minmax(0, 1fr); } }

@media (prefers-reduced-motion: reduce) {
  .pf-modal, .pf-card-shade, .pf-card-title, .pf-info-cta { transition: none; }
}
