/*
 * Every color/size/spacing value below reads from a --dp-* custom property
 * instead of a literal — this is what lets the Elementor widget's Style tab
 * (Part 3 of docs/abstract-twirling-frog.md) restyle everything by just
 * setting these variables scoped to one widget instance, with zero PHP/CSS
 * changes needed. A theme's plain CSS override can do the exact same thing
 * by redefining these variables on .dp-widget, no !important needed.
 */
.dp-widget {
    --dp-ink: #101826;
    --dp-muted: #5c6779;
    --dp-faint: #8994a3;
    --dp-line: #e1e5ec;
    --dp-surface: #ffffff;
    --dp-surface-2: #eef1f6;
    --dp-accent: #4f46e5;
    --dp-accent-2: #7c3aed;
    --dp-accent-soft: #eef0fd;
    --dp-good: #187a56;
    --dp-good-soft: #e3f6ee;
    --dp-crit: #b13a2e;
    --dp-crit-soft: #fbe9e6;
    --dp-warn: #a5690a;
    --dp-warn-soft: #fbf0dd;
    --dp-cta: #0f1c3e;

    --dp-radius: 12px;
    --dp-radius-sm: 8px;
    --dp-gap: 16px;
    --dp-padding: 20px;
    --dp-max-width: 640px;
    --dp-intro-max-width: 900px;

    --dp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --dp-question-size: 17px;
    --dp-question-weight: 700;

    width: 100%;
    font-family: var(--dp-font);
    color: var(--dp-ink);
    box-sizing: border-box;
}

.dp-admin-preview-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 6px 10px;
    border: 1px dashed var(--dp-line);
    border-radius: var(--dp-radius-sm);
    background: var(--dp-surface-2);
    font-size: 11.5px;
}

.dp-admin-preview-label {
    font-weight: 700;
    color: var(--dp-faint);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.dp-admin-preview-bar .dp-link-button {
    font-size: 11.5px;
}

.dp-widget *,
.dp-widget *::before,
.dp-widget *::after {
    box-sizing: inherit;
}

/* Each screen sets its own max-width and centers itself (rather than the
   whole .dp-widget carrying one shared max-width) specifically so the wider
   two-column paper-intro layout (--dp-intro-max-width) doesn't force the
   narrower single-column question/results/guest screens (--dp-max-width) to
   stretch to match it, and vice versa. */
.dp-screen {
    display: flex;
    flex-direction: column;
    gap: var(--dp-gap);
    width: 100%;
    max-width: var(--dp-max-width);
    margin: 0 auto;
}

.dp-screen--paper-intro {
    max-width: var(--dp-intro-max-width);
}

/* [hidden] and .dp-screen{display:flex} have equal specificity, and this
   stylesheet loads after the browser's own UA stylesheet — without this,
   the flex rule above wins the cascade and the hidden attribute is
   silently ignored, showing every screen stacked at once. */
.dp-widget [hidden] {
    display: none !important;
}

/* Driven by the Elementor widget's "Show progress bar" / "Show step badge"
   Content-tab toggles (and available to any hand-written page via these
   same classes on .dp-widget) — see class-elementor-widget.php. */
.dp-widget--no-progress .dp-progress-track {
    display: none !important;
}

.dp-widget--no-step-badge .dp-step-badge {
    display: none !important;
}

/* Paper-intro screen — mirrors the main app's own "Learn Through Video"
   screen (resources/js/Pages/Learner/PaperLearn.jsx): a centered heading
   above a two-column layout (video/details left, outcomes card right),
   collapsing to one column below 768px. */
.dp-intro-header {
    text-align: center;
}

.dp-eyebrow {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--dp-faint);
}

.dp-intro-heading {
    margin: 6px 0 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--dp-ink);
}

.dp-intro-subhead {
    margin: 6px 0 0;
    font-size: 13.5px;
    color: var(--dp-muted);
}

.dp-intro-grid {
    display: grid;
    gap: var(--dp-gap);
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .dp-intro-grid {
        grid-template-columns: 1fr 300px;
        align-items: stretch;
    }
}

.dp-video {
    aspect-ratio: 16 / 9;
    border-radius: var(--dp-radius);
    overflow: hidden;
    background: var(--dp-surface-2);
}

.dp-video iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.dp-title {
    margin: 16px 0 0;
    font-size: 15.5px;
    font-weight: 600;
}

.dp-video-url {
    display: block;
    margin: 4px 0 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    color: var(--dp-accent);
    text-decoration: none;
}

.dp-video-url:hover {
    text-decoration: underline;
}

.dp-creator-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 0;
}

