/* ============================================================
   exercises.css — styles for the "Find the mistake" exercise pages
   ============================================================
   Load AFTER style.css so these rules win ties without !important:

     <link rel="stylesheet" href="style.css">
     <link rel="stylesheet" href="exercises.css">

   Uses only variables defined in style.css's :root. Sections:
   Hub overrides, Back links, Page header, Problem picker,
   Problem text, Step rows & checkboxes, Check button,
   Analysis modal.
   ============================================================ */


/* ==========================================
   HUB OVERRIDES
   ========================================== */

/* Hub buttons: dark text, no underline, and a green lift on hover
   instead of style.css's blue. Specificity (0,2,1) beats both
   ".notes-content a" and ".main-note-link:hover", so no !important. */
.notes-content a.main-note-link {
    color: #111;
    text-decoration: none;
}

.notes-content a.main-note-link:hover {
    background-color: var(--accent-green);
    color: #111;
    border-color: #2ab870;
    transform: translateY(-2px);
    box-shadow: none;
}

/* style.css's .notes-card is 900px; the hub here is slightly wider. */
#exercises-hub .notes-card {
    max-width: 920px;
    margin: 24px auto;   /* re-centres the grid (beats .notes-content ul's margin-left: 4px) */
    padding: 0;          /* removes the 42px left padding from .notes-content ul */
}

/* Phones: style.css gives each hub card min-width: 320px, which is wider
   than the usable screen on small phones. Let them fill the row instead. */
@media (max-width: 600px) {
    #exercises-hub .notes-card {
        gap: 14px;
    }
    #exercises-hub .note-item-wrapper {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
        max-width: none;
    }
    #exercises-hub .main-note-link {
        font-size: 1.25rem;
        padding: 14px;
    }
}

/* Small screens: claw back space the page wrapper wastes. Only this
   page loads exercises.css, so targeting .container/body here is safe. */
@media (max-width: 768px) {
    #home-btn {
        margin-left: 0;       /* style.css reserves room for a hamburger button this page doesn't have */
        margin-bottom: 16px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 8px 4px;
    }
    .container {
        width: 100%;
        padding: 16px 10px 24px;
        border-radius: 8px;
    }
}


/* ==========================================
   BACK LINKS
   ========================================== */

/* Back links are real <a> tags, so undo the generic
   ".notes-content a" underline/colour for them. */
.notes-content a.back-btn {
    text-decoration: none;
    color: var(--accent-blue);
}

.notes-content a.back-btn:hover {
    color: #fff;
}

/* Previous / Next buttons at the bottom of a problem page
   (<button> elements don't inherit the page font by default). */
.pagination-controls .page-nav-btn {
    font-size: 1rem;
    font-family: inherit;
}


/* ==========================================
   PAGE HEADER
   ========================================== */
/* Back buttons, problem picker and section title share one bordered box.
   Back buttons far left, picker far right, title between. */

.notes-content .page-header {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--h2-bg);
    border: 2px solid var(--border-accent);
    border-radius: 6px;
    padding: 14px 20px;
    margin: 0 0 8px 0;
}

.notes-content .page-header-nav {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    flex-shrink: 0;
}

.notes-content .page-header .back-btn {
    margin: 0;
    white-space: nowrap;
}

.notes-content .page-header .page-header-title {
    flex: 1;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
    font-size: 2.4rem;
    line-height: 1.2;
    text-align: center;
}

/* Phones: back buttons left and picker right share the top row;
   the title gets its own row underneath.
   minmax(0, 1fr) is the important part: a plain 1fr can't shrink below
   its content, so the picker used to push the whole box wider than the
   screen (and the title overflowed with it). */
@media (max-width: 768px) {
    .notes-content .page-header {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "nav   picker"
            "title title";
        align-items: stretch;
        gap: 12px 10px;
        padding: 12px 14px;
    }
    .notes-content .page-header-nav {
        grid-area: nav;
    }
    .notes-content .problem-picker {
        grid-area: picker;
        min-width: 0;
    }
    .notes-content .page-header .page-header-title {
        grid-area: title;
        font-size: 1.7rem;
        overflow-wrap: anywhere;
    }
    .notes-content .page-header .back-btn {
        font-size: 0.8rem;
        padding: 5px 9px;
        white-space: normal;
        line-height: 1.25;
    }
}

