/* === Swipe game ====================================================
   Companion to js/games/swipe.js + games/swipe.partial.html.
   The four directional .swipe-option bubbles ring the .swipe-arena; the
   .swipe-puck (centered character) drags toward whichever romaji matches.
   .swipe-timer-fill drains over each round; .urgent bumps the fill to
   the warning color in the last seconds.

   Slide-in: .swipe-game inactive sits 40px right-of-center; .active
   slides it home, paired with .card-area.hidden translating -40px the
   other way for a cross-slide handoff.
   ==================================================================== */

.swipe-game {
    /* Overlays .card-area-stage (column-section bounds, below the
       toolbar). Same canvas pattern as Rain: cream background +
       dashed outline, flex column for header / arena / timer rows.
       Inactive state sits 40px right of center so it slides into
       place when .active lands — pairs with .card-area.hidden
       translating -40px the other way for a clean cross-slide. */
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    opacity: 0;
    pointer-events: none;
    transform: translateX(40px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
    z-index: 2;
    background: var(--bg);
    border: var(--dash);
    border-radius: 14px;
    /* Top + bottom padding absorb the 32px option-bubble overshoot
       (.swipe-option.top sits at -32px outside the arena). 48px gives
       the bubble a few pixels of breathing room above the dashed
       border regardless of whether the header content (score /
       progress) is visible — Recall-handoff mode hides some of those,
       so we can't rely on header chrome to push the arena down. */
    padding: 48px 14px 32px;
    box-sizing: border-box;
}

.swipe-game.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.swipe-game-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 4px;
}

.swipe-score {
    font-size: 0.85rem;
    color: var(--green);
    font-weight: 600;
}

.swipe-progress {
    font-size: 0.8rem;
    color: var(--text-faint);
}

.swipe-timer {
    width: 100%;
    height: 3px;
    background: var(--timer-bg);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4rem;
}

.swipe-timer-fill {
    height: 100%;
    border-radius: 2px;
    width: 100%;
    transition: width 0.1s linear, background 0.3s;
    background: var(--timer-fill);
}

.swipe-timer-fill.urgent {
    background: var(--timer-urgent);
}

/* Session progress bar — sits below the per-round timer. Subtler color
   so the eye reads the per-round timer first, the session progress
   second. The fill animates over 0.3s so re-queue / rebuild changes
   are perceptible rather than abrupt. */
.swipe-overall-progress {
    width: 100%;
    height: 4px;
    background: var(--subtle-bg);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}
.swipe-overall-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: var(--green);
    opacity: 0.7;
    transition: width 0.3s ease;
}

.swipe-arena {
    position: relative;
    width: 320px;
    height: 340px;
    /* Center inside the full-width .swipe-game canvas. margin:auto
       on a fixed-size flex child centers both axes inside the flex
       column; the surrounding header / timer stay flush top/bottom. */
    margin: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile — shrink the arena so the left / right option bubbles
   (which sit at -32px outside the arena) stop intersecting the
   .swipe-game's dashed border on phone-width viewports. 240×260
   gives a total footprint of 304×324 including the 32px bubble
   overshoot, fitting comfortably inside any modern phone width. */
@media (max-width: 600px) {
    .swipe-arena {
        width: 240px;
        height: 260px;
    }
}

/* Romaji option bubbles around the card */
.swipe-option {
    position: absolute;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-hover);
    border: 2px solid var(--accent-border);
    color: var(--accent);
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    font-family: inherit;
    z-index: 2;
}

.swipe-option.top    { top: -32px; left: 50%; transform: translateX(-50%); }
.swipe-option.right  { right: -32px; top: 50%; transform: translateY(-50%); }
.swipe-option.bottom { bottom: -32px; left: 50%; transform: translateX(-50%); }
.swipe-option.left   { left: -32px; top: 50%; transform: translateY(-50%); }

.swipe-option.correct {
    background: var(--green-bg);
    border-color: var(--green);
    color: var(--green);
    transform-origin: center;
}

.swipe-option.wrong {
    background: var(--red-bg);
    border-color: var(--red);
    color: var(--red);
}

/* Character puck in center */
.swipe-puck {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--puck-bg);
    border: 2px solid var(--puck-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 2.2rem;
    color: var(--text);
    z-index: 3;
    transition: top 0.3s ease-out, left 0.3s ease-out, opacity 0.3s;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.swipe-puck:active {
    cursor: grabbing;
}

.swipe-puck.fly {
    transition: top 0.25s ease-in, left 0.25s ease-in, opacity 0.2s;
}

.swipe-feedback {
    font-size: 0.85rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    text-align: center;
    margin-top: 8px;
    /* min-height (not height) so the empty-state still reserves a line
       of space, but multi-line completion messages can grow without
       overlapping the Continue button below. */
    min-height: 1.2rem;
    line-height: 1.35;
    padding: 0 8px;
}

/* End-of-session continue button. Hidden during play; revealed when
   the session completes so the user has time to read their score
   before launching Fall. */
/* End-of-session and start-of-session continue buttons retired — the
   between-activity transitions now use the shared Handoff prompt (see
   js/handoff.js + css/handoff.css). */

.swipe-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--close-bg);
    border: 1px solid var(--close-border);
    color: var(--close-color);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: all 0.2s;
}

.swipe-close:hover {
    background: var(--close-hover);
    color: var(--text-muted);
}

/* Game-over / round-complete overlay */
.swipe-overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.swipe-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
