/*
 * shell.css -- the CRT cabinet styling that wraps every game.
 *
 * Loaded by each game's index.html alongside cabinet.js. Keep the palette in
 * sync with /css/style.css (the catalog skin).
 */

/* Self-hosted chunky pixel display face (kept in sync with /css/style.css). */
@font-face {
  font-family: "Press Start 2P";
  src: url("/fonts/press-start-2p.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:        #0b0c14;  /* clean dark backdrop behind the screen */
  --bg-2:      #14121f;
  --ink:       #f5e6ff;
  --pink:      #ff2e88;
  --cyan-soft: #5ef3ff;
  --bezel:     #16161f;
  --bezel-2:   #08080e;
  --display: "Press Start 2P", "VT323", ui-monospace, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(80% 60% at 50% 26%, rgba(94, 243, 255, 0.06), transparent 70%),
    radial-gradient(120% 90% at 50% 0%, var(--bg-2), var(--bg) 70%);
  overflow: hidden;
  /* Mobile: touches drive the game, not page scroll/zoom/pull-to-refresh. */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--display);
  color: var(--ink);
}

/* faint dotted pixel texture on the backdrop */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.6;
  background: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 4px 4px;
}

/* Center the cabinet in the viewport. */
body {
  display: grid;
  place-items: center;
  padding: 0;
}

/* The cabinet: a clean dark monitor frame holding a curved CRT screen. */
.cabinet {
  position: relative;
  display: flex;
  flex-direction: column;
  /* The SCREEN (below) is the 4:3 element; the cabinet wraps it + the control
     bar, so the screen stays exactly 4:3 and the canvas fills it with no
     letterbox (which would otherwise offset pointer/touch mapping). */
  max-width: 96vw;
  max-height: 96vh;
  border-radius: 22px;
  padding: 1.8vmin;
  background: linear-gradient(180deg, var(--bezel), var(--bezel-2));
  box-shadow:
    inset 0 0 0 2px rgba(94, 243, 255, 0.12),
    inset 0 2px 0 rgba(255, 255, 255, 0.06),
    0 26px 64px rgba(0, 0, 0, 0.7);
}

/* a tiny power LED on the bezel */
.cabinet::after {
  content: "";
  position: absolute;
  right: 2.6vmin;
  bottom: 1.1vmin;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7dff8f;
  box-shadow: 0 0 8px #7dff8f;
}

/* The screen: rounded like a CRT tube. */
.cabinet-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  /* Largest 4:3 that fits the viewport. WIDTH is the controlled dimension and
     height is derived from aspect-ratio -- deriving height-from-width is
     reliable everywhere, whereas the reverse (width from an explicit height)
     renders tiny on iOS Safari. Budget for the cabinet padding (3.6vmin) + the
     control bar (~3rem). */
  width: min(calc(96vw - 3.6vmin), calc((96vh - 3.6vmin - 3rem) * 4 / 3));
  height: auto;
  border-radius: 20px / 15px;
  overflow: hidden;
  background: #05060a;
}

/* A soft scanline sweeping down the tube. */
.cabinet-screen::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 22%;
  pointer-events: none;
  z-index: 6;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(180, 240, 255, 0.06) 45%,
    rgba(255, 255, 255, 0.04) 55%,
    transparent
  );
  animation: crt-sweep 7s linear infinite;
}

/* The canvas fills the screen; internal resolution stays chunky. */
.cabinet-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;        /* 4:3 screen, so this fills exactly (no letterbox) */
  touch-action: none;         /* touches drive the game, not browser gestures */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Static scanlines. */
.cabinet-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.30) 3px,
    rgba(0, 0, 0, 0.30) 3px
  );
  mix-blend-mode: multiply;
}

/* Curved-tube feel: top glare + corner vignette + phosphor glow + slow flicker. */
.cabinet-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background:
    radial-gradient(140% 75% at 50% -15%, rgba(255, 255, 255, 0.10), transparent 45%),
    radial-gradient(130% 120% at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.6) 100%);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.55),
    inset 0 0 100px rgba(94, 243, 255, 0.06);
  animation: crt-flicker 6s linear infinite;
}

