/* The project gallery is repeated for desktop, tablet, and mobile. */
:is(#gallery, #gallery--t, #gallery--m) {
  background-color: #101319 !important;
  background-image:
    radial-gradient(ellipse at 12% 0%, rgb(216 65 28 / 0.12), transparent 56%),
    linear-gradient(rgb(255 255 255 / 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.026) 1px, transparent 1px) !important;
  background-size: auto, 32px 32px, 32px 32px !important;
}

:is(#gallery, #gallery--t, #gallery--m) > .wrap > h2 {
  text-wrap: balance;
}

:is(#gallery, #gallery--t, #gallery--m) > .wrap > p {
  color: #bbc0ca !important;
}

:is(#gallery, #gallery--t, #gallery--m) .ep-bar {
  gap: 10px 18px !important;
  margin-top: 20px !important;
}

:is(#gallery, #gallery--t, #gallery--m) .ep-bar > span {
  color: #afb6c2 !important;
  line-height: 1.5;
}

.gallery-script-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #665046;
  border-radius: 8px;
  color: #ffbcab;
  font-size: 13px;
  font-weight: 650;
}

.gallery-script-link:hover {
  border-color: #ffb29d;
  color: #ffded4;
}

.gallery-script-link:focus-visible {
  outline: 2px solid #ffb29d;
  outline-offset: 3px;
}

.gallery-script-link[hidden] {
  display: none;
}

.gallery-player-hint {
  font-size: 13px;
}

:is(#gallery, #gallery--t, #gallery--m) .ep-bar .gallery-hover-hint {
  color: inherit;
}

:is(#gallery, #gallery--t, #gallery--m) button[data-play-episode] {
  min-height: 44px !important;
  border-radius: 8px !important;
  background: #b53415 !important;
}

:is(#gallery, #gallery--t, #gallery--m) button[data-play-episode]:hover {
  background: #a62e13 !important;
}

:is(#gallery, #gallery--t, #gallery--m) button[data-play-episode]:focus-visible {
  outline: 2px solid #ffb29d;
  outline-offset: 3px;
}

:is(#gallery, #gallery--t, #gallery--m) .ep-bar + div {
  counter-reset: gallery-shot;
  gap: 16px !important;
  margin-top: 22px !important;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe {
  counter-increment: gallery-shot;
  background: #191d25 !important;
  border: 1px solid #383e49 !important;
  border-radius: 12px !important;
  box-shadow: 0 8px 20px rgb(5 8 12 / 0.24);
  animation: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

/* Keep the project number in the image and the title outside it. */
:is(#gallery, #gallery--t, #gallery--m) .gframe::before {
  content: counter(gallery-shot, decimal-leading-zero);
  position: absolute;
  z-index: 3;
  top: 9px;
  left: 9px;
  width: auto;
  height: auto;
  padding: 4px 6px;
  border: 1px solid rgb(255 255 255 / 0.25);
  border-radius: 5px;
  background: rgb(11 14 19 / 0.88);
  backdrop-filter: none;
  color: #fff;
  font: 600 11px/1 "JetBrains Mono", Consolas, monospace;
  opacity: 1 !important;
  transform: none;
  transition: none;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe::after {
  content: none;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe > span:first-child {
  height: auto !important;
  aspect-ratio: 16 / 9;
  background: #101319;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe > span:first-child > :is(img, video) {
  transform: none;
  transition: opacity 140ms ease;
}

/* SVG icon remains visible on touch devices and does not intercept the card click. */
:is(#gallery, #gallery--t, #gallery--m) .gframe > span:first-child::before {
  content: "";
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 46px;
  height: 46px;
  border: 1px solid rgb(255 255 255 / 0.74);
  border-radius: 50%;
  background: rgb(9 12 18 / 0.76)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23fff' d='m7 4 10 6-10 6z'/%3E%3C/svg%3E")
    center / 20px no-repeat;
  box-shadow: 0 3px 14px rgb(0 0 0 / 0.32);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 140ms ease, background-color 180ms ease;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe.is-playing > span:first-child::before {
  opacity: 0;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe > span:first-child::after {
  background: linear-gradient(180deg, rgb(7 9 14 / 0.24), transparent 40%);
}

:is(#gallery, #gallery--t, #gallery--m) .gallery-card-category,
:is(#gallery, #gallery--t, #gallery--m) .gallery-card-duration {
  position: absolute;
  right: 9px;
  z-index: 3;
  max-width: calc(100% - 54px);
  padding: 4px 7px;
  border: 1px solid rgb(255 255 255 / 0.25);
  border-radius: 5px;
  background: rgb(11 14 19 / 0.88);
  color: #fff;
  font-size: 11px;
  line-height: 1.2;
}

:is(#gallery, #gallery--t, #gallery--m) .gallery-card-category {
  top: 9px;
  font-weight: 700;
}

:is(#gallery, #gallery--t, #gallery--m) .gallery-card-duration {
  bottom: 9px;
  font-family: "JetBrains Mono", Consolas, monospace;
}

:is(#gallery, #gallery--t, #gallery--m) .gallery-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 13px 13px;
  border-top: 1px solid rgb(255 255 255 / 0.09);
}

:is(#gallery, #gallery--t, #gallery--m) .gallery-card-title {
  color: #fff;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

:is(#gallery, #gallery--t, #gallery--m) .gallery-card-note {
  color: #b9c1cd;
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe:hover {
  transform: none;
}

:is(#gallery, #gallery--t, #gallery--m) .gframe:focus-visible {
  outline: 2px solid #ffb29d;
  outline-offset: -3px;
}

@media (hover: hover) and (pointer: fine) {
  :is(#gallery, #gallery--t, #gallery--m) .gframe:hover {
    border-color: #a86656 !important;
    box-shadow: 0 12px 25px rgb(5 8 12 / 0.35);
  }

  :is(#gallery, #gallery--t, #gallery--m) .gframe:hover > span:first-child::before {
    background-color: #b53415;
  }
}

@media (hover: none), (pointer: coarse) {
  :is(#gallery, #gallery--t, #gallery--m) .gframe:hover {
    border-color: #383e49 !important;
    box-shadow: 0 8px 20px rgb(5 8 12 / 0.24);
  }
}

@media (hover: none), (pointer: coarse), (prefers-reduced-motion: reduce) {
  .gallery-hover-hint { display: none; }
}

@media (min-width: 440px) and (max-width: 599.98px) {
  #gallery--m .ep-bar + div {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(#gallery, #gallery--t, #gallery--m) .gframe,
  :is(#gallery, #gallery--t, #gallery--m) .gframe > span:first-child::before,
  :is(#gallery, #gallery--t, #gallery--m) .gframe > span:first-child > video {
    transition: none;
  }
}
