/* Worked Example — annotated reveal of a strong sample artefact.
 * Layered on top of activities/maths/shared/css/maths-activity.css so the
 * chrome (header / controls / palette / typography) matches the LCA maths
 * widgets. Worked-example-specific layout sits below. */

/* Defeat the `min-height: 100vh` inherited from activity-common.css.
 * The lesson page hosts this widget in an auto-resizing iframe that
 * sizes itself to `body.scrollHeight + 40`. If the body is pinned to
 * 100vh, scrollHeight tracks the iframe's own viewport — every parent
 * resize grows the viewport, which grows scrollHeight, which feeds
 * back into another parent resize. Letting the body collapse to its
 * natural content height stabilises the loop on the first cycle. */
body.worked-example-activity,
.worked-example-activity .activity-container {
    min-height: 0;
}

.maths-activity.worked-example-activity {
    background: var(--maths-bg);
    color: var(--maths-ink);
}

.we-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.75rem 0.75rem 1.25rem;
}

/* ----- Info card (title + kind + counter + context) ----- */
.we-info {
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 0.75rem;
}

.we-info-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.we-artefact-kind {
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
}

/* `.maths-pill` from maths-activity.css sets `display: inline-block`,
 * which would override the UA `[hidden]` rule — explicit override here. */
.we-artefact-kind[hidden] { display: none; }

.we-counter {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--maths-ink-muted);
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

.we-artefact-title {
    font-size: 1.15rem;
    line-height: 1.3;
    margin: 0 0 0.3rem;
    color: var(--maths-primary);
}

.we-context {
    margin: 0;
    color: var(--maths-ink-muted);
    font-size: 0.9rem;
    line-height: 1.45;
}

/* ----- Stage: artefact + rail (side-by-side) -----
 * Locked to two columns from very narrow widths so the registry preview
 * (480px column) and the codesite lesson view both keep the rail next to
 * the artefact. Only collapses below ~440px (phones in portrait). */
.we-stage {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(150px, 0.9fr);
    gap: 0.75rem;
    align-items: start;
}

.we-artefact {
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    font-family: 'Nunito', sans-serif;
    font-size: 0.98rem;
    line-height: 1.55;
    color: var(--maths-ink);
    min-height: 220px;
    transition: color 0.2s;
}

.we-artefact p {
    margin: 0 0 0.8em;
}

.we-artefact p:last-child {
    margin-bottom: 0;
}

.we-artefact ul,
.we-artefact ol {
    margin: 0 0 0.8em;
    padding-left: 1.4rem;
}

.we-artefact li {
    margin-bottom: 0.35em;
}

.we-artefact h2,
.we-artefact h3 {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    color: var(--maths-primary);
    margin: 1em 0 0.4em;
    font-size: 1.05rem;
}

.we-artefact strong { font-weight: 700; }
.we-artefact em { font-style: italic; }

/* Anchor highlight states. Resting state is a subtle tint that signals
 * the phrase is interactive without dominating the read. Active state
 * uses the maths accent orange so the focus is unmistakable on the IWB. */
.we-anchor {
    background: rgba(31, 111, 178, 0.10);
    color: inherit;
    border-bottom: 2px solid rgba(31, 111, 178, 0.35);
    padding: 0 2px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    border-radius: 2px;
}

.we-anchor:hover {
    background: rgba(31, 111, 178, 0.18);
    border-color: var(--maths-primary);
}

.we-anchor:focus {
    outline: 2px solid var(--maths-focus-ring);
    outline-offset: 2px;
}

.we-artefact.we-has-active {
    color: #7a8290;
}

.we-artefact.we-has-active .we-anchor {
    background: rgba(31, 111, 178, 0.06);
    border-color: transparent;
}

.we-artefact.we-has-active .we-anchor-active {
    background: rgba(232, 106, 51, 0.22);
    border-bottom: 2px solid var(--maths-accent);
    color: var(--maths-ink);
    box-shadow: 0 0 0 3px rgba(232, 106, 51, 0.14);
}

