/*
 * Touch tutorial / attract loop  (see assets/js/touch-tutorial.js)
 *
 * Plays after the screen has been idle: a hand icon floats to the real on-page
 * buttons and visibly presses them, prompting the passer-by to touch the screen.
 *
 * Skin-agnostic on purpose. The highlight is an overlay ring positioned and
 * shaped from the target's own computed geometry, so it traces the round nav
 * circles and the rectangular article tiles equally well on every club
 * stylesheet in assets/css/.
 *
 * To recolour for a club, override the custom properties:
 *   .gc-tt { --gc-tt-accent: #c8a45c; --gc-tt-accent-soft: rgba(200,164,92,.35); }
 */

.gc-tt {
    --gc-tt-accent: #7a9a01;
    --gc-tt-accent-soft: rgba(122, 154, 1, 0.35);
    --gc-tt-accent-glow: rgba(122, 154, 1, 0.5);
    --gc-tt-dim: rgba(0, 20, 45, 0.45);
    --gc-tt-ink: #00336a;
    --gc-tt-paper: #ffffff;
    /* Overwritten inline from the travelMs config value. */
    --gc-tt-travel: 1400ms;
    --gc-tt-ease: cubic-bezier(.45, .05, .25, 1);

    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    /* Above .loader.overlay (99999) and #whole-page-backdrop (1050). */
    z-index: 100050;
    /*
     * Inert from first frame to last, and no child ever sets this back to
     * auto. This is what lets the first real touch land on the button the user
     * aimed at instead of being swallowed by the tutorial. See wake().
     */
    pointer-events: none;
    opacity: 0;
    transition: opacity 600ms ease;
    -webkit-font-smoothing: antialiased;
}

.gc-tt.is-visible {
    opacity: 1;
}

.gc-tt.is-waking {
    opacity: 0;
    transition: opacity 450ms ease;
}


/* ---------------------------------------------------------------- veil ----- */

/*
 * Flat dim for the opening moment, before the first target is picked. Once the
 * ring is on, its huge outer box-shadow takes over the dimming (and leaves a
 * lit hole around the target), so this fades back out.
 */
.gc-tt__veil {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--gc-tt-dim);
    opacity: 1;
    transition: opacity 900ms ease;
}

.gc-tt.has-spot .gc-tt__veil {
    opacity: 0;
}


/*
 * Waking up. Both dimming layers go on their own short transition, much faster
 * than the overlay's own fade, so the button the user just tapped stops being
 * darkened almost immediately while the hand and ripple ghost out behind it.
 *
 * Kept after .gc-tt.has-spot above: equal specificity, so source order decides.
 */
.gc-tt.is-waking .gc-tt__veil,
.gc-tt.is-waking .gc-tt__ring {
    opacity: 0;
    transition: opacity 140ms ease;
}


/* ---------------------------------------------------------------- ring ----- */

/*
 * Position, size and border-radius are all written by JS from the target's own
 * getBoundingClientRect() and computed border-radius, so no button styling is
 * assumed here.
 *
 * The last box-shadow layer is the spotlight: a 100vmax spread of the dim
 * colour darkens everything *outside* the ring, and because it follows the
 * ring's transform, size and radius it tracks the hand for free.
 *
 * Note that width, height and border-radius are transitioned here on purpose,
 * even though they are not compositable and this element's paint region covers
 * the viewport (the box-shadow reaches past it). It is what gives the morph
 * from a round nav circle to a rectangular tile; snapping them instead is
 * visibly worse. The cost is a viewport-sized repaint per frame during travel,
 * which is a solid rounded-rect fill and cheap under GPU rasterisation. If a
 * panel is ever measured to struggle, the fix is to split the spotlight onto
 * its own transform-only element rather than to stop morphing the ring.
 */