.dp-creator-avatar {
    flex: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--dp-surface-2);
    color: var(--dp-muted);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.dp-creator-name {
    font-size: 13px;
    color: var(--dp-muted);
}

.dp-quick-review-wrap {
    margin: 20px 0 0;
}

.dp-section-heading {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--dp-ink);
}

.dp-quick-review {
    margin: 6px 0 0;
    color: var(--dp-muted);
    font-size: 13px;
    line-height: 1.6;
}

.dp-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 20px 0 0;
    padding: 16px;
    border-radius: var(--dp-radius-sm);
    background: var(--dp-warn-soft);
}

.dp-disclaimer-icon {
    flex: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--dp-surface);
    color: var(--dp-warn);
}

/* Elementor's icon picker can render an <i> (icon font glyph) or an <img>
   (uploaded SVG) instead of the plugin's own default inline <svg> — size
   whichever one shows up the same as the default so swapping icons never
   breaks the badge's proportions. */
.dp-disclaimer-icon i {
    font-size: 14px;
}

.dp-disclaimer-icon img,
.dp-disclaimer-icon svg {
    width: 16px;
    height: 16px;
}

.dp-disclaimer-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--dp-warn);
}

.dp-disclaimer-text {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--dp-warn);
}

.dp-card {
    border: 1px solid var(--dp-line);
    border-radius: var(--dp-radius);
    padding: var(--dp-padding);
    background: var(--dp-surface);
    box-shadow: 0 1px 2px rgba(16, 24, 38, 0.04);
}

.dp-outcomes-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.dp-outcomes-empty {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--dp-muted);
}

.dp-outcomes-lead {
    margin: 8px 0 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--dp-ink);
}

.dp-outcomes {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.dp-outcomes li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--dp-muted);
}

.dp-outcome-dot {
    flex: none;
    width: 6px;
    height: 6px;
    margin-top: 7px;
    border-radius: 999px;
    background: var(--dp-muted);
}

.dp-intro-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
    padding-top: 24px;
}

.dp-account-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--dp-radius-sm);
    background: var(--dp-surface-2);
}

.dp-account-banner-text {
    margin: 0;
    font-size: 12px;
    color: var(--dp-muted);
}

.dp-account-banner-text span {
    font-weight: 700;
    color: var(--dp-ink);
}

.dp-identity-switch {
    margin: 4px 0 0;
    padding-bottom: 2px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    row-gap: 4px;
    column-gap: 6px;
    font-size: 12px;
    color: var(--dp-muted);
}

.dp-identity-switch-sep {
    color: var(--dp-line);
}

.dp-link-button {
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--dp-accent);
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
}

.dp-link-button:hover,
.dp-link-button:focus {
    text-decoration: underline;
}

.dp-button-icon {
    display: block;
    flex: none;
}

.dp-error {
    margin: 0;
    padding: 10px 12px;
    border-radius: var(--dp-radius-sm);
    background: var(--dp-crit-soft);
    color: var(--dp-crit);
    font-size: 13px;
}

.dp-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    padding: 11px 20px;
    border-radius: var(--dp-radius-sm);
    border: 1px solid var(--dp-line);
    background: var(--dp-surface);
    color: var(--dp-ink);
    cursor: pointer;
}

.dp-button--primary {
    border: none;
    color: #fff;
    background: linear-gradient(135deg, var(--dp-accent), var(--dp-accent-2));
}

/* Declared after .dp-button on purpose — same equal-specificity/source-order
   convention as .dp-button--primary above, so this modifier's colors win
   over the plain .dp-button base for the "Start Diagnostic" button. */
.dp-button--cta {
    border: none;
    color: #fff;
    background: var(--dp-cta);
}

.dp-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.dp-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dp-form-hint {
    margin: 0;
    color: var(--dp-muted);
    font-size: 12.5px;
}

.dp-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--dp-muted);
}

.dp-field input {
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--dp-ink);
    padding: 10px 12px;
    border-radius: var(--dp-radius-sm);
    border: 1px solid var(--dp-line);
}

.dp-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dp-step-badge {
    flex: none;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--dp-accent);
    background: var(--dp-accent-soft);
    padding: 5px 12px;
    border-radius: 999px;
    white-space: nowrap;
}

.dp-progress-track {
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--dp-surface-2);
    overflow: hidden;
}

.dp-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--dp-accent), var(--dp-accent-2));
    transition: width 0.25s ease;
}

.dp-question-text {
    font-size: var(--dp-question-size);
    font-weight: var(--dp-question-weight);
    line-height: 1.5;
    margin: 0;
}

