/* Whack-a-Mole: the grid, the holes, the moles and the result window.
   Loaded after style.css, so it uses the tokens defined in style.css :root.

   whackamole.js writes each hole's phase on its button as data-phase:
     empty -> rising -> up -> sinking -> empty   (and "hit" after a tap)
   and, after a tap, data-result="right" or "wrong". This file draws those.
   The slide durations come from whackamole-rules.js as --mole-rise-ms and
   --mole-sink-ms, so the timing is written down only there. */

.mole-grid {
    display: grid;
    /* minmax(0, 1fr), not 1fr: plain 1fr won't shrink below a long word's width. */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 20px 0;
    /* Fast taps stay taps: no double-tap-to-zoom on the grid. */
    touch-action: manipulation;
}

/* The board holds the grid and lays the "3, 2, 1" over its middle. */
.mole-board {
    position: relative;
}

.start-countdown {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-family: var(--font-display);
    font-size: 5rem;
    line-height: 1;
    color: var(--color-accent);
    /* A soft white glow keeps the number readable over the dark holes. */
    text-shadow: 0 0 12px var(--color-surface), 0 0 24px var(--color-surface);
    pointer-events: none;
}

/* .hidden alone would lose to display: flex above, which comes later. */
.start-countdown.hidden {
    display: none;
}

/* The hole: a dark oval that clips whatever is below its rim. */
.mole-hole {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 5.5rem;
    padding: 0;
    border: none;
    border-radius: 50% / 40%;
    background: radial-gradient(ellipse at center, #6b4a30 0%, #4a3320 60%, #2e1f13 100%);
    box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.6);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* The mole: fills the hole when up, sits just below the rim when down. */
.mole {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 0.7rem;
    border-radius: inherit;
    background: #fdf6e3;
    color: #2e1f13;
    box-shadow: inset 0 0 0 3px var(--color-accent);
    /* Spectre's root is 20px, so 0.7rem = 14px. */
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.15;
    text-align: center;
    overflow-wrap: anywhere;
    overflow: hidden;
    transform: translateY(105%);
    transition: transform var(--mole-rise-ms) ease-out;
}

/* Answers over 30 characters (whackamole.js sets the class): smaller text,
   so up to 60 characters fit a phone-width hole. */
.mole--long {
    font-size: 0.6rem;
}

.mole-hole[data-phase="rising"] .mole,
.mole-hole[data-phase="up"] .mole,
.mole-hole[data-phase="hit"] .mole {
    transform: translateY(0);
}

.mole-hole[data-phase="sinking"] .mole {
    transform: translateY(105%);
    transition-duration: var(--mole-sink-ms);
    transition-timing-function: ease-in;
}

/* Emptied at once (the 10 s ran out mid-rise, say): no slide. */
.mole-hole[data-phase="empty"] .mole {
    transition: none;
}

/* After a tap: green or red, kept while it sinks. */
.mole-hole[data-result="right"] .mole {
    background: var(--color-success-bg);
    color: var(--color-success);
    box-shadow: inset 0 0 0 3px var(--color-success);
}

.mole-hole[data-result="wrong"] .mole {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    box-shadow: inset 0 0 0 3px var(--color-danger);
}

/* Reduced motion: no slide. The mole stays in place and fades in and out
   over the same durations, so the game's timing doesn't change. */
@media (prefers-reduced-motion: reduce) {
    .mole-hole[data-phase] .mole {
        transform: none;
        opacity: 1;
        transition: opacity var(--mole-rise-ms) linear;
    }

    .mole-hole[data-phase="sinking"] .mole {
        opacity: 0;
        transition-duration: var(--mole-sink-ms);
    }

    .mole-hole[data-phase="empty"] .mole {
        opacity: 0;
        transition: none;
    }
}

/* ---- Result window, shown after every question ---- */

.result-dialog {
    width: min(20rem, calc(100vw - 2rem));
    padding: 1.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    text-align: center;
}

.result-dialog::backdrop {
    background: rgba(24, 24, 27, 0.4);
}

.result-dialog h3 {
    margin: 0 0 0.5rem;
}

.result-verdict--passed {
    color: var(--color-success);
}

.result-verdict--failed {
    color: var(--color-danger);
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}
