/* Doorway Same or Different — activity styles.
   1em = 1/50th of activity width (set by doorway.js onResize).
   All sizing in em; no px except borders.
*/

/* --- Screen layout --- */

/* Flex-column skeleton comes from .dw-activity-screen in shared/doorway.css. */
.sad-screen {
    /* Layout is sized to fit the 800x450 stage — no scrolling. Without
       `hidden` here, a 1-2px rounding overflow from the bottom row triggers
       a vertical scrollbar and pushes the Next pencil partly off-screen. */
    overflow: hidden;
    padding: var(--dw-space-loose) var(--dw-space-loose) var(--dw-space-default);
    gap: var(--dw-space-narrow);
}

/* --- Welcome image --- */

/* Three picture cards (ladder | jam | ladder) from Flash welcome, rendered as
   three side-by-side <img>s rather than one wrapper SVG — <image href> inside
   an SVG loaded via <img src> won't fetch external resources, so the wrapper
   approach left the area blank. */
.welcome_image {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--dw-space-loose);
    width: 60%;
    max-width: 22em;
    margin: var(--dw-space-narrow) auto var(--dw-space-comfy);
}

.welcome_image img {
    width: 6em;
    height: auto;
}

/* Welcome screen vertical spacing.  Subtitle is constrained to the illustration
   width so it wraps to two lines, mirroring the Flash layout. */
.doorway_welcome .sub_title {
    font-size: 1.1em;
    margin: var(--dw-space-narrow) auto var(--dw-space-default);
    max-width: 18em;
}

/* --- Options screen --- */

/* Inner control fieldsets (exercise type, num questions, num cards) have no
   visible border in Flash. Suppress border/padding/margin on these. */
.options_group fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.sad-card-count-help {
    font-size: 0.9em;
    color: var(--dw-color-text-muted);
    margin: var(--dw-space-snug) 0 0 0;
    font-style: italic;
    /* Reserve enough width for the longest variant of this text — "Mode 2:
       3, 4, 5 or 6 cards" — so the fieldset doesn't change width when the
       user toggles between exercise types and the help text swaps. Without
       this, the fieldset's content-driven width changes on mode switch and
       the surrounding flex-wrap layout reflows mid-interaction. */
    min-width: 14em;
}

/* Base grid comes from the shared .dw-options-activity-grid class. */

/* Right column: Number of cards (row 1), Number of questions (row 2). */
.sad-grid-questions {
    grid-column: 2;
    grid-row: 2;
}

/* --- Activity screen layout --- */

.sad-activity-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: var(--dw-space-default);
}

/* Header is a 3-column grid so the mode title stays optically centred even when
   the question counter on the right has variable width. */
.sad-activity-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: baseline;
    gap: var(--dw-space-loose);
}

.sad-mode-title {
    grid-column: 2;
    font-size: 1.3em;
    font-weight: bold;
    margin: 0;
    text-align: center;
}

.sad-question-counter {
    grid-column: 3;
    justify-self: end;
    font-size: 1.1em;
    color: var(--dw-color-text-muted);
    margin: 0;
}

/* --- Card grid --- */

.sad-card-grid {
    display: flex;
    flex-direction: column;
    gap: 0.8em;
    align-items: center;
    flex: 1;
    padding: var(--dw-space-default) 0;
}

.sad-card-row {
    display: flex;
    gap: 0.8em;
    justify-content: center;
}

.sad-card {
    width: 6em;
    height: 9.5em;
    box-sizing: border-box;
    border: 2px solid var(--dw-color-border-neutral);
    border-radius: 0.5em;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    transition: border-color 0.25s, background-color 0.25s,
                transform 1.1s ease-out;
}

/* Mode 1 "two-the-same" reveal: after the user picks the matching pair we
   hide the other cards and reflow the pair into a single centred row at a
   larger size — see `_revealMode1Pair` in same-or-different.js. */
.sad-card-hidden {
    display: none;
}

.sad-pair-row {
    gap: 1.5em;
    margin-top: var(--dw-space-default);
}

.sad-pair-row .sad-card {
    width: 9em;
    height: 14em;
}

.sad-card:focus-visible {
    outline: 0.3em solid var(--dw-color-focus-ring);
    outline-offset: 0.1em;
}
@media (hover: hover) {
    .sad-card:hover {
        outline: 0.3em solid var(--dw-color-focus-ring);
        outline-offset: 0.1em;
    }
}