.dp-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dp-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    font-family: inherit;
    font-size: 13.5px;
    padding: 13px 16px;
    border-radius: var(--dp-radius-sm);
    border: 1px solid var(--dp-line);
    background: var(--dp-surface);
    color: var(--dp-ink);
    cursor: pointer;
}

.dp-option[aria-checked="true"] {
    border-color: var(--dp-accent);
    background: var(--dp-accent-soft);
}

.dp-option[data-dp-correct="true"] {
    border-color: var(--dp-good);
    background: var(--dp-good-soft);
}

.dp-option[data-dp-incorrect="true"] {
    border-color: var(--dp-crit);
    background: var(--dp-crit-soft);
}

.dp-option:disabled {
    cursor: default;
}

/* Hello Elementor's reset.css sets a global rule —
   button:focus, button:hover { background-color:#c36; color:#fff }
   (also matches [type=button] and [type=submit], which every button in
   this widget uses). That rule's specificity beats our plain .dp-button /
   .dp-link-button / .dp-option selectors for the color/background properties
   specifically, so clicking (=focusing) any of them re-tinted it pink
   with white text — most visibly, white text on the still-correctly-styled
   light-purple "selected" option background made the label unreadable.
   Reassert every state's intended colors here, scoped and !important, so
   no theme's generic button reset can win regardless of load order. */
.dp-widget .dp-button:hover,
.dp-widget .dp-button:focus {
    background: var(--dp-surface) !important;
    color: var(--dp-ink) !important;
}

.dp-widget .dp-button--primary:hover,
.dp-widget .dp-button--primary:focus {
    background: linear-gradient(135deg, var(--dp-accent), var(--dp-accent-2)) !important;
    color: #fff !important;
}

.dp-widget .dp-button--cta:hover,
.dp-widget .dp-button--cta:focus {
    background: var(--dp-cta) !important;
    color: #fff !important;
}

.dp-widget .dp-link-button:hover,
.dp-widget .dp-link-button:focus {
    background: transparent !important;
    color: var(--dp-accent) !important;
}

.dp-widget .dp-option:hover,
.dp-widget .dp-option:focus {
    background: var(--dp-surface) !important;
    color: var(--dp-ink) !important;
}

.dp-widget .dp-option[aria-checked="true"]:hover,
.dp-widget .dp-option[aria-checked="true"]:focus {
    background: var(--dp-accent-soft) !important;
    color: var(--dp-ink) !important;
}

.dp-widget .dp-option[data-dp-correct="true"]:hover,
.dp-widget .dp-option[data-dp-correct="true"]:focus {
    background: var(--dp-good-soft) !important;
    color: var(--dp-ink) !important;
}

.dp-widget .dp-option[data-dp-incorrect="true"]:hover,
.dp-widget .dp-option[data-dp-incorrect="true"]:focus {
    background: var(--dp-crit-soft) !important;
    color: var(--dp-ink) !important;
}

/* :hover and :focus are deliberately NOT combined here, unlike the other
   overrides above: for every other button on this page, hover/focus happen
   to resolve to the same color as that button's own idle state, so merging
   them was harmless. .dp-results-tile's idle background is transparent, but
   its hover affordance is --dp-surface-2 — and a clicked button keeps
   :focus (unlike :hover, which clears the instant the mouse leaves), so
   giving :focus that same gray left "Review answers" looking permanently
   highlighted after being clicked, while its sibling tile did not. :focus
   resets to the idle look instead; :hover keeps the gray affordance. */
.dp-widget .dp-results-tile:hover {
    background: var(--dp-surface-2) !important;
    color: var(--dp-ink) !important;
}

.dp-widget .dp-results-tile:focus {
    background: transparent !important;
    color: var(--dp-ink) !important;
}

.dp-option-letter {
    flex: none;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--dp-surface-2);
    color: var(--dp-muted);
    font-size: 12px;
    font-weight: 700;
}

