/* =================================================================
   ACTIVITY SHELL (v0.25.0.0)
   The frame every Learn Words activity sits in — js/activity-shell.js
   builds the markup. One header, one ⋯ menu, one start card, one bottom
   dock, so a student learns where to tap once.

   Everything is scoped under .as-* and every colour is a token with a
   dark-mode value, so nothing here can move a pixel in a module that has
   not opted in.

   Layout rules (docs/student-ux-review/):
     - 16px body, 14px floor for anything a student reads; the target-
       language word is always larger than its English gloss.
     - 44px minimum for anything tappable, 52px for the primary action.
     - Spacing 4 · 8 · 12 · 16 · 24 · 32. Radius 10 control · 16 card.
     - Green and red mark an ANSWER, never a button (core.css's own rule).
   ================================================================= */

/* The --as-* tokens moved to styles/core.css in v0.25.2.0 (F1): every
   zone's frame uses them now, not only the activities. */

/* ---- the activity ------------------------------------------------ */

.as-activity {
    max-width: 1080px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--as-ink);
    font-size: var(--as-fs-md);
}

.as-card {
    background: var(--as-surface);
    border: 1px solid var(--as-line);
    border-radius: var(--as-r-card);
    box-shadow: var(--as-shadow-1);
}

/* ---- header ------------------------------------------------------ */

.as-head {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 48px;
}

.as-head-id {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
    flex-wrap: wrap;
}

.as-title {
    margin: 0;
    font-size: var(--as-fs-xl);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--as-ink);
    white-space: nowrap;
}

.as-sub {
    font-size: var(--as-fs-sm);
    color: var(--as-ink3);
}

.as-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 200px;
    max-width: 340px;
    margin-left: auto;
}

/* Nothing to count before Start: keep the row's height, show nothing. */
.as-progress.as-idle { visibility: hidden; }

.as-bar {
    flex: 1;
    height: 8px;
    border-radius: 99px;
    background: var(--as-sunk);
    overflow: hidden;
}

.as-fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: 99px;
    background: var(--as-brand-fill);
    transition: width 0.3s ease;
}

.as-count {
    font-size: var(--as-fs-sm);
    font-weight: 600;
    color: var(--as-ink2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 3ch;
}

/* ---- the ⋯ menu --------------------------------------------------- */

.as-menu-wrap {
    position: relative;
    flex: none;
}

.as-head > .as-menu-wrap:first-child,
.as-progress + .as-menu-wrap { margin-left: 0; }
.as-head-id + .as-menu-wrap { margin-left: auto; }

.as-menu-btn {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--as-r-ctl);
    border: 1px solid var(--as-line);
    background: var(--as-surface);
    color: var(--as-ink2);
    font-size: var(--as-fs-lg);
    cursor: pointer;
}

.as-menu-btn:hover,
.as-menu-btn[aria-expanded="true"] {
    background: var(--as-sunk);
    color: var(--as-ink);
}

.as-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 60;
    min-width: 248px;
    padding: 6px;
    display: grid;
    gap: 2px;
    background: var(--as-surface);
    border: 1px solid var(--as-line);
    border-radius: 14px;
    box-shadow: var(--as-shadow-2);
}

.as-menu[hidden] { display: none; }

.as-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    width: 100%;
    padding: 0 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--as-ink);
    font: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}

.as-menu-item i {
    width: 18px;
    text-align: center;
    color: var(--as-ink3);
}

.as-menu-item:hover,
.as-menu-item:focus-visible {
    background: var(--as-sunk);
    outline: none;
}

.as-menu-item[hidden] { display: none; }

/* A toggle inside the menu (voice practice): the checkbox is the state. */
.as-menu-item input[type="checkbox"] {
    margin-left: auto;
    width: 20px;
    height: 20px;
    accent-color: var(--as-brand-fill);
}

/* ---- buttons ------------------------------------------------------ */

.as-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--as-r-ctl);
    border: 1px solid transparent;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

