/* Layers cut from the approved illustrations. Each game card is a single link. */
html[data-ludik-theme] .ld-reference-home {
  --feature-focus: #ffde29;
  --headline-paper: var(--ld-paper);
  overflow: clip;
  background: var(--ld-texture) center / cover no-repeat, var(--ld-shell);
}

html[data-ludik-theme="comic"] .ld-reference-home {
  --feature-focus: #99ffbd;
  --headline-paper: var(--ld-yellow);
  background-color: var(--ld-accent);
}

/* Use the same prices and actions as the Comic case and game catalogs. */
html[data-ludik-theme="comic"] #content:is([data-route="home"], [data-route="content"]) > .store-home {
  .ld-directory-grid .ld-preview-card:not([aria-disabled]) .ld-card-action {
    background: var(--ld-yellow);
  }

  .ld-directory-grid .ld-preview-card:focus-visible {
    outline: 2px solid var(--ld-yellow);
    outline-offset: 3px;
  }

  .store-case .store-credit svg {
    color: currentColor;
    filter: none;
  }

  .store-case:is(:hover, :focus-visible) .store-credit {
    border-color: var(--ld-ink);
    color: var(--ld-ink);
    background: var(--ld-yellow);
    box-shadow: 2px 2px 0 var(--ld-ink);
  }

  .store-player-shelf > .player-case-intro {
    color: var(--ld-muted);
  }

  .store-player-shelf .store-button:not(.store-button-soft) {
    border-color: var(--ld-ink);
    color: var(--ld-ink);
    background: var(--ld-yellow);
    box-shadow: 3px 3px 0 var(--ld-ink);
  }

  .store-player-shelf .store-button:not(.store-button-soft):is(:hover, :focus-visible) {
    background: var(--ld-paper);
  }
}

.ld-reference-hero,
.ld-reference-modes {
  width: min(100%, var(--ld-width));
  margin-inline: auto;
}

.ld-reference-hero {
  display: grid;
  grid-template:
    "heading games" auto
    "portrait games" 1fr / minmax(0, 348fr) minmax(0, 532fr);
  align-items: start;
  isolation: isolate;
}

html[data-ludik-theme="stencil"] .ld-reference-hero {
  grid-template:
    "portrait heading" auto
    "portrait games" auto / minmax(0, 330fr) minmax(0, 586fr);
}

.ld-reference-heading {
  position: relative;
  z-index: 1;
  grid-area: heading;
  justify-self: center;
  margin: .27em 7% .18em;
  padding: .34em .43em .29em;
  clip-path: polygon(0 11%, 10% 9%, 14% 4%, 19% 6%, 29% 1%, 35% 5%, 44% 0, 51% 4%, 61% 1%, 69% 6%, 78% 2%, 84% 6%, 97% 2%, 99% 13%, 98% 33%, 100% 49%, 98% 59%, 99% 73%, 97% 92%, 87% 94%, 81% 91%, 73% 98%, 65% 94%, 55% 100%, 48% 94%, 38% 98%, 29% 94%, 18% 99%, 11% 94%, 0 97%, 2% 76%, 0 61%, 2% 43%, 0 28%);
  white-space: nowrap;
  color: #16110a;
  background: var(--headline-paper) url("/redesign-art/paper.webp") center / 210px;
  background-blend-mode: multiply;
  font: italic 900 clamp(30px, 5vw, 75px)/.89 var(--ld-display);
  font-synthesis: style;
  letter-spacing: -.04em;
  text-transform: uppercase;
  transform: rotate(-4deg);
}

html[data-ludik-theme="stencil"] .ld-reference-heading {
  font-size: clamp(27px, 4.5vw, 67px);
  text-align: center;
}

.ld-reference-mascot-slot {
  position: relative;
  grid-area: portrait;
  align-self: end;
  aspect-ratio: 1.02;
  pointer-events: none;
}

