<script lang="ts">
  let { closing = false } = $props();
</script>

<div class="splash-screen" class:closing>
  <div class="content">
    <div class="logo-container">
      <img src="/logo-no-text.png" alt="Portal BTC Logo" class="logo" />
    </div>

    <div class="branding">
      <h1 class="app-name">
        <span class="portal">PORTAL</span><span class="btc">BTC</span>
      </h1>
      <p class="tagline">Your portal to everything Bitcoin</p>
    </div>

    <div class="loading-container">
      <div class="loading-bar">
        <div class="loading-fill"></div>
      </div>
      <div class="loading-text">Initializing wallet...</div>
    </div>
  </div>
  <div class="arx-branding">
    <span class="powered-by">Powered by</span>
    <img src="/arx-logo.svg" alt="Arx" class="arx-logo" />
  </div>
</div>

<style>
  .splash-screen.closing {
    animation: wipe-out 0.5s cubic-bezier(0.55, 0.085, 0.68, 0.53) forwards;
  }

  @keyframes wipe-out {
    from {
      clip-path: circle(150% at top right);
    }
    to {
      clip-path: circle(0% at top right);
    }
  }

  .splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    overflow: hidden;
  }

  .content {
    text-align: center;
  }

  .logo-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 2rem;
    animation: logoFloat 4s ease-in-out infinite;
  }

  @keyframes logoFloat {
    0%,
    100% {
      transform: translateY(0px);
    }
    50% {
      transform: translateY(-10px);
    }
  }

  .logo {
    position: relative;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 10px black) drop-shadow(0 0 20px black);
  }

  .branding {
    margin-bottom: 1.5rem;
  }

  .app-name {
    font-size: 2rem;
    margin: 0 0 1rem 0;
    letter-spacing: 0.2em;
    line-height: 1.2;
  }

  .portal {
    color: var(--primary-color);
    -webkit-text-fill-color: white;
    -webkit-text-stroke: 1px;
  }

  .btc {
    color: var(--accent-color);
    -webkit-text-fill-color: white;
    -webkit-text-stroke: 1px;
  }

  .tagline {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.8);
    -webkit-text-fill-color: white;
    -webkit-text-stroke: 1px;
    margin: 0;
    letter-spacing: 0.1em;
    animation: fadeInUp 1s ease-out 1s both;
  }

  @keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .loading-container {
    animation: fadeInUp 1s ease-out 1.5s both;
  }

  .loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--accent-color);
    border-radius: 2px;
    margin: 0 auto 1rem;
    overflow: hidden;
    position: relative;
  }

  .loading-fill {
    height: 100%;
    background: linear-gradient(
      90deg,
      var(--primary-color) 0%,
      var(--accent-color) 50%,
      var(--primary-color) 100%
    );
    border-radius: 2px;
    animation: loadingProgress 3s ease-in-out infinite;
  }

  @keyframes loadingProgress {
    0% {
      width: 0%;
      transform: translateX(-100%);
    }
    50% {
      width: 100%;
      transform: translateX(0%);
    }
    100% {
      width: 100%;
      transform: translateX(100%);
    }
  }

  .loading-text {
    font-size: 0.5rem;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.1em;
    animation: loadingText 2s ease-in-out infinite;
  }

  @keyframes loadingText {
    0%,
    20% {
      opacity: 1;
    }
    50% {
      opacity: 0.5;
    }
    80%,
    100% {
      opacity: 1;
    }
  }

  .arx-branding {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    animation: fadeInUp 1s ease-out 2s both;
  }

  .powered-by {
    font-size: 0.85rem;
    color: white;
    -webkit-text-fill-color: white;
    -webkit-text-stroke: 1px;
  }

  .arx-logo {
    height: 2rem;
    filter: drop-shadow(0 0 5px black);
  }

  @media (max-width: 768px) {
    .app-name {
      font-size: 1.5rem;
    }

    .tagline {
      font-size: 0.5rem;
    }

    .logo-container {
      width: 100px;
      height: 100px;
    }

    .loading-bar {
      width: 150px;
    }
  }

  @media (max-width: 480px) {
    .app-name {
      font-size: 1.2rem;
    }

    .logo-container {
      width: 80px;
      height: 80px;
    }
  }
</style>
