/* Frogscotch Game Styles
   Container, level-select, and button styling come from the site design
   system (fn-system.css, navigation.css, components.css). Only gameplay-
   specific rules live here: step counter, grid cells, tile/frog sprites,
   and simulation animations. */

/* ── Loading state ── */
.game-wrapper.loading {
    visibility: hidden;
}

.main-content:has(.game-wrapper.loading)::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    border: 4px solid var(--fn-border-light);
    border-top-color: var(--fn-frogscotch);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    transform: translate(-50%, -50%);
    z-index: 100;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ── Step counter ── */
/* Styled like an fn-btn but non-interactive — shares the wobbly radius,
   border, and surface background so it reads as a status pill. */
#step-counter-wrapper {
    margin-top: auto;
    font-family: var(--fn-font-body);
    color: var(--fn-ink);
    background: var(--fn-surface);
    border: 2px solid var(--fn-ink);
    border-radius: var(--fn-shape-a);
    padding: 0.5rem 1rem;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    line-height: 1.4;
}

#step-counter {
    font-weight: bold;
}

#step-counter.low {
    color: var(--fn-error);
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ── Game board ── */
.game-board-row {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

#game-container {
    display: inline-flex;
    justify-content: center;
    align-items: flex-start;
}

#grid-container {
    --tile-size: 64px;
    display: grid;
    grid-template-columns: repeat(var(--grid-cols, 6), var(--tile-size));
    grid-template-rows: repeat(var(--grid-rows, 8), var(--tile-size));
    gap: 0;
    background-color: #4a6741;
    border: 3px solid var(--fn-ink);
    position: relative;
}

.grid-cell {
    width: 64px;
    height: 64px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tile-sprite {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
    position: absolute;
    top: 0;
    left: 0;
    /* Hide alt text while the sprite loads; alt stays for screen readers. */
    font-size: 0;
    color: transparent;
}

.arrow-tile {
    transition: transform 0s;
}

/* ── Frog sprites ── */
.frog-sprite {
    object-fit: contain;
    image-rendering: auto;
    position: absolute;
    z-index: 10;
    cursor: grab;
    transition: transform 0.1s ease-out, filter 0.1s ease-out;
    user-select: none;
    -webkit-user-drag: none;
    /* Hide alt text while the sprite loads; alt stays for screen readers. */
    font-size: 0;
    color: transparent;
}

.frog-sprite:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.frog-sprite.dragging {
    cursor: grabbing;
    transform: scale(1.15);
    filter: brightness(1.2) drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
    z-index: 100;
}

/* ── Game buttons layout ── */
.game-buttons {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
}

/* Primary Hop button uses the frogscotch green instead of the default
   gold accent — green is the game's signature color. */
#hop-btn.fn-btn--primary {
    background: var(--fn-frogscotch);
    color: #ffffff;
}

/* fn-btn handles visuals; only disabled state needs a frogscotch rule
   because the JS toggles .disabled on #hop-btn. */
.fn-btn.disabled,
.fn-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Simulation animations ── */
.frog-sprite.hopping {
    animation: hop 0.15s ease-out;
}

.frog-sprite.bounce {
    animation: bounce 0.3s ease-out;
}

.frog-sprite.bounce-short {
    animation: bounce 0.4s ease-out;
}

.frog-sprite.despawning {
    animation: despawn 0.3s ease-out forwards;
    pointer-events: none;
}

@keyframes hop {
    0% {
        transform: scale(1) translateY(0);
    }
    50% {
        transform: scale(1.1) translateY(-8px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

@keyframes bounce {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(0.9);
    }
    60% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes despawn {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.8;
        filter: brightness(2) saturate(0);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* ── Tutorial button (matches housegame .tutorial-btn position) ── */
.frogscotch-tutorial-btn {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    width: 2.5rem;
    height: 2rem;
    padding: 0;
    z-index: 800;
    font-size: 1.2rem;
    font-weight: bold;
    min-height: unset;
}

/* ── Tutorial mini-game area ── */
.tut-game-area {
    position: relative;         /* cursor is absolute within here */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* Grid container for tutorial instances — same visuals as #grid-container
   but applied via class so multiple instances can coexist on one page. */
.tut-grid-container {
    display: grid;
    gap: 0;
    background-color: #4a6741;
    border: 3px solid var(--fn-ink);
    position: relative;
    flex-shrink: 0;
}

/* Side panel holding the Hop button and optional step counter */
.tut-side-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
}

/* Hop button in tutorial — same green as the real one, but pointer-events: none
   because the fake cursor drives all interaction. */
.tut-hop-btn {
    background: var(--fn-frogscotch);
    color: #ffffff;
    pointer-events: none;
}

/* Visual "pressed" state triggered by the choreography script */
.tut-btn-pressed {
    transform: translate(1px, 1px) !important;
    box-shadow: none !important;
    filter: brightness(0.9);
}

/* Step counter pill — mirrors #step-counter-wrapper styling */
.tut-step-counter {
    font-family: var(--fn-font-body);
    color: var(--fn-ink);
    background: var(--fn-surface);
    border: 2px solid var(--fn-ink);
    border-radius: var(--fn-shape-a);
    padding: 0.4rem 0.75rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

.tut-counter-val {
    font-weight: bold;
}

/* ── Fake cursor ── */
/* Custom froghand image. transform offsets the fingertip to the coordinate.
   Tweak translate() if the hotspot needs repositioning once you see the image. */
.tutorial-cursor {
    position: absolute;
    pointer-events: none;
    z-index: 200;
    transform: translate(-20%, -10%);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
    transition: opacity 0.3s ease;
}

.tutorial-cursor.pressing {
    transform: translate(-20%, -10%) scale(0.82);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
    transition: transform 0.1s ease, filter 0.1s ease !important;
}
