/* ==========================================================================
   WORKS: tabs, filters, fisheye galleries, previews, photography
   ========================================================================== */

/* ---------- Tabs (glass segmented control) ---------- */
.wk__tabs {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border-radius: var(--r-pill);
  background: rgba(var(--glass-tint), 0.5);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
  box-shadow: inset 0 1px 0 rgba(var(--glass-rim), var(--glass-rim-a)), 0 0 0 1px var(--line);
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}
.wk__tabs [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--r-pill);
  font: 600 0.9375rem / 1 var(--font-body);
  color: var(--ink-2);
  white-space: nowrap;
  transition: background-color 0.35s, color 0.3s, box-shadow 0.35s;
}
.wk__tabs [role="tab"] span { font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.wk__tabs [role="tab"]:hover { color: var(--ink); }
.wk__tabs [role="tab"][aria-selected="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 8px 22px -10px var(--glow);
}
.wk__tabs [role="tab"][aria-selected="true"] span { color: rgba(255, 255, 255, 0.75); }

.wk__panel { margin-top: 0; }
.wk__panel + .wk__panel { margin-top: clamp(64px, 8vw, 110px); padding-top: clamp(40px, 5vw, 64px); border-top: 1px solid var(--line); }
.wk__h {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  font: 700 clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem) / 1.1 var(--font-display);
  letter-spacing: -0.03em;
}
.wk__n { font: 600 0.875rem / 1 var(--font-body); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.wk__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  font: 600 0.8125rem / 1 var(--font-body);
  color: var(--ink-2);
  transition: border-color 0.3s, color 0.3s, background-color 0.3s;
}
.chip span { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chip:hover { color: var(--ink); border-color: var(--lavender); }
.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Fisheye stage ---------- */
.fe {
  --slot: 300px;
  --fe-h: clamp(300px, 34vw, 440px);
  position: relative;
  height: calc(var(--fe-h) + 60px);
  margin-top: 26px;
  outline: none;
  overflow-x: clip;
  /* fade the far edges into the page */
  -webkit-mask: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  mask: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);
  transition: opacity 0.25s;
}
.fe.is-switching { opacity: 0; }
#wk-videos .fe { --fe-h: clamp(240px, 22vw, 330px); }
.fe__stage {
  position: absolute;
  inset: 0;
  perspective: 1100px;
  perspective-origin: 50% 45%;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
}
.fe__stage.is-dragging { cursor: grabbing; }
.fe__item {
  position: absolute;
  left: 50%;
  top: 30px;
  width: var(--slot);
  height: var(--fe-h);
  margin-left: calc(var(--slot) / -2);
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  -webkit-tap-highlight-color: transparent;
}
.fe__item:focus-visible { outline: none; }
.fe__item:focus-visible .fe__card { outline: 2px solid var(--lavender); outline-offset: 4px; }

.fe__card {
  position: relative;
  display: block;
  aspect-ratio: var(--ar);
  width: 100%;
  max-height: 100%;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-3);
  box-shadow: 0 0 0 1px var(--line), 0 24px 50px -28px rgba(0, 0, 0, 0.7);
  transition: box-shadow 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
/* tall media: let height lead */
.fe__card--video[style*="9 / 16"],
.fe__card--poster { width: auto; height: 100%; max-width: 100%; }
.fe__card img { width: 100%; height: 100%; display: block; }
.fe__card--video img { object-fit: cover; }
.fe__card--poster img { object-fit: contain; background: var(--bg-2); }
.fe__card::after { /* side dimming, driven by distance from centre */
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(var(--bg-rgb), calc(var(--dim, 0) * 0.55));
  pointer-events: none;
}
.fe__item.is-center .fe__card {
  box-shadow: 0 0 0 1px var(--line-strong), 0 34px 70px -30px rgba(0, 0, 0, 0.75), 0 0 70px -10px var(--glow);
}
.fe__item.is-open .fe__card { transform: scale(1.06); }