.gc-tt__ring {
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: border-box;
    border: 3px solid var(--gc-tt-accent);
    background: rgba(255, 255, 255, 0.06);
    box-shadow:
            0 0 0 6px var(--gc-tt-accent-soft),
            0 0 2.5rem var(--gc-tt-accent-glow),
            0 0 0 100vmax var(--gc-tt-dim);
    opacity: 0;
    transition:
            transform var(--gc-tt-travel) var(--gc-tt-ease),
            width var(--gc-tt-travel) var(--gc-tt-ease),
            height var(--gc-tt-travel) var(--gc-tt-ease),
            border-radius var(--gc-tt-travel) var(--gc-tt-ease),
            opacity 500ms ease;
}

.gc-tt__ring.is-on {
    opacity: 1;
}

/*
 * The press pulse, on its own child rather than on the ring.
 *
 * Same reasoning: the pulse used to animate the ring's box-shadow, and a
 * keyframe touching box-shadow can never be composited, so it repainted the
 * 100vmax spotlight region for its whole 620ms on every single step. Scaling
 * and fading a duplicate border is compositor-only and reads the same.
 */
.gc-tt__ring-pulse {
    position: absolute;
    /* Sit on the ring's own border rather than inside it. */
    top: -3px;
    right: -3px;
    bottom: -3px;
    left: -3px;
    box-sizing: border-box;
    border: 3px solid var(--gc-tt-accent);
    border-radius: inherit;
    opacity: 0;
}

.gc-tt__ring.is-pressed .gc-tt__ring-pulse {
    animation: gc-tt-ring-pulse 620ms var(--gc-tt-ease);
}


/* -------------------------------------------------------------- cursor ----- */

.gc-tt__cursor {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    opacity: 0;
    transition:
            transform var(--gc-tt-travel) var(--gc-tt-ease),
            opacity 400ms ease;
    will-change: transform;
}

.gc-tt__cursor.is-on {
    opacity: 1;
}

/*
 * The idle bob lives on a child so it cannot fight the travel transform on the
 * parent. Nesting the two is what keeps the motion smooth.
 */
.gc-tt__cursor-bob {
    position: absolute;
    top: 0;
    left: 0;
    width: 5.5rem;
    height: 5.5rem;
    animation: gc-tt-bob 2600ms ease-in-out infinite;
}

.gc-tt__cursor.is-pressed .gc-tt__cursor-bob {
    animation: gc-tt-press 620ms var(--gc-tt-ease);
}

.gc-tt__hand {
    position: relative;
    z-index: 2;
    display: block;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0.35rem 0.75rem rgba(0, 20, 45, 0.75));
}

/*
 * Sits on the fingertip. Keep top/left in step with FINGER_Y_RATIO /
 * FINGER_X_RATIO in touch-tutorial.js.
 */
.gc-tt__ripple {
    position: absolute;
    top: 4%;
    left: 38.8%;
    z-index: 1;
    width: 1.6rem;
    height: 1.6rem;
    margin: -0.8rem 0 0 -0.8rem;
    border-radius: 50%;
    background: var(--gc-tt-accent);
    opacity: 0;
    pointer-events: none;
}

.gc-tt__cursor.is-pressed .gc-tt__ripple {
    animation: gc-tt-ripple 700ms ease-out;
}


/* ------------------------------------------------------------- caption ----- */

.gc-tt__caption {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 27rem;
    padding: 0.7rem 1.25rem;
    border-radius: 0.6rem;
    background: var(--gc-tt-ink);
    color: var(--gc-tt-paper);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    box-shadow: 0 0.4rem 1.5rem rgba(0, 20, 45, 0.4);
    opacity: 0;
    transition:
            transform var(--gc-tt-travel) var(--gc-tt-ease),
            opacity 400ms ease;
}

.gc-tt__caption.is-on {
    opacity: 1;
}

.gc-tt__caption em {
    font-style: normal;
    color: var(--gc-tt-accent);
}


/* -------------------------------------------------------------- banner ----- */

.gc-tt__banner {
    position: absolute;
    left: 50%;
    bottom: 6vh;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.15rem 2.5rem 1.15rem 1.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow:
            0 0.5rem 2.5rem rgba(0, 20, 45, 0.3),
            0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    transform: translateX(-50%);
    opacity: 0;
    animation: gc-tt-banner-in 900ms 400ms var(--gc-tt-ease) forwards;
}

