<script lang="ts">
  import { LoaderCircle } from 'lucide-svelte';
</script>

<section class="locked-card loading-card workspace-boot-card" aria-live="polite">
  <div class="workspace-boot-orb" aria-hidden="true">
    <LoaderCircle size={26} strokeWidth={2.1} />
  </div>
  <p class="workspace-label">Checking Workspace</p>
  <h2>Restoring your client workspace.</h2>
  <p>Hold on while we reload your saved session and bring the app back into place.</p>
  <div class="workspace-boot-progress" aria-hidden="true">
    <span class="workspace-boot-progress-bar"></span>
  </div>
</section>

<style>
  .locked-card {
    max-width: 42rem;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    background: var(--panel);
    box-shadow: var(--shadow);
  }

  .loading-card {
    min-height: 10rem;
  }

  .workspace-boot-card {
    position: relative;
    display: grid;
    gap: 0.85rem;
    align-items: start;
    min-height: 14rem;
    margin: 0 auto;
    padding: 1.45rem;
    overflow: hidden;
  }

  .workspace-boot-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
      radial-gradient(circle at top right, color-mix(in srgb, var(--color-brand) 18%, transparent), transparent 42%),
      linear-gradient(180deg, color-mix(in srgb, var(--color-brand) 4%, transparent), transparent 45%);
    pointer-events: none;
  }

  .workspace-boot-card > * {
    position: relative;
    z-index: 1;
  }

  .workspace-boot-orb {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.35rem;
    height: 3.35rem;
    border-radius: 1rem;
    background: color-mix(in srgb, var(--color-brand) 12%, var(--color-bg-surface));
    color: var(--color-brand);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--color-brand) 16%, transparent);
  }

  .workspace-boot-orb :global(svg) {
    animation: workspace-spin 1s linear infinite;
  }

  .workspace-boot-progress {
    width: min(16rem, 100%);
    height: 0.42rem;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--color-brand) 10%, var(--color-border));
  }

  .workspace-boot-progress-bar {
    display: block;
    width: 38%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--color-brand), color-mix(in srgb, var(--color-brand) 62%, white));
    animation: workspace-progress 1.15s ease-in-out infinite;
    transform-origin: left center;
  }

  .workspace-label {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  h2,
  p {
    margin: 0;
  }

  h2 {
    margin-top: 0.35rem;
    font-size: clamp(1.7rem, 3vw, 2.2rem);
  }

  p:last-of-type {
    margin-top: 0.45rem;
    color: var(--muted);
  }

  @keyframes workspace-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }

  @keyframes workspace-progress {
    0% { transform: translateX(-110%) scaleX(0.85); }
    55% { transform: translateX(135%) scaleX(1.05); }
    100% { transform: translateX(280%) scaleX(0.9); }
  }

  @media (prefers-reduced-motion: reduce) {
    .workspace-boot-orb :global(svg),
    .workspace-boot-progress-bar {
      animation: none;
    }
  }
</style>