.fe__play, .fe__zoom {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  color: #fff;
  background: rgba(20, 14, 38, 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.25);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.4s, transform 0.5s var(--ease-out);
}
.fe__play svg { width: 24px; height: 24px; margin-left: 3px; }
.fe__zoom svg { width: 22px; height: 22px; }
.fe__item.is-center .fe__play,
.fe__item.is-center .fe__zoom { opacity: 1; transform: none; }
.fe__item.is-center:hover .fe__play { transform: scale(1.1); }
.fe__tag {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: rgba(10, 8, 20, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #fff;
  font: 600 0.75rem / 1 var(--font-body);
  opacity: 0;
  transition: opacity 0.4s;
}
.fe__item.is-center .fe__tag { opacity: 1; }

/* ---------- Caption under the gallery ---------- */
.wk__cap {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.wk__info { min-height: 64px; }
.wk__cap.is-swap .wk__info { animation: cap-in 0.55s var(--ease-out); }
@keyframes cap-in { from { opacity: 0; transform: translateY(8px); } }
.wk__cat { font: 600 var(--fs-label) / 1.3 var(--font-body); color: var(--accent); }
:root[data-scheme="dark"] .wk__cat { color: var(--lavender); }
.wk__title { margin-top: 6px; font: 700 var(--fs-h3) / 1.25 var(--font-display); letter-spacing: -0.02em; }
.wk__desc { margin-top: 6px; color: var(--ink-2); font-size: 0.9375rem; max-width: 60ch; }
.wk__ctrl { display: flex; align-items: center; gap: 8px; flex: none; }
.wk__count { margin-right: 8px; font: 600 0.8125rem / 1 var(--font-body); font-variant-numeric: tabular-nums; color: var(--ink-3); }
.wk__arrow, .pv__btn, .pv__x {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: background-color 0.3s, box-shadow 0.3s, transform 0.4s var(--ease-out);
}
.wk__arrow svg, .pv__btn svg, .pv__x svg { width: 20px; height: 20px; }
.wk__arrow:hover, .pv__btn:hover, .pv__x:hover { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--lavender); }
.wk__arrow:active { transform: scale(0.94); }
.wk__empty { padding: 80px 0; text-align: center; color: var(--ink-3); }

@media (max-width: 640px) {
  .fe { --fe-h: clamp(260px, 92vw, 400px); }
  #wk-videos .fe { --fe-h: clamp(220px, 62vw, 300px); }
  .wk__cap { flex-direction: column; align-items: stretch; }
  .wk__ctrl { justify-content: space-between; }
  .wk__tabs { display: flex; }
  .wk__tabs [role="tab"] { flex: 1 1 auto; justify-content: center; padding: 0 14px; }
}

/* ---------- Modal base (video + image) ---------- */
.scroll-locked, .scroll-locked body { overflow: hidden; }
.pv, .iv {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.pv[hidden], .iv[hidden] { display: none; }
.pv__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(var(--bg-rgb), 0.78);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  backdrop-filter: blur(16px) saturate(130%);
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}
.is-open > .pv__backdrop { opacity: 1; }
.pv__panel, .iv__panel {
  position: relative;
  width: min(100%, 1180px);
  max-height: 100%;
  display: grid;
  gap: 14px;
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  transition: opacity 0.4s var(--ease-out), transform 0.55s var(--ease-out);
}
.is-open .pv__panel, .is-open .iv__panel { opacity: 1; transform: none; }

.pv__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.pv__cat { font: 600 var(--fs-label) / 1.3 var(--font-body); color: var(--accent); }
:root[data-scheme="dark"] .pv__cat { color: var(--lavender); }
.pv__title { margin-top: 4px; font: 700 clamp(1.125rem, 1rem + 0.8vw, 1.6rem) / 1.2 var(--font-display); letter-spacing: -0.02em; }
.pv__x { flex: none; background: rgba(var(--glass-tint), 0.6); }

.pv__screen {
  position: relative;
  justify-self: center;
  width: min(100%, calc((100svh - 220px) * (var(--ar-n, 1.7778))));
  aspect-ratio: var(--ar);
  max-height: calc(100svh - 220px);
  border-radius: var(--r-md);
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px var(--line-strong), 0 40px 100px -40px var(--glow), var(--shadow);
}
.pv__screen video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.pv__screen:fullscreen { border-radius: 0; max-height: none; width: 100%; }
.pv__big {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border-radius: 50%;
  color: #fff;
  background: rgba(143, 92, 255, 0.85);
  box-shadow: 0 0 0 8px rgba(143, 92, 255, 0.22), 0 18px 40px -12px rgba(143, 92, 255, 0.8);
  transition: transform 0.45s var(--ease-out), opacity 0.35s;
}
.pv__big svg { width: 32px; height: 32px; margin-left: 4px; }
.pv__big:hover { transform: scale(1.07); }
.pv.is-playing .pv__big { opacity: 0; pointer-events: none; transform: scale(0.8); }
.pv__spin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  opacity: 0;
  animation: spin 0.9s linear infinite;
  pointer-events: none;
}
.pv.is-loading .pv__spin, .iv__fig.is-loading .pv__spin { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

.pv__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: center;
  width: min(100%, 980px);
  padding: 8px 12px;
  border-radius: var(--r-pill);
  background: rgba(var(--glass-tint), 0.7);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  box-shadow: inset 0 1px 0 rgba(var(--glass-rim), var(--glass-rim-a)), 0 0 0 1px var(--line);
}
.pv__btn { flex: none; box-shadow: none; }
.pv__btn .i-pause, .pv.is-playing .pv__btn .i-play, .pv__btn .i-mute, .pv.is-muted .pv__btn .i-vol { display: none; }
.pv.is-playing .pv__btn .i-pause, .pv.is-muted .pv__btn .i-mute { display: block; }
.pv__time { flex: none; font: 600 0.8125rem / 1 var(--font-body); font-variant-numeric: tabular-nums; color: var(--ink-2); min-width: 36px; text-align: center; }
.pv__seek, .pv__vol {
  --p: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
.pv__seek { flex: 1 1 auto; }
.pv__vol { flex: 0 0 90px; --p: 100%; }
.pv__seek::-webkit-slider-runnable-track, .pv__vol::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--p), var(--line-strong) var(--p));
}
.pv__seek::-moz-range-track, .pv__vol::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line-strong); }
.pv__seek::-moz-range-progress, .pv__vol::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
.pv__seek::-webkit-slider-thumb, .pv__vol::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent);
}
.pv__seek::-moz-range-thumb, .pv__vol::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--accent); }
.pv__desc { justify-self: center; width: min(100%, 980px); color: var(--ink-2); font-size: 0.9375rem; }
@media (max-width: 600px) {
  .pv__vol { display: none; }
  .pv__bar { gap: 4px; padding: 6px 8px; }
  .pv__time[data-dur] { display: none; }
}