.ld-reference-portrait {
  --mascot-outline: polygon(48.7% 1.3%, 55.5% 4%, 59.5% 9.2%, 65.9% 15.9%, 65.8% 19.6%, 71.3% 17.9%, 77.5% 21.2%, 78.3% 27.6%, 84.5% 35.2%, 81.9% 43.5%, 88.5% 46.1%, 95.4% 58.1%, 95.1% 70.5%, 86.2% 79.9%, 74.3% 79.6%, 73.7% 97.3%, 69.7% 99.4%, 21.3% 99.7%, 11% 90.7%, 2.9% 79%, 5.7% 64.6%, 12.6% 48%, 16.9% 34.9%, 22.1% 31.7%, 27.1% 31.7%, 21.9% 26.7%, 28.9% 21.1%, 28.6% 15.6%, 33.4% 9.9%, 39.5% 4.5%);
  position: absolute;
  inset-inline-start: -6%;
  inset-block-end: -19%;
  width: 118%;
  aspect-ratio: 860 / 940;
}

html[data-ludik-theme="stencil"] .ld-reference-mascot-slot {
  aspect-ratio: .77;
}

html[data-ludik-theme="stencil"] .ld-reference-portrait {
  --coin-x: 28.52%;
  --coin-y: 14.26%;
  --coin-diameter: 6.92%;
  --coin-gold: #cd8d37;
  --coin-ink: #382214;
  --coin-arc-x: -3.5%;
  --coin-arc-y: -10.5%;
  --mascot-outline: polygon(47.6% .8%, 55.9% 2.5%, 58.5% 5.8%, 58.9% 10.6%, 61.6% 12.8%, 65.3% 18%, 79.3% 22%, 91.5% 31.3%, 97% 39.5%, 95.3% 46.6%, 88.4% 52.7%, 76.6% 57.4%, 77.8% 65.7%, 84.5% 77.7%, 80.2% 85.4%, 92.6% 97.3%, 84.2% 99.8%, 64.2% 98.9%, 63% 94.5%, 64.7% 90.5%, 57.3% 85.1%, 49% 74.8%, 46.4% 69.3%, 41.2% 79.7%, 30.9% 88.2%, 29.1% 95.8%, 27.2% 99.1%, 11.8% 99.7%, 5.5% 98.8%, 4.9% 97.4%, 14.6% 87.9%, 10.7% 80.7%, 12.2% 74.8%, 19% 60.5%, 18% 51.8%, 7.7% 49.5%, 3% 42.7%, 3.4% 35.4%, 9.3% 26.5%, 15.9% 22.4%, 18.5% 19.2%, 21.6% 16.5%, 24.9% 15.3%, 24.6% 13.9%, 26% 11.5%, 28.9% 11%, 31.4% 12.3%, 32.4% 15%, 33.7% 14.9%, 35% 9.5%, 38.6% 7%, 40.8% 3.4%);
  inset-inline-start: -4%;
  inset-block-end: -12%;
  width: 120%;
  aspect-ratio: 920 / 1077;
}

.ld-mascot-defs { position: absolute; }

.ld-reference-portrait :is(.ld-mascot-illustration, picture, .ld-mascot-coin, .ld-mascot-coin-spin, .ld-mascot-trigger) {
  position: absolute;
  inset: 0;
}

.ld-reference-portrait picture { display: block; }
.ld-reference-portrait img {
  display: block;
  width: 100%;
  height: 100%;
}

.ld-mascot-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
  pointer-events: none;
}

.ld-reference-portrait[data-toss-playing] .ld-mascot-body { visibility: hidden; }
.ld-reference-portrait[data-toss-playing] .ld-mascot-video { visibility: visible; }

html[data-ludik-theme] .ld-reference-portrait .ld-mascot-trigger {
  all: unset;
  position: absolute;
  inset: 0;
  clip-path: var(--mascot-outline);
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ld-reference-portrait:has(.ld-mascot-trigger:focus-visible) .ld-mascot-illustration {
  filter: drop-shadow(0 0 2px var(--feature-focus)) drop-shadow(0 0 3px var(--feature-focus));
}

.ld-mascot-coin { visibility: hidden; }
.ld-reference-portrait[data-flipping] .ld-mascot-coin { visibility: visible; }
.ld-mascot-coin-face { clip-path: url("#ld-mascot-coin-clip"); }

/* The printed face is partly behind the thumb. Complete its rim in the air. */
.ld-mascot-coin-spin::before {
  position: absolute;
  left: var(--coin-x);
  top: var(--coin-y);
  width: var(--coin-diameter);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--coin-gold) 58%, var(--coin-ink) 60%, var(--coin-ink) 69%, transparent 71%);
  opacity: 0;
  transform: translate(-50%, -50%);
  content: "";
}

