/* quiz-styles.css */

:root {
    --primary: #003741;
    --accent: #00778a;
    --accent-soft: #ebf4fa;
    --success: #1b7a3a;
    --success-bg: #e6f4ea;
    --error: #c62828;
    --error-bg: #fdecea;
    --bg: #ebf4fa;
    --card: #ffffff;
    --surface: #f6f8fb;
    --text: #131516;
    --text-light: #4d5a5c;
    --border: #ced9e5;
    --shadow: rgba(0, 55, 65, 0.16);
    --radius: 16px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #7fd0dd;
        --accent: #3fb2c4;
        --accent-soft: #123038;
        --success: #6fcf8a;
        --success-bg: #14301f;
        --error: #ff8a80;
        --error-bg: #3a1c1c;
        --bg: #0c1a1d;
        --card: #14262a;
        --surface: #1a3237;
        --text: #e6ebf1;
        --text-light: #a3b0bf;
        --border: #2f4a50;
        --shadow: rgba(0, 0, 0, 0.5);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Museo Sans Rounded', museo-sans-rounded, 'Nunito', 'Varela Round', 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
}

.hidden {
    display: none !important;
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Site header: dark bar, logo (tulip + name) centered on a white band */
.site-topbar {
    height: 10px;
    background: #003741;
}

.site-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 14px var(--shadow);
    display: flex;
    justify-content: center;
    padding: 14px 16px;
}

.site-logo {
    display: block;
    height: 48px;
    width: auto;
}

/* Layout */
.main-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 0;
}

.quiz-card {
    background: var(--card);
    max-width: 820px;
    width: 95%;
    border-radius: var(--radius);
    box-shadow: 0 10px 30px var(--shadow);
    padding: 36px;
    margin: 12px;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

h1 {
    margin: 0;
    color: var(--primary);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.25;
}

.quiz-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-input {
    display: none;
}

.github-footer {
    margin-top: auto;
    padding: 1rem 0;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-light);
    font-size: 0.9rem;
    background: var(--card);
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.github-link:hover {
    text-decoration: underline;
}

/* Buttons */
.btn,
.file-btn {
    display: inline-block;
    padding: 14px 28px;
    background: var(--accent);
    color: #fff;
    border: 2px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

@media (prefers-color-scheme: dark) {
    .btn,
    .file-btn {
        color: #0b1320;
    }
}

.btn:hover,
.file-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px var(--shadow);
    filter: brightness(1.08);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--card);
    color: var(--accent);
    border: 2px solid var(--accent);
}

@media (prefers-color-scheme: dark) {
    .btn-secondary {
        color: var(--accent);
    }
}

/* Progress */
#progress-wrap {
    margin-bottom: 24px;
}

#progress {
    font-weight: 600;
    color: var(--text-light);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

#progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

#progress-fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* Question */
.question-title {
    color: var(--primary);
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
}

.question-title:focus {
    outline: none;
}

