/* DMN Quiz — sidebar quiz widget. Matches dmn-theme tokens (--c-*, --radius, --font).
   Lives inside a .widget wrapper; the theme's existing .widget-title rule handles
   the "uppercase eyebrow + accent underline" signature — we don't redefine it here. */

.dmn-quiz-widget {
    --dmn-quiz-correct: #10b981;
    --dmn-quiz-correct-bg: rgba(16, 185, 129, 0.12);
    --dmn-quiz-correct-soft: rgba(16, 185, 129, 0.06);
    --dmn-quiz-wrong: #ef4444;
    --dmn-quiz-wrong-bg: rgba(239, 68, 68, 0.12);
    --dmn-quiz-accent-soft: rgba(99, 102, 241, 0.08);

    background: var(--c-bg2, #f8fafc);
    border: 1px solid var(--c-border, #e2e8f0);
    border-radius: var(--radius-lg, 12px);
    padding: 1rem 1.25rem;
    color: var(--c-text, #0f172a);
    font-family: var(--font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    position: relative;
    overflow: hidden;
}

/* Question copy — override entry-content paragraph margins if the widget
   ever lands inside an article context (defensive). */
.dmn-quiz-widget p.dmn-quiz-question {
    margin: 0.5rem 0 0.85rem;
    padding: 0;
    font-size: 0.95rem;
    line-height: 1.45;
    color: var(--c-text, #0f172a);
    font-weight: 500;
}

/* --- Answer stack --- */

.dmn-quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dmn-quiz-answer {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.55rem 0.8rem;
    background: var(--c-bg, #fff);
    color: var(--c-text, #0f172a);
    border: 1px solid var(--c-border, #e2e8f0);
    border-radius: var(--radius, 8px);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.dmn-quiz-answer:hover {
    background: var(--dmn-quiz-accent-soft);
    border-color: var(--c-accent, #6366f1);
}

.dmn-quiz-answer:focus-visible {
    outline: 2px solid var(--c-accent, #6366f1);
    outline-offset: 2px;
}

.dmn-quiz-answer:active { transform: translateY(1px); }

/* Letter prefix (A. B. C. D.) — populated in JS via data-letter, rendered here */
.dmn-quiz-answer .dmn-quiz-letter {
    display: inline-block;
    min-width: 1.4em;
    font-weight: 700;
    color: var(--c-text2, #475569);
    margin-right: 0.15rem;
}

/* --- Result states --- */

.dmn-quiz-answer.is-correct {
    background: var(--dmn-quiz-correct-bg);
    border: 2px solid var(--dmn-quiz-correct);
    padding: calc(0.55rem - 1px) calc(0.8rem - 1px);
    color: var(--c-text, #0f172a);
    cursor: default;
}
.dmn-quiz-answer.is-correct .dmn-quiz-letter { color: var(--dmn-quiz-correct); }
.dmn-quiz-answer.is-correct::before {
    content: "\2714\00a0";
    color: var(--dmn-quiz-correct);
    font-weight: 700;
}

.dmn-quiz-answer.is-wrong-chosen {
    background: var(--dmn-quiz-wrong-bg);
    border: 2px solid var(--dmn-quiz-wrong);
    padding: calc(0.55rem - 1px) calc(0.8rem - 1px);
    color: var(--c-text, #0f172a);
    cursor: default;
}
.dmn-quiz-answer.is-wrong-chosen .dmn-quiz-letter { color: var(--dmn-quiz-wrong); }
.dmn-quiz-answer.is-wrong-chosen::before {
    content: "\2715\00a0";
    color: var(--dmn-quiz-wrong);
    font-weight: 700;
}

.dmn-quiz-answer.is-unselected {
    opacity: 0.5;
    pointer-events: none;
}

/* Subtle reveal animation when a state class lands. */
.dmn-quiz-answer.is-correct,
.dmn-quiz-answer.is-wrong-chosen {
    animation: dmn-quiz-reveal 360ms cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes dmn-quiz-reveal {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.025); }
    100% { transform: scale(1); }
}

/* --- Result explanation --- */

.dmn-quiz-result {
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--c-text2, #475569);
}
.dmn-quiz-result:not([hidden]) {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--c-border, #e2e8f0);
    animation: dmn-quiz-fade 320ms ease;
}
.dmn-quiz-result strong {
    color: var(--c-text, #0f172a);
    font-weight: 700;
}

@keyframes dmn-quiz-fade {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Actions row (source CTA after answer) --- */

/* Hide by default — [hidden] alone is overridden by `display: flex` if we set
 * it unconditionally on the container, so we gate the visible state on
 * `:not([hidden])` and let the attribute do its job before answer. */
.dmn-quiz-actions[hidden] { display: none; }
.dmn-quiz-actions:not([hidden]) {
    display: flex;
    align-items: stretch;
    margin-top: 0.85rem;
    animation: dmn-quiz-fade 320ms ease 80ms both;
}

/* Source link becomes a full-width green primary CTA after the reader
 * answers — green matches `--dmn-quiz-correct` whether they got it right
 * or wrong, signalling "go deeper" rather than rating the answer. */
.dmn-quiz-source {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1rem;
    background: var(--dmn-quiz-correct);
    color: #fff;
    border-radius: var(--radius-full, 9999px);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.dmn-quiz-source:hover {
    background: #059669;
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.32);
}
.dmn-quiz-source:focus-visible {
    outline: 2px solid var(--dmn-quiz-correct);
    outline-offset: 2px;
}

/* --- Error / unavailable state --- */

.dmn-quiz-error {
    font-size: 0.86rem;
    color: var(--c-text2, #475569);
    text-align: center;
    padding: 0.5rem 0;
}
.dmn-quiz-error button {
    margin-top: 0.5rem;
    padding: 0.35rem 0.85rem;
    background: transparent;
    color: var(--c-accent, #6366f1);
    border: 1px solid var(--c-border, #e2e8f0);
    border-radius: var(--radius-full, 9999px);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.dmn-quiz-error button:hover {
    border-color: var(--c-accent, #6366f1);
    background: var(--dmn-quiz-accent-soft);
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
    .dmn-quiz-answer,
    .dmn-quiz-result,
    .dmn-quiz-actions,
    .dmn-quiz-answer.is-correct,
    .dmn-quiz-answer.is-wrong-chosen {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
