/* Arcade grid: 2 columns in portrait, 3 in landscape. */

:root {
  --pad-x: 6vw;
  --pad-top: clamp(40px, 5vh, 72px);
  --pad-bottom: clamp(40px, 6vh, 96px);
  --col-gap: 6vw;
  /* A caption is two lines now, so rows sit further apart: the space under a
     credit has to beat the space over its own name, or the credit reads as if
     it belongs to the card below. */
  --row-gap: clamp(44px, 6vh, 78px);
  --caption-gap: clamp(14px, 1.8vh, 24px); /* image to name */
  --credit-gap: clamp(3px, 0.5vh, 6px); /* name to credit: a tight pair */
  --caption-size: 20px;
  --credit-size: calc(var(--caption-size) * 0.75);
  --caption-tracking: -0.01em; /* names are set slightly tight */
  --credit-tracking: 0.005em; /* the credit is small, so it gets a little air */
}

@media (orientation: landscape) {
  :root {
    --col-gap: 4vw;
  }
}

@media (max-width: 480px) {
  :root {
    --caption-size: 17px;
    --credit-size: calc(var(--caption-size) * 0.8); /* stays readable when small */
  }
}

.arcade {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--col-gap);
  row-gap: var(--row-gap);
  max-width: 1600px;
  margin: 0 auto;
  padding:
    max(var(--pad-top), env(safe-area-inset-top))
    max(var(--pad-x), env(safe-area-inset-right))
    max(var(--pad-bottom), env(safe-area-inset-bottom))
    max(var(--pad-x), env(safe-area-inset-left));
}

@media (orientation: landscape) {
  .arcade {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.card {
  display: block;
  color: inherit;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.card--static {
  cursor: default;
}

.card__art {
  position: relative; /* the preview clip sits over the thumbnail */
  aspect-ratio: var(--card-ratio);
  background: var(--card-placeholder);
  border-radius: var(--card-radius);
  overflow: hidden;
  transition: transform 0.18s ease;
}

.card__art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The preview clip: invisible until frames are flowing, then a soft cross-fade */
.card__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.card__art.is-previewing .card__video {
  opacity: 1;
}

.card:not(.card--static):active .card__art {
  transform: scale(0.975);
}

.card:focus-visible .card__art {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

/* The name and who made it, read as one block under the image. */
.card__caption {
  margin-top: var(--caption-gap);
  text-align: center;
}

.card__name {
  font-size: var(--caption-size);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: var(--caption-tracking);
  overflow-wrap: anywhere;
}

.card__by {
  margin-top: var(--credit-gap);
  font-size: var(--credit-size);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: var(--credit-tracking);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.arcade__empty {
  margin: 0;
  padding: 20vh 24px;
  text-align: center;
  font-size: 18px;
  color: var(--text-muted);
}

.arcade__empty a {
  color: var(--accent);
}

/* QR button, sitting over the top-right of a card */
.card-wrap {
  position: relative;
}

.card__qr {
  position: absolute;
  top: clamp(8px, 1.4vw, 18px);
  right: clamp(8px, 1.4vw, 18px);
  display: grid;
  place-items: center;
  width: calc(var(--qr-icon-size) + 18px);
  height: calc(var(--qr-icon-size) + 18px);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 12px rgba(28, 30, 33, 0.18);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease;
}

.card__qr:active {
  transform: scale(0.92);
}

.card__qr:focus-visible {
  outline: 3px solid var(--qr-blue);
  outline-offset: 3px;
}

.card__qr-icon {
  display: block;
  width: var(--qr-icon-size);
  height: var(--qr-icon-size);
  background-color: #000;
  -webkit-mask: url("../img/qr-icon.png") center / contain no-repeat;
  mask: url("../img/qr-icon.png") center / contain no-repeat;
}

/* The code itself, shown big enough to scan across a table */
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  background: rgba(16, 18, 27, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.qr-overlay[hidden] {
  display: none;
}

body.has-overlay {
  overflow: hidden;
}

.qr-dialog {
  /* The deeplink codes are dense, so the code needs room: a phone reads it far
     more easily when each module gets a few pixels. */
  width: min(92vw, 640px);
  max-height: 100%;
  overflow-y: auto;
  padding: 28px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(16, 18, 27, 0.3);
  text-align: center;
}

.qr-dialog__title {
  margin: 0 0 20px;
  font-size: 22px;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.qr-dialog__image {
  display: block;
  width: 100%;
  max-height: 62vh;
  margin-bottom: 24px;
  aspect-ratio: 1;
  object-fit: contain;
  background: #fff;
}

.qr-dialog__close {
  min-height: 48px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: var(--qr-blue);
  color: #fff;
  font: inherit;
  font-size: 17px;
  cursor: pointer;
}

.qr-dialog__close:active {
  transform: scale(0.97);
}
