/**
 * File: main.css
 * Game: Space Invaders
 * Author: Suwayba
 * Date:  2025-05-27
 * 
 * Description: 
 * Styles for the Space Invaders game. 
 * Includes game-specific styling for layouts, texts and animations.
 * 
 */


  /* ====================================
    DESIGN TOKENS
    ==================================== */

  :root {
    --color-primary: #000000;
    --color-secondary: #ffffff;
    --color-bg-primary: #0a0a0a;
    --accent-color: #00ffff;
    --font-primary: 'Raster Forge Regular', sans-serif;
    --font-secondary: 'Press Start 2P', monospace;
    --spacing-small: .5rem;
    --spacing-medium: 1rem;
    --spacing-large: 1.5rem;
  }


  /* ====================================
    TYPOGRAPHY
   ==================================== */
  
  @font-face {
    font-family: "Raster Forge Regular";
    src: url('/assets/raster-forge-font/raster-forge-regular.ttf') format('truetype');
  }

  .font-secondary {
    font-family: var(--font-secondary), 'Play', sans-serif;
  }

  .text-lgr {
    font-size: 2.8rem;
  }

  .text-lg {
    font-size: var(--spacing-large);
  }

  .text-md {
    font-size: var(--spacing-medium);
  }

  .text-xs {
    font-size: var(--spacing-small);
  }

  .text-shadow-dark {
    text-shadow: 0 0 6px #58f5ff, 0 0 12px rgba(88, 245, 255, 0.3);
  }

  .warm-brown {
    color: #a35c36;
  }


  /* ====================================
    LAYOUT
   ==================================== */

  *, *::before, *::after {
    margin: 0;
    padding: 0;
  }
  
  body {
    margin: 0;
    background: url(/assets/images/space-invaders-background.jpg) no-repeat bottom center fixed;
    height: 100dvh;
    font-family: var(--font-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.5;
  }

  .canvas {
    display: block;
    margin: 0 auto;
    position: relative;
    max-width: 95%;
    box-shadow: 0 0 20px var(--accent-color);
    border-radius: 10px;
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
    animation: glowPulse 2s infinite;
  }

  .ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    min-height: 100dvh;
    width: 100%;
    text-align: center;
    color: white;
    box-shadow: inset 0 0 0 1000px rgba(0, 0, 0, 0.5);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-small);
    opacity: 0;
    display: flex;
    z-index: 2;
    transition: opacity 0.8s ease;
    pointer-events: none;
  }



  /* ====================================
    UTILITIES
   ==================================== */

  .visible {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto;
  }

  .rotate-90 {
    transform: rotate(90);
  }



  
  /* ====================================
    COMPONENTS
   ==================================== */

  .start-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    font-family: var(--font-secondary), 'Play', sans-serif;
    z-index: 1;
    opacity: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-large);
  }

  .credits {
    color: #94f0c3;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-small);
  }

  #loading-start-screen {
    background: url(/assets/images/space-invaders-background.jpg) no-repeat bottom center fixed;
    height: 100dvh;
  }

  .loader {
    height: .875rem;
    aspect-ratio: 6;
    display: flex;
    z-index: 300;
  }

  .loader:before,
  .loader:after {
    content: "";
    flex: 1;
    padding-left: calc(100%/6);
    background: radial-gradient(
      closest-side at calc(100%/3) 50%,
      #fff 90%, rgba(255, 255, 255, 0)) 
      0/75% 100% content-box;
    animation: l20 2s infinite;
  }

  .loader:after {
    --_s:-1;
  }
  
  .btn-link {
    cursor: pointer;
    margin-top: var(--spacing-medium);
  }
  
  .btn-link:hover {
    color: var(--accent-color);
  }

  .show-desktop {
    display: block;
  }

  .show-mobile {
    display: none;
  }

  #mobile-controls {
    display: none;
  }

  #desktop-controls {
    display: flex;
  }

  #pause-play-button {
    position: absolute;
    top: 4.5dvw;
    left: 3.9dvw;
    display: flex;
    align-items: center;
    background-color: inherit;
    cursor: pointer;
    outline: none;
    border: 0;
  }

  #pause-play-button:focus,
  #pause-play-button:focus-visible {
    outline: none;
    border: 0;
  }

  #pauseBtn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
  }




  /* ====================================
    ANIMATIONS
   ==================================== */

  @keyframes blink {
    50% { opacity: 0; }
  }
    
  @keyframes pulse {
    0%   { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.1); opacity: 1; }
  }

  @keyframes glowPulse {
    0%, 100% {
      box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
    }

    50% {
      box-shadow: 0 0 20px var(--accent-color), 0 0 40px var(--accent-color);
    }
  }

  @keyframes spin {
    0%, 100% {
      transform: scale(1) rotate(0deg);
    }

    50% {
      transform: scale(0.5) rotate(180deg);
    }
  }

  @keyframes l20 {
    0%       {transform:scale(var(--_s,1)) translate(0)    rotate(0)}
    25%      {transform:scale(var(--_s,1)) translate(-25%) rotate(0)}
    50%      {transform:scale(var(--_s,1)) translate(-25%) rotate(1turn)}
    75%,100% {transform:scale(var(--_s,1)) translate(0)    rotate(1turn)}
  }



   /* ====================================
    BREAKPOINTS
   ==================================== */
   @media screen and (max-width: 768px) {
    .text-lgr {
      font-size: 8dvw;
    }

    .text-md {
      font-size: 3dvw;
    }

    .text-xs {
      font-size: 1.5dvw;
    }

    #mobile-controls {
      display: flex;
    }

    #desktop-controls {
      display: none;
    }

    #pause-play-button {
      top: 10dvh;
      left: 6dvw;
    }

    .show-desktop {
      display: none;
    }

    .show-mobile {
      display: block;
    }
   }