@keyframes crt-sweep {
  /* translateY is relative to the band's own height (22% of the screen), so to
     sweep the FULL height: -100% starts it just above the top, and 455%
     (= 100/22 * 100) carries it just past the bottom before looping. */
  0% { transform: translateY(-100%); }
  100% { transform: translateY(455%); }
}

@keyframes crt-flicker {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.86; }
  98.5% { opacity: 0.97; }
}

/* HUD overlay (score, messages) drawn above the canvas. */
.cabinet-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  padding: 1.2vmin 1.6vmin;
  font-size: clamp(8px, 1.6vmin, 16px);
  text-shadow: 0 0 6px var(--cyan-soft);
}

.hud-score { color: var(--cyan-soft); }
.hud-hi { color: var(--pink); }

.hud-center {
  flex: 1;
  display: none;
  place-items: center;
  text-align: center;
  padding: 2vmin;
}

/* Soft dark vignette behind centered messages so titles / game-over text stay
   legible over any busy game art (no hard box -- fades out at the edges). */
.hud-center.is-visible {
  display: grid;
  background: radial-gradient(ellipse 60% 50% at center,
    rgba(5, 6, 12, 0.78) 0%, rgba(5, 6, 12, 0.58) 50%, transparent 78%);
}

.hud-center h1 {
  font-size: clamp(12px, 3vmin, 28px);
  color: var(--pink);
  text-shadow: 0 2px 0 #000, 0 0 10px var(--pink);
  margin: 0 0 2vmin;
}

.hud-center p {
  font-size: clamp(8px, 1.8vmin, 16px);
  color: var(--ink);
  text-shadow: 0 1px 2px #000, 0 1px 0 #000;
  margin: 0.6vmin 0;
}

.hud-center .blink { animation: blink 1s steps(2, start) infinite; }

@keyframes blink { to { visibility: hidden; } }

/* Persistent one-line control hint, pinned to the bottom of the screen. */
.hud-bottom {
  margin-top: auto;
  justify-content: center;
}

.hud-hint {
  display: none;
  font-size: clamp(6px, 1.2vmin, 11px);
  color: var(--cyan-soft);
  opacity: 0.7;
  text-shadow: 0 0 6px rgba(94, 243, 255, 0.5);
  text-align: center;
}

.hud-hint.is-visible { display: inline; }

