/* ============================================================
   algebra_organize.css — styles for the "Organize the steps" exercise
   ============================================================
   Load AFTER style.css and exercises.css. The header, problem picker,
   problem box and success popup come from exercises.css (the root div
   has class "notes-content"); this file only holds what is unique here.
   Everything is prefixed "ao-" so it can't collide with other pages.
   Sections: Header, Problem box, Progress pills, Phase panel,
   Step cards (pool / solution), Choice cards, Messages & buttons,
   Done view, Phones, Two-column order phase + dragging.
   ============================================================ */

.ao-page { padding-bottom: 40px; }
.ao-page .container { max-width: 1600px; width: 98%; padding-left: 28px; padding-right: 28px; }

#ao-root { color: var(--text-primary); }

/* style.css gives .notes-content lists/headings/paragraphs their own spacing;
   undo it for this page's own components. */
#ao-root ol.ao-progress, #ao-root ul.ao-list, #ao-root ol.ao-list, #ao-root ol.ao-recap {
    padding-left: 0; margin-left: 0; margin-bottom: 0;
}
#ao-root li { font-size: inherit; margin-bottom: 0; }
#ao-root .problem-box h3 { margin-top: 0; text-decoration: none; }
#ao-root .ao-panel p, #ao-root .ao-card p { margin-bottom: 0; }
#ao-root .problem-box { margin: 0 auto 18px; }

/* ==========================================
   PROBLEM BOX
   ========================================== */
.problem-box h3 { font-size: 1.1rem; color: var(--accent-green); margin-bottom: 6px; }
.problem-box .problem-prompt { color: var(--text-heading); margin-bottom: 0; }

/* ==========================================
   PROGRESS PILLS
   ========================================== */
.ao-progress {
    list-style: none;
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}
.ao-pill {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 6px;
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}
.ao-pill.active { border-color: var(--accent-amber); color: var(--accent-amber); background: rgba(240, 165, 0, 0.1); }
.ao-pill.done { border-color: var(--accent-green); color: var(--accent-green); }

/* ==========================================
   PHASE PANEL
   ========================================== */
.ao-panel {
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: var(--shadow-soft);
}
.ao-panel h4 {
    font-size: 1.15rem;
    color: var(--text-heading);
    margin-bottom: 6px;
}
.ao-instr {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.ao-section-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-amber);
    margin: 14px 0 8px;
}

.ao-math {
    font-size: 1.15rem;
    line-height: 1.6;
    color: var(--text-heading);
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
}

/* Cancel strikes drawn by MathJax's \cancel (like the (x-3) crossed out in
   Problem 1) use the same amber as the rest of the page. Only the line is
   coloured; the crossed-out text keeps its normal colour. The #ao-root prefix
   is needed: MathJax adds its own stylesheet later, which would otherwise win. */
#ao-root mjx-ustrike, #ao-root mjx-dstrike, #ao-root mjx-hstrike, #ao-root mjx-vstrike {
    border-top-color: var(--accent-amber);
}

/* ==========================================
   STEP CARDS (pool and solution)
   ========================================== */
.ao-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 20px;
}

.ao-empty {
    padding: 16px;
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
    border: 2px dashed var(--border-main);
    border-radius: 10px;
}

.ao-pool-card {
    width: 100%;
    text-align: left;
    font: inherit;
    background: var(--h4-bg);
    border: 2px solid var(--border-main);
    border-left: 4px solid var(--accent-blue);
    border-radius: 8px;
    padding: 10px 14px;
    color: inherit;
    transition: border-color 0.2s, transform 0.15s, background 0.2s;
    /* none, not manipulation/pan-y: otherwise the browser claims the
       vertical gesture as a page scroll, fires pointercancel, and a
       drag in progress snaps back. Touch elsewhere to scroll the page. */
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ao-pool-card:hover { border-color: var(--accent-green); background: #343c52; }
.ao-pool-card:active { transform: scale(0.99); }

.ao-sol-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--h4-bg);
    border: 2px solid var(--border-main);
    border-left: 4px solid var(--accent-amber);
    border-radius: 8px;
    padding: 8px 10px 8px 12px;
    transition: border-color 0.2s, background 0.2s;
    /* see .ao-pool-card above for why this is none */
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.ao-sol-card.bad { border-color: #e53935; background: rgba(229, 57, 53, 0.12); }

.ao-sol-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--accent-amber);
    color: var(--accent-amber);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ao-sol-body { flex: 1; min-width: 0; }

.ao-sol-actions { flex-shrink: 0; display: flex; gap: 6px; }
.ao-icon-btn {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-main);
    border-radius: 8px;
    background: var(--bg-header);
    color: var(--text-primary);
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.2s, color 0.2s;
}
.ao-icon-btn:hover:not(:disabled) { border-color: var(--accent-blue); color: var(--accent-blue); }
.ao-icon-btn.remove:hover:not(:disabled) { border-color: #e53935; color: #ff7b78; }
.ao-icon-btn:disabled { opacity: 0.3; cursor: default; }

/* ==========================================
   CHOICE CARDS (reasons / legal check / final question)
   ========================================== */
.ao-card {
    background: var(--h4-bg);
    border: 2px solid var(--border-main);
    border-left: 4px solid var(--accent-blue);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.ao-card.ok { border-color: var(--accent-green); border-left-color: var(--accent-green); }
.ao-card.bad { border-color: #e53935; border-left-color: #e53935; }

.ao-card-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-amber);
    margin-bottom: 4px;
}
.ao-question {
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-heading);
    margin-bottom: 10px;
}
.ao-card .ao-math { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-main); }