.as-btn:active { transform: scale(0.98); }
.as-btn:focus-visible { outline: 2px solid var(--as-brand); outline-offset: 2px; }

.as-btn-primary {
    background: var(--as-brand-fill);
    color: var(--as-on-brand);
}

.as-btn-primary:hover { background: var(--as-brand-fill-hover); }

.as-btn-neutral {
    background: var(--as-surface);
    border-color: var(--as-line-strong);
    color: var(--as-ink);
}

.as-btn-neutral:hover { background: var(--as-sunk); }

.as-btn-ghost {
    background: transparent;
    color: var(--as-ink2);
}

.as-btn-ghost:hover { background: var(--as-sunk); color: var(--as-ink); }

.as-btn-lg {
    min-height: 52px;
    padding: 0 26px;
    font-size: var(--as-fs-md);
    border-radius: 14px;
}

.as-btn-block { width: 100%; }

.as-btn:disabled,
.as-btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Round icon buttons: listen, flip, record. */
.as-icon-btn {
    width: 52px;
    height: 52px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    border: 1px solid var(--as-line-strong);
    background: var(--as-surface);
    color: var(--as-ink2);
    font-size: 19px;
    cursor: pointer;
    flex: none;
    transition: background 0.15s ease, transform 0.1s ease;
}

.as-icon-btn:hover { background: var(--as-sunk); color: var(--as-ink); }
.as-icon-btn:active { transform: scale(0.95); }
.as-icon-btn.as-icon-primary {
    width: 64px;
    height: 64px;
    font-size: 23px;
    border-color: transparent;
    background: var(--as-brand-fill);
    color: var(--as-on-brand);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}
.as-icon-btn.as-icon-primary:hover { background: var(--as-brand-fill-hover); }
.as-icon-btn.as-on { color: var(--as-ok); border-color: var(--as-ok-line); background: var(--as-ok-wash); }

/* ---- start card -------------------------------------------------- */

.as-start {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 40px 24px;
    background: var(--as-surface);
    border: 1px solid var(--as-line);
    border-radius: var(--as-r-card);
    box-shadow: var(--as-shadow-1);
}

.as-start-ic {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--as-brand-wash);
    color: var(--as-brand);
    font-size: 26px;
    margin-bottom: 4px;
}

.as-start-title {
    margin: 0;
    font-size: var(--as-fs-xl);
    font-weight: 700;
    color: var(--as-ink);
}

.as-start-text {
    margin: 0;
    font-size: var(--as-fs-md);
    color: var(--as-ink2);
    max-width: 44ch;
}

.as-start-meta {
    margin: 0 0 8px;
    font-size: var(--as-fs-sm);
    color: var(--as-ink3);
}

/* ---- answers ------------------------------------------------------ */

.as-opts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.as-opt {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 12px 16px;
    border: 1.5px solid var(--as-line);
    border-radius: 14px;
    background: var(--as-surface);
    color: var(--as-ink);
    font: inherit;
    font-size: 20px;
    font-weight: 650;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--as-shadow-1);
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease, opacity 0.2s ease;
}

.as-opt:hover { border-color: var(--as-line-strong); }
.as-opt:active { transform: scale(0.99); }
.as-opt:focus-visible { outline: 2px solid var(--as-brand); outline-offset: 2px; }

.as-opt-key {
    flex: none;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: grid;
    place-items: center;
    background: var(--as-sunk);
    color: var(--as-ink3);
    font-size: 13px;
    font-weight: 700;
}

.as-opt.as-ok {
    border-color: var(--as-ok-line);
    background: var(--as-ok-wash);
    color: var(--as-ok);
}

.as-opt.as-no {
    border-color: var(--as-no-line);
    background: var(--as-no-wash);
    color: var(--as-no);
    animation: as-shake 0.3s ease;
}

.as-opt.as-gone {
    opacity: 0.35;
    pointer-events: none;
}