@media (max-width: 480px) {
    .notes-content .page-header {
        padding: 10px;
        gap: 10px 8px;
    }
    .notes-content .page-header .page-header-title {
        font-size: 1.3rem;
    }
    .notes-content .page-header .back-btn {
        font-size: 0.75rem;
        padding: 4px 8px;
    }
}

/* Wide screens: three columns with equal outer widths, so the title sits
   in the exact middle of the box. Narrower than this, the flex layout
   above centres it in the space between the two sides. */
@media (min-width: 1400px) {
    .notes-content .page-header {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
    }
    .notes-content .page-header-nav {
        justify-self: start;
    }
    .notes-content .page-header .page-header-title {
        justify-self: center;
    }
    .notes-content .problem-picker {
        justify-self: end;
    }
}


/* ==========================================
   PROBLEM PICKER (amber "Problem N ▾" button + menu)
   ========================================== */
/* Amber on purpose: every other button is blue or green, so this
   reads as a different kind of control. */

.notes-content .problem-picker {
    position: relative;
    display: flex;
    align-self: stretch;
    flex-shrink: 0;
    min-width: 210px;
}

.notes-content .problem-picker-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    width: 100%;
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 11px 18px;
    font: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.notes-content .problem-picker-btn:hover {
    background: #ffbb2e;
}

.notes-content .problem-picker-btn:active {
    transform: scale(0.98);
}

.notes-content .problem-picker-arrow {
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.notes-content .problem-picker-btn[aria-expanded="true"] .problem-picker-arrow {
    transform: rotate(180deg);
}

.notes-content .problem-picker-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 100%;
    max-height: 50vh;
    overflow-y: auto;
    list-style: none;
    margin: 0;
    padding: 6px;
    background: var(--bg-card);
    border: 2px solid var(--accent-amber);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    z-index: 50;
}

.notes-content .problem-picker-menu[hidden] {
    display: none;
}

.notes-content .problem-picker-menu li {
    margin: 0;
    font-size: 1.1rem;
}

.notes-content .problem-picker-menu a {
    display: block;
    padding: 9px 14px;
    border-radius: 5px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}

.notes-content .problem-picker-menu a:hover {
    background: rgba(240, 165, 0, 0.18);
    color: var(--accent-amber);
}

.notes-content .problem-picker-menu a.current {
    background: rgba(240, 165, 0, 0.25);
    color: var(--accent-amber);
}

@media (max-width: 768px) {
    /* Must live AFTER the base .problem-picker rule above: same specificity,
       so the later rule wins. (It used to sit in the header section, where
       the base rule's min-width: 210px overrode it.) */
    .notes-content .problem-picker {
        min-width: 0;
    }
    .notes-content .problem-picker-btn {
        font-size: 1.15rem;
        padding: 8px 12px;
        gap: 8px;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .notes-content .problem-picker-btn {
        font-size: 1rem;
        padding: 8px 10px;
        gap: 6px;
    }
    .notes-content .problem-picker-menu li {
        font-size: 1rem;
    }
}


/* ==========================================
   PROBLEM TEXT
   ========================================== */
/* .problem-prompt  the sentence that asks the question (a <p>)
   .problem-box     rounded bordered box for the maths itself; each <p>
                    inside is one line. Add .problem-steps to left-align
                    and use <span class="step-label"> for "Step 1" etc.
   Sizes use clamp() so text stays large on phones without getting silly
   on big monitors. The box scrolls sideways if an equation is too wide. */

.notes-content .problem-prompt {
    font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.75rem);
    line-height: 1.6;
    margin-bottom: 20px;
}

.notes-content .problem-box {
    --problem-box-border: var(--text-primary);   /* change the box colour here */
    max-width: 900px;
    margin: 24px auto;
    padding: 20px 28px;
    background: var(--bg-header);
    border: 3px solid var(--problem-box-border);
    border-radius: 22px;
    font-size: clamp(1rem, 0.8rem + 0.8vw, 1.35rem); 
    line-height: 1.6;
    text-align: center;
    color: var(--text-heading);
    overflow-x: auto;
}