/* ----- Rail ----- */
.we-rail {
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 10px;
    padding: 0.75rem 0.7rem 0.6rem;
}

.we-rail-heading {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--maths-ink-muted);
    margin: 0 0 0.55rem;
}

.we-beat-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.we-beat {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.45rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.we-beat:hover {
    background: var(--maths-surface-alt);
}

.we-beat-num {
    flex: 0 0 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--maths-surface-alt);
    color: var(--maths-primary-dark);
    font-weight: 800;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.we-beat-label {
    flex: 1 1 auto;
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.3;
    color: var(--maths-ink);
    word-break: break-word;
}

.we-beat-active {
    background: #fdecdf;
}

.we-beat-active .we-beat-num {
    background: var(--maths-accent);
    color: #fff;
}

.we-beat-active .we-beat-label {
    color: var(--maths-ink);
}

/* ----- Callout (revealed explanation) ----- */
.we-callout {
    background: #fff8e1;
    border: 1px solid #f0c14b;
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
    margin-top: 0.75rem;
    animation: weCalloutIn 0.18s ease-out;
}

@keyframes weCalloutIn {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

.we-callout-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.35rem;
}

.we-callout-num {
    flex: 0 0 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--maths-accent);
    color: #fff;
    font-weight: 800;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.we-callout-title {
    font-weight: 800;
    font-size: 0.95rem;
    color: var(--maths-ink);
}

.we-callout-text {
    margin: 0;
    font-size: 0.92rem;
    line-height: 1.5;
    color: var(--maths-ink);
}

/* ----- Empty state -----
 * `display: flex` here would override the user-agent `[hidden]
 * { display: none }` rule (class selector outranks attribute UA rule),
 * so the hidden attribute would silently stop hiding. Use `[hidden]`
 * override explicitly. Same pattern applied to .we-callout below since
 * it also has a `hidden` toggle. */
.we-empty {
    background: var(--maths-surface);
    border: 1px solid var(--maths-border);
    border-radius: 10px;
    padding: 0.75rem;
    color: var(--maths-ink-muted);
    text-align: center;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.we-empty[hidden] { display: none; }

.we-empty i {
    color: var(--maths-primary);
}

/* ----- Active "Next" control gets accent treatment for IWB visibility ----- */
.we-pc-next {
    background: var(--maths-primary) !important;
    color: #fff !important;
    border-color: var(--maths-primary) !important;
}

.we-pc-next:hover {
    background: var(--maths-primary-dark) !important;
    border-color: var(--maths-primary-dark) !important;
}

/* ----- Responsive ----- */
@media (max-width: 600px) {
    .we-stage {
        grid-template-columns: minmax(0, 1.5fr) minmax(130px, 1fr);
        gap: 0.5rem;
    }
    .we-artefact {
        padding: 0.8rem;
        font-size: 0.92rem;
    }
    .we-beat-label { font-size: 0.82rem; }
    .we-beat-num   { flex-basis: 22px; height: 22px; font-size: 0.75rem; }
    .we-rail { padding: 0.55rem 0.5rem 0.5rem; }
    .we-artefact-title { font-size: 1.05rem; }
}

@media (max-width: 440px) {
    /* Only stack at phone-portrait widths — at any practical IWB or
     * preview width the rail stays beside the artefact as requested. */
    .we-stage {
        grid-template-columns: 1fr;
    }
}

/* ----- Fullscreen polish ----- */
:fullscreen .we-container,
:-webkit-full-screen .we-container {
    max-width: none;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

:fullscreen .we-stage,
:-webkit-full-screen .we-stage {
    flex: 1 1 auto;
    min-height: 0;
}

:fullscreen .we-artefact,
:-webkit-full-screen .we-artefact {
    font-size: 1.1rem;
    line-height: 1.65;
    max-height: 100%;
    overflow-y: auto;
}

:fullscreen .we-rail,
:-webkit-full-screen .we-rail {
    max-height: 100%;
    overflow-y: auto;
}
