﻿body.public-page.diag-exam-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.diag-exam-page > .diag-exam-main {
    flex: 1 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.diag-exam-page > .diag-exam-main > .hp-diagnos.diag-backend {
    width: 100%;
}

.hp-diagnos.diag-backend {
    width: 560px;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.diag-backend .box.box-1,
.diag-backend .box-body,
.diag-backend .question {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.hp-diagnos.diag-backend .box-header {
    gap: 8px;
}

.hp-diagnos.diag-backend .box-title {
    min-width: 0;
}

.diag-backend .diag-time {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    margin-inline-start: auto;
    color: #fff;
    font-size: .875rem;
    font-variant-numeric: tabular-nums;
}

.diag-backend .diag-time-track {
    display: block;
    width: 100%;
    height: 4px;
    appearance: none;
    border: 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, .12);
    overflow: hidden;
}

.diag-backend .diag-time-track::-webkit-progress-value {
    border-radius: 4px;
    background:
        linear-gradient(
            100deg,
            transparent 0%,
            rgba(255, 255, 255, .65) 50%,
            transparent 100%
        ) no-repeat,
        linear-gradient(90deg, #16a34a, #5eead4);
    background-size: 40px 100%, 100% 100%;
    background-position: -40px 0, 0 0;
    animation: diag-shimmer 5s ease-in-out infinite;
}

.diag-backend .diag-time-track::-moz-progress-bar {
    border-radius: 4px;
    background:
        linear-gradient(
            100deg,
            transparent 0%,
            rgba(255, 255, 255, .65) 50%,
            transparent 100%
        ) no-repeat,
        linear-gradient(90deg, #16a34a, #5eead4);
    background-size: 40px 100%, 100% 100%;
    background-position: -40px 0, 0 0;
    animation: diag-shimmer 5s ease-in-out infinite;
}

/* Glimtet sveper under de första ~1,25 s av varje 5-sekundersperiod, vilar resten */
@keyframes diag-shimmer {
    0%   { background-position: -40px 0, 0 0; }
    25%  { background-position: calc(100% + 40px) 0, 0 0; }
    100% { background-position: calc(100% + 40px) 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .diag-backend .diag-time-track::-webkit-progress-value,
    .diag-backend .diag-time-track::-moz-progress-bar {
        animation: none;
        background: linear-gradient(90deg, #16a34a, #5eead4);
    }
}

.hp-diagnos.diag-backend .box-body .question {
    overflow-x: auto;
    margin: 4px 0 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    color: #fff;
    font-size: 1.125rem;
}

.hp-diagnos.diag-backend .box-body .question img {
    box-sizing: border-box;
    max-width: 100% !important;
    height: auto;
}

/* Mörk bildyta även när diagramfilen är transparent. */
.hp-diagnos.diag-backend img {
    background: #111822 !important;
	width:500px;
	height:auto;
	max-width:100% !important;
}

.hp-diagnos.diag-backend .box-body .question p {
    color: inherit;
    font-size: inherit;
}

.diag-backend .box.box-1 {
    container-type: inline-size;
}

.diag-backend .diag-answers {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: 0;
}

@container (min-width: 420px) {
    .diag-backend .diag-answers {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.diag-backend .diag-answers .answer-row {
    position: relative;
    min-width: 0;
    min-height: 44px;
    padding: 6px 10px;
    margin: 0;
}

.diag-backend .answer-row input {
    position: absolute;
    opacity: 0;
}

.diag-backend .answer-row:has(input:focus-visible) {
    outline: 2px solid #1ed760;
    outline-offset: 2px;
}

.diag-backend .answer-row:has(input:checked) {
    background: rgba(46, 102, 255, .85);
    border-color: #2e66ff;
}

.diag-backend .diag-answer-feedback {
    display: none;
}

#diag-exam-form:has(#diag-current-solution:not([hidden])) .answer-row.diag-answer-correct {
    background: #16372a;
    border-color: #52d792;
}

#diag-exam-form:has(#diag-current-solution:not([hidden])) .answer-row:not(.diag-answer-correct):has(input:checked) {
    background: #481d25;
    border-color: #ff7885;
}

#diag-exam-form:has(#diag-current-solution:not([hidden])) .answer-row.diag-answer-correct .diag-answer-feedback,
#diag-exam-form:has(#diag-current-solution:not([hidden])) .answer-row:has(input:checked) .diag-answer-feedback {
    display: block;
    margin-top: 2px;
    font-size: .85em;
    font-weight: 600;
}

:is(#diag-exam-form, #diag-home-form) > article.box.box-1 {
    border: 1px solid transparent;
    border: 1px solid transparent;
background:
  linear-gradient(rgba(18, 24, 34, .96), rgba(18, 24, 34, .96)) padding-box,
  radial-gradient(circle at 12% 0%, rgba(255, 255, 255, .55), rgba(255, 255, 255, .18) 16%, transparent 34%) border-box,
  radial-gradient(circle at 88% 100%, rgba(76, 155, 80, .38), rgba(76, 155, 80, .12) 18%, transparent 36%) border-box,
  linear-gradient(135deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02)) border-box;
}

.diag-backend .answer-label {
    cursor: pointer;
}

.diag-backend .answer-label::after {
    content: "";
    position: absolute;
    inset: 0;
}

.diag-backend .answer-text {
    min-width: 0;
    overflow-x: auto;
}

.diag-backend .diag-card-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 8px;
}

.diag-backend .diag-card-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
}

.diag-backend .diag-card-buttons .hpq-button {
    min-height: 44px;
    padding: 6px clamp(6px, 2vw, 12px);
    font-size: .875rem;
    line-height: 1.2;
}

.hp-diagnos.diag-backend .hpq-button.diag-ghost {
    color: #fff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .35);
}

.hp-diagnos.diag-backend .hpq-button.diag-ghost:enabled:hover {
    background: rgba(255, 255, 255, .08);
}

.hp-diagnos.diag-backend .diag-card-footer .source {
    min-width: 0;
    padding: 0;
    margin: 0;
    color: #cfd3dc;
    font-size: .75rem;
    overflow-wrap: anywhere;
}

@container (min-width: 420px) {
    .hp-diagnos.diag-backend .diag-card-footer .source {
        margin-inline-start: auto;
    }
}

@container (max-width: 419px) {
    .diag-backend .diag-card-footer .source {
        flex-basis: 100%;
    }
}

.diag-backend .hpq-feedback .diag-solution {
    cursor: pointer;
}

.hp-diagnos.diag-backend .box-body .question.diag-reading-prompt {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
}

.diag-backend .diag-current-solution[hidden] {
    display: none;
}

.diag-backend .diag-current-solution {
    box-sizing: border-box;
    scroll-margin-top: 5rem;
}

/* Mjuk öppning av lösningsrutan */
.diag-backend .diag-current-solution:not([hidden]) {
    animation: diagSolutionOpen 220ms ease-out both;
}

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

@media (prefers-reduced-motion: reduce) {
    .diag-backend .diag-current-solution:not([hidden]) {
        animation: none;
    }
}

.diag-backend .diag-current-solution h3 {
    margin: 0 0 6px;
}

.diag-backend .diag-image-trigger {
    display: inline-grid;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: #a8d5ff;
    text-align: start;
    font: inherit;
    cursor: zoom-in;
}

.diag-backend .diag-image-trigger span {
    font-size: .875rem;
    text-decoration: underline;
}

.diag-exam-page:has(.diag-image-dialog[open]) {
    overflow: hidden;
}

.diag-exam-page .diag-image-dialog {
    box-sizing: border-box;
    width: min(96vw, 1200px);
    max-width: 96vw;
    max-height: 94dvh;
    margin: auto;
    padding: 12px;
    overflow: hidden;
    border: 1px solid #394354;
    border-radius: 14px;
    background: #111822;
    color: #fff;
}

.diag-exam-page .diag-image-dialog[open] {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diag-image-dialog::backdrop {
    background: rgba(4, 8, 14, .82);
}

.diag-image-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.diag-exam-page .diag-image-toolbar h2 {
    margin: 0 auto 0 0;
    color: inherit;
    font-size: 1rem;
}

.diag-image-toolbar button {
    min-width: 44px;
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid #54647a;
    border-radius: 7px;
    background: #202b3b;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

.diag-image-toolbar button:disabled {
    opacity: .55;
    cursor: default;
}

.diag-image-viewport {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
}

.diag-exam-page .diag-image-viewport img {
    display: block;
    width: 100%;
    max-width: none !important;
    max-height: none !important;
    height: auto !important;
}

.hp-diagnos.diag-backend .diag-result h2,
.hp-diagnos.diag-backend .diag-result-heading {
    margin: 0;
    color: #fff;
}

.hp-diagnos.diag-backend .diag-result .diag-result-score {
    margin: 4px 0 0;
    color: #e7edf5;
    font-size: 1rem;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.diag-result-score strong {
    color: #fff;
    font-size: clamp(2rem, 9vw, 2.75rem);
}

.hp-diagnos.diag-backend .diag-result .diag-result-counts {
    margin: 4px 0 14px;
    color: #c4cdd9;
    font-size: .875rem;
}

.hp-diagnos.diag-backend .diag-result-heading {
    font-size: 1rem;
}

.hp-diagnos.diag-backend .diag-result .diag-result-parts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    list-style: none;
    margin: 8px 0 12px;
    padding: 0;
}

.hp-diagnos.diag-backend .diag-result-parts li {
    display: grid;
    grid-template-columns: 2.5rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 5px 6px;
    border-radius: 6px;
    background: #111822;
    font-size: .8125rem;
    font-variant-numeric: tabular-nums;
}

.hp-diagnos.diag-backend .diag-result-parts li::before {
    content: none;
}

.diag-result-part-code {
    font-weight: 700;
}

.diag-result-parts progress {
    box-sizing: border-box;
    width: 100%;
    height: 5px;
    accent-color: #37da8c;
}

@container (max-width: 300px) {
    .hp-diagnos.diag-backend .diag-result .diag-result-parts {
        grid-template-columns: minmax(0, 1fr);
    }
}

.hp-diagnos.diag-backend .diag-result .diag-result-focus {
    margin: 0 0 12px;
    padding: 8px 10px;
    border-left: 2px solid #37da8c;
    background: rgba(55, 218, 140, .08);
    color: #eff7f2;
    font-size: .9375rem;
}

.diag-result-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.diag-result-actions form {
    margin: 0;
}

.diag-result-actions a.hpq-button {
    display: inline-block;
    text-decoration: none;
}

.hp-diagnos.diag-backend .diag-result-review {
    margin-top: 10px;
    padding-block: 12px;
}

.diag-result-review summary {
    cursor: pointer;
    list-style: none;
}

.diag-result-review summary::-webkit-details-marker {
    display: none;
}

/* Pil för visa lösning under pågående diagnosprov */
.diag-backend [data-diag-solution]::after {
    margin-inline-start: .55em;
}

.diag-backend .solution-content {
    max-height: 22rem;
    max-height: min(22rem, 48dvh);
    overflow: auto;
	scrollbar-width: thin;
    scrollbar-color: #3b4250 #0b101a;
}

.diag-backend .solution-content:focus-visible {
    outline: 2px solid #52d792;
    outline-offset: -2px;
}

@supports selector(details::details-content) and (interpolate-size: allow-keywords) {
    @media (prefers-reduced-motion: no-preference) {
        .diag-result-review {
            interpolate-size: allow-keywords;
        }

        .diag-result-review::details-content,
        .diag-result-review details::details-content {
            block-size: 0;
            overflow: clip;
            opacity: 0;
            transition: block-size 230ms ease-in-out, opacity 230ms ease-in-out,
                        content-visibility 230ms allow-discrete;
        }

        .diag-result-review[open]::details-content,
        .diag-result-review details[open]::details-content {
            block-size: auto;
            opacity: 1;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .diag-backend [data-diag-solution]::after,
    .diag-result-review summary::before {
        transition: none;
    }
}

.diag-result-review .solution-content img, .diag-result-review .solution-content .factsimg {
    max-width: 100% !important;
    height: auto;
}

.diag-result-review .solution-content img.factsimg {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
}

.diag-result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.hp-diagnos.diag-backend .diag-result-header .diag-result-counts {
    margin-bottom: 0;
}

.diag-result-hp {
    display: grid;
    flex: 0 0 auto;
    justify-items: center;
    gap: 4px;
    color: #dbe5ef;
    font-size: .8125rem;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
}

.diag-result-hp small {
    color: #c4cdd9;
    font-size: .6875rem;
    font-weight: 400;
}

.diag-result-hp-ring {
    display: grid;
    align-content: center;
    width: 64px;
    aspect-ratio: 1;
    gap: 2px;
    border-radius: 50%;
    background:
        radial-gradient(circle, #111822 61%, transparent 63%),
        conic-gradient(#1ed760 var(--diag-hp-fill), #3b4655 var(--diag-hp-fill));
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.diag-result-hp-ring strong {
    font-size: 1.125rem;
}

.hp-history-label{    
	color: #1ed760;
    margin: 0 0 12px 0;
}

#diag-exam-form .box-body > .question:has(+ .diag-reading-prompt) {
    max-height: 22rem;
    max-height: min(22rem, 48dvh);
    overflow-y: auto;
	scrollbar-width: thin;
    scrollbar-color: #3b4250 #0b101a;
}



/* Diagnosprov – accordion-pilar */

/* Diagnosprov – fylld chevron med rotation */

.diag-result-review > summary,
.diag-result-review .hpq-feedback > summary {
    list-style: none;
    cursor: pointer;
}

.diag-result-review > summary::-webkit-details-marker,
.diag-result-review .hpq-feedback > summary::-webkit-details-marker {
    display: none;
}

/* Stängd: fylld chevron-right */
.diag-result-review > summary::before,
.diag-result-review .hpq-feedback > summary::before {
    content: "\f0da";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 14px;

    display: inline-block;
    width: 12px;
    margin-right: 8px;
    color: #bfc5cc;

    background: none;
    -webkit-mask: none;
    mask: none;
    border: 0;

    transform: rotate(0deg);
    transform-origin: center;
    transition: transform 0.2s ease;
}

/* Öppen: rotera 90 grader nedåt */
.diag-result-review[open] > summary::before,
.diag-result-review .hpq-feedback[open] > summary::before {
    transform: rotate(90deg);
}

/* Lösningsknappen – fylld caret med rotation */

/* Lösningsknappen – animerad fylld caret */
.diag-backend button[data-diag-solution]::after {
    content: "\f0d7";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 14px;

    display: inline-block;
    width: 12px;
    margin-left: 8px;
    color: inherit;

    border: 0;
    background: none;
    transform: rotate(0deg);
    transform-origin: 50% 50%;
    transition: transform 400ms ease-in-out;
}

/* Rotera pilen när lösningen öppnas */
.diag-backend button[data-diag-solution][aria-expanded="true"]::after {
    transform: rotate(180deg);
}

/* Respektera inställningar för reducerad rörelse */
@media (prefers-reduced-motion: reduce) {
    .diag-backend button[data-diag-solution]::after {
        transition: none;
    }
}

/* Knapprad */
.diag-backend .diag-card-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* Gemensam bas */
.diag-backend .diag-card-buttons .hpq-button {
    min-height: 44px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.2;
    transition: background-color .15s, border-color .15s, transform .1s;
}

.diag-backend .diag-card-buttons .hpq-button:active:enabled {
    transform: translateY(1px);
}

/* Sekundära: Föregående, Lösning, Rätta */
.hp-diagnos.diag-backend .hpq-button.diag-ghost {
    color: #dbe5ef;
    background: rgba(255, 255, 255, .06);
    border: 1px solid transparent;
}

.hp-diagnos.diag-backend .hpq-button.diag-ghost:enabled:hover {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(255, 255, 255, .2);
}

.hp-diagnos.diag-backend .hpq-button.diag-ghost:disabled {
    opacity: .4;
}

/* Rätta – svag grön ton */
.hp-diagnos.diag-backend .hpq-button[value="grade"] {
    color: #5eead4;
    background: rgba(94, 234, 212, .08);
    border-color: rgba(94, 234, 212, .35);
}

.hp-diagnos.diag-backend .hpq-button[value="grade"]:enabled:hover {
    background: rgba(94, 234, 212, .16);
    border-color: rgba(94, 234, 212, .55);
}

/* Primär: Nästa uppgift – skjuts åt höger */
.diag-backend .diag-card-buttons .hpq-button[value="next"] {
    margin-inline-start: auto;
    padding-inline: 20px;
}

.diag-backend [data-diag-solution]::after {
    content: "\f078"; /* chevron-down */
    font: var(--fa-font-solid, 900 .7em/1 "Font Awesome 6 Free");
    inline-size: auto;
    block-size: auto;
    border: 0;
    margin-inline-start: .5em;
    vertical-align: middle;
    transform: none;
}

.diag-backend [data-diag-solution][aria-expanded="true"]::after {
    transform: rotate(180deg);
}


/* anim results */

/* Resultatrader: animerad uppritning */
.hp-diagnos.diag-backend .diag-result-parts progress {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    border-radius: 4px;
    background: rgba(255, 255, 255, .12);
    overflow: hidden;
}

.hp-diagnos.diag-backend .diag-result-parts progress::-webkit-progress-bar {
    background: transparent;
}

.hp-diagnos.diag-backend .diag-result-parts progress::-webkit-progress-value {
    border-radius: 4px;
    background: linear-gradient(90deg, #16a34a, #37da8c);
    animation: diag-bar-reveal 900ms cubic-bezier(.22, 1, .36, 1) both;
    animation-delay: var(--diag-delay, 0ms);
}

.hp-diagnos.diag-backend .diag-result-parts progress::-moz-progress-bar {
    border-radius: 4px;
    background: linear-gradient(90deg, #16a34a, #37da8c);
    animation: diag-bar-reveal 900ms cubic-bezier(.22, 1, .36, 1) both;
    animation-delay: var(--diag-delay, 0ms);
}

@keyframes diag-bar-reveal {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 0 0 0); }
}

/* Stafett: varje rad startar lite efter den förra */
.diag-result-parts li:nth-child(1) { --diag-delay: 0ms; }
.diag-result-parts li:nth-child(2) { --diag-delay: 80ms; }
.diag-result-parts li:nth-child(3) { --diag-delay: 160ms; }
.diag-result-parts li:nth-child(4) { --diag-delay: 240ms; }
.diag-result-parts li:nth-child(5) { --diag-delay: 320ms; }
.diag-result-parts li:nth-child(6) { --diag-delay: 400ms; }
.diag-result-parts li:nth-child(7) { --diag-delay: 480ms; }
.diag-result-parts li:nth-child(8) { --diag-delay: 560ms; }

@media (prefers-reduced-motion: reduce) {
    .hp-diagnos.diag-backend .diag-result-parts progress::-webkit-progress-value,
    .hp-diagnos.diag-backend .diag-result-parts progress::-moz-progress-bar {
        animation: none;
    }
}

/* Gör variabeln animerbar */
@property --diag-hp-progress {
    syntax: "<percentage>";
    inherits: false;
    initial-value: 0%;
}

.diag-result-hp-ring {
    display: grid;
    align-content: center;
    width: 64px;
    aspect-ratio: 1;
    gap: 2px;
    border-radius: 50%;
    background:
        radial-gradient(circle, #111822 61%, transparent 63%),
        conic-gradient(#1ed760 var(--diag-hp-progress), #3b4655 var(--diag-hp-progress));
    color: #fff;
    font-variant-numeric: tabular-nums;

    /* Animationen använder måltalet från din inline-style */
    --diag-hp-progress: var(--diag-hp-fill);
    animation: diag-hp-fill 1200ms cubic-bezier(.22, 1, .36, 1) 200ms both;
}

@keyframes diag-hp-fill {
    from { --diag-hp-progress: 0%; }
    to   { --diag-hp-progress: var(--diag-hp-fill); }
}

/* Siffrorna tonas in när ringen nästan är klar */
.diag-result-hp-ring strong,
.diag-result-hp-ring small {
    animation: diag-hp-text 600ms ease-out 600ms both;
}

@keyframes diag-hp-text {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .diag-result-hp-ring,
    .diag-result-hp-ring strong,
    .diag-result-hp-ring small {
        animation: none;
    }
}
