/* ==========================================================================
   chrome.css: shared chrome on EVERY page (home, game pages, plain pages).
   The footer "end credits" and its post-credits sting.
   Game pages load this file but not home.js, so everything here must look
   finished with CSS alone. home.js only re-times the sting flicker.
   Scope: .credits*, .cr-*, .sting-*
   ========================================================================== */

.credits {
  --cr-black: #060504;
  position: relative;
  padding-top: clamp(120px, 16vw, 210px);
  background: linear-gradient(180deg, transparent 0, var(--cr-black) clamp(100px, 14vw, 190px));
  color: var(--bone-2);
  text-align: center;
  overflow: hidden;
}
.credits-inner {
  display: grid;
  justify-items: center;
}

/* ── Title card ─────────────────────────────────────────────────────── */
.credits-crest {
  width: clamp(96px, 9.5vw, 128px);
  height: auto;
  margin-bottom: clamp(28px, 3.4vw, 40px);
  filter: drop-shadow(0 8px 30px rgba(242, 177, 62, .16));
}
.credits-line {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(27px, 3.3vw, 46px);
  line-height: 1.12;
  letter-spacing: .005em;
  color: var(--bone);
  font-feature-settings: 'palt';
  text-wrap: balance;
}
.credits-sub {
  margin-top: 14px;
  font-family: var(--f-pixel);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--fog);
}

/* ── The roll: title | number spine | status, like film credits ──────── */
.credits-roll {
  list-style: none;
  width: 100%;
  max-width: 900px;
  margin-top: clamp(64px, 8vw, 104px);
  display: grid;
  gap: 2px;
}
.credits-roll::before {
  content: 'Featuring';
  content: 'Featuring' / '';
  display: block;
  margin-bottom: clamp(20px, 2.4vw, 30px);
  font-family: var(--f-pixel);
  font-size: 11px;
  letter-spacing: .4em;
  text-transform: uppercase;
  color: var(--fog-2);
}
.credits-roll a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.6em minmax(0, 1fr);
  align-items: baseline;
  padding: 9px 0;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.cr-title {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  text-align: right;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(18px, 1.75vw, 24px);
  line-height: 1.3;
  color: var(--bone);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
  transition: color .25s, text-decoration-color .25s;
}
.cr-no {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  font-family: var(--f-pixel);
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--fog-2);
  transition: color .25s;
}
.cr-status {
  grid-column: 3;
  grid-row: 1;
  justify-self: start;
  text-align: left;
  font-family: var(--f-pixel);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--fog);
}
.cr-out { color: var(--seal-hot); }
.cr-wishlist { color: var(--gold); }
.cr-soon { color: var(--fog); }
@media (hover: hover) {
  .credits-roll a:hover .cr-title { color: #fff8ee; text-decoration-color: var(--seal); }
  .credits-roll a:hover .cr-no { color: var(--bone); }
}
.credits-roll a:focus-visible { outline-offset: 2px; }
.credits-roll a:focus-visible .cr-title { text-decoration-color: var(--gold); }

/* ── Links + legal ──────────────────────────────────────────────────── */
.credits-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: clamp(60px, 7vw, 92px);
  font-family: var(--f-pixel);
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.credits-links > * {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
}
.credits-links > * + *::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 50%;
  width: 4px; height: 4px;
  margin-top: -2px;
  background: var(--fog-2);
}
.credits-links a { color: var(--bone-2); transition: color .2s; }
.credits-links a:hover { color: var(--bone); }
.credits-soon { color: var(--fog-2); }
.credits-legal {
  margin-top: 22px;
  max-width: 60ch;
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--fog-2);
}
.credits-addr { display: block; }