.sad-card img {
    width: 88%;
    height: 88%;
    object-fit: contain;
}

.sad-card.sad-card-selected {
    border-color: var(--dw-color-feedback-correct);
    border-width: 0.3em;
    background: #e8ffe8;
}

/* `.sad-card-correct` highlights the answer card(s) once the round resolves. */
.sad-card.sad-card-correct {
    border-color: var(--dw-color-feedback-correct);
    border-width: 0.3em;
    background: #e8ffe8;
    box-shadow: 0 0 0.6em rgba(0, 119, 0, 0.6);
}

/* Test mode: neutral highlight for a pick that has not yet been evaluated
   (Mode 1 first-of-two). Reads as "selected but pending", distinct from the
   green correct/selected state. */
.sad-card.sad-card-provisional {
    border-color: #2266cc;
    border-width: 0.3em;
    background: #eef4ff;
}

/* Test mode: red flash + shake when picks are wrong. Class is applied for
   ~700 ms then removed so the same cards can be picked again. The
   `:focus-visible` override keeps the last-clicked card readable as
   wrong — the default blue focus outline would otherwise hide the red
   border underneath. */
.sad-card.sad-card-error {
    border-color: var(--dw-color-feedback-wrong);
    border-width: 0.3em;
    background: #ffe8e8;
    animation: sad-card-shake 0.3s ease-in-out;
}
.sad-card.sad-card-error:focus,
.sad-card.sad-card-error:focus-visible {
    outline: 0.3em solid var(--dw-color-feedback-wrong);
    outline-offset: 0.1em;
}

@keyframes sad-card-shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-0.3em); }
    40%      { transform: translateX(0.3em); }
    60%      { transform: translateX(-0.2em); }
    80%      { transform: translateX(0.2em); }
}

/* --- Feedback banner ---
   Plain text at the bottom of the screen — no box, no green outline. */

.sad-banner {
    text-align: center;
    padding: 0;
    /* Fade/slide in once the banner is un-hidden. */
    opacity: 0;
    transform: translateY(0.4em);
    transition: opacity 0.35s ease-out, transform 0.35s ease-out;
}

.sad-banner.sad-banner-shown {
    opacity: 1;
    transform: translateY(0);
}

.sad-banner-text {
    font-size: var(--dw-font-size-heading);
    font-weight: bold;
    color: var(--dw-color-feedback-correct);
    margin: 0;
}

/* --- Bottom row: banner (centre) | Next pencil (right). ---
   3-column grid keeps the banner optically centred and the Next button
   pinned to the right edge in both Mode 1 (banner under the reflowed pair)
   and Mode 2 (banner alongside Next at the bottom). */
.sad-activity-bottom {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--dw-space-loose);
    margin-top: auto;
}

.sad-banner { grid-column: 2; }

.sad-next-button {
    grid-column: 3;
    justify-self: end;
}

/* --- Results screen --- */

.sad-results-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: var(--dw-space-loose);
    text-align: center;
}

.sad-results-heading {
    font-size: 1.6em;
    font-weight: bold;
    margin: 0 0 var(--dw-space-snug);
}

.sad-congrat-text {
    font-size: 2.5em;
    font-weight: bold;
    margin: 0;
    color: var(--dw-color-feedback-correct);
}

/* Labelled results block: two columns (label / value) split at the
   midpoint so all four colons line up vertically. `column-gap` provides
   the visual space around the colon. The blank gap row is a real grid
   row of fixed height between "Cards" and "Questions". */
.sad-results-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 0.35em;
    row-gap: 0.15em;
    margin: 0;
    font-size: 1.3em;
    line-height: 1.35;
}

.sad-results-row {
    display: contents;
}

.sad-results-summary dt {
    grid-column: 1;
    justify-self: end;
    margin: 0;
}

.sad-results-summary dt::after {
    content: ":";
}

.sad-results-summary dd {
    grid-column: 2;
    justify-self: start;
    margin: 0;
}

/* Blank visual row between "Cards" and "Questions" — matches the Flash
   spacing where Cards sits alone above the Questions/Tries/Score cluster. */
.sad-results-row-after-gap > dt,
.sad-results-row-after-gap > dd {
    margin-top: 1.2em;
}

.sad-results-nav {
    display: flex;
    gap: var(--dw-space-loose);
    justify-content: center;
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