.ld-mascot-glint {
  position: absolute;
  left: var(--coin-x);
  top: var(--coin-y);
  width: calc(var(--coin-diameter) * .55);
  aspect-ratio: 1;
  background: #fff1a2;
  clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(15deg);
}

.ld-reference-portrait[data-flipping] .ld-mascot-coin {
  animation: ld-mascot-toss 780ms both;
}

.ld-reference-portrait[data-flipping] .ld-mascot-body { mask: url("#ld-mascot-body-mask"); }
.ld-reference-portrait[data-flipping] .ld-mascot-illustration {
  animation: ld-mascot-flick 780ms ease-out;
}
.ld-reference-portrait[data-flipping] .ld-mascot-coin-spin {
  transform-origin: var(--coin-x) var(--coin-y);
  animation: ld-mascot-spin 780ms linear;
}
.ld-reference-portrait[data-flipping] .ld-mascot-coin-spin::before {
  animation: ld-mascot-airborne-rim 780ms linear;
}
.ld-reference-portrait[data-flipping] .ld-mascot-glint {
  animation: ld-mascot-glint 780ms ease-out;
}

@keyframes ld-mascot-toss {
  0%, 100% { transform: translate(0, 0); }
  14% { transform: translate(0, 1%); animation-timing-function: cubic-bezier(.18,.6,.55,1); }
  51% { transform: translate(var(--coin-arc-x), var(--coin-arc-y)); animation-timing-function: cubic-bezier(.5,0,.84,.35); }
  91% { transform: translate(0, 0); }
  95% { transform: translate(0, 1.2%); }
}

@keyframes ld-mascot-spin {
  0%, 14% { transform: none; }
  91%, 100% { transform: rotateX(1080deg) rotateZ(0); }
  52% { transform: rotateX(550deg) rotateZ(24deg); }
}

@keyframes ld-mascot-airborne-rim {
  0%, 15%, 90%, 100% { opacity: 0; }
  22%, 85% { opacity: 1; }
}

@keyframes ld-mascot-flick {
  0%, 100% { transform: none; }
  14% { transform: translateY(.7%) rotate(-.55deg); }
  29% { transform: translateY(-1.2%) rotate(.9deg); }
  90% { transform: translateY(.55%) rotate(-.45deg); }
}

@keyframes ld-mascot-glint {
  0%, 43%, 65%, 100% { opacity: 0; }
  51% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .ld-reference-portrait[data-flipping] :is(.ld-mascot-illustration, .ld-mascot-glint) { animation: none; }
  .ld-reference-portrait[data-flipping] .ld-mascot-body { mask: none; }
  .ld-reference-portrait[data-flipping] .ld-mascot-coin-spin { display: none; }
  .ld-reference-portrait[data-flipping] .ld-mascot-glint { opacity: 1; }
  .ld-reference-portrait[data-flipping] .ld-mascot-coin {
    animation: ld-mascot-flash 240ms ease-out both;
  }
  @keyframes ld-mascot-flash {
    from { opacity: 1; }
    to { opacity: 0; }
  }
}

.ld-reference-games {
  position: relative;
  z-index: 1;
  grid-area: games;
  display: grid;
  align-items: start;
  min-width: 0;
  padding: 4.14% .75% 0 0;
  pointer-events: none;
}

html[data-ludik-theme="stencil"] .ld-reference-games {
  grid-template-columns: minmax(0, 274fr) minmax(0, 292fr);
  gap: 1.2%;
  padding: 0 2.22% 0 0;
}

.ld-featured-card {
  position: relative;
  display: block;
  isolation: isolate;
  min-width: 0;
  aspect-ratio: var(--feature-ratio);
  clip-path: var(--feature-outline, none);
  touch-action: manipulation;
  pointer-events: auto;
}

.ld-feature-art {
  position: relative;
  display: block;
  width: 100%;
  height: auto;
}

html[data-ludik-theme="comic"] .ld-featured-card[data-preview="cases"] {
  --feature-ratio: 522 / 198;
  margin-inline-start: 1.14%;
}

html[data-ludik-theme="comic"] .ld-featured-card[data-preview="dice"] {
  --feature-ratio: 528 / 192;
  margin-top: -.76%;
}

html[data-ludik-theme="stencil"] .ld-featured-card[data-preview="plinko"] {
  --feature-ratio: 274 / 281;
  --motion-box: 20.997% 14.964% 22.42% 14.234%;
}
html[data-ludik-theme="stencil"] .ld-featured-card[data-preview="dice"] {
  --feature-ratio: 292 / 281;
}

