/*
  Project: Bloc Buster
  Description: Global styles for the various game screens.
  Author: Dominique Thomas (github.com/dominique-thomas)
  License: Shared publicly for demonstration purposes only. Reuse or redistribution not permitted without permission.
*/
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
  --cab-nudge-x: 0px;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Press Start 2P", monospace;
  color: cyan;
  background: #1f1f20;
}

.arcade-container {
  position: relative;
  height: 100svh;
  max-height: 100vh;
  aspect-ratio: 1024 / 1536;
  margin: 0 auto;
  transform: translateX(var(--cab-nudge-x));
  will-change: transform;
}

.arcade-overlay,
.arcade-window {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.arcade-overlay {
  background: url('../images/Bloc_Buster_Arcade_Overlay.png') center center no-repeat;
  background-size: auto 100%;
  pointer-events: none;
  z-index: 100;
}

.arcade-window {
  top: calc(409 / 1536 * 100%);
  left: calc(192 / 1024 * 100%);
  width: calc(640 / 1024 * 100%);
  height: calc(767 / 1536 * 100%);
  z-index: 80;
  background: #090c0e;
}

.arcade-window::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom,
      rgba(28, 241, 241, 0.5) 1px,
      transparent 2px);
  opacity: 0.25;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 1;
}

.arcade-content,
.splash-screen,
.game-container,
.game-over-screen {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  z-index: 2;
}

.title {
  color: magenta;
  font-size: clamp(1.2rem, 3vw, 2rem);
}

.splash-screen {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.text-glow {
  text-shadow: 0 0 6px cyan;
}

.player-label {
  text-align: left;
  width: 50%;
}

.high-score {
  text-align: right;
  width: 50%;
}

.btn.primary {
  margin: auto;
}

.blinking {
  animation: blinkText 3s ease-in-out infinite;
}

.hidden {
  display: none !important;
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  padding: 0.4rem 0.8rem;
  border: 2px solid #0ff;
  background: transparent;
  color: #0ff;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.btn:hover {
  border-color: magenta;
  color: magenta;
}

.btn.small {
  font-size: 0.6rem;
  padding: 0.3rem 0.6rem;
}

canvas {
  image-rendering: pixelated;
  border: 2px solid cyan;
  background: #000;
  display: block;
  max-width: 100%;
  height: auto;
  touch-action: none;
  -ms-touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.marquee-text {
  position: absolute;
  top: calc(140 / 1536 * 100%);
  left: calc(36 / 1024 * 100%);
  width: calc(952 / 1024 * 100%);
  height: calc(100 / 1536 * 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1010;
}

.marquee-text h1 {
  font-size: calc(0.5 * (100vh * (130 / 1536)));
}

.game-over-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  height: 100%;
  padding: 0.5rem;
  font-size: clamp(0.6rem, 1.2vw, 0.9rem);
}

#start-btn {
  font-size: 0.85rem;
  /* a bit bigger */
  padding: 0.8rem 1.8rem;

  animation: pulseGlow 2.5s ease-in-out infinite;
}

.top-scores-title {
  margin-top: 0.3rem;
  font-size: 0.9em;
}

.emphasis {
  text-shadow: 0 0 6px cyan, 0 0 6px magenta;
}

#game-over {
  margin-bottom: .5px;
}

#leaderboard {
  flex: 0.75;
  overflow-y: auto;
  text-align: center;
  font-size: 0.8em;
}

#name-entry {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
}

#name-input {
  width: 3ch;
  background: transparent;
  border: none;
  border-bottom: 2px solid #0ff;
  color: #0ff;
  font-family: inherit;
  font-size: 1.2rem;
  text-transform: uppercase;
  caret-color: #0ff;
  outline: none;
  text-align: left;
}

#name-input::placeholder {
  color: cyan;
  opacity: 0.5;
}

.score-table {
  margin: 0 auto;
  border-collapse: collapse;
  width: 90%;
  text-align: left;
}

.score-table td {
  padding: 0.25rem 0;
}

.score-table .score {
  text-align: right;
}

#back-btn {
  margin-top: 0.8rem;
}

#clear-storage {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translate(-50%);
  z-index: 9999;
}

.hud-bottom,
.hud-top,
.hud-top-centered {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 3rem;
  padding: 0.5rem 0.5rem;
  font-size: 0.7rem;
}

.player-label,
.high-score {
  color: cyan;
}

.controls {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  background: none;
  border: none;
  color: magenta;
  opacity: 0.7;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.icon-btn:hover {
  opacity: 1;
  color: magenta;
}

.arcade-window .game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
}

.arcade-window .game-wrapper {
  flex: 0 0 auto;
  display: flex;
  max-height: 80%;
  justify-content: center;
}

.popup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 998;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup {
  position: relative;
  border: 2px solid cyan;
  padding: 0.5rem;
  z-index: 999;
  max-width: 90%;
}

.controls-image {
  max-width: 100%;
  height: auto;
  display: block;
}

.close-x {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  color: magenta;
  opacity: 0.8;
  font-size: 1rem;
}

.close-x:hover {
  opacity: 1;
}


.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 950;
}

.pause-overlay span {
  font-size: 1.5rem;
}

.glitch {
  position: relative;
  animation: glitch-skew 5s infinite ease-in-out alternate;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  color: magenta;
  z-index: -1;
}

.glitch::before {
  animation: glitch-anim 6s infinite ease-in-out;
  text-shadow: -2px 0 magenta;
}

.glitch::after {
  animation: glitch-anim2 5s infinite ease-in-out;
  text-shadow: 2px 0 cyan;
}

@keyframes glitch-anim {
  0% {
    clip-path: inset(0 0 85% 0);
  }

  10% {
    clip-path: inset(5% 0 70% 0);
  }

  20% {
    clip-path: inset(10% 0 50% 0);
  }

  30% {
    clip-path: inset(15% 0 40% 0);
  }

  40% {
    clip-path: inset(20% 0 30% 0);
  }

  50% {
    clip-path: inset(25% 0 20% 0);
  }

  60% {
    clip-path: inset(30% 0 10% 0);
  }

  70% {
    clip-path: inset(35% 0 5% 0);
  }

  100% {
    clip-path: inset(0 0 85% 0);
  }
}

@keyframes glitch-anim2 {
  0% {
    clip-path: inset(50% 0 0 0);
  }

  25% {
    clip-path: inset(40% 0 10% 0);
  }

  50% {
    clip-path: inset(30% 0 20% 0);
  }

  75% {
    clip-path: inset(20% 0 30% 0);
  }

  100% {
    clip-path: inset(10% 0 40% 0);
  }
}

@keyframes glitch-skew {
  0% {
    transform: skew(0deg);
  }

  50% {
    transform: skew(1deg, 0.5deg);
  }

  100% {
    transform: skew(0deg);
  }
}

@keyframes blinkText {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

@keyframes pulseGlow {

  0%,
  100% {
    box-shadow: 0 0 4px rgba(0, 255, 255, 0.3), 0 0 8px rgba(0, 255, 255, 0.15);
  }

  50% {
    box-shadow: 0 0 6px rgba(0, 255, 255, 0.4), 0 0 12px rgba(0, 255, 255, 0.4);
  }
}

@media (max-width: 768px) {
  .marquee-text h1 {
    font-size: clamp(1rem, 6vmin, 3rem);
  }

  .arcade-container {
    width: 100%;
    height: auto;
  }

  .hud-top-centered {
    gap: 1rem;
  }

  .icon-btn {
    font-size: 0.8rem;
  }

  .hud-bottom,
  .hud-top,
  .hud-top-centered {
    font-size: 0.5rem;
  }
}