.notes-content .problem-box p {
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    margin: 0 0 14px 0;
}

.notes-content .problem-box p:last-child {
    margin-bottom: 0;
}

.notes-content .problem-steps {
    text-align: left;
}

.notes-content .problem-box .step-label {
    display: block;
    font-size: 0.5em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-amber);
    line-height: 1.4;
}

/* Same label inside a solution <h4>. The rule above only matches inside a
   .problem-box, which is why the label had no styling in the solution.
   The h4 text is much smaller than the problem box text, so the label
   uses a larger fraction of it to stay readable. */
.notes-content .question-answer .step-label {
    display: block;
    font-size: 0.7em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-amber);
    line-height: 1.4;
    text-align: left;
}

/* Phones: smaller base text, tighter box. exercises.js then shrinks the
   maths a little further, only if a line still doesn't fit its row. */
@media (max-width: 600px) {
    .notes-content .problem-prompt {
        font-size: 1.1rem;
        margin-bottom: 14px;
    }
    .notes-content .problem-box {
        font-size: clamp(0.9rem, 0.6rem + 2vw, 1.15rem);
        padding: 12px 10px;
        border-width: 2px;
        border-radius: 16px;
        margin: 16px auto;
    }
    .notes-content .problem-box p {
        margin-bottom: 10px;
    }
}

@media (max-width: 380px) {
    .notes-content .problem-box {
        padding: 12px 10px;
    }
}

/* Runs of <h4> equation boxes in a solution (wrapped by exercises.js).
   The group is one column as wide as its widest box, centred on the page;
   every box is stretched to that full width, so they all match.
   minmax(0, max-content) lets the column shrink on narrow screens. */
.notes-content .question-answer .h4-group {
    display: grid;
    grid-template-columns: minmax(0, max-content);
    justify-content: center;
    justify-items: stretch;   /* every box fills the column = same width as the widest */
    row-gap: 12px;
    margin: 12px 0 16px;
}

.notes-content .question-answer .h4-group > h4 {
    display: block;
    max-width: 100%;
    margin: 0;
    text-align: left;     /* every line (incl. after a <br>) starts at the same left edge */
}

/* Hidden by default so it doesn't give away the answer */
.notes-content .problem-steps ~ .question-dropdown {
    display: none;
}

/* Revealed on the page once the correct step is checked */
.notes-content .problem-steps ~ .question-dropdown.revealed {
    display: block;
    animation: analysisFadeIn 0.3s ease;
}


/* ==========================================
   STEP ROWS & CHECKBOXES
   ========================================== */

.notes-content .steps-header-instruction {
    text-align: right;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    padding-right: 4px;
}

.notes-content .step-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.notes-content .step-row:last-child {
    margin-bottom: 0;
}

/* min-width: 0 lets this column shrink to the space beside the checkbox
   (flex items refuse to by default, which pushed the checkbox off-screen).
   overflow-x is only a last-resort fallback: exercises.js scales the maths
   to fit first, so a line scrolls by itself, never the whole box. */