/* ---- local leaderboard overlay (leaderboard.js) ---- */
.lb {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: auto;
  display: none; /* JS sets flex when shown */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1vmin;
  padding: 3vmin;
  text-align: center;
  background: rgba(5, 6, 12, 0.85);
}
.lb-title { margin: 0; font-size: clamp(14px, 3.4vmin, 30px); color: var(--pink); text-shadow: 0 0 10px var(--pink); }
.lb-score { margin: 0; font-size: clamp(8px, 1.8vmin, 15px); color: var(--cyan-soft); }
.lb-prompt { margin: 0.4vmin 0 0; font-size: clamp(7px, 1.4vmin, 12px); color: var(--ink); }
.lb-initials {
  font-family: var(--display); text-transform: uppercase; text-align: center;
  width: 5em; font-size: clamp(12px, 3vmin, 26px); letter-spacing: 0.3em;
  color: var(--ink); background: #0b0a14; border: 2px solid var(--cyan-soft);
  padding: 0.5vmin 0.2vmin; caret-color: var(--pink); outline: none;
}
.lb-btn {
  font-family: var(--display); font-size: clamp(7px, 1.5vmin, 13px);
  color: #0b0a14; background: var(--cyan-soft); border: none; cursor: pointer;
  padding: 0.9vmin 1.8vmin; box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.5);
}
.lb-btn:hover, .lb-btn:focus-visible { background: var(--pink); color: #fff; outline: none; }
.lb-actions { display: flex; flex-wrap: wrap; gap: 1vmin; justify-content: center; align-items: center; margin-top: 0.6vmin; }
.lb-home { text-decoration: none; display: inline-flex; align-items: center; }
/* post-play feedback CTA on the game-over screen */
.lb-feedback {
  margin-top: 1.4vmin;
  font-size: clamp(7px, 1.4vmin, 12px);
  color: var(--pink, #ff2e88);
  text-decoration: none;
  text-shadow: 0 0 8px rgba(255, 46, 136, 0.5);
}
.lb-feedback:hover, .lb-feedback:focus-visible { text-decoration: underline; outline: none; }
.lb-board { list-style: none; margin: 0.3vmin 0; padding: 0; width: min(72%, 250px); display: flex; flex-direction: column; gap: 0.4vmin; overflow-y: auto; max-height: 46%; }
.lb-board li { display: flex; align-items: center; gap: 0.7em; font-size: clamp(7px, 1.5vmin, 13px); color: var(--ink); }
.lb-rank { width: 1.6em; text-align: right; color: var(--cyan-soft); }
.lb-name { width: 3em; color: var(--pink); letter-spacing: 0.15em; }
.lb-val { flex: 1; text-align: right; }
.lb-board li.me { color: #fff; text-shadow: 0 0 8px var(--cyan-soft); }
.lb-board li.me .lb-name { color: #fff; }
.lb-empty { justify-content: center; opacity: 0.6; }

/* Respect users who ask for less motion: kill the blink, sweep, and flicker. */
@media (prefers-reduced-motion: reduce) {
  .hud-center .blink { animation: none; }
  .cabinet-screen::after { animation: none; opacity: 0; }
  .cabinet-glow { animation: none; }
}

/* Cabinet control bar (added by cabinet.js): sits ABOVE the screen so it never
   overlaps the game or the game-over overlay. "‹ ARCADE" on the left, share +
   mute on the right. */
.cabinet-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5vmin;
  height: clamp(22px, 3.2vmin, 32px);
  margin-bottom: 0.8vmin;
  padding: 0 0.3vmin;
}
/* Back + Share, matching text-pill buttons. */
.cabinet-btn {
  display: inline-flex;
  align-items: center;
  height: clamp(20px, 3vmin, 28px);
  padding: 0 0.9vmin;
  font-family: inherit;
  font-size: clamp(7px, 1.4vmin, 11px);
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--ink, #d6f3ff);
  background: rgba(8, 8, 14, 0.5);
  border: 2px solid rgba(120, 130, 160, 0.4);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.cabinet-btn:hover, .cabinet-btn:focus-visible {
  opacity: 1;
  border-color: var(--cyan-soft, #5ef3ff);
  outline: none;
}
.cabinet-btn svg { width: 1.2em; height: 1.2em; vertical-align: middle; margin-right: 0.3em; }

/* Instruction-manual (📖) overlay (cabinet.js): screenshot + objective + controls. */
.cabinet-help {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vmin;
  overflow-y: auto;            /* the manual scrolls if it's taller than the screen */
  background: rgba(5, 6, 12, 0.92);
}
.cabinet-help[hidden] { display: none; }
.help-panel {
  max-width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6vmin;
  text-align: center;
}
.help-title {
  margin: 0;
  font-size: clamp(13px, 3vmin, 26px);
  color: var(--pink, #ff2e88);
  text-shadow: 0 2px 0 #000, 0 0 10px var(--pink, #ff2e88);
}
.help-shot {
  width: min(68%, 280px);
  image-rendering: pixelated;
  border: 2px solid var(--cyan-soft, #5ef3ff);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
.help-desc {
  margin: 0;
  font-size: clamp(8px, 1.7vmin, 14px);
  line-height: 1.7;
  color: var(--ink, #f5e6ff);
}
.help-controls {
  margin: 0;
  font-size: clamp(8px, 1.6vmin, 13px);
  line-height: 1.6;
  color: var(--cyan-soft, #5ef3ff);
}
.help-label { display: block; margin-bottom: 0.6vmin; letter-spacing: 0.1em; opacity: 0.8; }
.help-report {
  font-size: clamp(7px, 1.3vmin, 11px);
  color: var(--pink, #ff2e88);
  text-decoration: none;
  opacity: 0.85;
}
.help-report:hover, .help-report:focus-visible { text-decoration: underline; opacity: 1; outline: none; }
.help-close { margin-top: 0.4vmin; }

/* Transient "Link copied!" toast (share.js). */
.pork-toast {
  position: fixed;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%) translateY(10px);
  z-index: 20;
  padding: 0.7em 1.1em;
  font-family: inherit;
  font-size: clamp(8px, 1.6vmin, 13px);
  color: #06121a;
  background: var(--cyan-soft, #5ef3ff);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.pork-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Share modal (share.js): X / Reddit / Facebook + copy link ---- */
.share-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 4vmin;
  background: rgba(5, 5, 12, 0.74);
}
.share-modal.show { display: flex; }
.share-panel {
  position: relative;
  width: min(92vw, 360px);
  padding: 1.5rem 1.2rem 1.2rem;
  text-align: center;
  color: #f3eefb;
  font-family: ui-monospace, "Courier New", monospace;
  background: linear-gradient(180deg, #1a1730, #120f22);
  border: 2px solid rgba(94, 243, 255, 0.4);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
}
.share-close {
  position: absolute; top: 0.4rem; right: 0.6rem;
  background: none; border: none; cursor: pointer;
  color: #9c93b6; font-size: 1.5rem; line-height: 1;
}
.share-close:hover { color: #ff5fa2; }
.share-title {
  margin: 0 0 0.6rem;
  font-size: 0.95rem; letter-spacing: 0.03em; color: #ff8ec2;
}
.share-blurb { margin: 0 0 1rem; font-size: 0.82rem; color: #c9c0e0; line-height: 1.4; }
.share-links { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 0.9rem; }
.share-link {
  flex: 1; padding: 0.6rem 0.3rem; border-radius: 8px;
  font-size: 0.8rem; font-weight: bold; text-decoration: none; color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.14);
  transition: transform 0.08s ease, filter 0.08s ease;
}
.share-link:hover, .share-link:focus-visible { transform: translateY(-2px); filter: brightness(1.18); outline: none; }
.share-x { background: #1da1f2; border-color: #1a91da; }   /* classic Twitter blue */
.share-reddit { background: #ff4500; }
.share-fb { background: #1877f2; }
.share-link { font-size: 0.74rem; }   /* fits the longer "Twitter/X" label */
.share-copy-row { display: flex; gap: 0.4rem; }
.share-url {
  flex: 1; min-width: 0; padding: 0.5rem 0.6rem;
  font-size: 0.72rem; font-family: ui-monospace, monospace; color: #c9c0e0;
  background: #0c0a16; border: 2px solid rgba(255, 255, 255, 0.12); border-radius: 8px;
}
.share-copy {
  padding: 0.5rem 0.85rem; border: none; border-radius: 8px; cursor: pointer;
  font-size: 0.75rem; font-weight: bold; font-family: ui-monospace, monospace;
  color: #06222a; background: #5ef3ff;
}
.share-copy.copied { background: #9dffb0; }
.share-native {
  width: 100%; margin-top: 0.8rem; padding: 0.55rem; cursor: pointer;
  font-size: 0.75rem; font-family: ui-monospace, monospace; color: #c9c0e0;
  background: transparent; border: 2px solid rgba(255, 255, 255, 0.18); border-radius: 8px;
}
.share-native:hover { border-color: var(--cyan-soft, #5ef3ff); }

/* ---- Related-games (gen-related.mjs + leaderboard.js) ---- */
/* The static <section> is hidden; leaderboard.js reads its links and renders
   them inside the game-over overlay where they're visible and on-brand. */
.related-games { display: none; }

/* In-leaderboard "more games" rail shown on the game-over board screen. */
.lb-related-label {
  margin: 0.5vmin 0 0;
  font-size: clamp(6px, 1.2vmin, 10px);
  color: var(--pink);
  letter-spacing: 0.12em;
  text-shadow: 0 0 6px var(--pink);
}
.lb-related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5vmin 1vmin;
  justify-content: center;
  max-width: 92%;
  margin: 0;
}
.lb-related-card {
  font-size: clamp(6px, 1.2vmin, 10px);
  color: var(--cyan-soft);
  text-decoration: none;
  border: 1px solid rgba(94, 243, 255, 0.3);
  border-radius: 4px;
  padding: 0.35vmin 0.75vmin;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.lb-related-card:hover,
.lb-related-card:focus-visible {
  border-color: var(--cyan-soft);
  background: rgba(94, 243, 255, 0.09);
  outline: none;
}
