/* Story Detective (/games/story-detective). Effects follow the Grammar Gauntlet kit, prefix sdt-. */

.sdt-hero { background: linear-gradient(135deg, #1e293b, #7c2d12); }
.sdt-card { overflow: hidden; }

/* The stage clips every effect. */
.sdt-recall { max-width: 24rem; }
.sdt-stage { position: relative; overflow: hidden; }

.sdt-steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; }
@media (min-width: 768px) { .sdt-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sdt-steps li { display: flex; align-items: center; gap: 0.5rem; padding: 0.45rem 0.6rem; border-radius: 0.6rem; background: #fdf8ef; border: 1px solid #ecdcc0; font-size: 0.85rem; line-height: 1.25; }
.sdt-steps i { color: #9a3412; font-size: 1.15rem; width: 1.2rem; text-align: center; }

.sdt-band-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
@media (min-width: 768px) { .sdt-band-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sdt-band { display: flex; flex-direction: column; align-items: center; padding: 0.55rem 0.4rem; border: 2px solid #d6c4a8; border-radius: 0.75rem; background: #fff; color: #1f2937; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.sdt-band span { font-size: 0.78rem; color: #6b7280; text-align: center; }
.sdt-band.active, .sdt-band[aria-pressed="true"] { background: linear-gradient(135deg, #1e293b, #9a3412); border-color: #f59e0b; color: #fff; }
.sdt-band.active span, .sdt-band[aria-pressed="true"] span { color: #fde68a; }
@media (hover: hover) { .sdt-band:hover:not(.active) { border-color: #9a3412; } }
.sdt-band:active { transform: scale(0.97); }
.sdt-band.sdt-picked { animation: sdt-pop 0.3s ease; }

.sdt-hud { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.6rem; }
.sdt-heart { display: inline-block; color: #dc2626; font-size: 1.15rem; }
.sdt-heart-lost { color: #9ca3af; }
.sdt-heart-reserve { font-size: 0.85rem; font-weight: 700; }
.sdt-heart-restored { animation: sdt-heart-restored 0.55s ease-out; }
@keyframes sdt-heart-restored {
    45% { transform: scale(1.55); }
}
.sdt-sound { margin-left: auto; }
.sdt-combo-badge { color: #fff; background: #6b7280; }
.sdt-combo-badge.sdt-combo-2 { background: #0284c7; }
.sdt-combo-badge.sdt-combo-3 { background: #7c3aed; }
.sdt-combo-badge.sdt-combo-4 { background: #ea580c; }
.sdt-combo-badge.sdt-combo-5 { background: linear-gradient(135deg, #dc2626, #f97316); animation: sdt-glow 1.2s ease-in-out infinite; }

/* The desk view reserves its height so nothing below it moves when 3D arrives. */
.sdt-scene { position: relative; height: 170px; border-radius: 0.75rem; background: linear-gradient(180deg, #1b2230, #141a26); overflow: hidden; margin-bottom: 0.6rem; }
@media (min-width: 768px) { .sdt-scene { height: 230px; } }
.sdt-scene .sdt-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sdt-scene-3d .sdt-flat { display: none; }
.sdt-flat { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.7rem; padding: 0 8%; }
.sdt-flat-folder { position: relative; font-size: 2.6rem; color: #d9b46a; line-height: 1; }
.sdt-flat-solved::after { content: "SOLVED"; position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%) rotate(-10deg); font-size: 0.7rem; font-weight: 900; color: #fca5a5; border: 2px solid #fca5a5; padding: 0 0.2rem; }
.sdt-flat-no { position: absolute; right: -1.6rem; top: 0.2rem; font-size: 0.85rem; font-weight: 800; color: #fde68a; }
.sdt-flat-row { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: center; }
.sdt-pin { width: 16px; height: 16px; border-radius: 50%; background: #3b3f4a; border: 2px solid #565b68; }
.sdt-pin-right { background: #e8b33a; border-color: #fde68a; animation: sdt-pop 0.35s ease; }
.sdt-pin-miss { background: #8f98a3; border-color: #cbd5e1; }

/* The case file: a manila folder with ruled paper. */
.sdt-file { border: 2px solid #d9b46a; border-radius: 0.75rem; background: #fffdf6; overflow: hidden; }
.sdt-file-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.3rem; padding: 0.35rem 0.75rem; background: #f3e3bd; }
.sdt-file-tab { font-weight: 800; color: #7a5520; letter-spacing: 0.02em; }
.sdt-file-lines { padding: 0.6rem 0.9rem; }
.sdt-file.sdt-deal { animation: sdt-deal-in 0.35s ease backwards; }
.sdt-file-line { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; font-size: 1.35rem; line-height: 1.65; margin: 0; color: #111827; }
.sdt-file-sentence { min-width: 0; }
.sdt-sentence-audio { flex: 0 0 auto; min-width: 2.75rem; min-height: 2.75rem; }
.sdt-file-line + .sdt-file-line { margin-top: 0.85rem; }
.sdt-file-line .sdt-en { margin: 0.1rem 0 0; }
.sdt-line ruby rt { font-size: 0.55em; color: #6b7280; }
.sdt-multi { text-decoration: underline dotted #9ca3af; text-underline-offset: 0.25em; cursor: help; }
.sdt-en { display: block; font-size: 0.85rem; line-height: 1.35; color: #4b5563; margin-bottom: 0.25rem; }
#sdtPinyinBtn.active, #sdtEnglishBtn.active { background: #1e293b; border-color: #1e293b; color: #fff; }

.sdt-kind { color: #9a3412; letter-spacing: 0.05em; }
.sdt-question { min-height: 1.5rem; }
.sdt-prompt { --sdt-recall-correct: #15803d; --sdt-recall-incorrect: #b91c1c; }
.sdt-prompt p { font-size: 1.35rem; line-height: 2.2; text-align: center; margin: 0; padding: 0.4rem 0.6rem; border: 2px dashed #d9b46a; border-radius: 0.75rem; background: #fffdf6; color: #111827; }
.sdt-prompt.sdt-deal { animation: sdt-deal-in 0.3s ease backwards; }
.sdt-blank { display: inline-block; min-width: 2.6em; margin: 0 0.15em; border-bottom: 3px solid #9a3412; color: #9a3412; text-align: center; font-weight: 800; }

.sdt-slots { display: grid; gap: 0.35rem; }
.sdt-slot { display: flex; align-items: center; gap: 0.5rem; min-height: 2.6rem; padding: 0.25rem 0.6rem; border: 2px dashed #d6c4a8; border-radius: 0.6rem; font-size: 1.1rem; }
.sdt-slot-filled { border-style: solid; border-color: #b8913f; background: #fdf6e3; }
.sdt-slot.sdt-picked { animation: sdt-pop 0.3s ease; }
.sdt-slot-no { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 1.6rem; height: 1.6rem; border-radius: 50%; background: #b8913f; color: #fff; font-weight: 800; font-size: 0.85rem; }

.sdt-options { display: grid; gap: 0.45rem; }
.sdt-option {
    position: relative; display: flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 3rem; padding: 0.45rem 0.7rem 0.45rem 1.9rem;
    border: 2px solid #cbd5e1; border-radius: 0.7rem; background: #fff; color: #111827; text-align: left; font-size: 1.1rem; line-height: 1.6;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    animation: sdt-deal-in 0.28s ease backwards;
}
.sdt-options-mean .sdt-option { font-size: 1rem; }
.sdt-key { position: absolute; left: 0.5rem; top: 50%; transform: translateY(-50%); font-size: 0.72rem; font-weight: 800; color: #94a3b8; }
@media (hover: hover) { .sdt-option:hover:not(:disabled) { border-color: #9a3412; transform: translateY(-1px); } }
.sdt-option:active:not(:disabled) { transform: scale(0.98); background: #fef3c7; }
.sdt-option:disabled { opacity: 1; color: #111827; }
.sdt-option.sdt-right { border-color: #16a34a; background: #dcfce7; animation: sdt-pop 0.3s ease; }
.sdt-option.sdt-wrong { border-color: #dc2626; background: #fee2e2; }

.sdt-peek-file { padding: 0.5rem 0.75rem; border: 2px solid #d9b46a; border-radius: 0.75rem; background: #fffdf6; }
.sdt-peek-file .sdt-file-line { font-size: 1.1rem; }
.sdt-evidence-line { font-size: 1.05rem; line-height: 2; }
.sdt-evidence-line .sdt-en { display: block; font-size: 0.85rem; }
#sdtPlay #sdtAsk.sdt-shake { animation: sdt-shake 0.4s ease; }

.sdt-chest { display: inline-block; padding: 0.75rem 1.25rem; border-radius: 0.75rem; background: #fef3c7; border: 2px solid #f59e0b; color: #78350f; }
.sdt-review li { padding: 0.4rem 0; border-bottom: 1px solid #ecdcc0; }

/* Hints: a note under the prompt, and a crossed-out option that cannot be chosen. */
.sdt-hint-box { max-width: 30rem; margin: 0 auto 0.5rem; padding: 0.35rem 0.75rem; border: 1px solid #fcd34d; border-radius: 0.6rem; background: #fffbeb; color: #78350f; font-size: 0.95rem; }
.sdt-hint-line + .sdt-hint-line { margin-top: 0.2rem; }
.sdt-hint-line.sdt-deal { animation: sdt-deal-in 0.25s ease backwards; }
.sdt-hint-line i { color: #b45309; }
.sdt-hint-btn:disabled { opacity: 0.55; }
.sdt-option.sdt-struck, .sdt-option.sdt-struck:disabled { opacity: 0.4; text-decoration: line-through; border-style: dashed; }
.sdt-options-choice { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 24rem; margin-left: auto; margin-right: auto; }
.sdt-options-choice .sdt-option { font-size: 1.3rem; }
.sdt-word-audio { padding: 0.1rem 0.45rem; vertical-align: baseline; }

/* The casebook: the title, its next step and the latest case's time. */
.sdt-casebook { max-width: 30rem; margin: 0.75rem auto 0; padding: 0.5rem 0.75rem; border: 1px solid #ecdcc0; border-radius: 0.75rem; background: #fdf8ef; font-size: 0.9rem; text-align: left; }
.sdt-casebook i { color: #9a3412; }
.sdt-casebook-time { margin-bottom: 0.3rem; }
.sdt-casebook-best { font-weight: 700; color: #15803d; }
.sdt-casebook-promoted strong { color: #b45309; }
.sdt-casebook-bar { height: 0.4rem; margin: 0.35rem 0 0.2rem; background: #ecdcc0; }
.sdt-casebook-bar .progress-bar { background: #b45309; }
.sdt-casebook-next { font-size: 0.8rem; color: #6b7280; }

/* ── Effects (chrome: never clickable, clipped by the stage) ───────── */
.sdt-float {
    position: absolute; transform: translate(-50%, -50%);
    font-weight: 800; font-size: 1.5rem; color: #15803d; text-shadow: 0 1px 0 #fff;
    pointer-events: none; z-index: 4;
    animation: sdt-float-up 0.9s ease-out forwards;
}
@keyframes sdt-float-up {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
    20% { transform: translate(-50%, -70%) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}
.sdt-particle {
    position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
    pointer-events: none; z-index: 3;
    animation: sdt-burst 0.7s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}
.sdt-spark { width: 6px; height: 6px; animation-duration: 1s; animation-fill-mode: both; }
@keyframes sdt-burst {
    0% { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}
.sdt-confetti {
    position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px;
    pointer-events: none; z-index: 6;
    animation: sdt-confetti-fall 1.8s ease-in forwards;
}
@keyframes sdt-confetti-fall {
    0% { opacity: 1; transform: translate(0, 0) rotate(0); }
    100% { opacity: 0; transform: translate(var(--drift), 460px) rotate(var(--spin)); }
}
.sdt-combo-pop {
    position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%);
    font-size: clamp(1.6rem, 7vw, 2.4rem); font-weight: 900; color: #b45309;
    text-shadow: 0 2px 0 #fff, 0 6px 18px rgba(245, 158, 11, 0.45);
    white-space: nowrap; pointer-events: none; z-index: 4;
    animation: sdt-combo-pop 1.1s ease-out forwards;
}
.sdt-combo-pop-3 { color: #7c3aed; }
.sdt-combo-pop-4 { color: #ea580c; }
.sdt-combo-pop-5 { color: #dc2626; }
@keyframes sdt-combo-pop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15) rotate(2deg); }
    45% { transform: translate(-50%, -50%) scale(1) rotate(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}
.sdt-toast {
    position: absolute; top: 0.6rem; left: 50%; transform: translateX(-50%);
    padding: 0.35rem 0.9rem; border-radius: 999px;
    background: #facc15; color: #422006;
    font-weight: 800; font-size: 0.9rem; white-space: nowrap;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
    pointer-events: none; z-index: 4;
    animation: sdt-toast 2.1s ease forwards;
}
@keyframes sdt-toast {
    0% { opacity: 0; transform: translate(-50%, -12px); }
    12% { opacity: 1; transform: translate(-50%, 0); }
    85% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -6px); }
}
.sdt-heart.sdt-heart-break { animation: sdt-heart-break 0.6s ease; }
@keyframes sdt-heart-break {
    0% { transform: scale(1); }
    30% { transform: scale(1.5); color: #ef4444; }
    60% { transform: scale(0.7) rotate(-12deg); }
    100% { transform: scale(0.85); }
}
.sdt-bump { display: inline-block; animation: sdt-bump 0.35s ease; }
@keyframes sdt-bump { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes sdt-pop { 0% { transform: scale(1); } 45% { transform: scale(1.05); } 100% { transform: scale(1); } }
@keyframes sdt-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes sdt-deal-in { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes sdt-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.55); }
    50% { box-shadow: 0 0 0 6px rgba(249, 115, 22, 0); }
}

/* ── Dark theme: selected states named explicitly so they out-rank the plain dark rules ── */
[data-bs-theme="dark"] .sdt-band { background: #1f2937; color: #f3f4f6; border-color: #4b5563; }
[data-bs-theme="dark"] .sdt-band span { color: #cbd5e1; }
[data-bs-theme="dark"] .sdt-band.active,
[data-bs-theme="dark"] .sdt-band[aria-pressed="true"] { background: linear-gradient(135deg, #334155, #9a3412); border-color: #fbbf24; color: #fff; }
[data-bs-theme="dark"] .sdt-band.active span,
[data-bs-theme="dark"] .sdt-band[aria-pressed="true"] span { color: #fde68a; }
[data-bs-theme="dark"] .sdt-steps li { background: #1f2937; border-color: #4b5563; color: #f3f4f6; }
[data-bs-theme="dark"] .sdt-steps i { color: #fdba74; }
[data-bs-theme="dark"] .sdt-file, [data-bs-theme="dark"] .sdt-peek-file { background: #1c1917; border-color: #a16207; }
[data-bs-theme="dark"] .sdt-file-head { background: #44310f; }
[data-bs-theme="dark"] .sdt-file-tab { color: #fde68a; }
[data-bs-theme="dark"] .sdt-file-line, [data-bs-theme="dark"] .sdt-prompt p { color: #f9fafb; }
[data-bs-theme="dark"] .sdt-prompt p { background: #1c1917; border-color: #a16207; }
[data-bs-theme="dark"] .sdt-line ruby rt, [data-bs-theme="dark"] .sdt-en { color: #cbd5e1; }
[data-bs-theme="dark"] .sdt-kind { color: #fdba74; }
[data-bs-theme="dark"] .sdt-blank { color: #fdba74; border-color: #fdba74; }
[data-bs-theme="dark"] .sdt-slot { border-color: #6b5a3a; }
[data-bs-theme="dark"] .sdt-slot-filled { background: #2a2414; border-color: #ca8a04; }
[data-bs-theme="dark"] .sdt-option, [data-bs-theme="dark"] .sdt-option:disabled { background: #1f2937; color: #f9fafb; border-color: #4b5563; }
[data-bs-theme="dark"] .sdt-option:active:not(:disabled) { background: #44310f; }
[data-bs-theme="dark"] .sdt-option.sdt-right { background: #14532d; border-color: #4ade80; color: #fff; }
[data-bs-theme="dark"] .sdt-option.sdt-wrong { background: #7f1d1d; border-color: #f87171; color: #fff; }
[data-bs-theme="dark"] #sdtPinyinBtn.active, [data-bs-theme="dark"] #sdtEnglishBtn.active { background: #fde68a; border-color: #fde68a; color: #1f2937; }
[data-bs-theme="dark"] .sdt-chest { background: #451a03; color: #fde68a; }
[data-bs-theme="dark"] .sdt-review li { border-color: #374151; }
[data-bs-theme="dark"] .sdt-hint-box { background: #422006; border-color: #a16207; color: #fde68a; }
[data-bs-theme="dark"] .sdt-hint-line i { color: #fbbf24; }
[data-bs-theme="dark"] .sdt-casebook { background: #1f2937; border-color: #4b5563; color: #f3f4f6; }
[data-bs-theme="dark"] .sdt-casebook i, [data-bs-theme="dark"] .sdt-casebook-promoted strong { color: #fdba74; }
[data-bs-theme="dark"] .sdt-casebook-best { color: #4ade80; }
[data-bs-theme="dark"] .sdt-casebook-bar { background: #374151; }
[data-bs-theme="dark"] .sdt-casebook-bar .progress-bar { background: #f59e0b; }
[data-bs-theme="dark"] .sdt-casebook-next { color: #cbd5e1; }
[data-bs-theme="dark"] .sdt-float { text-shadow: none; }

[data-bs-theme="dark"] .sdt-prompt { --sdt-recall-correct: #4ade80; --sdt-recall-incorrect: #f87171; }
.sdt-slots .sdt-slot.sdt-slot-correct { border-color: var(--bs-success-border-subtle); background: var(--bs-success-bg-subtle); }
.sdt-slots .sdt-slot.sdt-slot-incorrect { border-color: var(--bs-danger-border-subtle); background: var(--bs-danger-bg-subtle); }
.sdt-slot-verdict { margin-inline-start: auto; }
.sdt-slot-correct .sdt-slot-verdict { color: var(--bs-success-text-emphasis); }
.sdt-slot-incorrect .sdt-slot-verdict { color: var(--bs-danger-text-emphasis); }
.sdt-prompt.sdt-recall-correct p { border-color: var(--sdt-recall-correct); }
.sdt-prompt.sdt-recall-incorrect p { border-color: var(--sdt-recall-incorrect); }
.sdt-prompt.sdt-recall-correct .sdt-blank { color: var(--sdt-recall-correct); border-color: currentColor; }
.sdt-prompt.sdt-recall-incorrect .sdt-blank { color: var(--sdt-recall-incorrect); border-color: currentColor; }

/* Last in the file: reduced motion turns every effect off, not just slower. */
@media (prefers-reduced-motion: reduce) {
    .sdt-stage *, .sdt-hud * { animation: none !important; transition: none !important; }
    .sdt-option:active:not(:disabled), .sdt-band:active { transform: none; }
}