.dp-question-nav {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Results screen — mirrors the main app's own results screen
   (resources/js/Pages/Learner/QuizResults.jsx): a score ring + tier pill +
   comparison chips in a hero row, a difficulty breakdown with progress
   bars, an action-tile row, then separate cards for the outcome breakdown
   and score history. */
.dp-results-card {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.dp-results-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: var(--dp-padding);
    text-align: center;
}

@media (min-width: 480px) {
    .dp-results-hero {
        flex-direction: row;
        text-align: left;
    }
}

.dp-score-ring-wrap {
    position: relative;
    flex: none;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dp-score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.dp-score-ring-track {
    fill: none;
    stroke: var(--dp-surface-2);
    stroke-width: 10;
}

.dp-score-ring-fill {
    fill: none;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.7s ease, stroke 0.3s ease;
}

.dp-score-value {
    position: absolute;
    font-size: 26px;
    font-weight: 800;
    color: var(--dp-ink);
}

.dp-results-summary {
    flex: 1;
    min-width: 0;
}

.dp-results-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

@media (min-width: 480px) {
    .dp-results-chips {
        justify-content: flex-start;
    }
}

.dp-tier-pill,
.dp-delta-pill,
.dp-percentile-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 700;
}

.dp-tier-pill--good,
.dp-delta-pill--good {
    background: var(--dp-good-soft);
    color: var(--dp-good);
}

.dp-tier-pill--warn,
.dp-delta-pill--warn {
    background: var(--dp-warn-soft);
    color: var(--dp-warn);
}

.dp-tier-pill--crit,
.dp-delta-pill--crit {
    background: var(--dp-crit-soft);
    color: var(--dp-crit);
}

.dp-delta-pill--neutral {
    background: var(--dp-surface-2);
    color: var(--dp-muted);
}

.dp-percentile-pill {
    background: var(--dp-accent-soft);
    color: var(--dp-accent);
}

.dp-score-detail {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--dp-ink);
}

.dp-duration {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    color: var(--dp-faint);
}

.dp-score-message {
    margin: 10px 0 0;
    font-size: 13.5px;
    color: var(--dp-muted);
}

.dp-breakdown-wrap {
    border-top: 1px solid var(--dp-line);
    padding: var(--dp-padding);
}

.dp-section-heading {
    display: flex;
    align-items: center;
    gap: 7px;
}

.dp-breakdown-insight {
    margin: 6px 0 0;
    font-size: 12.5px;
    color: var(--dp-muted);
}

.dp-difficulty-grid {
    display: grid;
    gap: 16px;
    margin-top: 16px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.dp-difficulty-row-head {
    display: flex;
    justify-content: space-between;
    font-size: 12.5px;
    margin-bottom: 6px;
}

.dp-difficulty-label {
    font-weight: 600;
    color: var(--dp-ink);
}

.dp-difficulty-count {
    color: var(--dp-muted);
}

.dp-difficulty-track {
    height: 6px;
    border-radius: 999px;
    background: var(--dp-surface-2);
    overflow: hidden;
}

.dp-difficulty-fill {
    height: 100%;
    border-radius: 999px;
}

.dp-difficulty-fill--easy {
    background: var(--dp-good);
}

.dp-difficulty-fill--medium {
    background: var(--dp-warn);
}

.dp-difficulty-fill--hard {
    background: var(--dp-crit);
}

.dp-slowest-question {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 16px 0 0;
    font-size: 12px;
    color: var(--dp-muted);
}

.dp-slowest-question svg {
    flex: none;
    margin-top: 2px;
}

.dp-results-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--dp-line);
}

.dp-results-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--dp-ink);
    background: transparent;
    border: none;
    cursor: pointer;
}

.dp-results-tile:first-child {
    border-right: 1px solid var(--dp-line);
}

.dp-results-tile-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.dp-results-tile-icon {
    color: var(--dp-accent);
    flex: none;
}

.dp-breakdown-card {
    margin-top: 20px;
}

.dp-outcome-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.dp-outcome-list li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    color: var(--dp-ink);
}

.dp-outcome-fraction {
    flex: none;
    font-weight: 700;
}

.dp-outcome-fraction--good {
    color: var(--dp-good);
}

.dp-outcome-fraction--warn {
    color: var(--dp-warn);
}

.dp-outcome-fraction--crit {
    color: var(--dp-crit);
}

.dp-score-history-sub {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--dp-muted);
}

.dp-score-history-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 80px;
    margin-top: 20px;
}

.dp-score-history-bar-wrap {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.dp-score-history-bar {
    width: 100%;
    border-radius: 3px 3px 0 0;
    background: var(--dp-surface-2);
}

.dp-score-history-bar--current {
    background: var(--dp-accent);
}

.dp-score-history-label {
    font-size: 10.5px;
    color: var(--dp-faint);
}

.dp-breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--dp-line);
    font-size: 13px;
}

.dp-review {
    padding: var(--dp-padding);
    border-top: 1px solid var(--dp-line);
}

.dp-review-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--dp-line);
}

.dp-review-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.dp-review-item p {
    margin: 4px 0 0;
    font-size: 12.5px;
    color: var(--dp-muted);
}

.dp-review-item[data-dp-correct="true"] .dp-review-answer {
    color: var(--dp-good);
}

.dp-review-item[data-dp-correct="false"] .dp-review-answer {
    color: var(--dp-crit);
}
