/* Games: one look for every game on the site (/games). Loaded on every game page, after the app kit and apps.css
   (Views/SeoLanding/Page.cshtml), so all games share these rules instead of each keeping its own copy.

   Every game root is an app-kit root in the games category:
       <div class="filter-landing-app ak-app <slug>-landing-app" data-ak-category="games"> (the site blue accent)
   and its buttons are kit buttons with the shared button icons (css/app-kit/components.css):
       <button class="ak-btn ak-btn--primary ak-btn--new">New game</button>   the main action, filled blue
       <button class="ak-btn ak-btn--pause">Pause</button>                    a toggle; aria-pressed="true" shows it held
       <button class="ak-btn ak-btn--hint">Hint</button>                      outlined, with the lightbulb
       <button class="ak-btn">Undo</button>                                   everything else, outlined
   in a row of two columns: <div class="game-actions"> (older games keep their .spirograph-playback-row); the rows and
   the icons are shared with every landing app (components.css). An auto-solve Pause button keeps the pause icon while
   it is held: add ak-btn--keep-pause (the label stays Pause). Touch pads: .game-pad (see below). */

/* --- The games accent for the site's shared controls too (checkboxes, sliders, chips use --landing-accent) -------
   Set on the stage and the control panel, where the kit's light or dark tokens apply. */

.ak-app[data-ak-category="games"] > .filter-landing-stage,
.ak-app[data-ak-category="games"] > .filter-landing-controls {
    --landing-accent: var(--ak-accent);
    --landing-accent-deep: color-mix(in srgb, var(--ak-accent) 85%, var(--ak-text));
    --landing-accent-semi-transparent: color-mix(in srgb, var(--ak-accent) 73%, transparent);
}

/* Checkboxes and sliders of the shared app controls (<app-check>, <app-slider>) take the accent too. */
.ak-app[data-ak-category="games"] :is(.app-check-row, .app-slider-row) input {
    accent-color: var(--ak-accent);
}

/* --- Touch pads: under the board, only on touch screens ----------------------------------------------------------
   <div class="game-pad"> holds a direction pad (<div class="game-dpad"> with .game-key--up/left/right/down buttons;
   .game-dpad--row for left and right only)
   and, for games with an action, a round <button class="game-key game-key--fire">; .game-pad--grid lays the keys out
   in one row of equal buttons instead (.game-key--wide spans the row). */

.game-pad {
    display: none;
    width: min(100%, 780px);
    align-items: center;
    justify-content: space-between;
    gap: var(--ak-space-3);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.game-pad--center {
    justify-content: center;
}

.game-pad--grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.4rem;
}

@media (hover: none) and (pointer: coarse) {
    .game-pad {
        display: flex;
    }

    .game-pad.game-pad--grid {
        display: grid;
    }
}

.game-dpad {
    display: grid;
    grid-template-columns: repeat(3, 3.3rem);
    grid-template-rows: repeat(3, 3.3rem);
    gap: 0.25rem;
}

.game-dpad--row {
    grid-template-columns: repeat(2, 4.4rem);
    grid-template-rows: 3.6rem;
}

.game-dpad--row .game-key {
    grid-area: auto;
}

.game-key {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3.2rem;
    border: 1px solid var(--ak-border);
    border-radius: 0.8rem;
    background: var(--ak-panel);
    color: var(--ak-text);
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.game-key:active {
    background: var(--ak-hover);
}

.game-key--up { grid-area: 1 / 2; }
.game-key--left { grid-area: 2 / 1; }
.game-key--right { grid-area: 2 / 3; }
.game-key--down { grid-area: 3 / 2; }

/* The main action on a pad (place a charge, drop a piece): the accent colour. */
.game-key--fire,
.game-key--wide {
    border-color: transparent;
    background: var(--ak-accent);
    color: var(--ak-on-accent);
}

.game-key--fire:active,
.game-key--wide:active {
    background: var(--ak-accent);
    filter: brightness(0.9);
}

.game-key--fire {
    width: 5.5rem;
    height: 5.5rem;
    border-radius: 50%;
}

.game-key--wide {
    grid-column: 1 / -1;
}

/* --- A board canvas in the kit's stage ---------------------------------------------------------------------------- */

.game-board-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--ak-space-3);
}

/* --- Stat tiles: the value next to its label (Score 40), one slim line per tile, so the board starts higher ----- */

.ak-app[data-ak-category="games"] .ak-stats {
    gap: var(--ak-space-2);
}

.ak-app[data-ak-category="games"] .ak-stat {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    column-gap: 0.5rem;
    row-gap: 0;
    padding: 0.45rem 0.75rem;
}

.ak-app[data-ak-category="games"] .ak-stat-label {
    font-size: 0.85rem;
}

.ak-app[data-ak-category="games"] .ak-stat .ak-stat-value,
.ak-app[data-ak-category="games"] .ak-stat--main .ak-stat-value {
    font-size: var(--ak-fs-lg);
    overflow-wrap: normal;
}

.ak-app[data-ak-category="games"] .ak-stat .ak-stat-value.is-long,
.ak-app[data-ak-category="games"] .ak-stat .ak-stat-value.is-xlong {
    font-size: 1rem;
}

/* --- Phones: two tiles per row (three for three), still label and value on one line ----------------------------- */

@media (max-width: 640px) {
    .ak-app[data-ak-category="games"] .ak-stats,
    .ak-app[data-ak-category="games"] .ak-stats[data-ak-cols] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Three tiles fit on one row. */
    .ak-app[data-ak-category="games"] .ak-stats[data-ak-cols="3"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .ak-app[data-ak-category="games"] .ak-stats[data-ak-cols="3"] > .ak-stat {
        grid-column: auto;
    }

    .ak-app[data-ak-category="games"] .ak-stat {
        padding: 0.35rem 0.6rem;
    }

    .ak-app[data-ak-category="games"] .ak-stat-label {
        font-size: 0.8rem;
    }

    .ak-app[data-ak-category="games"] .ak-stat .ak-stat-value,
    .ak-app[data-ak-category="games"] .ak-stat--main .ak-stat-value {
        font-size: 1.05rem;
    }
}