/* ---------- Image viewer ---------- */
.iv__fig {
  position: relative;
  justify-self: center;
  height: min(calc(100svh - 150px), 1400px);
  max-width: 100%;
  aspect-ratio: var(--ar);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-2) center / contain no-repeat;
  box-shadow: 0 0 0 1px var(--line-strong), var(--shadow), 0 40px 100px -40px var(--glow);
}
.iv__fig img { width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 0.4s; }
.iv__fig img.is-loaded { opacity: 1; }
.iv__bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; justify-self: center; width: min(100%, 980px); }
.iv__nav { display: flex; align-items: center; gap: 6px; flex: none; }
.iv.is-single [data-step], .iv.is-single #iv-count { display: none; }
.iv__exif { margin-top: 6px; font: 600 0.8125rem / 1.4 var(--font-body); color: var(--ink-3); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .iv__fig { height: auto; width: 100%; max-height: calc(100svh - 190px); }
  .iv__bar { flex-direction: column; align-items: stretch; }
}

/* ---------- Photography: focus-pull reveal ---------- */
.ph {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1.35fr);
  gap: clamp(16px, 2.5vw, 28px);
  align-items: end;
  margin-top: 26px;
}
.ph__item { margin: 0; }
.ph__frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--ar);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-3);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
.ph__frame img { width: 100%; height: 100%; object-fit: cover; transition: transform 1.2s var(--ease-out), filter 1.2s var(--ease-out); }
.ph__frame:hover img { transform: scale(1.03); }
.ph__frame:focus-visible { outline: 2px solid var(--lavender); outline-offset: 4px; }

/* Autofocus brackets that close in on the subject, then fade */
.ph__af { position: absolute; inset: 18%; pointer-events: none; }
.ph__af i { position: absolute; width: 22px; height: 22px; border: 0 solid #fff; opacity: 0; }
.ph__af i:nth-child(1) { left: 0; top: 0; border-top-width: 2px; border-left-width: 2px; }
.ph__af i:nth-child(2) { right: 0; top: 0; border-top-width: 2px; border-right-width: 2px; }
.ph__af i:nth-child(3) { left: 0; bottom: 0; border-bottom-width: 2px; border-left-width: 2px; }
.ph__af i:nth-child(4) { right: 0; bottom: 0; border-bottom-width: 2px; border-right-width: 2px; }
.ph__flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }

.js .ph__item[data-reveal] img { transform: scale(1.1); filter: blur(14px) brightness(0.7); }
.js .ph__item[data-reveal].is-in img { transform: none; filter: none; transition-delay: 0.25s; }
.js .ph__item.is-in .ph__af { animation: af-close 1.3s var(--ease-out) 0.05s both; }
.js .ph__item.is-in .ph__af i { animation: af-show 1.5s var(--ease-io) 0.05s both; }
.js .ph__item.is-in .ph__flash { animation: shutter 0.5s ease-out 1.05s both; }
.ph__item:nth-child(2).is-in img, .ph__item:nth-child(2).is-in .ph__af, .ph__item:nth-child(2).is-in .ph__af i { animation-delay: 0.35s; transition-delay: 0.55s; }
.ph__item:nth-child(2).is-in .ph__flash { animation-delay: 1.35s; }
@keyframes af-close { from { inset: 4%; } to { inset: 18%; } }
@keyframes af-show { 0% { opacity: 0; } 15%, 70% { opacity: 0.9; } 100% { opacity: 0; } }
@keyframes shutter { 0% { opacity: 0; } 25% { opacity: 0.28; } 100% { opacity: 0; } }

.ph__cap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-top: 14px; }
.ph__title { font: 700 1.0625rem / 1.3 var(--font-display); letter-spacing: -0.01em; }
.ph__exif { display: flex; flex-wrap: wrap; gap: 6px; }
.ph__exif span {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font: 600 0.75rem / 1.2 var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
@media (max-width: 760px) {
  .ph { grid-template-columns: minmax(0, 1fr); }
  .ph__item.is-tall { width: min(100%, 420px); }
}
@media (prefers-reduced-motion: reduce) {
  .js .ph__item[data-reveal] img { transform: none; filter: none; }
  .ph__af, .ph__flash { display: none; }
}
