/* Projects showcase: a project list on the left, one large preview stage on the right.
   Replaces the old filter row + card grid + deck controls (see projects.js). */

@property --pj-c {
  syntax: "<color>";
  inherits: true;
  initial-value: #e0b457;
}

body .work-scene {
  display: block;
  min-height: 0;
  padding-block: clamp(90px, 11vw, 130px);
}

.pj-head {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(28px, 5vw, 80px);
  align-items: end;
  margin-bottom: clamp(36px, 5vw, 60px);
}

.pj-head .section-heading {
  margin: 0;
}

.work-scene .section-heading h2 {
  max-width: 9ch;
}

.pj-lede {
  max-width: 44ch;
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.65;
}

.pj {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
}

/* ------------------------------------------------------------------ list */

.pj-list {
  display: grid;
  gap: 12px;
}

.pj-item {
  --pc: #83aaff;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 350ms ease, background 350ms ease, box-shadow 350ms ease;
}

.pj-item::before {
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--pc);
  content: "";
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity 350ms ease, transform 500ms var(--ease);
}

.pj-item.is-active {
  border-color: color-mix(in srgb, var(--pc) 45%, var(--line));
  background: linear-gradient(150deg, color-mix(in srgb, var(--pc) 10%, transparent), rgba(255, 255, 255, 0.02));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.pj-item.is-active::before {
  opacity: 1;
  transform: scaleY(1);
}

.pj-tab {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 22px 24px 22px 26px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.pj-tab:focus-visible {
  outline-offset: -4px;
}

.pj-num {
  color: var(--ink-faint);
  font: 600 13px/1 var(--mono);
  transition: color 300ms ease;
}

.pj-item.is-active .pj-num {
  color: var(--pc);
}

.pj-id {
  display: grid;
  gap: 8px;
}

.pj-name {
  color: var(--ink-soft);
  font-size: clamp(1.6rem, 2.6vw, 2.3rem);
  font-weight: 620;
  letter-spacing: -0.055em;
  line-height: 1;
  transition: color 300ms ease;
}

.pj-item:hover .pj-name,
.pj-item.is-active .pj-name {
  color: var(--ink);
}

.pj-meta {
  color: var(--ink-faint);
  font: 12px/1.3 var(--mono);
  letter-spacing: 0.04em;
}

/* autoplay progress */
.pj-bar {
  position: absolute;
  right: 26px;
  bottom: 0;
  left: 26px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: transparent;
}

.pj-item.is-active .pj-bar {
  background: rgba(255, 255, 255, 0.07);
}

.pj-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--pc);
  transform: scaleX(0);
  transform-origin: left;
}

.pj.is-auto .pj-item.is-active .pj-bar i {
  animation: pj-progress var(--pj-interval, 8000ms) linear forwards;
}

.pj.is-paused .pj-item.is-active .pj-bar i {
  animation-play-state: paused;
}

@keyframes pj-progress {
  to {
    transform: scaleX(1);
  }
}

/* ------------------------------------------------------------------ expanding panel */

.pj-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 600ms var(--ease);
}

.pj-item.is-active .pj-panel {
  grid-template-rows: 1fr;
}

.pj-panel-inner {
  display: grid;
  gap: 20px;
  min-height: 0;
  padding: 0 26px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 400ms ease, padding 600ms var(--ease);
}

.pj-item.is-active .pj-panel-inner {
  padding: 4px 26px 28px;
  opacity: 1;
  transition-delay: 120ms, 0s;
}

.pj-summary {
  max-width: 46ch;
  margin: 0;
  color: var(--ink);
  font-size: 1.04rem;
  line-height: 1.6;
}

.pj-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pj-stats li {
  display: grid;
  gap: 8px;
  padding: 14px 14px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 12, 20, 0.35);
}