/* A picture as the answer (Audio Match). The tile stays square so the
   answers line up; the picture fits inside it whole (contain), since a
   card's picture or animation is usually taller than wide and cover cut
   off heads and feet (v0.25.67.0). */
.as-opt-pic {
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
}

.as-opt-pic .as-opt-key {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1;
    background: var(--as-surface);
    box-shadow: var(--as-shadow-1);
}

.as-opt-pic img,
.as-opt-pic video {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    border-radius: 10px;
    background: var(--as-sunk);
}

/* ---- the prompt picture ------------------------------------------ */

/* One track that may shrink below the picture's own height: with an auto
   track, height: 100% resolved to the picture's height and a box with a set
   height (Write It's 112px on a phone) cut off its bottom (v0.25.67.0). */
.as-figure {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr);
    place-items: center;
    background: var(--as-sunk);
    border-radius: var(--as-r-card);
    overflow: hidden;
}

.as-figure img,
.as-figure video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.as-word {
    font-size: var(--as-word);
    font-weight: 750;
    letter-spacing: -0.01em;
    line-height: 1.12;
    color: var(--as-ink);
    overflow-wrap: anywhere;
}

.as-gloss {
    font-size: 17px;
    color: var(--as-ink3);
}

.as-eyebrow {
    font-size: var(--as-fs-xs);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--as-ink3);
}

/* ---- dock -------------------------------------------------------- */

.as-dock {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
}

.as-dock-msg {
    flex: 1;
    min-width: 0;
    font-size: var(--as-fs-md);
    font-weight: 600;
    color: var(--as-ink2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.as-dock-msg:empty { visibility: hidden; }
.as-dock-msg.as-ok { color: var(--as-ok); }
.as-dock-msg.as-no { color: var(--as-no); }
.as-dock-msg small { font-size: var(--as-fs-sm); font-weight: 500; color: var(--as-ink3); }

/* Keyboard hints — a desktop affordance, never shown to a touchscreen. */
.as-kbd-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 13px;
    color: var(--as-ink3);
}

.as-kbd {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    border: 1px solid var(--as-line-strong);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--as-surface);
    font-size: var(--as-fs-xs);
    font-weight: 700;
    text-align: center;
    color: var(--as-ink2);
}

@media (hover: none), (max-width: 768px) {
    .as-kbd-hint, .as-opt-key:not(.as-keep) { display: none; }
}

/* An empty state written into a board that is otherwise a grid. (0,3,0)
   ties the boards' own `.module-x.as-activity .as-…-stage { display: grid }`
   and this sheet loads after theirs; :not([hidden]) lets a hidden board
   stay hidden, which the !important this replaced did not (v0.25.42.0). */
.as-activity .as-empty:not([hidden]) { display: block; }

/* ---- finish / all-caught-up card --------------------------------- */

.as-done {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 36px 20px;
    background: var(--as-surface);
    border: 1px solid var(--as-line);
    border-radius: var(--as-r-card);
}

.as-done h3 { margin: 0; font-size: var(--as-fs-xl); color: var(--as-ink); }
.as-done p { margin: 0; color: var(--as-ink2); max-width: 46ch; }

.as-done-ic {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--as-ok-wash);
    color: var(--as-ok);
    font-size: 26px;
}

.as-done-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
}

/* ---- SRS session line and review tag (v0.25.79.0) ---------------- */

/* "17 from this lesson · 8 review" under the header, drawn by
   SRSSession.setMix() only when the session holds review cards. */
.as-mix {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: -4px 0 10px;
}

.as-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: var(--as-r-pill);
    border: 1px solid var(--as-line);
    background: var(--as-surface);
    color: var(--as-ink2);
    font-size: var(--as-fs-xs);
    font-weight: 600;
    line-height: 1.8;
}

.as-chip-review {
    border-color: transparent;
    background: var(--as-brand-wash);
    color: var(--as-brand);
}

