/* ===================================================================
   Rebuilding Tutorial — styles
   =================================================================== */

.tutorial-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem 3rem;
    /* Not Bootstrap's system-ui: on Windows that is Segoe UI, whose curly
       quotes are near-identical wedges, so &ldquo;/&rdquo; read as straight. */
    font-family: var(--mp-font-ui);
}

/* --- Header --- */
.tutorial-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.tutorial-header h1 {
    font-family: var(--mp-font-ui);
    color: var(--mp-olive, #666633);
    font-size: 1.6rem;
    margin-bottom: 0.3rem;
}
.tutorial-subtitle {
    color: var(--mp-tan, #999966);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

/* --- Voting bar --- */
.tutorial-voting-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.tutorial-classroom-btn {
    background: var(--mp-cream, #f8f8f0);
    border: 1px solid var(--mp-tan-light, #cccc99);
    color: var(--mp-olive, #666633);
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}
.tutorial-classroom-btn:hover {
    background: var(--mp-tan-light, #cccc99);
}
.tutorial-classroom-btn.active {
    background: var(--mp-olive, #666633);
    color: white;
    border-color: var(--mp-olive, #666633);
}
.voting-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.voting-or {
    color: #999;
    font-size: 0.8rem;
}
.tutorial-code-input {
    width: 6em;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--mp-tan-light, #cccc99);
    border-radius: 4px;
    font-size: 0.9rem;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.15em;
}
.voting-status {
    font-size: 0.85rem;
    font-weight: 600;
}
.voting-status.connected {
    color: var(--mp-success, #336633);
}
.voting-status.error {
    color: var(--mp-danger, #993333);
}
.tutorial-room-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--mp-cream, #f8f8f0);
    border: 2px solid var(--mp-olive, #666633);
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    font-size: 1rem;
    letter-spacing: 0.2em;
    font-weight: 700;
    color: var(--mp-olive, #666633);
}

/* --- Level tabs --- */
.tutorial-level-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.tutorial-level-tab {
    flex: 1;
    min-width: 80px;
    padding: 0.5rem 0.5rem;
    background: var(--mp-cream, #f8f8f0);
    border: 1px solid var(--mp-tan-light, #cccc99);
    border-bottom: 2px solid transparent;
    color: var(--mp-tan, #999966);
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}
.tutorial-level-tab:hover {
    background: var(--mp-tan-light, #cccc99);
    color: var(--mp-olive, #666633);
}
.tutorial-level-tab.active {
    background: white;
    color: var(--mp-olive, #666633);
    border-bottom-color: var(--mp-olive, #666633);
    font-weight: 600;
}
.tutorial-level-tab.locked {
    opacity: 0.6;
}

/* --- Level panels --- */
.tutorial-level {
    animation: tutorialFadeIn 0.2s ease;
}
.tutorial-level h2 {
    font-family: var(--mp-font-ui);
    color: var(--mp-maroon, #660000);
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
}
.tutorial-intro {
    color: #555;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

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

/* --- Step grid: a step and its figures share a .step-row, which bounds the sticky figures --- */
.tutorial-narrative {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    column-gap: 2rem;
}
.tutorial-narrative > * {
    grid-column: 1;
}
.tutorial-narrative > .step-row {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    align-items: start;
}
.step-row > .step-figures {
    grid-column: 2;
    position: sticky;
    top: 1rem;
}
@media (max-width: 900px) {
    .tutorial-narrative {
        grid-template-columns: minmax(0, 1fr);
    }
    .step-row > .step-figures {
        grid-column: 1;
        position: static;
        max-width: 480px;
        margin: 0 auto 1rem;
    }
}

/* --- Steps --- */
.tutorial-step {
    border: 1px solid #ddd;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #fafaf5;
    border-radius: 6px;
}
.step-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}
.step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--mp-maroon, #660000);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.step-title {
    font-weight: 600;
    color: var(--mp-olive, #666633);
    font-size: 1rem;
}
.step-body {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #444;
}
.step-body p {
    margin-bottom: 0.6rem;
}
.step-body code {
    background: #e8e8dd;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.88em;
}
.step-body ul, .step-body ol {
    padding-left: 1.5rem;
    margin-bottom: 0.6rem;
}

/* --- Hints --- */
.step-hint {
    margin-top: 0.5rem;
}
.hint-toggle {
    background: none;
    border: none;
    color: var(--mp-tan, #999966);
    cursor: pointer;
    font-size: 0.82rem;
    padding: 0;
    text-decoration: underline;
}
.hint-toggle:hover {
    color: var(--mp-olive, #666633);
}
/* Moorhen tool icons (tutorial/moorhen-icon_*.png), inline in the text */
.moorhen-icon {
    width: 2em;
    height: 2em;
    vertical-align: middle;
}
.hint-content {
    margin-top: 0.4rem;
    padding: 0.5rem 0.75rem;
    background: #f0f0e5;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #555;
    border: 1px solid var(--mp-tan, #999966);
}

/* --- Tutorial notes --- */
.tutorial-note {
    margin-top: 0.6rem;
    padding: 0.6rem 0.8rem;
    background: #f5f0e0;
    border: 1px solid var(--mp-olive, #666633);
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* --- Bonus round warning (shared boilerplate, see _bonus_round_warning.html) --- */
.tutorial-bonus-warning {
    margin-bottom: 0.8rem;
    padding: 0.6rem 0.8rem;
    background: #fdf1d8;
    border: 1px solid #a8760c;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #5c4106;
}
.tutorial-bonus-warning p:last-child {
    margin-bottom: 0;
}

/* --- Validation flags --- */
.flag-rotamer {
    background: #ffcc99;
    color: #663300;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.82em;
    font-weight: 600;
}
.flag-clash {
    background: #ff99cc;
    color: #660066;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.82em;
    font-weight: 600;
}
.flag-hbond {
    background: #99cc99;
    color: #003300;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.82em;
    font-weight: 600;
}
.flag-vdw {
    background: #99ccff;
    color: #003366;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.82em;
    font-weight: 600;
}
.flag-cbeta {
    background: #ff66ff;
    color: #330033;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.82em;
    font-weight: 600;
}
.flag-geomred {
    background: #ff6666;
    color: #330000;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.82em;
    font-weight: 600;
}

/* --- Figures --- */
.step-figures {
    display: flex;
    flex-direction: column;
}
.tutorial-figure {
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--mp-tan-light, #cccc99);
}
.figure-caption {
    font-size: 0.78rem;
    color: var(--mp-tan, #999966);
    font-style: italic;
    text-align: center;
    margin: 0.2rem 0 0.8rem;
}
.tutorial-figure-placeholder {
    background: #e8e8dd;
    border: 2px dashed var(--mp-tan-light, #cccc99);
    border-radius: 8px;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--mp-tan, #999966);
    font-size: 0.82rem;
    font-style: italic;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Outlier list --- */
.tutorial-outlier-list {
    padding-left: 1.2rem;
    margin-bottom: 0.6rem;
}
.tutorial-outlier-list li {
    margin-bottom: 0.3rem;
    font-size: 0.88rem;
}

/* --- Density viewer (warm-up) --- */
.tutorial-density-row {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    margin-top: 1rem;
}
@media (max-width: 768px) {
    .tutorial-density-row {
        grid-template-columns: 1fr;
    }
}
.tutorial-density-viewer {
    display: flex;
    flex-direction: column;
}
.tutorial-density-viewer .mp-game-canvas-wrap {
    min-height: 350px;
    position: relative;
}
.tutorial-density-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    flex-wrap: wrap;
}
.tutorial-res-display {
    font-size: 0.9rem;
    color: var(--mp-olive, #666633);
}
.res-label {
    color: var(--mp-tan, #999966);
}
.res-value {
    font-weight: 700;
    margin-left: 0.3rem;
}
.tutorial-density-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
}
.reveal-answer {
    display: inline-block;
    font-size: 1rem;
    font-weight: 700;
    color: #44cc44;
    background: rgba(26, 26, 46, 0.85);
    padding: 0.35rem 1rem;
    border-radius: 0 0 6px 6px;
}

/* --- Buttons --- */
.tutorial-btn {
    background: var(--mp-olive, #666633);
    color: white;
    border: none;
    padding: 0.4rem 0.9rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.tutorial-btn:hover:not(:disabled) {
    background: var(--mp-maroon, #660000);
}
.tutorial-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.tutorial-btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}
.tutorial-btn-reveal {
    background: #cc9900;
}
.tutorial-btn-reveal:hover {
    background: #aa7700;
}

/* --- AA Vote grid --- */
.tutorial-vote-panel {
    display: flex;
    flex-direction: column;
}
.tutorial-vote-panel h4 {
    font-size: 0.95rem;
    color: var(--mp-olive, #666633);
    margin-bottom: 0.5rem;
}
.tutorial-aa-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
}
.tutorial-aa-btn {
    padding: 0.3rem 0.1rem;
    border: 1px solid #555;
    border-radius: 3px;
    cursor: pointer;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    transition: transform 0.1s, opacity 0.15s;
    color: #222;
}
.tutorial-aa-btn:hover:not(:disabled):not(.selected) {
    transform: scale(1.05);
    filter: brightness(1.1);
}
.tutorial-aa-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.tutorial-aa-btn.selected {
    outline: 2px solid white;
    outline-offset: -2px;
    transform: scale(1.05);
}
.tutorial-aa-btn.correct {
    background: #44cc44 !important;
    color: white;
}
.tutorial-aa-btn.wrong {
    background: #cc4444 !important;
    color: white;
}

/* AA color groups */
.tutorial-aa-btn.nonpolar { background: #b0b0b0; }
.tutorial-aa-btn.aromatic { background: #c4a0d0; }
.tutorial-aa-btn.polar    { background: #90c090; }
.tutorial-aa-btn.positive { background: #90b0d8; }
.tutorial-aa-btn.negative { background: #d8a090; }

/* --- Ligand candidate diagrams (Level 4) --- */
.ligand-candidates {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0.5rem 0;
}
.ligand-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--mp-cream, #f8f8f0);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 6px 8px 4px;
    min-width: 100px;
    flex: 1;
}
.ligand-diagram {
    width: 100%;
    max-width: 120px;
    height: auto;
}
.ligand-diagram .bond {
    stroke: #555;
    stroke-width: 1.5;
}
.ligand-diagram .atom-label {
    font-size: 9px;
    font-family: var(--mp-font-ui);
    fill: #333;
}
.ligand-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--mp-olive, #666633);
    margin-top: 2px;
}
.ligand-atoms {
    font-size: 0.72rem;
    color: #888;
}
.poll-subtext {
    font-size: 0.82rem;
    color: #666;
    margin-bottom: 0.3rem;
}

/* --- Inline poll (for level steps) --- */
.tutorial-poll-inline {
    margin: 0.75rem 0;
    padding: 0.6rem 0.8rem;
    background: #f0f0e5;
    border-radius: 6px;
    border: 1px solid var(--mp-tan-light, #cccc99);
}
.poll-question {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--mp-olive, #666633);
    margin-bottom: 0.4rem;
}
.poll-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* --- Vote buttons (generic) --- */
.vote-btn {
    background: var(--mp-cream, #f8f8f0);
    border: 1px solid var(--mp-tan-light, #cccc99);
    color: var(--mp-olive, #666633);
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    transition: background 0.15s;
}
.vote-btn:hover:not(:disabled):not(.selected) {
    background: var(--mp-tan-light, #cccc99);
}
.vote-btn.selected {
    background: var(--mp-olive, #666633);
    color: white;
    border-color: var(--mp-olive, #666633);
}
.vote-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.vote-btn.correct {
    background: #2d8a4e;
    color: white;
    border-color: #2d8a4e;
    opacity: 1;
}
.vote-btn.incorrect {
    background: #c0392b;
    color: white;
    border-color: #c0392b;
    opacity: 1;
}
/* Multi-select: a correct option the student did not tick */
.vote-btn.missed {
    background: transparent;
    color: #2d8a4e;
    border: 1px dashed #2d8a4e;
    opacity: 1;
}
.poll-submit-btn {
    margin-top: 0.4rem;
}
.poll-feedback {
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: #555;
}

/* --- Vote count + reveal --- */
.vote-count {
    font-size: 0.8rem;
    color: var(--mp-tan, #999966);
    margin-top: 0.4rem;
    font-style: italic;
}
.poll-reveal-btn {
    margin-top: 0.3rem;
    margin-left: 0.5rem;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
}

/* --- Vote results bar chart --- */
.vote-bar-chart {
    margin-top: 0.5rem;
}
.vote-bar-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 3px;
    font-size: 0.8rem;
}
.vote-bar-label {
    min-width: 80px;
    text-align: right;
    color: #555;
    font-weight: 500;
}
.vote-bar-track {
    flex: 1;
    height: 18px;
    background: #e0e0d5;
    border-radius: 3px;
    overflow: hidden;
}
.vote-bar-fill {
    height: 100%;
    background: var(--mp-olive, #666633);
    border-radius: 3px;
    transition: width 0.3s ease;
    min-width: 0;
}
.vote-bar-count {
    min-width: 30px;
    color: #777;
    font-size: 0.78rem;
}
/* Multi-select chart: correct options in green, exact-match count below */
.vote-bar-row.is-correct .vote-bar-label {
    color: #2d8a4e;
}
.vote-bar-row.is-correct .vote-bar-fill {
    background: #2d8a4e;
}
.vote-bar-exact {
    margin-top: 0.3rem;
    font-size: 0.8rem;
    color: #555;
}

/* --- Vote results in warm-up panel --- */
.tutorial-vote-results h4 {
    font-size: 0.9rem;
    color: var(--mp-olive, #666633);
    margin: 0.5rem 0 0.3rem;
}

/* --- Warmup density explanation callout --- */
.warmup-density-note {
    margin: 0.6rem 0;
    padding: 0.6rem 0.8rem;
    background: rgba(51, 153, 255, 0.4); /*#3399ff*/
    border: 1px solid #3399ff;
    border-radius: 4px;
    line-height: 1.5;
}

/* --- Warmup backbone explanation callout --- */
.warmup-backbone-note {
    margin: 0.6rem 0;
    padding: 0.6rem 0.8rem;
    background: rgba(0, 204, 204, 0.2);
    border: 1px solid #00cccc;
    border-radius: 4px;
    line-height: 1.5;
}

/* --- Warmup progress bar --- */
.warmup-progress-bar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0.8rem 0;
    font-size: 0.85rem;
    color: #666;
}
#warmupRoundIndicator {
    white-space: nowrap;
    font-weight: 600;
}
.warmup-progress-segments {
    display: flex;
    gap: 3px;
    flex: 1;
    max-width: 200px;
}
.warmup-progress-segment {
    height: 6px;
    flex: 1;
    background: #ddd;
    border-radius: 3px;
    transition: background 0.3s;
}
.warmup-progress-segment.filled {
    background: var(--mp-olive, #666633);
}
.warmup-progress-segment.current {
    background: var(--mp-olive, #666633);
    box-shadow: 0 0 4px rgba(102, 102, 51, 0.4);
}

/* --- Warmup completion panel --- */
.warmup-complete-panel {
    text-align: center;
    padding: 2rem;
    max-width: 500px;
    margin: 2rem auto;
}
.warmup-complete-panel h3 {
    color: var(--mp-olive, #666633);
    margin-bottom: 0.8rem;
}
.warmup-complete-panel p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1.2rem;
}
.warmup-complete-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}
.tutorial-btn-secondary {
    background: transparent;
    color: var(--mp-olive, #666633);
    border: 1px solid var(--mp-olive, #666633);
}
.tutorial-btn-secondary:hover {
    background: rgba(102, 102, 51, 0.1);
}

/* --- Waiting room --- */
.warmup-waiting-room {
    text-align: center;
    padding: 3rem 1rem;
    max-width: 500px;
    margin: 2rem auto;
}
.waiting-room-content h3 {
    color: var(--mp-olive, #666633);
    margin-bottom: 0.5rem;
}
.waiting-room-content p {
    color: #666;
    font-size: 0.95rem;
}
.waiting-room-pulse {
    width: 12px;
    height: 12px;
    background: var(--mp-success, #336633);
    border-radius: 50%;
    margin: 1rem auto;
    animation: waiting-pulse 1.5s ease-in-out infinite;
}
@keyframes waiting-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.3); }
}

/* --- Sync toast --- */
.tutorial-sync-toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background: var(--mp-olive, #666633);
    color: white;
    padding: 0.5rem 1.2rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.tutorial-sync-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Shareable URL --- */
.tutorial-share-url {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-basis: 100%;
    margin-top: 0.4rem;
    flex-wrap: wrap;
}
.share-label {
    font-size: 0.8rem;
    color: var(--mp-tan, #999966);
    font-weight: 600;
}
.share-url-text {
    font-size: 0.8rem;
    background: var(--mp-cream, #f8f8f0);
    border: 1px solid var(--mp-tan-light, #cccc99);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    word-break: break-all;
    user-select: all;
}

/* --- Start Warmup button --- */
.tutorial-btn-start {
    background: var(--mp-success, #336633);
    font-size: 0.95rem;
    padding: 0.5rem 1.2rem;
}
.tutorial-btn-start:hover:not(:disabled) {
    background: #2a5528;
}

/* --- Level 1 tab pulse animation --- */
@keyframes tab-pulse {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 8px rgba(102, 102, 51, 0.6); }
}
.tab-pulse {
    animation: tab-pulse 1.5s ease-in-out 3;
}