.pj-stats strong {
  color: var(--pc);
  font-size: clamp(1.15rem, 1.8vw, 1.55rem);
  font-weight: 600;
  letter-spacing: -0.05em;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pj-stats span {
  color: var(--ink-faint);
  font: 12px/1.35 var(--mono);
}

.pj-how {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.65;
}

.pj-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pj-tags li {
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font: 12px/1 var(--mono);
}

.pj-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.pj-lab {
  padding: 12px 6px;
  border: 0;
  background: transparent;
  color: var(--pc);
  cursor: pointer;
  font: 600 0.95rem/1 var(--display);
  letter-spacing: -0.02em;
}

.pj-lab span {
  display: inline-block;
  transition: translate 300ms var(--ease);
}

.pj-lab:hover span,
.pj-lab:focus-visible span {
  translate: 5px 0;
}

/* ------------------------------------------------------------------ stage */

.pj-stage {
  --pj-c: #e0b457;
  --rx: 0deg;
  --ry: 0deg;
  --mx: 0;
  --my: 0;
  position: sticky;
  top: 104px;
  transition: --pj-c 700ms ease;
}

.pj-glow {
  position: absolute;
  inset: -12% -8%;
  background: radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--pj-c) 34%, transparent), transparent 62%);
  filter: blur(40px);
  opacity: 0.7;
  pointer-events: none;
}

.pj-views {
  position: relative;
  aspect-ratio: 1.8;
  transform: perspective(1400px) rotateX(var(--rx)) rotateY(var(--ry));
  transform-style: preserve-3d;
  will-change: transform;
}

.pj-view {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  scale: 0.93;
  translate: 0 22px;
  filter: blur(6px);
  transition: opacity 600ms ease, scale 800ms var(--ease), translate 800ms var(--ease), filter 600ms ease;
}

.pj-view.is-active {
  opacity: 1;
  pointer-events: auto;
  scale: 1;
  translate: 0 0;
  filter: blur(0);
}

.pj-frame {
  position: absolute;
  inset: 0 0 0 0;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  background: #0b1220;
  box-shadow:
    0 40px 100px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(7, 12, 20, 0.6),
    0 0 80px -10px color-mix(in srgb, var(--pc) 35%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.pj-frame-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #1a2438, #121a2a);
}

.pj-frame-bar i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff6b6b;
}

.pj-frame-bar i:nth-child(2) {
  background: #ffc857;
}

.pj-frame-bar i:nth-child(3) {
  background: #5fe3a1;
}

.pj-frame-bar span {
  margin-left: 12px;
  padding: 5px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink-soft);
  font: 12px/1 var(--mono);
}

.pj-frame img {
  display: block;
  width: 100%;
  height: auto; /* full width, the bottom of the page is what gets cropped */
}

.pj-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.pj-chip {
  position: absolute;
  z-index: 2;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(14, 22, 38, 0.72);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color: var(--ink);
  font: 600 13px/1 var(--display);
  letter-spacing: -0.01em;
  transform: translateZ(60px);
}

.pj-chip::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--pc);
  box-shadow: 0 0 12px var(--pc);
  content: "";
}

.pj-chip-a {
  top: -16px;
  right: 24px;
  translate: calc(var(--mx) * -14px) calc(var(--my) * -10px);
}

.pj-chip-b {
  bottom: -16px;
  left: 28px;
  translate: calc(var(--mx) * 18px) calc(var(--my) * 12px);
}

/* ------------------------------------------------------------------ footer note */

.work-scene .work-footer {
  margin-top: clamp(48px, 6vw, 72px);
}

/* ------------------------------------------------------------------ responsive + motion */

@media (max-width: 980px) {
  .pj-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .work-scene .section-heading h2 {
    max-width: none;
  }

  .pj {
    grid-template-columns: 1fr;
  }

  .pj-stage {
    position: relative;
    top: auto;
    order: -1;
    margin: 18px 0 28px;
  }
}

@media (max-width: 640px) {
  .pj-tab {
    padding: 18px 18px 18px 20px;
  }

  .pj-panel-inner,
  .pj-item.is-active .pj-panel-inner {
    padding-inline: 20px;
  }

  .pj-stats {
    grid-template-columns: 1fr;
  }

  .pj-stats li {
    grid-template-columns: auto 1fr;
    align-items: baseline;
    gap: 14px;
  }

  .pj-chip {
    padding: 8px 12px;
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pj-view,
  .pj-panel,
  .pj-panel-inner,
  .pj-item,
  .pj-item::before {
    transition: none;
  }

  .pj-view {
    filter: none;
  }

  .pj-views {
    transform: none;
  }

  .pj.is-auto .pj-item.is-active .pj-bar i {
    animation: none;
  }
}
