/*
 * Coding Ireland proprietary interactive activity
 * Copyright (c) 2017-2026 Coding Ireland. All rights reserved.
 *
 * Part of the Coding Ireland online learning platform. Licensed for use only
 * as delivered on the platform. Copying, redistributing, or adapting this
 * file, in whole or in part, for use in any other product or service is not
 * permitted. Ref: CI-arts-script-builder
 */
/*
 * script-builder — drama story-building tool for the IWB.
 * beats variant: story-beat cards placed into numbered slots.
 * script variant: playscript rows (speaker / line / direction) with
 * tap-to-edit and add-a-line. printView: big-type performance view.
 * Namespace: sb-
 */

/* The hidden attribute must always win, even over display:flex/grid below
   (boards, done banner, tray and mode chip are toggled via hidden). */
.sb-activity [hidden] {
    display: none !important;
}

.maths-activity .sb-stage {
    background: #fffaf0;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 1.25rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(20, 40, 80, 0.05);
}

.maths-activity .sb-mode-chip {
    display: inline-block;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    margin-top: 0.25rem;
}

/* ------ Beats: numbered slots ------ */

.maths-activity .sb-slot-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.875rem;
    margin-bottom: 1rem;
}

.maths-activity .sb-slot {
    position: relative;
    min-width: 180px;
    max-width: 240px;
    min-height: 130px;
    flex: 1 1 180px;
    background: #fff;
    border: 3px dashed #cbd5e1;
    border-radius: 14px;
    padding: 1.5rem 0.6rem 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 150ms ease, background 150ms ease;
}

.maths-activity .sb-slot.sb-filled {
    border-style: solid;
    border-color: #aed581;
    background: #fcfff5;
}

.maths-activity .sb-slot.sb-over {
    border-color: var(--maths-primary, #2E7D32);
    background: #f1f8e9;
}

.maths-activity .sb-slot-num {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(20, 40, 80, 0.2);
}

.maths-activity .sb-slot-content {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maths-activity .sb-slot-prompt {
    font-style: italic;
    font-weight: 600;
    color: #6b7280;
    text-align: center;
    font-size: 1rem;
    padding: 0.25rem;
}

@keyframes sb-next-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0.35); }
    50%      { box-shadow: 0 0 0 8px rgba(46, 125, 50, 0.08); }
}

.maths-activity .sb-slot.sb-slot-next {
    border-color: var(--maths-primary, #2E7D32);
    animation: sb-next-pulse 1.8s ease-in-out infinite;
}

/* ------ Beats: cards + tray ------ */

.maths-activity .sb-tray-wrap {
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 14px;
    padding: 0.875rem 1rem;
}

.maths-activity .sb-tray-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--maths-text-muted, #6b7280);
}

.maths-activity .sb-tray-hint {
    font-size: 0.95rem;
    font-weight: 600;
    color: #6b7280;
    margin: 0.15rem 0 0.5rem;
}

.maths-activity .sb-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-height: 84px;
    align-items: flex-start;
    border-radius: 10px;
    transition: background 150ms ease;
}

.maths-activity .sb-tray.sb-over {
    background: #f1f8e9;
}

.maths-activity .sb-beat-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 64px;
    max-width: 230px;
    padding: 0.6rem 0.875rem;
    border-radius: 12px;
    border: 2px solid transparent;
    box-shadow: 0 2px 6px rgba(20, 40, 80, 0.12);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.maths-activity .sb-beat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(20, 40, 80, 0.16);
}

.maths-activity .sb-beat-card.sb-dragging { opacity: 0.35; }

