/* grigoriangames.com home page. Script: static/js/ui/pages/gg-home.js */
@layer page {
    /* ---------- hero ---------- */

    .hero {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: clamp(24px, 5vw, 80px);
        /* a little short of the full screen, so the next section shows its
           head and invites the scroll */
        min-height: min(86dvh, 800px);
        padding-block: var(--s-7);
    }

    .hero__copy {
        display: grid;
        gap: var(--s-5);
        justify-items: start;
    }

    .hero__title {
        font-family: var(--font-pixel);
        font-weight: 400;
        font-size: clamp(20px, 0.7rem + 1.7vw, 36px);
        line-height: 1.55;
        letter-spacing: 0;
        color: var(--ink);
        text-shadow: 3px 3px 0 var(--sapphire-deep);
        max-width: 16em;
    }

    .hero__title .nowrap {
        white-space: nowrap;
    }

    .hero__copy .btn-row {
        margin-top: var(--s-3);
    }

    .hero__seal {
        position: relative;
        display: grid;
        justify-items: center;
        gap: var(--s-2);
    }

    .hero__seal .sgc {
        --sgc-size: min(600px, 46vw, 72vh);
    }

    /* the light the rings sit in */
    .hero__seal::before {
        content: "";
        position: absolute;
        inset: -8%;
        z-index: -1;
        border-radius: 50%;
        background: radial-gradient(closest-side, rgb(0 202 205 / 0.26), rgb(9 95 143 / 0.16) 55%, transparent 74%);
        pointer-events: none;
    }

    .hero__hint {
        font-family: var(--font-pixel);
        font-size: 8px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--dim);
        animation: ui-blink 2.4s steps(2, jump-none) infinite;
        transition: opacity var(--slow);
    }

    /* The blink is an animation, and a running animation beats a plain
       opacity: it has to stop too, or the hint keeps blinking under the
       open mark. It keeps its place, so nothing moves. */
    .hero__seal:has(.is-playing) .hero__hint,
    html.seal-played .hero__hint {
        animation: none;
        opacity: 0;
    }

    /* ---------- the Hresh card ---------- */

    .game {
        --frame: color-mix(in oklab, var(--sapphire-hi) 55%, var(--line-strong));
        --game-pad: clamp(24px, 4vw, 56px);
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: var(--s-7);
        padding: var(--game-pad);
        background:
            radial-gradient(70% 110% at 100% 60%, rgb(194 45 35 / 0.1), transparent 62%),
            radial-gradient(80% 120% at 0% 0%, rgb(9 95 143 / 0.22), transparent 60%),
            linear-gradient(180deg, var(--panel-hi), var(--panel));
    }

    .game__body {
        display: grid;
        gap: var(--s-4);
        justify-items: start;
    }

    .game__title {
        margin-block: var(--s-2);
    }

    .game__title img {
        width: 200px;
    }

    .game__pitch {
        font-size: var(--text-lg);
        font-weight: 650;
        color: var(--ink);
        max-width: 26rem;
    }

    .game__body .muted {
        max-width: 28rem;
    }

    .game__body .btn-row {
        margin-top: var(--s-4);
    }

    .game__stage {
        display: grid;
        gap: var(--s-3);
    }

    /* ---------- the craft ---------- */

    .forge {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: clamp(32px, 6vw, 96px);
    }

    .creed {
        display: grid;
        gap: var(--s-6);
        max-width: 30rem;
    }

    .creed li {
        display: grid;
        gap: var(--s-2);
        padding-left: var(--s-5);
        border-left: 2px solid var(--line-strong);
    }

    .creed li:nth-child(2) {
        transition-delay: 90ms;
    }

    .creed li:nth-child(3) {
        transition-delay: 180ms;
    }

    .creed p {
        color: var(--muted);
    }

    .forge__bench {
        --plate: 384px; /* 64 art pixels at 6x; always a multiple of 64 */
        display: grid;
        justify-items: center;
        gap: var(--s-4);
    }

    /* the drafting plate: one square of the faint grid per art pixel */
    .forge__plate {
        position: relative;
        width: var(--plate);
        height: var(--plate);
        background:
            linear-gradient(rgb(115 169 206 / 0.07) 1px, transparent 1px) 0 0 / calc(var(--plate) / 64) calc(var(--plate) / 64),
            linear-gradient(90deg, rgb(115 169 206 / 0.07) 1px, transparent 1px) 0 0 / calc(var(--plate) / 64)
                calc(var(--plate) / 64),
            radial-gradient(closest-side, rgb(9 95 143 / 0.28), transparent),
            #0c101b;
        box-shadow:
            0 calc(var(--px) * -1) 0 0 var(--line-strong),
            0 var(--px) 0 0 var(--line-strong),
            calc(var(--px) * -1) 0 0 0 var(--line-strong),
            var(--px) 0 0 0 var(--line-strong),
            var(--shadow);
    }

    .forge__still,
    .forge__canvas {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
    }

    .forge__canvas {
        image-rendering: pixelated;
    }

    /* once the script is drawing, the plain image steps aside */
    .forge__bench.is-live .forge__still {
        visibility: hidden;
    }

    .forge__readout {
        display: flex;
        justify-content: space-between;
        width: var(--plate);
        font-family: var(--font-pixel);
        font-size: 8px;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--dim);
        font-variant-numeric: tabular-nums;
    }

    .forge__readout b {
        font-weight: 400;
        color: var(--gold);
    }

    .forge__readout [data-forge-name] {
        color: var(--ink);
    }

    .forge__picker {
        display: flex;
        gap: var(--s-1);
    }

    .forge__pick {
        display: grid;
        place-items: center;
        width: 64px;
        height: 64px;
        border-radius: 10px;
        opacity: 0.55;
        transition:
            opacity var(--fast),
            background-color var(--fast),
            box-shadow var(--fast);
    }

    .forge__pick img {
        width: 64px;
        height: 64px;
    }

    .forge__pick:hover {
        opacity: 1;
        background: rgb(115 169 206 / 0.12);
    }

    .forge__pick[aria-pressed="true"] {
        opacity: 1;
        background: rgb(9 95 143 / 0.3);
        box-shadow: 0 0 0 2px var(--gold);
    }

    /* ---------- closing row: what is next, and the newest haiku ---------- */

    .closing {
        display: grid;
        grid-template-columns: 1.4fr 1fr;
        gap: var(--s-6);
    }

    .workbench,
    .haiku-tease {
        display: flex;
        align-items: center;
        gap: var(--s-6);
    }

    .workbench img {
        flex: none;
        width: 150px;
    }

    .workbench > div,
    .haiku-tease > div {
        display: grid;
        gap: var(--s-2);
        justify-items: start;
    }

    .haiku-tease {
        transition:
            transform var(--slow) var(--ease),
            box-shadow var(--fast);
    }

    .haiku-tease:hover {
        --frame: var(--gold);
    }

    .haiku-tease img {
        flex: none;
        width: 72px;
    }

    .haiku-tease__title {
        font-family: var(--font-serif);
        font-size: 1.5rem;
        font-weight: 400;
        font-style: italic;
        letter-spacing: 0.01em;
    }

    .haiku-tease .link {
        margin-top: var(--s-2);
        font-size: var(--text-sm);
    }
}

