<script>
    import { push } from 'svelte-spa-router';
    import { gameCompleted } from '../stores/colorStore.js';

    function startGame() {
        push('/levelselect');
    }
</script>

<div class="title-screen">

    {#if $gameCompleted}

        <!-- ── NG+ home screen ── -->
        <div class="content">
            <h1 class="rainbow-title">The Full Hue</h1>
            <p class="ng-lead">you've brought all the color back.</p>
            <p class="ng-body">
                go through the world again — now in full color and without sorrows.<br>
                take your time. view the scenery. learn about your hues.
            </p>
            <button on:click={startGame}>go again</button>
        </div>

    {:else}

        <!-- ── original home screen ── -->
        <div class="content">
            <h1>The Full Hue</h1>
            <p class="tagline">Bring back your color</p>
            <button on:click={startGame}>begin</button>
        </div>

    {/if}

</div>

<style>
    .title-screen {
        width: 800px;
        height: 450px;
        margin: 0 auto;
        position: relative;
        overflow: hidden;
        background: #111;
    }

    .content {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        color: white;
        padding: 0 80px;
    }

    /* ── shared heading ── */
    h1 {
        font-family: 'Courier New', Courier, monospace;
        font-size: 64px;
        font-weight: 400;
        margin: 0;
        text-shadow: 0 2px 12px rgba(0,0,0,0.7);
    }

    /* ── original tagline ── */
    .tagline {
        font-family: 'Courier New', Courier, monospace;
        font-size: 22px;
        opacity: 0.8;
        margin: 0;
    }

    /* ── NG+ rainbow title ── */
    .rainbow-title {
        background: linear-gradient(
            90deg,
            #FF4136, #FF851B, #FFDC00, #2ECC40,
            #0074D9, #B10DC9, #FF69B4, #FF4136
        );
        background-size: 200% auto;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
        animation: shimmer 4s linear infinite;
    }

    @keyframes shimmer {
        from { background-position: 0% center; }
        to   { background-position: 200% center; }
    }

    /* ── NG+ text ── */
    .ng-lead {
        font-family: 'Courier New', Courier, monospace;
        font-size: 18px;
        color: rgba(255, 255, 255, 0.75);
        margin: 4px 0 0;
        text-align: center;
    }

    .ng-body {
        font-family: 'Courier New', Courier, monospace;
        font-size: 14px;
        color: rgba(255, 255, 255, 0.45);
        line-height: 1.75;
        margin: 0;
        text-align: center;
    }

    /* ── shared button ── */
    button {
        margin-top: 20px;
        padding: 12px 40px;
        font-family: 'Courier New', Courier, monospace;
        font-size: 22px;
        background: rgba(255, 255, 255, 0.15);
        color: white;
        border: 1px solid rgba(255, 255, 255, 0.4);
        border-radius: 30px;
        cursor: pointer;
        transition: background 0.2s;
    }

    button:hover { background: rgba(255, 255, 255, 0.3); }
</style>