.notes-content .step-main {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.notes-content .step-check-container {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The real radio input is visually hidden; its <label> is the visible box. */
.notes-content .step-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.notes-content .step-checkbox:focus-visible + .step-checkbox-label {
    outline: 3px solid var(--accent-blue);
    outline-offset: 3px;
}

.notes-content .step-checkbox-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 2px solid var(--text-primary);
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    transition: all 0.2s ease;
}

.notes-content .step-checkbox-label:hover {
    border-color: #e53935;
}

.notes-content .step-checkbox:checked + .step-checkbox-label {
    background: rgba(229, 57, 53, 0.15);
    border-color: #e53935;
}

.notes-content .step-checkbox:checked + .step-checkbox-label::after {
    content: "✕";
    color: #e53935;
    font-size: 1.25rem;
    font-weight: bold;
    line-height: 1;
}

/* Phones: tighter rows, slightly bigger tap target for the checkbox. */
@media (max-width: 600px) {
    .notes-content .step-row {
        gap: 10px;
        margin-bottom: 12px;
    }
    .notes-content .step-checkbox-label {
        width: 36px;
        height: 36px;
    }
    .notes-content .steps-header-instruction {
        font-size: 0.75rem;
        margin-bottom: 8px;
    }
}


/* ==========================================
   CHECK BUTTON
   ========================================== */

.check-step-btn {
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 10px 24px;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.check-step-btn:hover {
    background: #ffbb2e;
}

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

/* ==========================================
   CHECK BUTTON & FEEDBACK MESSAGE
   ========================================== */

.check-step-btn {
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 10px 24px;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.check-step-btn:hover {
    background: #ffbb2e;
}

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

/* Row holding the feedback text and Check button */
.check-step-row {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Locks the button to the right permanently */
    gap: 16px;
    margin-top: 20px;
}

.feedback-msg {
    color: #e53935;
    font-weight: 600;
    font-size: 1.05rem;
    margin-right: auto; /* Pushes text to the left so it doesn't move the button */
    display: none;
}

.feedback-msg.visible {
    display: inline-block;
}

/* Mobile responsive stacking for the check row */
@media (max-width: 768px) {
    .check-step-row {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .check-step-row .check-step-btn {
        width: 100%;
    }
    .feedback-msg {
        margin-right: 0;
        margin-bottom: 4px;
    }
}


/* ==========================================
   ANALYSIS MODAL (opened by a correct answer)
   ========================================== */
/* Keyframes are prefixed "analysis" so they can never collide with a
   generic fadeIn/scaleUp defined (or referenced) in style.css. */

.analysis-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 0;
    animation: analysisFadeIn 0.2s forwards;
}

.analysis-modal-content {
    background: var(--bg-card);
    border: 3px solid var(--accent-amber);
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    position: relative;
    color: var(--text-primary);
    transform: scale(0.9);
    animation: analysisScaleUp 0.2s forwards;
}

.analysis-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.analysis-modal-close:hover {
    color: var(--text-primary);
}

.analysis-modal-title {
    margin: 0 0 14px 0;
    padding-right: 36px;   /* keeps a long title clear of the × button */
    font-size: 1.4rem;
    color: var(--accent-amber);
}

/* The modal lives on <body>, outside .notes-content, so the notes
   typography doesn't reach it — give its text the same basics. */
.analysis-modal-body p {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 14px;
}

.analysis-modal-body p:last-child {
    margin-bottom: 0;
}

.analysis-modal-body ol,
.analysis-modal-body ul {
    padding-left: 28px;
    margin-bottom: 14px;
}

.analysis-modal-body li {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 8px;
}

/* Phones: smaller padding so the solution text gets the width, and
   dvh so the browser's collapsing address bar can't cut the box off. */
@media (max-width: 600px) {
    .analysis-modal-overlay {
        padding: 10px;
    }
    .analysis-modal-content {
        padding: 22px 16px 18px;
        border-width: 2px;
        border-radius: 12px;
        max-height: 90vh;
        max-height: 90dvh;
    }
    .analysis-modal-close {
        top: 8px;
        right: 12px;
    }
    .analysis-modal-title {
        font-size: 1.2rem;
    }
    .analysis-modal-body p,
    .analysis-modal-body li {
        font-size: 1rem;
    }
}


/* ==========================================
   PREVIOUS / NEXT BUTTONS (phones)
   ========================================== */
@media (max-width: 480px) {
    .pagination-controls {
        gap: 10px;
    }
    .pagination-controls .page-nav-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
    }
}


@keyframes analysisFadeIn {
    to { opacity: 1; }
}

@keyframes analysisScaleUp {
    to { transform: scale(1); }
}

/* ==========================================
   SUCCESS CHECKMARK ANIMATION OVERLAY
   ========================================== */

@keyframes checkmarkPopFade {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.4);
    }
    30% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.15);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

.success-popup-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #14191e; /* Solid dark color with zero transparency */
    border: 3px solid #3dd68c;
    border-radius: 24px;
    padding: 28px 42px;
    font-size: 5.5rem;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    animation: checkmarkPopFade 0.9s ease forwards;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================
   COMPACT SOLUTION VIEW (phones only)
   ========================================== */