.ao-opts { display: flex; flex-direction: column; gap: 8px; }
.ao-opt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 9px 12px;
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 8px;
    cursor: pointer;
    line-height: 1.5;
    font-size: 1rem;
    transition: border-color 0.2s, background 0.2s;
}
.ao-opt:hover { border-color: var(--accent-blue); }
.ao-opt input { margin-top: 4px; flex-shrink: 0; accent-color: var(--accent-amber); width: 17px; height: 17px; }
.ao-opt.chosen { border-color: var(--accent-amber); background: rgba(240, 165, 0, 0.08); }
.ao-card.ok .ao-opt.chosen { border-color: var(--accent-green); background: rgba(61, 214, 140, 0.1); }
.ao-card.bad .ao-opt.chosen { border-color: #e53935; background: rgba(229, 57, 53, 0.1); }
.ao-opt-text { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; }

.ao-fb {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.5;
}
.ao-fb.bad { background: rgba(229, 57, 53, 0.12); border-left: 3px solid #e53935; color: #ffb4b2; }
.ao-fb.ok { background: rgba(61, 214, 140, 0.1); border-left: 3px solid var(--accent-green); color: var(--accent-green); }

/* ==========================================
   MESSAGE + BUTTONS
   ========================================== */
.ao-msg {
    margin-top: 12px;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.5;
}
.ao-msg.bad { color: #ff7b78; }
.ao-msg.info { color: var(--accent-amber); }

.ao-hint {
    margin-top: 10px;
    padding: 8px 12px;
    border-left: 3px solid var(--accent-amber);
    background: rgba(240, 165, 0, 0.1);
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Per-phase explanation blocks and done-screen analysis */
.ao-note {
    margin-top: 14px;
    padding: 12px 16px;
    background: rgba(61, 214, 140, 0.08);
    border-left: 4px solid var(--accent-green);
    border-radius: 6px;
}
.ao-note-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-green);
    margin-bottom: 6px;
}
.ao-note-body {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.6;
    color: var(--text-primary);
}
.ao-note + .ao-note { margin-top: 10px; }

/* Full analysis on the done screen */
.ao-analysis-title {
    text-align: center;
    font-size: 1.4rem;
    color: var(--text-heading);
    margin: 24px 0 16px;
    font-weight: 700;
}
.ao-analysis-body {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 24px;
}

/* Text that comes from the <template> blocks in the HTML */
.ao-rich { overflow-x: auto; overflow-wrap: break-word; }
#ao-root .ao-rich p { margin: 0 0 0.7em; font-size: inherit; line-height: inherit; color: inherit; }
.ao-rich > :last-child { margin-bottom: 0; }
.ao-rich ul, .ao-rich ol { margin: 0 0 0.7em; padding-left: 1.4em; }
.ao-rich li { font-size: inherit; margin-bottom: 0.3em; }
.ao-rich strong { color: var(--text-heading); }

.ao-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.ao-btn {
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 10px 24px;
    font: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.ao-btn:hover { background: #ffbb2e; }
.ao-btn:active { transform: scale(0.98); }
.ao-btn.secondary {
    background: var(--bg-header);
    color: var(--text-primary);
    border-color: var(--border-main);
    font-size: 1rem;
    padding: 8px 16px;
}
.ao-btn.secondary:hover { background: #2a3144; }
.ao-btn.green { background: var(--accent-green); border-color: #2ab870; }
.ao-btn.green:hover { background: #55e6a1; }

/* ==========================================
   DONE VIEW
   ========================================== */
.ao-done-head {
    text-align: center;
    margin-bottom: 14px;
}
.ao-done-head h4 { font-size: 1.5rem; color: var(--accent-green); }
.ao-score { color: var(--text-secondary); margin-top: 4px; }

.ao-recap { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.ao-recap li {
    background: var(--h4-bg);
    border: 2px solid var(--border-main);
    border-left: 4px solid var(--accent-green);
    border-radius: 8px;
    padding: 10px 14px;
}
.ao-recap-why {
    margin-top: 4px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
    overflow-wrap: break-word;
}

.ao-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 26px;
    padding-top: 18px;
    border-top: 1px solid var(--border-main);
}
.ao-nav .ao-btn { font-size: 1rem; padding: 10px 20px; }
.ao-nav .ao-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ==========================================
   PHONES
   ========================================== */
@media (max-width: 768px) {
    .ao-panel { padding: 14px 12px; }
}

@media (max-width: 520px) {
    .ao-page { padding: 8px 4px 24px; }
    .ao-page .container { padding: 12px 8px 20px; }
    .ao-progress { gap: 5px; }
    .ao-pill { flex-direction: column; gap: 3px; font-size: 0.68rem; padding: 6px 3px; }
    .ao-math { font-size: 1rem; }
    .ao-opt { padding: 8px 10px; font-size: 0.95rem; }
    .ao-actions { justify-content: stretch; }
    .ao-actions .ao-btn { flex: 1; }
    .ao-sol-actions { flex-direction: column; gap: 4px; }
    .ao-icon-btn { width: 34px; height: 30px; }
    .ao-note { padding: 10px 12px; }
}

/* spacing around the shared header / problem box */
#ao-root .page-header { margin-bottom: 18px; }
#ao-root ol.ao-progress { margin-bottom: 12px; }

/* ==========================================
   TWO-COLUMN ORDER PHASE + DRAGGING
   ========================================== */
.ao-split {
    display: grid;
    grid-template-columns: minmax(260px, 28%) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.ao-pool-panel {
    align-self: stretch;   /* fill the row so the panel reaches the bottom of the right column */
    transition: border-color 0.2s, background 0.2s;
}

.ao-pool-panel.ao-drop-remove { border-color: var(--accent-amber); background: rgba(240, 165, 0, 0.08); }
.ao-main { min-width: 0; }

.ao-grip { color: var(--text-secondary); font-size: 1.1rem; letter-spacing: -2px; flex-shrink: 0; touch-action: none; padding: 4px 2px; cursor: grab; }

.ao-sol-list { min-height: 70px; border-radius: 10px; transition: background 0.2s; }
.ao-sol-list.ao-drop-ready { background: rgba(61, 214, 140, 0.06); }
.ao-sol-list.ao-dragging .ao-empty { display: none; }

.ao-drag-source { opacity: 0.35; }
.ao-placeholder {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 8px 12px;
    border: 2px dashed var(--accent-green);
    border-radius: 8px;
    background: rgba(61, 214, 140, 0.1);
}
.ao-placeholder .ao-sol-num { border-color: var(--accent-green); color: var(--accent-green); }

.ao-ghost {
    position: fixed;
    z-index: 10000;
    margin: 0;
    pointer-events: none;
    list-style: none;
    opacity: 0.95;
    transform: rotate(1.5deg) scale(1.02);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
    border-color: var(--accent-green) !important;
    background: #343c52 !important;
}

@media (max-width: 768px) {
    .ao-split { grid-template-columns: minmax(0, 1fr); }
}




/* ==========================================
   INTRO POPUP pictures (shown each time the page opens)
   ========================================== */
/* The popup itself (dark overlay, card, numbered steps, start button) is styled
   in exercises.css, which this page already loads. Only the four little
   pictures are specific to this page. Built by showIntro() in algebra_organize.js. */

.ia-label {
    margin-bottom: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-amber);
}

/* a step card, like the ones in the real pool / solution lists */
.ia-card {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding: 5px 8px;
    background: var(--h4-bg);
    border: 2px solid var(--border-main);
    border-left: 4px solid var(--accent-blue);
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-heading);
}

.ia-card:last-child {
    margin-bottom: 0;
}

.ia-card.amber {
    border-left-color: var(--accent-amber);
}

/* the dashed green spot where a dragged step will land */
.ia-card.drop {
    min-height: 1.6em;
    border: 2px dashed var(--accent-green);
    background: rgba(61, 214, 140, 0.1);
}

.ia-grip {
    color: var(--text-secondary);
    letter-spacing: -2px;
}

.ia-num {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--accent-amber);
    color: var(--accent-amber);
    font-size: 0.7rem;
    font-weight: 700;
}

.ia-card.drop .ia-num {
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.ia-arrow {
    margin: 2px 0 6px;
    text-align: center;
    font-size: 0.8rem;
    line-height: 1;
    color: var(--text-secondary);
}

/* a step's maths line or a question, above the answer options */
.ia-eq {
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-main);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-heading);
}

/* radio-style answer options */
.ia-opt {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    padding: 3px 6px;
    background: var(--bg-card);
    border: 2px solid var(--border-main);
    border-radius: 6px;
    font-size: 0.78rem;
    line-height: 1.2;
    color: var(--text-primary);
}

.ia-opt:last-child {
    margin-bottom: 0;
}

.ia-opt .ia-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    box-sizing: border-box;
    border: 2px solid var(--text-secondary);
    border-radius: 50%;
}

.ia-opt.chosen {
    border-color: var(--accent-amber);
    background: rgba(240, 165, 0, 0.08);
}

.ia-opt.chosen .ia-dot {
    border-color: var(--accent-amber);
    background: var(--accent-amber);
}

.ia-opt.ok {
    border-color: var(--accent-green);
    background: rgba(61, 214, 140, 0.1);
}

.ia-opt.ok .ia-dot {
    border-color: var(--accent-green);
    background: var(--accent-green);
}

/* "legal / trap" rows for the spot-the-illegal-step picture */
.ia-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-heading);
}

.ia-row:last-child {
    margin-bottom: 0;
}

.ia-tag {
    flex-shrink: 0;
    padding: 2px 8px;
    border: 2px solid currentColor;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
}

.ia-tag.ok  { color: var(--accent-green); background: rgba(61, 214, 140, 0.1); }
.ia-tag.bad { color: #e53935; background: rgba(229, 57, 53, 0.12); }

/* ==========================================
   MOBILE SWIPE DRAWER (Steps to place)
   ========================================== */
.ao-show-steps-btn { display: none; }
.ao-pool-header { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; margin-bottom: 8px; }
.ao-pool-header .ao-section-label { margin: 0; }
.ao-drawer-close { display: none; }

@media (max-width: 768px) and (orientation: portrait) {
    .ao-split {
        display: block; /* Remove grid layout */
    }
    .ao-pool-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 290px;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--bg-container);
        border-right: 2px solid var(--border-main);
        box-shadow: 4px 0 12px rgba(0,0,0,0.5);
        display: flex;
        flex-direction: column;
        padding: 16px;
        box-sizing: border-box;
        margin-bottom: 0;
    }
    .ao-pool-panel.ao-open {
        transform: translateX(0);
    }
    body.ao-drawer-open {
        overflow: hidden;
    }
    .ao-drawer-tab {
        position: fixed;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        background: var(--accent-amber);
        color: #111;
        padding: 16px 6px;
        border-radius: 0 8px 8px 0;
        writing-mode: vertical-rl;
        text-orientation: mixed;
        font-weight: 700;
        font-size: 0.8rem;
        letter-spacing: 1px;
        z-index: 1000;
        cursor: pointer;
        box-shadow: 2px 0 8px rgba(0,0,0,0.3);
        transition: transform 0.3s;
        user-select: none;
        -webkit-user-select: none;
    }
    body.ao-drawer-open .ao-drawer-tab {
        transform: translateY(-50%) translateX(-100%);
    }
    .ao-drawer-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }
    .ao-drawer-overlay.ao-open {
        opacity: 1;
        pointer-events: auto;
    }
    .ao-show-steps-btn {
        display: block;
        width: 100%;
        margin-bottom: 12px;
        font-size: 1rem;
        padding: 10px;
    }
    .ao-drawer-close {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        line-height: 1;
        margin: 0;
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
}

/* Pagination controls for the intro popup */
.intro-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 22px;
    gap: 12px;
}

.intro-btn {
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 10px 26px;
    font: inherit;
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.intro-btn:hover {
    background: #ffbb2e;
}

.intro-btn:active {
    transform: scale(0.98);
}

.intro-btn.back {
    background: var(--bg-header);
    color: var(--text-primary);
    border-color: var(--border-main);
}

.intro-btn.back:hover {
    background: #2a3144;
}

@media (max-width: 600px) {
    .intro-footer {
        flex-direction: column-reverse;
        margin-top: 16px;
    }
    .intro-btn {
        width: 100%;
        padding: 10px;
        font-size: 1rem;
    }
}