/* Project browser. A listing on the left, a preview pane on the right that
   swaps on hover. On narrow screens the panes open under their rows. */

.pj {
  border: 1px solid #262626;
  background: #0c0c0c;
}

.pj-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #262626;
  font-size: 0.75rem;
  color: #737373;
}

.pj-bar b {
  font-weight: 400;
  color: #d4d4d4;
}

.pj-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-rows: repeat(var(--n), auto) 1fr;
}

/* Rows ------------------------------------------------------------------ */

.pj-row {
  grid-column: 1;
  position: relative;
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr);
  align-items: baseline;
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 0.9rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #1a1a1a;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.2s;
}

.pj-row::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e5e5e5;
  transform: scaleY(0);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pj-idx {
  font-size: 0.7rem;
  color: #525252;
  transition: color 0.2s;
}

.pj-name {
  font-size: 0.95rem;
  color: #a3a3a3;
  transition: color 0.2s;
}

.pj-award {
  margin-left: 0.35rem;
  font-size: 0.7rem;
  color: #737373;
  vertical-align: 0.1em;
  transition: color 0.2s;
}

.pj-row[aria-expanded="true"] .pj-award {
  color: #e5e5e5;
}

.pj-sub {
  grid-column: 2;
  margin-top: 0.15rem;
  font-size: 0.72rem;
  color: #525252;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s;
}

.pj-row:hover {
  background: #111;
}

.pj-row:hover .pj-name {
  color: #e5e5e5;
}

.pj-row:focus-visible {
  outline: 1px solid #737373;
  outline-offset: -1px;
}

.pj-row[aria-expanded="true"] {
  background: #141414;
}

.pj-row[aria-expanded="true"]::before {
  transform: scaleY(1);
}

.pj-row[aria-expanded="true"] .pj-idx,
.pj-row[aria-expanded="true"] .pj-name {
  color: #fff;
}

.pj-row[aria-expanded="true"] .pj-sub {
  color: #a3a3a3;
}

.pj-hint {
  grid-column: 1;
  grid-row: -2 / -1;
  align-self: end;
  padding: 1rem 0.9rem;
  font-size: 0.7rem;
  color: #404040;
}

/* Pane ------------------------------------------------------------------ */

/* Every pane shares one cell, so the box is as tall as the longest project
   and never jumps while browsing */
.pj-pane {
  grid-column: 2;
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  background: #0f0f0f;
  border-left: 1px solid #262626;
  visibility: hidden;
  opacity: 0;
}

.pj-pane.is-open {
  visibility: visible;
  opacity: 1;
}

.pj-shot {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0a0a0a;
  border-bottom: 1px solid #262626;
}

.pj-shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.4s, transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pj-shot img.pj-contain {
  object-fit: contain;
}

.pj-shot img.pj-invert {
  filter: invert(1) hue-rotate(180deg);
}

/* Scanlines */
.pj-shot::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  transition: opacity 0.5s;
}

/* The bright edge that rides the image in */
.pj-shot::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  z-index: 2;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 14px 2px rgba(255, 255, 255, 0.35);
  opacity: 0;
}

.pj-shot:hover img {
  filter: brightness(1.08);
  transform: scale(1.02);
}

.pj-shot:hover img.pj-invert {
  filter: invert(1) hue-rotate(180deg) brightness(1.08);
}

.pj-shot:hover::before {
  opacity: 0.4;
}

.pj-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 1.1rem 1.25rem 1.2rem;
}

.pj-title {
  font-size: 1.3rem;
  line-height: 1.3;
  font-weight: 600;
  color: #fff;
}

.pj-title::after {
  content: "_";
  margin-left: 0.1em;
  animation: xp-caret 1s steps(1) infinite;
}

.pj-body .xp-points {
  margin-top: 0.75rem;
}

.pj-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.pj-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.75rem;
  color: #d4d4d4;
  border: 1px solid #404040;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.pj-links a:hover {
  background: #fff;
  color: #000;
  border-color: #fff;
}

/* Opening a pane -------------------------------------------------------- */

.pj-pane.is-open .pj-shot img {
  animation: pj-develop 0.6s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}

.pj-pane.is-open .pj-shot::after {
  animation: pj-edge 0.6s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}

.pj-pane.is-open .pj-title {
  animation: pj-type calc(var(--len) * 24ms) steps(var(--len)) 0.12s both;
}

.pj-pane.is-open .xp-points li,
.pj-pane.is-open .xp-foot,
.pj-pane.is-open .pj-links {
  animation: pj-rise 0.4s ease-out both;
}

.pj-pane.is-open .xp-points li:nth-child(1) { animation-delay: 0.18s; }
.pj-pane.is-open .xp-points li:nth-child(2) { animation-delay: 0.24s; }
.pj-pane.is-open .xp-points li:nth-child(3) { animation-delay: 0.3s; }
.pj-pane.is-open .xp-points li:nth-child(4) { animation-delay: 0.36s; }
.pj-pane.is-open .xp-foot { animation-delay: 0.42s; }
.pj-pane.is-open .pj-links { animation-delay: 0.46s; }

@keyframes pj-develop {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes pj-edge {
  0% { top: 0; opacity: 1; }
  85% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

@keyframes pj-type {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes pj-rise {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

/* Narrow screens: an accordion ------------------------------------------ */

@media (max-width: 767px) {
  .pj-grid {
    display: block;
  }

  .pj-pane {
    display: none;
    border-left: 0;
    border-bottom: 1px solid #262626;
  }

  .pj-pane.is-open {
    display: flex;
  }

  .pj-hint {
    display: none;
  }

  .pj-pane.is-open .pj-title {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pj-pane.is-open .pj-shot img,
  .pj-pane.is-open .pj-shot::after,
  .pj-pane.is-open .pj-title,
  .pj-pane.is-open .xp-points li,
  .pj-pane.is-open .xp-foot,
  .pj-pane.is-open .pj-links,
  .pj-title::after {
    animation: none;
  }

  .pj-shot:hover img {
    transform: none;
  }
}