/* The switch is hidden everywhere except phones */
.notes-content .question-answer .compact-switch {
    display: none;
}

@media (max-width: 768px) {

    /* ---- the switch ---- */
    .notes-content .question-answer .compact-switch {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0 0 14px 0;
        cursor: pointer;
        user-select: none;
        font-size: 0.9rem;
        font-weight: 700;
        color: var(--text-secondary);
    }

    .compact-switch input {
        position: absolute;
        opacity: 0;
        width: 1px;
        height: 1px;
    }

    .compact-switch-track {
        position: relative;
        flex-shrink: 0;
        width: 44px;
        height: 24px;
        border-radius: 12px;
        background: var(--bg-card);
        border: 2px solid var(--text-secondary);
        transition: background-color 0.2s ease, border-color 0.2s ease;
    }

    .compact-switch-track::after {
        content: "";
        position: absolute;
        top: 2px;
        left: 2px;
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: var(--text-secondary);
        transition: transform 0.2s ease, background-color 0.2s ease;
    }

    .compact-switch input:checked + .compact-switch-track {
        background: var(--accent-green);
        border-color: #2ab870;
    }

    .compact-switch input:checked + .compact-switch-track::after {
        transform: translateX(20px);
        background: #111;
    }

    .compact-switch input:focus-visible + .compact-switch-track {
        outline: 3px solid var(--accent-blue);
        outline-offset: 3px;
    }

    /* ---- compact mode: remove the h4 boxes, shrink the text ---- */
    .notes-content .question-answer.compact .h4-group {
        display: block;
        margin: 6px 0 10px;
    }

    .notes-content .question-answer.compact h4,
    .notes-content .question-answer.compact .h4-group > h4 {
        background: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0;
        margin: 0 0 12px 0;
        width: auto;
        max-width: 100%;
        font-size: 0.9rem;
        font-weight: 400;
        line-height: 1.5;
        text-align: left;
        overflow-x: auto;
    }

    .notes-content .question-answer.compact p,
    .notes-content .question-answer.compact li {
        font-size: 0.9rem;
        line-height: 1.5;
    }

    .notes-content .question-answer.compact .step-label {
        font-size: 0.75em;
    }

    /* left-align the big $$ equations and tighten their spacing */
    .notes-content .question-answer.compact mjx-container[display="true"] {
        text-align: left;
        margin: 0.4em 0;
    }
}

/* ==========================================
   INTRO POPUP (shown when a section is newly entered)
   ========================================== */
/* Three illustrated steps: check the wrong step, read the analysis, run
   through the problems. Built by showIntro() in exercises.js. Reuses the
   analysisFadeIn / analysisScaleUp keyframes. The popup lives on <body>,
   outside .notes-content, so it sets its own text sizes. */

body.intro-open {
    overflow: hidden;   /* stop the page scrolling behind the popup */
}

.intro-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 20px;
    opacity: 0;
    animation: analysisFadeIn 0.2s forwards;
}

.intro-modal-content {
    position: relative;
    background: var(--bg-card);
    border: 3px solid black;
    border-radius: 16px;
    max-width: 760px;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 30px 32px 26px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    transform: scale(0.9);
    animation: analysisScaleUp 0.2s forwards;
}

.intro-modal-close {
    position: absolute;
    top: 12px;
    right: 18px;
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
}

.intro-modal-close:hover {
    color: var(--text-primary);
}

.intro-modal-close:focus-visible,
.intro-modal-start:focus-visible {
    outline: 3px solid var(--accent-blue);
    outline-offset: 3px;
}

.intro-modal-title {
    margin: 0 0 6px 0;
    padding-right: 36px;      /* keeps the title clear of the × button */
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--accent-amber);
}

.intro-modal-sub {
    margin: 0 0 20px 0;
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ---- the three steps ---- */
.intro-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 14px;
}

.intro-step {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) 200px;
    align-items: center;
    gap: 18px;
    margin: 0;
    padding: 16px 18px;
    background: var(--bg-header);
    border: 2px solid var(--border-main);
    border-radius: 14px;
}

.intro-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-amber);
    color: #111;
    font-size: 1.15rem;
    font-weight: 700;
}