.question-text {
    font-size: 17px;
    margin: 0 0 24px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.btn-option {
    position: relative;
    padding: 16px 52px 16px 20px;
    min-height: 56px;
    border: 2px solid var(--border);
    background: var(--card);
    cursor: pointer;
    border-radius: 12px;
    text-align: left;
    font-size: 16px;
    line-height: 1.4;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-option:hover:not(.disabled) {
    background: var(--accent-soft);
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Questions with several correct answers: toggle options plus a check button */
.multi-hint {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.btn-option.multi {
    padding-left: 52px;
}

.btn-option.multi::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 50%;
    width: 20px;
    height: 20px;
    transform: translateY(-50%);
    box-sizing: border-box;
    border: 2px solid var(--text-light);
    border-radius: 5px;
    background: var(--card);
    font-size: 14px;
    line-height: 16px;
    text-align: center;
    color: #fff;
}

.btn-option.multi.selected:not(.disabled) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.btn-option.multi.selected::before {
    /* stays visible after checking so you see what you chose */
    content: '\2713';
    background: var(--accent);
    border-color: var(--accent);
}

.check-btn {
    align-self: flex-start;
}

/* Answer states: tinted background, colored border and an icon (not color alone) */
.btn-option.correct {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--text);
}

.btn-option.wrong {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--text);
}

.btn-option.correct::after,
.btn-option.wrong::after {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: #fff;
}

.btn-option.correct::after {
    content: '\2713';
    background: var(--success);
}

.btn-option.wrong::after {
    content: '\2717';
    background: var(--error);
}

@media (prefers-color-scheme: dark) {
    .btn-option.correct::after,
    .btn-option.wrong::after {
        color: #0b1320;
    }
}

.btn-option.missed {
    border-style: dashed;
}

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

.btn-option.disabled:not(.correct):not(.wrong) {
    opacity: 0.6;
}

/* Answer animations */
.btn-option.correct {
    animation: correctPop 0.55s ease-out, correctGlow 0.9s ease-out;
}

.btn-option.wrong {
    animation: wrongShake 0.5s ease-in-out;
}

.btn-option.correct::after,
.btn-option.wrong::after {
    animation: iconPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

@keyframes correctPop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.04); }
    100% { transform: scale(1); }
}

@keyframes correctGlow {
    0%   { box-shadow: 0 0 0 0 rgba(27, 122, 58, 0.55); }
    100% { box-shadow: 0 0 0 18px rgba(27, 122, 58, 0); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    15%      { transform: translateX(-9px); }
    30%      { transform: translateX(8px); }
    45%      { transform: translateX(-6px); }
    60%      { transform: translateX(5px); }
    75%      { transform: translateX(-3px); }
}

@keyframes iconPop {
    from { transform: translateY(-50%) scale(0) rotate(-120deg); }
    to   { transform: translateY(-50%) scale(1) rotate(0); }
}

/* Confetti burst from a correct answer */
.confetti-piece {
    position: absolute;
    left: calc(100% - 32px);
    top: 50%;
    width: 8px;
    height: 12px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    animation: confettiFly 0.9s cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

@keyframes confettiFly {
    0%   { opacity: 1; transform: translate(0, 0) rotate(0); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); }
}

/* Feedback / explanation */
.feedback {
    border-top: 1px solid var(--border);
    padding-top: 24px;
    margin-top: 24px;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* "Toelichting" is a tab on top of the explanation box: same background, same text color */
.feedback h3 {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 18px 10px 20px;
    background: var(--surface);
    color: var(--text);
    border-left: 4px solid var(--accent);
    border-radius: 12px 12px 0 0;
    font-size: 18px;
    font-weight: 700;
}

/* Concave corner where the tab flows into the box below */
.feedback h3::after {
    content: '';
    position: absolute;
    right: -12px;
    bottom: 0;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle at 100% 0, transparent 11.5px, var(--surface) 12px);
    pointer-events: none;
}

/* Light bulb icon */
.feedback h3::before {
    content: '';
    width: 24px;
    height: 24px;
    flex: none;
    background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300778a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 21h4'/%3E%3Cpath d='M12 3a6 6 0 0 0-3.5 10.9c.9.7 1.5 1.6 1.5 2.6V17h4v-.5c0-1 .6-1.9 1.5-2.6A6 6 0 0 0 12 3z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
    .feedback h3::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233fb2c4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 21h4'/%3E%3Cpath d='M12 3a6 6 0 0 0-3.5 10.9c.9.7 1.5 1.6 1.5 2.6V17h4v-.5c0-1 .6-1.9 1.5-2.6A6 6 0 0 0 12 3z'/%3E%3C/svg%3E");
    }
}

.explanation-container {
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
    padding: 16px 20px;
    background: var(--surface);
    margin-bottom: 24px;
    line-height: 1.7;
}

#explanation {
    color: var(--text);
}

