/* Cinematic dialogue panel */
.dialogue-root {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 1.5rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.dialogue-root.active {
    opacity: 1;
    pointer-events: auto;
}

.dialogue-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 10, 15, 0.78);
    backdrop-filter: blur(2px);
}

.dialogue-panel {
    position: relative;
    display: flex;
    gap: 1.25rem;
    width: 100%;
    max-width: 900px;
    background: linear-gradient(135deg, rgba(21, 25, 32, 0.96), rgba(11, 13, 18, 0.98));
    border: 1px solid rgba(0, 212, 240, 0.35);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.65), 0 0 40px rgba(0, 212, 240, 0.08);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    animation: dialogueIn 0.35s ease forwards;
}

.dialogue-root.active .dialogue-panel {
    transform: translateY(0);
}

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

.dialogue-portrait-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
}

.dialogue-portrait {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    image-rendering: pixelated;
    box-shadow: 0 0 24px rgba(0, 212, 240, 0.25);
    border: 2px solid rgba(0, 212, 240, 0.35);
}

.dialogue-portrait-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-weight: 700;
    font-size: 1.5rem;
}

.dialogue-body {
    flex: 1;
    min-width: 0;
}

.dialogue-meta {
    margin-bottom: 0.35rem;
}

.dialogue-name {
    font-weight: 700;
    color: var(--accent);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dialogue-text {
    font-size: 1.15rem;
    line-height: 1.55;
    color: var(--text);
    min-height: 3.5rem;
}

.dialogue-text.typing::after {
    content: '|';
    color: var(--accent);
    animation: blink 0.8s infinite;
}

.dialogue-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
}

.dialogue-choice {
    animation: choiceIn 0.3s ease both;
}

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

.dialogue-hint {
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--muted);
    opacity: 0.7;
}

.dialogue-skip {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s, border-color 0.2s;
    z-index: 1;
}

.dialogue-skip:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent);
}

@media (max-width: 640px) {
    .dialogue-panel {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1rem;
    }
    .dialogue-portrait {
        width: 64px;
        height: 64px;
    }
    .dialogue-text {
        font-size: 1rem;
    }
}

/* Module 0 lessons: the idea, a worked example that stays on screen, and a real Python editor. */
.lesson {
    margin: 1rem 0 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(0, 212, 240, 0.04);
}

.lesson h3 {
    margin: 0.75rem 0 0.4rem;
    font-size: 1rem;
    color: var(--accent);
}

.lesson-idea {
    line-height: 1.6;
}

.lesson-idea code,
.py-files code {
    background: #0f1115;
    border-radius: 4px;
    padding: 0 0.3rem;
}

.lesson-file {
    margin-bottom: 0.5rem;
}

.lesson-file-name {
    font-size: 0.8rem;
    color: var(--muted);
}

.py-editor {
    width: 100%;
    box-sizing: border-box;
    background: #0f1115;
    color: #c8d1db;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    tab-size: 4;
    resize: vertical;
}

.py-editor:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.py-output {
    background: #07090c;
    color: var(--success);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin: 0.5rem 0;
    white-space: pre-wrap;
    max-height: 16rem;
    overflow: auto;
}

.py-error {
    border: 1px solid var(--error);
    border-radius: var(--radius);
    padding: 0.6rem 0.75rem;
    margin: 0.5rem 0;
    color: var(--text);
    background: rgba(255, 82, 82, 0.08);
}

.py-files {
    color: var(--muted);
    font-size: 0.9rem;
}

.py-answer-label {
    display: block;
    margin-top: 0.75rem;
    font-weight: 600;
}

