/* ==========================================================================
   Selected-work horizontal cards + detail panel.
   Loaded only on pages that pass `workPanel` to BaseLayout.

   The detail panel is a right-side overlay drawer by default (backdrop,
   fixed, slides in). On viewports wide enough to give it real room
   (>=1280px), the whole page splits into two columns instead: the
   existing page content shifts left (still centered within its own
   column) and the panel occupies the right column at full height,
   with no backdrop, border or shadow — just a continuation of the page.
   ========================================================================== */

/* ---------- Page-level split (inline mode only) ---------- */

@media (min-width: 1280px) {
  body[data-wp-mode="inline"] .viewport-split {
    display: flex;
    align-items: stretch;
  }

  body[data-wp-mode="inline"] .page-shell {
    flex: 1 1 100%;
    min-width: 0;
    transition: flex-basis .45s var(--ease);
  }

  body[data-wp-mode="inline"][data-wp-open] .page-shell {
    flex-basis: 50%;
  }

  body[data-wp-mode="inline"] .wp-aside {
    display: block;
    position: static;
    flex: 0 0 0%;
    min-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: flex-basis .45s var(--ease), opacity .3s var(--ease);
  }

  body[data-wp-mode="inline"][data-wp-open] .wp-aside {
    flex-basis: 50%;
    opacity: 1;
    overflow: visible;
  }

  body[data-wp-mode="inline"] .wp-panel__backdrop { display: none; }

  body[data-wp-mode="inline"] .wp-panel__sheet {
    position: sticky;
    top: 0;
    right: auto;
    height: 100vh;
    width: auto;
    max-width: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fff;
    border-left: 1px solid var(--line);
    box-shadow: none;
    padding: clamp(28px, 4vw, 48px) clamp(24px, 4vw, 48px) 56px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  body[data-wp-mode="inline"] .wp-panel__sheet::-webkit-scrollbar {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-shell,
  .wp-aside { transition: none; }
}

/* ---------- Selected work grid ---------- */

.wp-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  list-style: none;
}

@media (min-width: 640px) {
  .wp-row { grid-template-columns: repeat(2, 1fr); }
}

.wp-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 10px 24px -18px color-mix(in srgb, var(--ink) 40%, transparent);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}

.wp-card:hover,
.wp-card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 18px 34px -18px color-mix(in srgb, var(--ink) 50%, transparent);
  border-color: color-mix(in srgb, var(--link) 45%, var(--line));
}

.wp-card__thumb {
  display: block;
  aspect-ratio: 16 / 9;
  background: var(--surface);
  overflow: hidden;
}

.wp-card__thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; }

.wp-card__thumb .dither,
.wp-panel__hero .dither { display: block; }

.wp-card__body {
  flex: 1;
  min-height: 0;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wp-card__title {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--text-title);
  color: var(--ink);
}

.wp-card__blurb {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  font-size: var(--text-sm2);
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Carousel arrows ---------- */

.wp-carousel__arrow {
  position: absolute;
  top: calc(var(--gutter) + 60px);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 8px 20px -12px color-mix(in srgb, var(--ink) 45%, transparent);
  opacity: 1;
  transition: opacity .25s var(--ease), transform .2s var(--ease), box-shadow .25s var(--ease);
}

.wp-carousel__arrow:hover { box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--ink) 55%, transparent); transform: translateY(-1px); }
.wp-carousel__arrow:disabled { opacity: 0; pointer-events: none; }

@media (max-width: 640px) {
  .wp-carousel__arrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .wp-card,
  .wp-carousel__arrow { transition: none; }
  .wp-card:hover, .wp-card:focus-visible { transform: none; }
}

/* ---------- Story thumbnail row: same arrow + fade treatment as the cards row ---------- */

.wp-story__nav {
  position: relative;
  margin-top: 14px;
}

.wp-story__nav .wp-story__dots { margin-top: 0; }

.wp-story__nav .wp-carousel__arrow {
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
}

.wp-story__nav .wp-carousel__arrow:hover { transform: translateY(-50%) translateY(-1px); }
.wp-story__arrow--prev { left: -4px; }
.wp-story__arrow--next { right: -4px; }

/* ---------- Detail panel: overlay mode (default, narrow/medium screens) ---------- */

.wp-aside { display: none; }
.wp-aside[data-open] { display: block; position: fixed; inset: 0; z-index: 60; }

.wp-panel__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: color-mix(in srgb, var(--ink) 55%, transparent);
  cursor: default;
}

.wp-panel__sheet {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 90vw;
  overflow-y: auto;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 60px -24px color-mix(in srgb, var(--ink) 35%, transparent);
  padding: clamp(24px, 4vw, 40px) clamp(20px, 4vw, 32px) 48px;
}