/* ── Post-credits sting: the shack far off, one cabinet flickers on ─── */
.credits-sting {
  /* shack art width, and the middle cabinet screen's centre / size in that art (fractions) */
  --sw: clamp(220px, 22vw, 320px);
  --sx: .5625; --sy: .5040;
  --sww: .052; --swh: .03;
  position: relative;
  display: grid;
  justify-items: center;
  width: calc(var(--sw) + 64px);
  max-width: 100%;
  /* a short black beat after the legal line: long enough to feel like the end, short enough to be found */
  margin: clamp(96px, 18vh, 200px) auto 0;
  padding-bottom: clamp(64px, 9vw, 120px);
  color: var(--gold);
  -webkit-tap-highlight-color: transparent;
  /* the shack art only loads once the sting is near the viewport */
  content-visibility: auto;
  contain-intrinsic-block-size: auto 520px;
}
.credits-sting::before {
  content: '';
  display: block;
  width: var(--sw);
  aspect-ratio: 1040 / 1240;
  background: url('/assets/brand/arcade-shack.webp') center / cover no-repeat;
  -webkit-mask-image: radial-gradient(ellipse 58% 50% at 54% 55%, #000 34%, rgba(0, 0, 0, .55) 58%, transparent 80%);
  mask-image: radial-gradient(ellipse 58% 50% at 54% 55%, #000 34%, rgba(0, 0, 0, .55) 58%, transparent 80%);
  filter: brightness(.6) saturate(.85);
  transition: filter .8s var(--ease-out);
}
.sting-screen {
  display: block;
}
/* the lit cabinet screen */
.sting-screen::before {
  content: '';
  position: absolute;
  left: calc(50% + var(--sw) * (var(--sx) - .5));
  top: calc(var(--sw) * 1.19231 * var(--sy));
  width: calc(var(--sw) * var(--sww));
  height: calc(var(--sw) * var(--swh));
  transform: translate(-50%, -50%);
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, .14) 0 1px, transparent 1px 2px),
    radial-gradient(ellipse at 50% 45%, #fff1c9 0%, #ffc75a 45%, #d9482c 100%);
  box-shadow: 0 0 5px 1px rgba(255, 199, 90, .85), 0 0 18px 6px rgba(242, 177, 62, .38), 0 0 42px 14px rgba(217, 72, 44, .22);
  animation: stingBuzz 9s steps(1, end) infinite;
}
/* its light on the boardwalk */
.sting-screen::after {
  content: '';
  position: absolute;
  left: calc(50% + var(--sw) * (var(--sx) - .5));
  top: calc(var(--sw) * 1.19231 * (var(--sy) + .15));
  width: calc(var(--sw) * .42);
  height: calc(var(--sw) * .16);
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(242, 177, 62, .22), rgba(242, 177, 62, 0));
  pointer-events: none;
  animation: stingBuzz 9s steps(1, end) infinite;
}
.sting-text {
  position: relative;
  display: block;
  margin-top: calc(var(--sw) * -.24);
  padding-left: .3em; /* balances the trailing letter-spacing */
  font-family: var(--f-pixel);
  font-size: clamp(17px, 1.7vw, 22px);
  line-height: 1.3;
  letter-spacing: .3em;
  white-space: nowrap;
  color: var(--gold);
  text-shadow: 0 0 6px rgba(242, 177, 62, .75), 0 0 24px rgba(242, 177, 62, .32);
  animation: stingBuzz 9s steps(1, end) infinite;
  transition: color .3s, text-shadow .3s;
}
@media (hover: hover) {
  .credits-sting:hover::before { filter: brightness(.85) saturate(1); }
  .credits-sting:hover .sting-text { color: var(--gold-hot); text-shadow: 0 0 8px rgba(255, 199, 90, .9), 0 0 30px rgba(242, 177, 62, .5); }
}
.credits-sting:focus-visible { outline-offset: 10px; }

/* steps() flicker: power-on, then the odd buzz of a tired tube */
@keyframes stingOn {
  0%   { opacity: 0; }
  9%   { opacity: .85; }
  13%  { opacity: 0; }
  31%  { opacity: 1; }
  34%  { opacity: .12; }
  38%  { opacity: .75; }
  42%  { opacity: 0; }
  57%  { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes stingBuzz {
  0%, 84%, 100% { opacity: 1; }
  85% { opacity: .35; }
  86% { opacity: 1; }
  89% { opacity: .6; }
  90% { opacity: 1; }
}

/* home.js (home + plain pages) arms the screen dark, then lights it when it scrolls into view */
.credits-sting.is-armed .sting-screen { opacity: 0; }
.credits-sting.is-lit .sting-screen { opacity: 1; animation: stingOn 2.3s steps(1, end) .35s both; }

/* game pages (no home.js): browsers with scroll timelines flicker it on as it arrives */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .credits-sting { view-timeline: --jw-sting block; }
    .credits-sting:not(.is-armed):not(.is-lit) .sting-screen {
      animation: stingOn steps(1, end) both;
      animation-timeline: --jw-sting;
      animation-range: entry 45% entry 100%;
    }
    .credits-roll li,
    .credits-crest,
    .credits-line,
    .credits-sub {
      animation: crIn linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 90%;
    }
  }
}
@keyframes crIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .sting-screen, .sting-screen::before, .sting-screen::after, .sting-text,
  .credits-sting.is-lit .sting-screen { animation: none !important; opacity: 1 !important; }
}

/* ── Phones and small tablets ───────────────────────────────────────── */
@media (max-width: 699px) {
  .credits { padding-top: 110px; }
  .credits-roll { margin-top: 56px; }
  .credits-roll a {
    grid-template-columns: 1fr;
    justify-items: center;
    row-gap: 3px;
    padding: 11px 0;
  }
  .cr-no, .cr-title, .cr-status {
    grid-column: 1;
    grid-row: auto;
    justify-self: center;
    text-align: center;
  }
  .cr-no { font-size: 11px; }
  .cr-title { font-size: 20px; }
  .cr-status { font-size: 11px; }
  .credits-links { margin-top: 52px; flex-direction: column; align-items: center; }
  .credits-links > * { padding: 0 16px; }
  .credits-links > * + *::before { display: none; }
  .credits-legal { font-size: 12px; }
  .credits-sting { margin-top: 96px; padding-bottom: 56px; }
}