#explanation h4,
#explanation h3,
#explanation h2 {
    color: var(--primary);
    margin: 16px 0 6px;
    font-size: 16px;
}

#explanation strong,
#explanation b {
    color: var(--primary);
}

#explanation ul,
#explanation ol {
    margin: 8px 0;
    padding-left: 24px;
}

#explanation li {
    margin-bottom: 6px;
}

#explanation a {
    color: var(--accent);
}

/* Callouts in explanations: [ok] [bad] [tip] [warn] [fact] at the start of a line */
.callout {
    position: relative;
    margin: 8px 0;
    padding: 8px 12px 8px 40px;
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--accent-soft);
    line-height: 1.5;
}

.callout::before {
    position: absolute;
    left: 10px;
    top: 7px;
    font-size: 20px;
    line-height: 1.4;
}

.callout.ok { border-color: var(--success); background: var(--success-bg); }
.callout.ok::before { content: '\2705'; }
.callout.bad { border-color: var(--error); background: var(--error-bg); }
.callout.bad::before { content: '\274C'; }
.callout.tip { border-color: var(--accent); background: var(--accent-soft); }
.callout.tip::before { content: '\1F4A1'; }
.callout.warn { border-color: #e08a00; background: #fff4e0; }
.callout.warn::before { content: '\26A0\FE0F'; }
.callout.fact { border-color: #3949ab; background: #e8eaf6; }
.callout.fact::before { content: '\1F4CC'; }

@media (prefers-color-scheme: dark) {
    .callout.warn { background: #3a2b0d; border-color: #f0a830; }
    .callout.fact { background: #1f2547; border-color: #9fa8da; }
}

/* Inline formatting in questions, options and explanations */
.question-title strong,
.question-text strong,
.question-text b,
.btn-option strong,
.btn-option b {
    color: var(--primary);
    font-weight: 700;
}

.question-text em,
.btn-option em {
    font-style: italic;
    color: var(--accent);
}

.question-text code,
.btn-option code,
#explanation code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--primary);
    word-break: break-word;
}

.question-text del,
.btn-option del {
    text-decoration: line-through;
    color: var(--text-light);
}

/* Results */
.results {
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

.results h2 {
    color: var(--primary);
    margin: 0 0 24px;
    font-size: 26px;
}

.score-display {
    margin: 24px 0;
    padding: 28px 24px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

#score-percentage {
    --pct: 0;
    width: 140px;
    height: 140px;
    margin: 0 auto 16px;
    order: 1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 800;
    color: var(--primary);
    background:
        radial-gradient(closest-side, var(--surface) 78%, transparent 80% 100%),
        conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
}

#score-number {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-light);
    order: 2;
}

.score-display {
    display: flex;
    flex-direction: column;
}

#score-message {
    font-size: 17px;
    color: var(--text);
    margin-top: 16px;
    order: 3;
}

.result-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Prize draw */
.prize-draw {
    margin-top: 32px;
    padding: 24px;
    border: 2px dashed var(--accent);
    border-radius: var(--radius);
    background: var(--accent-soft);
    text-align: center;
}

.prize-draw p {
    margin: 0 0 16px;
}

.prize-draw form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.prize-draw input[type="email"] {
    flex: 1 1 240px;
    max-width: 360px;
    padding: 12px 14px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    border: 2px solid var(--border);
    border-radius: 8px;
}

.prize-draw input[type="email"]:focus {
    border-color: var(--accent);
}

.prize-status:empty {
    display: none;
}

.prize-status {
    margin: 12px 0 0;
    min-height: 1.2em;
    color: var(--error);
}

/* Start page */
.info-section {
    background: var(--surface);
    border-radius: 10px;
    padding: 24px;
    margin-bottom: 20px;
}

.info-section h2 {
    color: var(--primary);
    margin: 0 0 12px;
    font-size: 20px;
}

.info-section ul {
    margin-left: 20px;
    padding-left: 0;
}

.info-section li {
    margin-bottom: 8px;
}

.info-section a {
    color: var(--accent);
}

.url-quiz-info {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 16px;
    margin: 16px 0;
}

.url-quiz-info h3 {
    color: var(--primary);
    margin: 0 0 8px;
    font-size: 16px;
}

.url-quiz-info p,
.url-quiz-info li {
    font-size: 14px;
    margin: 6px 0;
}

.source-link {
    font-size: 12px;
    color: var(--text-light);
}

details {
    margin-top: 16px;
}

summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
    padding: 8px 0;
}

.format-examples h4 {
    color: var(--primary);
    margin: 20px 0 8px;
}

.format-examples pre {
    background: #1f2933;
    color: #e6ebf1;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.4;
}

/* Loader and errors */
.loader {
    text-align: center;
    padding: 40px;
}

.loader-spinner {
    border: 4px solid var(--accent-soft);
    border-top: 4px solid var(--accent);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.url-info {
    margin-top: 10px;
    font-size: 12px;
    word-break: break-all;
    color: var(--text-light);
}

.error {
    background: var(--error-bg);
    border: 2px solid var(--error);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
}

.error h3 {
    color: var(--error);
    margin: 0 0 12px;
}

.error p {
    margin: 0 0 20px;
}

.error code {
    display: block;
    background: var(--card);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    word-break: break-all;
    margin: 6px 0;
}

.error ul {
    text-align: left;
    margin: 10px 0;
    padding-left: 20px;
}

/* Small screens */
@media (max-width: 600px) {
    .main-content {
        padding: 0;
    }

    .site-logo {
        height: 38px;
    }

    .quiz-card {
        width: 100%;
        margin: 0;
        padding: 20px 16px;
        border-radius: 0;
    }

    .quiz-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    h1 {
        font-size: 24px;
    }

    .question-title {
        font-size: 19px;
    }

    .question-text {
        font-size: 16px;
    }

    .result-actions {
        flex-direction: column;
        align-items: stretch;
    }

}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* Landing page */
.landing {
    text-align: center;
    padding-top: 48px;
    padding-bottom: 48px;
}

.landing h1 {
    margin-bottom: 20px;
}

.landing-lead {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary);
}

.landing .btn {
    margin-top: 16px;
}

/* Next question button: indigo box, same bold style as the explanation heading */
#next-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 18px 8px 14px;
    min-height: 44px;
    background: #3949ab;
    color: #fff;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
}