html[data-ludik-theme="stencil"] .ld-featured-card {
  background: radial-gradient(ellipse at 50% 40%, #2f271b, #0f0e0c 75%);
}

/* A WebGL frame stays visible between previews. The printed board is the fallback. */
.ld-feature-motion {
  position: absolute;
  z-index: 1;
  inset: var(--motion-box);
  width: auto;
  height: auto;
  pointer-events: none;
  opacity: 0;
}
html[data-ludik-theme="stencil"] .ld-feature-motion { width: 70.8%; height: 56.58%; }
.ld-feature-motion[data-renderer="webgl"] { opacity: 1; }

.ld-featured-status {
  position: absolute;
  z-index: 2;
  inset: auto 6% 6% auto;
  padding: .24em .48em;
  border: 1px solid #17120d;
  border-radius: 4px;
  background: #efdbb9;
  color: #17120d;
  font: 800 clamp(.75rem, 1.65vw, 1.125rem)/1.15 var(--font-interface);
  pointer-events: none;
}

html[data-ludik-theme] .ld-reference-home :is(.ld-featured-card, .ld-feature-mode):focus-visible {
  outline: none;
}

.ld-reference-home :is(.ld-featured-card, .ld-feature-mode):focus-visible::after {
  position: absolute;
  z-index: 3;
  inset: 7% 5%;
  border: 2px solid var(--feature-focus);
  border-radius: 4px;
  box-shadow: 0 0 0 1px #1d140e;
  pointer-events: none;
  content: "";
}

@media (hover: hover) {
  .ld-featured-card:not([aria-disabled="true"]):hover { filter: brightness(1.07); }
}

.ld-reference-modes {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 236fr) minmax(0, 200fr) minmax(0, 210fr) minmax(0, 234fr);
  gap: .3%;
  padding-inline: .45%;
  pointer-events: none;
}

html[data-ludik-theme="stencil"] .ld-reference-modes {
  grid-template-columns: minmax(0, 222fr) minmax(0, 218fr) minmax(0, 217fr) minmax(0, 232fr);
  gap: .54%;
  padding-inline: .65%;
}

.ld-feature-mode {
  position: relative;
  display: grid;
  min-width: 0;
  align-self: start;
  align-items: start;
  transform: translateY(0);
  clip-path: var(--feature-outline, none);
  touch-action: manipulation;
  pointer-events: auto;
}

.ld-feature-mode img { display: block; width: 100%; height: auto; pointer-events: none; }
.ld-feature-mode:hover { filter: brightness(1.1); }

@media (prefers-reduced-motion: no-preference) {
  .ld-featured-card { transition: filter 180ms ease; }
  .ld-feature-mode {
    transition: transform 220ms cubic-bezier(.2,.75,.31,1.35), filter 180ms ease;
  }
  @media (hover: hover) {
    .ld-feature-mode:hover { transform: translateY(-4px); }
  }
}

@media (max-width: 560px) {
  html[data-ludik-theme] .ld-reference-hero {
    grid-template:
      "portrait heading" auto
      "games games" auto / minmax(100px, 37%) minmax(0, 1fr);
    align-items: center;
    gap: 0 4px;
    padding: 0 8px 8px;
  }

  .ld-reference-heading {
    justify-self: start;
    margin-inline: 3%;
    font-size: clamp(24px, 7.3vw, 44px);
  }

  html[data-ludik-theme="stencil"] .ld-reference-heading { font-size: clamp(24px, 7.3vw, 44px); }

  html[data-ludik-theme] .ld-reference-mascot-slot {
    height: clamp(125px, 40vw, 226px);
    aspect-ratio: auto;
  }

  html[data-ludik-theme] .ld-reference-portrait {
    inset-inline-start: -9%;
    inset-block-end: -35%;
    width: 136%;
  }

  html[data-ludik-theme="stencil"] .ld-reference-portrait {
    --coin-arc-y: -9.5%;
    inset-inline-start: -3%;
    inset-block-end: -43%;
  }

  html[data-ludik-theme] .ld-reference-games {
    gap: 5px;
    padding: 0;
  }

  html[data-ludik-theme="comic"] .ld-featured-card {
    margin: 0;
  }

  html[data-ludik-theme] .ld-reference-modes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 0 8px 8px;
  }
}