.wp-panel__content {
  max-width: 640px;
  margin: 0 auto;
}

.wp-panel__close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}

.wp-panel__close:hover { background: var(--surface); color: var(--ink); }

body.has-wp-panel { overflow: hidden; }

/* ---------- Panel content ---------- */

.wp-panel__title {
  margin-top: 8px;
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--h2-card);
  color: var(--ink);
}

.wp-panel__desc {
  margin-top: 14px;
  font-size: var(--text-sm2);
  line-height: 1.6;
  color: var(--muted);
}

.wp-stats {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm2);
  color: var(--ink);
}

.wp-stats__item { display: inline-flex; align-items: center; gap: 5px; }
.wp-stats__star { width: 15px; height: 15px; color: #f0ad4e; }
.wp-stats__muted { color: var(--muted); }
.wp-stats__divider { color: var(--faint); }

.wp-used-by {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.wp-used-by__logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 22px;
}

.wp-used-by__logos li {
  display: flex;
  align-items: center;
}

.wp-used-by__logos img {
  height: 18px;
  width: auto;
  max-width: 90px;
  object-fit: contain;
}

.wp-used-by__note {
  margin-top: 10px;
  font-size: var(--text-2xs);
  color: var(--faint);
}

.wp-panel__details {
  margin-top: 14px;
  padding-left: 1.15em;
  font-size: var(--text-sm2);
  line-height: 1.6;
  color: var(--muted);
}

.wp-panel__details li { margin-bottom: 4px; }

.wp-panel__notes {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: var(--text-sm2);
  line-height: 1.65;
  color: var(--muted);
}

.wp-panel__notes-label {
  color: var(--ink);
  font-weight: 600;
}

.wp-panel__nda {
  margin-top: 22px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: var(--text-sm2);
  line-height: 1.55;
  color: var(--muted);
}

.wp-panel__nda-icon { width: 16px; height: 16px; flex: 0 0 auto; margin-top: 2px; color: var(--faint); }

.wp-case {
  margin-top: 26px;
}

.wp-case.wp-case--highlight {
  padding: 20px 20px 22px;
  border: 1px solid color-mix(in srgb, var(--link) 30%, var(--line));
  border-left: 3px solid var(--link);
  border-radius: 10px;
  background: color-mix(in srgb, var(--link) 6%, var(--paper));
}

.wp-case--highlight .wp-case__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--link);
}

.wp-case--highlight .wp-case__heading-icon { width: 18px; height: 18px; flex: 0 0 auto; }

.wp-case:first-of-type { margin-top: 22px; }

.wp-case__heading {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--text-title);
  color: var(--ink);
}

.wp-case__p {
  margin-top: 10px;
  font-size: var(--text-sm2);
  line-height: 1.65;
  color: var(--muted);
}

.wp-case__list {
  margin-top: 10px;
  padding-left: 1.15em;
  font-size: var(--text-sm2);
  line-height: 1.65;
  color: var(--muted);
}

.wp-case__list li { margin-bottom: 6px; }

.wp-case__shot {
  margin-top: 14px;
  position: relative;
  aspect-ratio: 16 / 9;
  max-width: 380px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wp-case__shot .dither { position: absolute; inset: 0; display: block; }

.wp-case__shot-label {
  position: relative;
  z-index: 1;
  font-family: var(--pixel);
  font-size: var(--text-2xs);
  color: var(--faint);
}

.wp-case__image {
  margin-top: 14px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}

.wp-case__image img { display: block; width: 100%; height: auto; }

.wp-case__footnote {
  margin-top: 10px;
  font-size: var(--text-2xs);
  line-height: 1.5;
  color: var(--faint);
}

.wp-facts {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.wp-facts__item {
  padding: 12px 14px;
  border-left: 1px solid var(--line);
}

.wp-facts__item:first-child {
  border-left: 0;
}

.wp-meta-stack {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wp-meta-stack__label {
  font-family: var(--sans);
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.wp-meta-stack__value {
  margin-top: 4px;
  font-size: var(--text-sm2);
  line-height: 1.4;
  color: var(--ink);
}

.wp-facts__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: var(--text-2xs);
  font-weight: 500;
  color: var(--muted);
}

.wp-facts__icon { width: 14px; height: 14px; flex: 0 0 auto; color: var(--muted); }

.wp-facts__value {
  margin-top: 4px;
  font-size: var(--text-sm2);
  line-height: 1.6;
  color: var(--muted);
}

.wp-case--first { margin-top: 26px; }

.wp-panel__hero {
  margin-top: 22px;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.wp-panel__cta {
  margin-top: 22px;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  transition: text-decoration-color var(--speed) var(--ease);
}

.wp-panel__cta:hover {
  text-decoration-color: var(--ink);
}

.wp-panel__cta svg { color: inherit; }

.wp-gallery {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wp-gallery__group {
  padding: 26px 0;
}

.wp-gallery__group:first-child {
  padding-top: 0;
}

.wp-gallery__name {
  font-family: var(--display);
  font-weight: 600;
  font-size: var(--text-title);
  color: var(--ink);
}

.wp-gallery__desc {
  margin-top: 6px;
  font-size: var(--text-sm2);
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- Story-style carousel: hero slide + caption + progress dots ---------- */

.wp-story { margin-top: 18px; }

.wp-story__stage {
  position: relative;
  height: clamp(280px, 34vw, 460px);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: zoom-in;
}

.wp-story__zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 65%, transparent);
  color: #fff;
  opacity: .85;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}

.wp-story__zoom:hover { opacity: 1; transform: scale(1.06); }

.wp-story__slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .5s var(--ease);
}

.wp-story__slide[data-active] { opacity: 1; }

.wp-story__slide img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.wp-story__caption {
  margin-top: 0;
  min-height: 1.4em;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: var(--paper);
  font-size: var(--text-2xs);
  line-height: 1.4;
  color: var(--faint);
  text-align: center;
}

.wp-story__dots {
  margin-top: 14px;
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  padding: 0 4px 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%);
}

.wp-story__dots::-webkit-scrollbar { display: none; }

.wp-story__dots[data-at-start] {
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 20px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 20px), transparent 100%);
}

