/* Lesson diagrams (science courses): textbook-style SVG diagrams in lessons - still, animated, step-by-step,
   compare (states), flip cards and label quizzes. Behaviour in /js/lesson-diagrams.js.
   Loaded by scripts/show-course-content.php only on lessons that contain a sci- block.
   Lesson HTML is written by the lesson-diagrams skill (.claude/skills/lesson-diagrams). */

.sci-diagram, .sci-steps, .sci-states, .sci-label-quiz, .sci-cards {
    margin: 26px auto;
    max-width: 640px;
    text-align: center;
}
.sci-diagram svg, .sci-steps svg, .sci-states svg, .sci-label-quiz svg {
    display: block;
    width: 100%;
    height: auto;
    max-height: 460px;
    background: #fff;
    border: 1px solid #e6e9f2;
    border-radius: 12px;
    padding: 10px;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}
.sci-diagram .diagram-caption, .sci-steps .diagram-caption, .sci-states .diagram-caption,
.sci-label-quiz .diagram-caption, .sci-cards .diagram-caption {
    font-size: 0.92rem; color: #5a6275; margin: 8px 0 0; font-style: italic; text-align: center;
}

/* ---------- controls added by the JS ---------- */
.sci-controls {
    display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center;
    margin: 10px 0 0;
}
.sci-btn {
    font-family: var(--heading-font, 'Poppins', sans-serif);
    font-weight: 700; font-size: 0.92rem;
    border: 2px solid #3D4FB5; background: #fff; color: #3D4FB5;
    border-radius: 999px; padding: 6px 16px; cursor: pointer; line-height: 1.2;
    transition: background .15s, color .15s;
}
.sci-btn:hover:not(:disabled), .sci-btn:focus-visible { background: #3D4FB5; color: #fff; outline: none; }
.sci-btn:disabled { opacity: .35; cursor: default; }
.sci-btn.is-on { background: #3D4FB5; color: #fff; }
.sci-btn-main { background: #ffd500; border-color: #e6b400; color: #222; }
.sci-btn-main:hover:not(:disabled), .sci-btn-main:focus-visible { background: #e6b400; color: #222; }
.sci-count { font-size: 0.9rem; color: #5a6275; font-weight: 600; min-width: 92px; }

/* the note for the current step / state */
.sci-note {
    margin: 10px auto 0; max-width: 600px; text-align: left;
    background: #f4f6ff; border-left: 4px solid #3D4FB5; border-radius: 8px;
    padding: 10px 14px; font-size: 1rem; line-height: 1.5; min-height: 2.6em;
}
.sci-note strong { color: #2a3890; }

/* step and state notes: all shown as a list when the JS has not run, one at a time when it has */
.sci-steps ol.step-notes, .sci-states ol.state-notes { text-align: left; margin: 10px auto 0; max-width: 600px; }
.sci-ready ol.step-notes, .sci-ready ol.state-notes { display: none; }

/* states: without the JS only the first state shows */
.sci-states g[data-state]:not([data-state='1']) { display: none; }

/* label quiz markers */
.sci-label-quiz .sci-marker { cursor: pointer; }
.sci-label-quiz .sci-marker circle { fill: #ffd500; stroke: #222; stroke-width: 1.5; }
.sci-label-quiz .sci-marker text { font-weight: 700; font-size: 15px; fill: #222; text-anchor: middle; dominant-baseline: central; }
.sci-label-quiz .sci-marker:hover circle, .sci-label-quiz .sci-marker:focus circle { fill: #ff9a00; }

/* ---------- flip cards ---------- */
.sci-cards .sci-card-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px;
}
.sci-card {
    perspective: 900px; min-height: 160px; cursor: pointer; text-align: center;
    border-radius: 14px; outline: none;
}
.sci-card-inner {
    position: relative; width: 100%; height: 100%; min-height: 160px;
    transition: transform .5s; transform-style: preserve-3d;
}
.sci-card.flipped .sci-card-inner { transform: rotateY(180deg); }
.sci-card .card-front, .sci-card .card-back {
    position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    border-radius: 14px; padding: 12px; box-sizing: border-box;
}
.sci-card .card-front { background: #fff; border: 2px solid #d5dbe8; box-shadow: 0 3px 10px rgba(0,0,0,.06); }
.sci-card .card-back { background: #fff8d6; border: 2px solid #ffd500; transform: rotateY(180deg); }
.sci-card:focus-visible .card-front, .sci-card:hover .card-front { border-color: #3D4FB5; }
.sci-card .card-front svg { width: 100%; max-width: 150px; height: auto; max-height: 90px; }
.sci-card p { margin: 0; font-size: 0.98rem; line-height: 1.35; }
.sci-card .card-front p { font-weight: 700; }
/* without the JS: cards show both sides, one under the other */
.sci-cards:not(.sci-ready) .sci-card-inner { min-height: 0; }
.sci-cards:not(.sci-ready) .card-front, .sci-cards:not(.sci-ready) .card-back { position: static; transform: none; margin-bottom: 6px; }
.sci-cards .sci-cards-hint { font-size: 0.9rem; color: #5a6275; margin: 0 0 10px; }

@media (max-width: 600px) {
    .sci-btn { padding: 6px 12px; font-size: 0.88rem; }
    .sci-cards .sci-card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .sci-card, .sci-card-inner { min-height: 150px; }
}
@media (prefers-reduced-motion: reduce) {
    .sci-card-inner { transition: none; }
}
@media print {
    .sci-controls, .sci-cards-hint { display: none; }
    .sci-ready ol.step-notes, .sci-ready ol.state-notes { display: block; }
}