.intro-step-title {
    margin: 0 0 4px 0;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-heading);
}

.intro-step-text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text-primary);
}

.intro-step-art {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- illustrations (miniatures of the real page) ---- */
.intro-art {
    width: 100%;
    max-width: 200px;
    box-sizing: border-box;
    background: var(--bg-card);
    border: 2px solid var(--text-primary);
    border-radius: 14px;
    padding: 10px 14px 12px;
}

.intro-art-label {
    margin-bottom: 6px;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.intro-mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

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

.intro-mini-eq {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
}

.intro-mini-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border: 2px solid var(--text-primary);
    border-radius: 6px;
    background: var(--bg-card);
}

/* Same red cross as a ticked step on the real page */
.intro-mini-box.checked {
    border-color: #e53935;
    background: rgba(229, 57, 53, 0.15);
    animation: introPulse 1.8s ease-in-out infinite;
}

.intro-mini-box.checked::after {
    content: "\2715";
    color: #e53935;
    font-size: 0.95rem;
    font-weight: bold;
    line-height: 1;
}

.intro-art-heading {
    margin-bottom: 8px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-amber);
}

.intro-squiggle {
    display: block;
    width: 100%;
    height: 10px;
    margin-bottom: 8px;
}

.intro-squiggle:last-child {
    margin-bottom: 0;
}

.intro-squiggle path {
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 2;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

/* The amber picker has no frame: it is the whole picture */
.intro-art.intro-art-picker {
    background: none;
    border: none;
    padding: 0;
}

.intro-mini-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 1.1rem;
    font-weight: 700;
}

.intro-mini-arrow {
    font-size: 1rem;
    line-height: 1;
}

/* ---- start button ---- */
.intro-modal-start {
    display: block;
    margin: 22px 0 0 auto;
    background: var(--accent-amber);
    color: #111;
    border: 2px solid #c98a00;
    border-radius: 8px;
    padding: 10px 26px;
    font: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.intro-modal-start:hover {
    background: #ffbb2e;
}

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

@keyframes introPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.45); }
    50%      { box-shadow: 0 0 0 6px rgba(229, 57, 53, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .intro-mini-box.checked {
        animation: none;
    }
}

/* Phones: ultra-compact to avoid scrolling. */
@media (max-width: 600px) {
    .intro-modal-overlay {
        padding: 6px;
    }
    .intro-modal-content {
        padding: 12px 10px 10px;
        border-width: 2px;
        border-radius: 12px;
    }
    .intro-modal-close {
        top: 2px;
        right: 8px;
        font-size: 1.6rem;
    }
    .intro-modal-title {
        font-size: 1.25rem;
        margin-bottom: 0;
    }
    /* Hide the subtitle on mobile to save 2 lines of text */
    .intro-modal-sub {
        display: none;
    }
    .intro-steps {
        gap: 8px;
    }
    .intro-step {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 4px 8px;
        padding: 8px 10px;
        border-radius: 8px;
    }
    .intro-step-num {
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }
    .intro-step-title {
        font-size: 1rem;
        margin-bottom: 0;
    }
    .intro-step-text {
        font-size: 0.8rem;
        line-height: 1.3;
    }
    .intro-step-art {
        grid-column: 1 / -1;
        justify-content: center;
        margin-top: 2px;
    }
    /* Extremely compact illustrations */
    .intro-art {
        padding: 4px 8px;
    }
    .intro-mini-row {
        margin-bottom: 2px;
    }
    .intro-mini-eq {
        font-size: 0.8rem;
    }
    .intro-mini-box {
        width: 18px;
        height: 18px;
    }
    .intro-mini-box.checked::after {
        font-size: 0.7rem;
    }
    .intro-art-heading {
        margin-bottom: 2px;
        font-size: 0.85rem;
    }
    /* Hide the squiggly lines on mobile, the heading is enough */
    .intro-squiggle {
        display: none;
    }
    .intro-mini-picker {
        padding: 4px 10px;
        font-size: 0.9rem;
    }
    .intro-modal-start {
        width: 100%;
        margin-top: 8px;
        padding: 6px 12px;
        font-size: 1rem;
    }
}