.wp-story__dots[data-at-end] {
  mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 20px, #000 100%);
}

.wp-story__dots[data-at-start][data-at-end] {
  mask-image: none;
  -webkit-mask-image: none;
}

.wp-story__dot {
  position: relative;
  width: 136px;
  flex: 0 0 auto;
  padding: 0;
  opacity: .5;
  transition: opacity .25s var(--ease), transform .2s var(--ease);
}

.wp-story__dot[data-active] { opacity: 1; }
.wp-story__dot:hover { opacity: .8; transform: translateY(-2px); }
.wp-story__dot[data-active]:hover { opacity: 1; }

.wp-story__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.wp-story__thumb img { width: 100%; height: 100%; object-fit: cover; }

.wp-story__bar {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 4px;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 35%, transparent);
}

.wp-story__bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--story-accent, #ccff00);
  box-shadow: 0 0 6px color-mix(in srgb, var(--story-accent, #ccff00) 70%, transparent);
}

.wp-story__bar-fill.is-animating {
  transition: width 5s linear;
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .wp-story__slide,
  .wp-story__dot { transition: none; }
  .wp-story__bar-fill.is-animating { transition: none; width: 100%; }
}

/* ---------- Full-screen lightbox / gallery viewer ---------- */

.wp-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px clamp(20px, 6vw, 72px) calc(20px + env(safe-area-inset-bottom));
}

.wp-lightbox[data-open] { display: flex; }

.wp-lightbox__backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: color-mix(in srgb, #fff 60%, transparent);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  cursor: zoom-out;
}

.wp-lightbox__stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 24px);
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.wp-lightbox__frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(1400px, 84vw);
  max-height: 100%;
  pointer-events: none;
}

.wp-lightbox__frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 40px 90px -24px color-mix(in srgb, var(--ink) 30%, transparent);
}

.wp-lightbox__arrow {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, #fff 75%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--ink) 30%, transparent);
  transition: background-color .2s var(--ease), transform .15s var(--ease);
}

.wp-lightbox__arrow:hover { background: #fff; transform: scale(1.05); }
.wp-lightbox__arrow[hidden] { display: none; }

.wp-lightbox__caption {
  position: relative;
  z-index: 1;
  margin-top: 16px;
  font-size: var(--text-sm2);
  color: var(--muted);
  text-align: center;
  max-width: 60ch;
}

.wp-lightbox__thumbs {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding: 4px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.wp-lightbox__thumbs::-webkit-scrollbar { display: none; }
.wp-lightbox__thumbs[hidden] { display: none; }

.wp-lightbox__thumb {
  flex: 0 0 auto;
  width: 128px;
  height: 88px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  opacity: .5;
  transition: opacity .2s var(--ease), border-color .2s var(--ease);
}

.wp-lightbox__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.wp-lightbox__thumb:hover { opacity: .8; }
.wp-lightbox__thumb[data-active] { opacity: 1; border-color: var(--ink); }

.wp-lightbox__close {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in srgb, #fff 75%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: var(--text-xl);
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--ink) 30%, transparent);
  transition: background-color .2s var(--ease);
}

.wp-lightbox__close:hover { background: #fff; }

body.has-wp-lightbox { overflow: hidden; }