.gc-tt__banner-icon {
    display: block;
    width: 3rem;
    height: 3rem;
    flex: 0 0 auto;
    animation: gc-tt-nudge 2200ms ease-in-out infinite;
}

.gc-tt__banner-icon .gc-tt__hand {
    filter: drop-shadow(0 0.15rem 0.3rem rgba(0, 20, 45, 0.25));
    fill: var(--gc-tt-ink);
}

.gc-tt__banner-text {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.01em;
    color: var(--gc-tt-ink);
    white-space: nowrap;
}

.gc-tt__banner-sub {
    display: block;
    margin-top: 0.2rem;
    font-size: 1.5rem;
    font-weight: 400;
    opacity: 0.6;
}


/* --------------------------------------------------------- wake feedback --- */

/* Ripple drawn at the point the passer-by actually touched. Positioned with
 * left/top rather than a transform, because the animation owns transform. */
.gc-tt__wake {
    position: absolute;
    width: 12rem;
    height: 12rem;
    margin: -6rem 0 0 -6rem;
    border-radius: 50%;
    border: 3px solid var(--gc-tt-accent);
    background: rgba(122, 154, 1, 0.18);
    opacity: 0;
    pointer-events: none;
    animation: gc-tt-wake 650ms ease-out forwards;
}


/* ------------------------------------------------- highlighted target ----- */

/*
 * The only class we add to a real element, and it is visual only: no synthetic
 * events are dispatched and the theme's own .active class (owned by
 * load-content.js) is never touched, so nothing on the page actually activates.
 */
.gc-tt-target {
    transition: transform 300ms cubic-bezier(.45, .05, .25, 1), filter 300ms ease;
}

.gc-tt-target.gc-tt-target--pressed {
    transform: scale(0.94);
    filter: brightness(1.12);
}


/* ----------------------------------------------------------- keyframes ---- */

@keyframes gc-tt-banner-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(1.5rem) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

@keyframes gc-tt-nudge {
    0%, 100% { transform: translateY(0); }
    45%      { transform: translateY(-0.32rem); }
    70%      { transform: translateY(0.1rem); }
}

@keyframes gc-tt-bob {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    50%      { transform: translate3d(0, -0.55rem, 0) rotate(-3deg); }
}

@keyframes gc-tt-press {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    28%  { transform: translate3d(0, 0.5rem, 0) scale(0.86); }
    55%  { transform: translate3d(0, 0, 0) scale(1.04); }
    100% { transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes gc-tt-ripple {
    0% {
        opacity: 0.55;
        transform: scale(0.3);
    }
    100% {
        opacity: 0;
        transform: scale(4.5);
    }
}

/*
 * Runs on .gc-tt__ring-pulse, not on the ring. transform and opacity only, so
 * the compositor handles it and the ring's 100vmax spotlight is never redrawn.
 * The earlier version animated box-shadow, which forced a larger-than-fullscreen
 * repaint for the whole 620ms on every step.
 */
@keyframes gc-tt-ring-pulse {
    0% {
        opacity: 0.95;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.16);
    }
}

@keyframes gc-tt-wake {
    0% {
        opacity: 0.9;
        transform: scale(0.2);
    }
    100% {
        opacity: 0;
        transform: scale(1.6);
    }
}


/* --------------------------------------------------- reduced motion ------- */

/*
 * Keep the tutorial itself (it is the entire point of the screen) but drop the
 * travel and bob in favour of crossfades.
 */
@media (prefers-reduced-motion: reduce) {
    .gc-tt {
        --gc-tt-travel: 1ms;
    }

    .gc-tt__cursor-bob,
    .gc-tt__banner-icon,
    .gc-tt__ring.is-pressed .gc-tt__ring-pulse,
    .gc-tt__cursor.is-pressed .gc-tt__cursor-bob,
    .gc-tt__cursor.is-pressed .gc-tt__ripple {
        animation: none !important;
    }

    .gc-tt__cursor,
    .gc-tt__ring,
    .gc-tt__caption {
        transition: opacity 400ms ease;
    }

    .gc-tt-target.gc-tt-target--pressed {
        transform: none;
    }
}