/* ---------- motion tied to the scrollbar ---------- */

/* As the hero scrolls away the seal sinks back and dims and the copy lifts
   off, so the first screen hands over to the next instead of sliding past.
   Only where the browser can drive an animation from scroll position, and
   only for visitors who have not asked for less motion. */
@media (prefers-reduced-motion: no-preference) {
    @supports (animation-timeline: scroll()) {
        @layer page {
            .hero__seal {
                animation: hero-seal-away linear both;
                animation-timeline: scroll(root block);
                animation-range: 0px 720px;
            }

            .hero__copy {
                animation: hero-copy-away linear both;
                animation-timeline: scroll(root block);
                animation-range: 0px 560px;
            }

            @keyframes hero-seal-away {
                to {
                    transform: translateY(140px) scale(0.84);
                    opacity: 0.12;
                }
            }

            @keyframes hero-copy-away {
                to {
                    transform: translateY(-48px);
                    opacity: 0;
                }
            }
        }
    }
}

/* ---------- narrower ---------- */

/* the board is eight 64px tiles wide; below this the card's copy beside it
   would be squeezed under 350px, so the board goes below the copy */
@media (max-width: 1180px) {
    @layer page {
        .game {
            grid-template-columns: 1fr;
        }

        .game__stage {
            justify-self: center;
        }
    }
}

@media (max-width: 1100px) {
    @layer page {
        .closing {
            grid-template-columns: 1fr;
        }
    }
}

@media (max-width: 900px) {
    @layer page {
        .hero {
            grid-template-columns: 1fr;
            justify-items: center;
            min-height: 0;
            padding-block: var(--s-6) var(--s-7);
            text-align: center;
        }

        /* Stacked, the seal sits above the copy, so sinking the one and
           lifting the other runs them into each other: no scroll motion. */
        .hero__seal {
            order: -1;
            animation: none;
        }

        .hero__seal .sgc {
            --sgc-size: min(420px, 76vw, 48vh);
        }

        .hero__copy {
            justify-items: center;
            animation: none;
        }

        .hero__copy .btn-row {
            justify-content: center;
        }

        .hero__title {
            max-width: 20ch;
        }

        .forge {
            grid-template-columns: 1fr;
            justify-items: center;
        }

        .forge__copy {
            justify-self: stretch;
        }
    }
}

@media (max-width: 560px) {
    @layer page {
        .forge__bench {
            --plate: 320px;
        }

        .forge__pick,
        .forge__pick img {
            width: 48px;
            height: 48px;
        }

        .forge__pick img {
            width: 32px;
            height: 32px;
        }

        .workbench,
        .haiku-tease {
            flex-direction: column;
            text-align: center;
        }

        .workbench > div,
        .haiku-tease > div {
            justify-items: center;
        }
    }
}

@media (max-width: 359px) {
    @layer page {
        .forge__bench {
            --plate: 256px;
        }

        /* six pieces across 288px */
        .forge__picker {
            gap: 0;
        }

        .forge__pick {
            width: 44px;
            height: 44px;
        }
    }
}

/* On a phone the board fills the card: the stage spans the card edge to
   edge and skirmish.js sizes the board to it (see fit()). */
@media (max-width: 640px) {
    @layer page {
        .game__stage {
            justify-self: stretch;
            justify-items: center;
            margin-inline: calc(var(--game-pad) * -1);
        }
    }
}

/* On a 2x or 1x phone the board's art lands on uneven screen pixels, which
   break it up; skirmish.js marks the board .is-smooth there (see fit()). */
@layer page {
    .board.is-smooth,
    .board.is-smooth .px {
        image-rendering: auto;
    }
}