.maths-activity .sb-beat-card.sb-selected {
    outline: 3px solid var(--maths-primary, #2E7D32);
    outline-offset: 2px;
    transform: scale(1.03);
}

.maths-activity .sb-card-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.maths-activity .sb-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.maths-activity .sb-card-label {
    font-weight: 800;
    font-size: 1.05rem;
    color: #1f2937;
    line-height: 1.25;
}

.maths-activity .sb-card-text {
    font-weight: 600;
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.3;
}

/* Warm pastel tints, cycled per card. */
.maths-activity .sb-tint-0 { background: #ffe4c7; border-color: #f0b26b; }
.maths-activity .sb-tint-1 { background: #dcefdc; border-color: #8fc98f; }
.maths-activity .sb-tint-2 { background: #dbeafe; border-color: #7fb1f0; }
.maths-activity .sb-tint-3 { background: #fce7f3; border-color: #eb9dc6; }
.maths-activity .sb-tint-4 { background: #ede9fe; border-color: #b49df0; }
.maths-activity .sb-tint-5 { background: #fef9c3; border-color: #e3d05e; }

/* A card sitting inside a slot fills it nicely. */
.maths-activity .sb-slot .sb-beat-card {
    max-width: 100%;
    width: 100%;
    justify-content: flex-start;
}

/* Locked order: a fixed sequence for showing — no pick-up affordances. */
.maths-activity .sb-locked .sb-beat-card {
    cursor: default;
}
.maths-activity .sb-locked .sb-beat-card:hover {
    transform: none;
    box-shadow: 0 2px 6px rgba(20, 40, 80, 0.12);
}
.maths-activity .sb-locked .sb-slot {
    cursor: default;
}

/* Done banner */
.maths-activity .sb-done {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #f1f8e9;
    border: 1px solid #aed581;
    border-radius: 14px;
    padding: 0.875rem 1.125rem;
    margin-bottom: 1rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #33691e;
}

.maths-activity .sb-done-icon {
    font-size: 1.6rem;
    line-height: 1;
}

/* ------ Script rows ------ */

.maths-activity .sb-script-rows {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.maths-activity .sb-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid var(--maths-border, #e0e7ef);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    box-shadow: 0 1px 4px rgba(20, 40, 80, 0.05);
}

.maths-activity .sb-row-editable {
    cursor: pointer;
}

.maths-activity .sb-row-editable:hover,
.maths-activity .sb-row-editable:focus-visible {
    border-color: var(--maths-primary, #2E7D32);
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.15);
}

.maths-activity .sb-row-speaker {
    flex-shrink: 0;
    color: #fff;
    font-weight: 800;
    font-size: 1rem;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    min-width: 72px;
    text-align: center;
}

.maths-activity .sb-row-body {
    flex: 1;
    min-width: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.5;
}

.maths-activity .sb-row-direction {
    font-style: italic;
    font-weight: 600;
    color: #6b7280;
    margin-right: 0.5rem;
}

.maths-activity .sb-row-prompt {
    font-style: italic;
    font-weight: 600;
    color: #6b7280;
}

.maths-activity .sb-row-pen {
    flex-shrink: 0;
    color: #9ca3af;
    font-size: 0.95rem;
    align-self: center;
}

.maths-activity .sb-empty {
    text-align: center;
    font-weight: 600;
    color: #6b7280;
    padding: 1.25rem 0.5rem;
}

/* Row editor */
.maths-activity .sb-editor {
    background: #f8fafc;
    border: 2px solid var(--maths-primary, #2E7D32);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.maths-activity .sb-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin: 0;
}

.maths-activity .sb-field-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: #374151;
}

.maths-activity .sb-input {
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 600;
    color: #1f2937;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    width: 100%;
}

.maths-activity .sb-input:focus {
    outline: 3px solid rgba(46, 125, 50, 0.3);
    border-color: var(--maths-primary, #2E7D32);
}

.maths-activity .sb-textarea {
    resize: vertical;
    min-height: 66px;
}

.maths-activity .sb-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.maths-activity .sb-btn {
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 800;
    padding: 0.65rem 1.25rem;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #374151;
    cursor: pointer;
}

.maths-activity .sb-btn:hover { filter: brightness(0.97); }

.maths-activity .sb-btn-primary {
    background: var(--maths-primary, #2E7D32);
    border-color: var(--maths-primary, #2E7D32);
    color: #fff;
    box-shadow: 0 3px 8px rgba(46, 125, 50, 0.25);
}

.maths-activity .sb-btn-primary:hover { filter: brightness(1.08); }

.maths-activity .sb-btn-danger {
    color: #b91c1c;
    border-color: #fca5a5;
    background: #fef2f2;
}

.maths-activity .sb-add-row {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--maths-primary-dark, #1b5e20);
    background: #fcfff5;
    border: 3px dashed #aed581;
    border-radius: 12px;
    padding: 0.8rem;
    cursor: pointer;
    transition: background 150ms ease;
}

.maths-activity .sb-add-row:hover { background: #f1f8e9; }

/* ------ Performance view ------ */

.maths-activity .sb-print {
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
}

.maths-activity .sb-print-title {
    font-size: 1.9rem;
    font-weight: 800;
    color: #1f2937;
    text-align: center;
    margin-bottom: 1.25rem;
}

.maths-activity .sb-print-row {
    font-size: 1.5rem;
    line-height: 1.7;
    color: #1f2937;
    margin-bottom: 1rem;
}

.maths-activity .sb-print-speaker {
    font-weight: 800;
    margin-right: 0.6rem;
}

.maths-activity .sb-print-dir {
    font-style: italic;
    color: #6b7280;
    font-size: 1.2rem;
    margin-right: 0.6rem;
}

.maths-activity .sb-print-beat {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 0.875rem;
}

.maths-activity .sb-print-beat-num {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--maths-primary, #2E7D32);
    color: #fff;
    font-weight: 800;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.maths-activity .sb-print-beat-icon {
    font-size: 2.2rem;
    line-height: 1;
    flex-shrink: 0;
}

.maths-activity .sb-print-beat-label {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.4;
    color: #1f2937;
}

/* ------ Utility ------ */

.sb-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ------ Display mode ------
 * Header chrome is hidden by the shared CSS; here we tighten the stage,
 * drop the how-to hint, and let content self-size (min-height: 0).
 * Cards stay draggable and rows stay editable when the config allows —
 * the teacher drives the screen.
 */

body[data-display-mode="true"] .sb-tray-hint,
body.display-mode .sb-tray-hint {
    display: none;
}

body[data-display-mode="true"] .sb-stage,
body.display-mode .sb-stage {
    min-height: 0;
    padding: 0.85rem;
    margin-bottom: 0.5rem;
}

body[data-display-mode="true"] .sb-tray-wrap,
body.display-mode .sb-tray-wrap {
    padding: 0.6rem 0.75rem;
}

body[data-display-mode="true"] .sb-print,
body.display-mode .sb-print {
    padding: 0.75rem 1rem;
}