#next-btn::before {
    content: '\1F449'; /* backhand index pointing right */
    font-size: 22px;
    line-height: 1;
}

@media (prefers-color-scheme: dark) {
    #next-btn {
        background: #9fa8da;
        color: #0b1320;
    }
}

/* Explanation heading on the left, Next button on the right of the same row */
.feedback {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 16px;
    align-items: end;
}

.feedback h3 {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
}

.feedback #next-btn {
    grid-column: 2;
    grid-row: 1;
    margin: 0 0 10px;
}

.feedback .explanation-container {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-bottom: 0;
}

@media (max-width: 600px) {
    .feedback {
        column-gap: 8px;
    }

    .feedback h3,
    #next-btn {
        font-size: 15px;
        white-space: nowrap;
    }

    #next-btn::before {
        font-size: 18px;
    }

    .feedback h3 {
        padding: 8px 12px 8px 14px;
    }

    #next-btn {
        padding: 6px 12px 6px 10px;
    }
}

/* Very narrow phones: the button goes on its own row above the tab, right aligned */
@media (max-width: 400px) {
    .feedback {
        grid-template-columns: 1fr;
    }

    .feedback #next-btn {
        grid-column: 1;
        grid-row: 1;
        justify-self: end;
        margin: 0 0 14px;
    }

    .feedback h3 {
        grid-row: 2;
    }

    .feedback .explanation-container {
        grid-row: 3;
    }
}