.lesson-next {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.lesson-next p {
    margin: 0;
    width: 100%;
}

/* Sheet coordinates in the CSV grid: column letters above, row numbers down the side. */
.csv-letters td,
.csv-rownum {
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    user-select: none;
}

.csv-rownum {
    width: 2.5rem;
    font-variant-numeric: tabular-nums;
}

/* ---------- Spreadsheets From Zero: the lesson page and its sheet ---------- */
.lesson-track {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: lesson;
}

.lesson-track li {
    counter-increment: lesson;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
}

.lesson-track li::before {
    content: counter(lesson) ".";
    color: var(--muted);
    min-width: 1.5rem;
}

.lesson-track li a {
    flex: 1;
    display: flex;
    align-items: center;
    min-height: 24px;
    color: var(--text);
    text-decoration: none;
}

.lesson-track li.current {
    background: rgba(0, 212, 240, 0.12);
    outline: 1px solid var(--accent);
}

.lesson-track li.complete a {
    color: var(--success);
}

.lesson-track-meta {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.lesson-intro {
    color: var(--text);
    line-height: 1.6;
}

.lesson-step {
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 1rem 0;
}

.lesson-step-count {
    margin: 0 0 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.lesson-say {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.lesson-answer {
    display: flex;
    flex-wrap: wrap;            /* on a phone the button drops under the input instead of past the edge */
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.lesson-answer input {
    flex: 1 1 10rem;
    min-width: 0;
    max-width: 14rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}

.lesson-feedback {
    min-height: 1.5rem;
    margin: 0 0 0.5rem;
    color: var(--text);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.lesson-controls {
    display: flex;
    gap: 0.5rem;
}

/* The sheet itself looks like a spreadsheet: light cells, dark ink, grey headings. */
.sheet {
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f7f8fa;
    color: #1b1f24;
}

.sheet-tabs {
    display: flex;
    gap: 2px;
    background: #e3e6ea;
    padding: 4px 4px 0;
}

.sheet-tab {
    border: 1px solid #c4c9d0;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    background: #eef0f3;
    color: #1b1f24;
    padding: 0.25rem 0.9rem;
    font: inherit;
    cursor: pointer;
}

.sheet-tab.active {
    background: #ffffff;
    font-weight: 600;
}

.sheet-tab.lit {
    outline: 2px solid #b26a00;
}

.sheet-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem;
    border-bottom: 1px solid #c4c9d0;
    background: #ffffff;
}

.sheet-address {
    width: 5.5rem;
    font: 600 0.95rem ui-monospace, Consolas, monospace;
    text-align: center;
    border: 1px solid #c4c9d0;
    border-radius: 4px;
    padding: 0.3rem;
    color: #1b1f24;
    background: #f7f8fa;
}

.sheet-fx {
    font-style: italic;
    color: #555d68;
}

.sheet-formula {
    flex: 1;
    font: 0.95rem ui-monospace, Consolas, monospace;
    border: 1px solid #c4c9d0;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    color: #1b1f24;
    background: #ffffff;
}

.sheet-formula:focus,
.sheet-grid:focus {
    outline: 2px solid #1a73e8;
    outline-offset: -2px;
}

.sheet-grid-wrap {
    max-width: 100%;
    overflow: auto;
    max-height: 26rem;
}

.sheet-grid {
    border-collapse: collapse;
    font: 0.95rem system-ui, sans-serif;
    user-select: none;
}

.sheet-grid th {
    background: #e9ecef;
    color: #3c434d;
    font-weight: 600;
    font-size: 0.8rem;
    border: 1px solid #c4c9d0;
    padding: 0.2rem 0.4rem;
    min-width: 2.2rem;
}

.sheet-grid th.lit {
    background: #ffd27a;
    color: #1b1f24;
}

.sheet-corner {
    background: #dde1e6;
}

.sheet-cell {
    border: 1px solid #d5d9df;
    min-width: 6.5rem;
    height: 1.9rem;
    padding: 0 0.45rem;
    white-space: nowrap;
    background: #ffffff;
    cursor: cell;
}

.sheet-cell.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sheet-cell.err {
    color: #b3261e;
}

.sheet-cell.lit {
    background: #fff1cc;
}

/* On touch, a drag that starts on a selected cell stretches the range instead of scrolling (static/js/sheet.js). */
.sheet-cell.sel {
    touch-action: none;
}

.sheet-cell.sel {
    outline: 2px solid #1a73e8;
    outline-offset: -2px;
    background: #e8f0fe;
}

@media (max-width: 640px) {
    .sheet-cell { min-width: 4.5rem; }
}

/* The data-analytics lifecycle, shown on every lesson with its stage lit. */
.lifecycle-strip {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0;
    margin: 0.75rem 0 0;
}

.lifecycle-strip li {
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.85rem;
}

.lifecycle-strip li + li::before {
    content: "→ ";
    color: var(--muted);
}

.lifecycle-strip li.lit {
    border-color: var(--warning);
    color: var(--text);
    background: rgba(255, 179, 0, 0.14);
    font-weight: 600;
}

.lesson-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

/* Each mission phase names its lifecycle stage, in the same words the lessons use. */
.phase-stage {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* The lesson track on the Board. */
.lesson-pills {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0;
    margin: 1rem 0 0;
}

.lesson-pills li a {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
}

.lesson-pills li.complete a {
    border-color: var(--success);
    color: var(--success);
}

.lesson-track-panel .btn-primary {
    display: inline-block;
    margin-top: 0.5rem;
}

.lesson-link {
    color: var(--accent);
    font-weight: 600;
}

.sheet-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem 0.4rem;
    background: #f1f3f5;
    border-bottom: 1px solid #c4c9d0;
}

.sheet-tools button {
    font: 0.85rem system-ui, sans-serif;
    color: #1b1f24;
    background: #ffffff;
    border: 1px solid #c4c9d0;
    border-radius: 4px;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
}

.sheet-tools button:hover {
    background: #e8f0fe;
}

.case-gate {
    color: var(--text);
    font-size: 0.9rem;
}

.case-gate a {
    display: inline-block;
    min-width: 24px;
    min-height: 24px;
    line-height: 24px;
    text-align: center;
    color: var(--accent);
    font-weight: 600;
}

.lesson-stage {
    margin: 0 0 0.5rem;
    color: var(--text);
}

.lesson-bridge {
    margin: 0 0 0.5rem;
    line-height: 1.6;
}

.flag-btn {
    margin-top: 0.5rem;
}

.flag-note {
    margin: 0.5rem 0 0;
    color: var(--warning);
}

/* How Rigor scores the quality checks, and the line under a wrong first answer. */
.quality-note {
    color: var(--muted);
    font-size: 0.95rem;
}

.pick-again {
    margin: 0.25rem 0 0.5rem;
    color: var(--warning);
}