/* On the picture, word or prompt of a card from an earlier lesson. */
.as-review-tag {
    display: inline-block;
    padding: 2px 9px;
    border-radius: var(--as-r-pill);
    background: var(--as-brand-fill);
    color: var(--as-on-brand);
    font-size: var(--as-fs-xs);
    font-weight: 700;
    line-height: 1.6;
    letter-spacing: 0.01em;
}

.as-review-tag-row {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.as-review-tag-float {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    pointer-events: none;
}

/* ---- text answers (Write It) ------------------------------------- */

.as-input {
    width: 100%;
    min-height: 56px;
    padding: 0 16px;
    border: 1.5px solid var(--as-line-strong);
    border-radius: 12px;
    background: var(--as-surface);
    color: var(--as-ink);
    font: inherit;
    font-size: var(--as-fs-xl);
    font-weight: 600;
    letter-spacing: 0.01em;
}

.as-input:focus {
    outline: none;
    border-color: var(--as-brand);
    box-shadow: 0 0 0 3px var(--as-brand-wash);
}

.as-input.as-ok { border-color: var(--as-ok-line); background: var(--as-ok-wash); color: var(--as-ok); }
.as-input.as-no { border-color: var(--as-no-line); background: var(--as-no-wash); color: var(--as-no); }
.as-input:disabled { opacity: 1; }

.as-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.as-letters[hidden] { display: none; }

.as-letter {
    min-width: 44px;
    height: 44px;
    padding: 0 10px;
    border: 1px solid var(--as-line-strong);
    border-radius: 10px;
    background: var(--as-surface);
    color: var(--as-ink);
    font: inherit;
    font-size: var(--as-fs-lg);
    font-weight: 600;
    cursor: pointer;
}

.as-letter:hover { background: var(--as-sunk); }

.as-answer { color: var(--as-ink); font-weight: 750; }

/* ---- segmented control (Speak It's three modes) ------------------ */

.as-seg {
    display: flex;
    gap: 3px;
    padding: 3px;
    border-radius: 12px;
    background: var(--as-sunk);
}

.as-seg > button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--as-ink2);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.as-seg > button[aria-pressed="true"],
.as-seg > button.active {
    background: var(--as-surface);
    color: var(--as-ink);
    box-shadow: var(--as-shadow-1);
}

.as-seg > button:disabled {
    color: var(--as-ink3);
    cursor: not-allowed;
}

.as-seg > button .as-seg-done { color: var(--as-ok); }

/* ---- phone ------------------------------------------------------- */

@media (max-width: 768px) {
    .as-activity { gap: 12px; }

    /* The app bar already names the activity; the row is progress + ⋯. */
    .as-title,
    .as-sub { display: none; }
    .as-head { gap: 12px; min-height: 44px; }
    .as-head-id { display: none; }
    .as-progress { max-width: none; margin-left: 0; }

    .as-start { padding: 28px 18px; }

    .as-opts { gap: 10px; }
    .as-opt { min-height: 60px; font-size: var(--as-fs-lg); padding: 10px 14px; }

    /* The dock pins to the bottom of the screen while its activity is in
       view, so the primary action never scrolls below the fold. Sticky,
       not fixed: it leaves with its module and cannot cover another one. */
    .as-dock {
        position: sticky;
        bottom: 0;
        z-index: 20;
        margin: 0 -12px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        background: var(--as-surface);
        border-top: 1px solid var(--as-line);
        box-shadow: 0 -6px 16px rgba(17, 19, 34, 0.06);
        flex-wrap: wrap;
    }

    .as-dock:empty { display: none; }
    .as-dock .as-btn-primary { flex: 1 1 160px; min-height: 52px; font-size: var(--as-fs-md); }

    /* The next-module bar sat below the fold on every screen. While an
       activity is open it lives in the ⋯ menu ("Next activity"), and the
       completion popup offers it when the activity is finished. */
    #moduleContainer:has(> .as-activity) > .next-module-bar { display: none; }
}

@keyframes as-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
    .as-opt.as-no { animation: none; }
    .as-fill, .as-btn, .as-opt, .as-icon-btn { transition: none; }
}
