@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* ════════════════════════════════════════════════════════
   SVENSKA 365 — READING PRACTICE HUB
   ════════════════════════════════════════════════════════ */

:root {
    --bg-color: #b3e5fc;
    --sidebar-bg: #e8f8ff;
    --card-bg: #ffffff;
    --primary-green: #4caf50;
    --primary-blue: #1565c0;
    --accent-blue: #1d72ff;
    --text-main: #1a2a3a;
    --text-muted: #4a6070;
    --shadow: 0 4px 12px rgba(0,0,0,0.1);
    --border-radius: 16px;
    --card-border: 1px solid rgba(255,255,255,0.6);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(145deg, #b3e5fc 0%, #81d4fa 50%, #a5d8f0 100%);
    min-height: 100vh;
    color: var(--text-main);
}

.hide { display: none !important; }

/* ════════════════════════════════════════════════════════
   HEADER
   ════════════════════════════════════════════════════════ */

.title {
    background: linear-gradient(135deg, #0d47a1 0%, #1565c0 40%, #1976d2 100%);
    padding: 28px 40px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(13, 71, 161, 0.35);
}

.title h1 {
    color: #ffffff;
    font-size: 2.1rem;
    font-weight: 900;
    letter-spacing: -0.3px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* ════════════════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════════════════ */

.workspace-container {
    display: flex;
    flex-direction: row;
    gap: 24px;
    padding: 28px 32px;
    max-width: 1200px;
    margin: 0 auto;
    align-items: flex-start;
}

/* ════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════ */

.topics-sidebar {
    min-width: 220px;
    width: 240px;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 22px 18px;
    box-shadow: 0 6px 24px rgba(21, 101, 192, 0.13);
    border: var(--card-border);
    flex-shrink: 0;
    position: sticky;
    top: 24px;
}

.topics-sidebar h2 {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ddeef8;
}

.level-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.level-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    transition: background 0.18s, color 0.18s;
    user-select: none;
}

.level-item:hover {
    background: #d6eef9;
    color: var(--primary-blue);
}

.level-item input[type="checkbox"] {
    accent-color: var(--primary-blue);
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════
   MAIN AREA
   ════════════════════════════════════════════════════════ */

.tests-display-area {
    flex: 1;
    min-width: 0;
}

.tests-display-area > h2 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 4px;
}

#panel-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0;
}

.panel-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

/* ════════════════════════════════════════════════════════
   PRACTICE CARDS — ACCORDION
   ════════════════════════════════════════════════════════ */

.practice-card {
    background: rgba(255,255,255,0.92);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 3px 14px rgba(21, 101, 192, 0.10);
    border: var(--card-border);
    transition: box-shadow 0.2s;
}

.practice-card:hover {
    box-shadow: 0 6px 24px rgba(21, 101, 192, 0.18);
}

.test-card-title {
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    padding: 16px 20px;
    user-select: none;
    transition: background 0.15s;
}

.test-card-title:hover {
    background: rgba(213, 238, 251, 0.45);
}

.card-icon-img {
    width: 2.4rem;
    height: 2.4rem;
    object-fit: contain;
    border-radius: 50%;
    flex-shrink: 0;
}

.card-text {
    flex: 1;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: capitalize;
}

.card-count {
    font-size: 1rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text-muted);
    margin-left: 4px;
}

.card-arrow {
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: transform 0.25s;
}

.button-container {
    border-top: 1px solid #ddeef8;
    background: #f4fbff;
}

/* ════════════════════════════════════════════════════════
   TEST TITLE LIST
   ════════════════════════════════════════════════════════ */

.test-title-item {
    padding: 11px 20px 11px 48px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    border-bottom: 1px solid #e8f4fb;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.test-title-item::before {
    content: '📖';
    font-size: 13px;
    flex-shrink: 0;
    position: absolute;
    left: 20px;
}

.test-title-item:hover {
    background: #d6eef9;
    color: var(--primary-blue);
}

.test-title-item:last-child { border-bottom: none; }

.rq-loading {
    padding: 12px 20px;
    font-size: 0.88rem;
    color: var(--text-muted);
    font-style: italic;
}

.rq-error {
    padding: 12px 20px;
    font-size: 0.88rem;
    color: #c62828;
}

/* ════════════════════════════════════════════════════════
   QUIZ CONTAINER
   ════════════════════════════════════════════════════════ */

#quiz-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 16px;
}

/* ════════════════════════════════════════════════════════
   READING QUIZ CARD
   ════════════════════════════════════════════════════════ */

.reading-quiz {
    background: rgba(255,255,255,0.92);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 18px rgba(21, 101, 192, 0.12);
    border: var(--card-border);
}

/* ── Title row ── */
.reading-quiz__title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: linear-gradient(90deg, #dceefb 0%, #cfe8f7 100%);
    border-bottom: 1px solid #b5d4ee;
}

.reading-quiz__index {
    display: none;
}

.reading-quiz__title {
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--text-main);
}

/* ════════════════════════════════════════════════════════
   READING QUIZ BODY — STACKED LAYOUT
   image + text side by side on top, questions full-width below
   ════════════════════════════════════════════════════════ */

.reading-quiz__body {
    display: flex;
    flex-direction: column;
    padding: 20px 22px;
    gap: 24px;
}

/* ── Top section: image left, passage right ── */
.reading-quiz__passage-row {
    display: flex;
    flex-direction: row;
    gap: 18px;
    align-items: center;
}

.reading-quiz__image-col {
    flex-shrink: 0;
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
}

.reading-quiz__image {
    width: 120px;
    height: 120px;
    border-radius: 14px;
    object-fit: cover;
    box-shadow: 0 3px 12px rgba(21,101,192,0.13);
    display: block;
}

.reading-quiz__content-col {
    flex: 1;
    min-width: 0;
}

.reading-quiz__content {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.9;
    color: var(--text-main);
    white-space: pre-line;
    background: linear-gradient(160deg, #ffffff 60%, #eaf5fd 100%);
    border: 1px solid #d0e8f5;
    border-radius: 14px;
    padding: 16px 18px;
    margin: 0;
}

/* ── Questions section: full width below passage ── */
.reading-quiz__questions-col {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Question block ── */
.rq-question-block {
    padding: 18px 0;
    border-bottom: 1px dashed #d0e8f5;
}

.rq-question-block:first-child { padding-top: 0; }
.rq-question-block:last-of-type { border-bottom: none; }

.rq-question-text {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 12px;
    line-height: 1.5;
}

.rq-question-num {
    display: inline-block;
    min-width: 22px;
    color: var(--accent-blue);
    font-weight: 900;
}

/* ── Options — 2 columns, full width ── */
.rq-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.rq-option {
    padding: 12px 18px;
    border: 2px solid #d0e8f5;
    border-radius: 12px;
    background: #ffffff;
    font-size: 0.88rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: transform 0.15s, background 0.15s, border-color 0.15s;
    box-shadow: 0 2px 6px rgba(21,101,192,0.07);
    line-height: 1.4;
    width: 100%;
}

.rq-option:hover:not(:disabled) {
    transform: scale(1.02);
    background: #e3f2fd;
    border-color: #90caf9;
}

.rq-option.selected {
    background: #e3f2fd;
    border-color: var(--accent-blue);
    color: var(--primary-blue);
}

.rq-option.correct {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
    font-weight: 800;
}

.rq-option.incorrect {
    background: #fce4ec;
    border-color: #e53935;
    color: #c62828;
    font-weight: 800;
}

.rq-option:disabled {
    cursor: default;
    transform: none;
}

/* ── Explanation ── */
.rq-explanation {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.6;
    font-weight: 600;
}

.rq-explanation.correct {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 3px solid #4caf50;
}

.rq-explanation.incorrect {
    background: #fce4ec;
    color: #c62828;
    border-left: 3px solid #e53935;
}

/* ── Submit button ── */
.reading-quiz__submit {
    display: block;
    margin: 20px 0 0 auto;
    padding: 10px 28px;
    background: linear-gradient(90deg, #1d72ff 0%, #1565c0 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.8px;
    box-shadow: 0 3px 10px rgba(29,114,255,0.3);
    transition: filter 0.2s, transform 0.15s;
}

.reading-quiz__submit:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.reading-quiz__submit:active { transform: translateY(0); }

/* ── Score banner ── */
.rq-score-banner {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 20px 16px;
    background: linear-gradient(160deg, #ffffff 60%, #eaf5fd 100%);
    border: 1px solid #d0e8f5;
    border-radius: 16px;
    text-align: center;
}

.rq-score-emoji {
    font-size: 3rem;
    display: block;
    line-height: 1;
}

.rq-score-msg {
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--text-main);
    display: block;
}

.rq-score-stats {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

.rq-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 20px;
    border-radius: 14px;
    min-width: 72px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(21,101,192,0.08);
}

.rq-stat--correct { background: #e8f5e9; border: 1px solid #a5d6a7; color: #2e7d32; }
.rq-stat--wrong   { background: #fce4ec; border: 1px solid #f48fb1; color: #c62828; }
.rq-stat--pct     { background: linear-gradient(135deg, #e8f0fe, #dceefb); border: 1px solid #b0c4f5; color: var(--primary-blue); }

.rq-bar-wrap {
    width: 100%;
    max-width: 320px;
    height: 12px;
    background: #ddeef8;
    border-radius: 50px;
    overflow: hidden;
}

.rq-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #1d72ff);
    border-radius: 50px;
    transition: width 0.8s ease;
}

/* ════════════════════════════════════════════════════════
   BACK BUTTONS
   ════════════════════════════════════════════════════════ */

.rq-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    padding: 9px 20px;
    background: rgba(255,255,255,0.85);
    color: var(--primary-blue);
    border: 2px solid #b5d4ee;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.3px;
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(21,101,192,0.10);
    transition: background 0.18s, border-color 0.18s, transform 0.15s;
}

.rq-back-btn:hover {
    background: #d6eef9;
    border-color: #90caf9;
    transform: translateX(-2px);
}

.rq-score-actions {
    margin-top: 6px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.rq-back-after-result-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 28px;
    background: linear-gradient(90deg, #1d72ff 0%, #1565c0 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    letter-spacing: 0.8px;
    box-shadow: 0 3px 10px rgba(29,114,255,0.3);
    transition: filter 0.2s, transform 0.15s;
}

.rq-back-after-result-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.rq-back-after-result-btn:active {
    transform: translateY(0);
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE — TABLET
   ════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .workspace-container {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }

    .topics-sidebar {
        width: 100%;
        position: static;
        padding: 16px 14px;
    }

    .topics-sidebar h2 {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .level-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .level-item {
        padding: 8px 12px;
        border-radius: 50px;
        background: rgba(21, 101, 192, 0.07);
        font-size: 0.88rem;
    }

    .level-item:hover {
        background: #d6eef9;
    }

    .title {
        padding: 18px 16px;
    }

    .title h1 {
        font-size: 1.2rem;
    }

    .tests-display-area > h2 {
        font-size: 1.1rem;
    }

    #panel-title {
        font-size: 0.88rem;
    }

    .test-card-title {
        padding: 14px 16px;
        gap: 10px;
    }

    .card-icon-img {
        width: 2rem;
        height: 2rem;
    }

    .card-text {
        font-size: 0.92rem;
    }

    .card-count {
        font-size: 0.92rem;
    }

    .test-title-item {
        padding: 12px 16px 12px 44px;
        font-size: 0.88rem;
    }

    .reading-quiz__title {
        font-size: 1rem;
    }

    .reading-quiz__passage-row {
        flex-direction: column;
        align-items: center;
    }

    .reading-quiz__image-col {
        width: 100%;
        justify-content: center;
    }

    .reading-quiz__image {
        width: 130px;
        height: 130px;
    }

    .reading-quiz__content {
        font-size: 0.92rem;
        line-height: 1.75;
        padding: 14px;
    }

    .rq-question-text {
        font-size: 0.88rem;
    }

    .rq-options {
        grid-template-columns: 1fr;
    }

    .rq-option {
        font-size: 0.85rem;
        padding: 11px 14px;
    }

    .reading-quiz__body {
        padding: 14px;
        gap: 18px;
    }

    .reading-quiz__submit {
        width: 100%;
        text-align: center;
        padding: 12px 20px;
        font-size: 0.92rem;
    }

    .rq-score-emoji {
        font-size: 2.4rem;
    }

    .rq-score-msg {
        font-size: 1.2rem;
    }

    .rq-stat {
        padding: 10px 14px;
        font-size: 0.75rem;
        min-width: 64px;
    }

    .rq-back-btn {
        font-size: 0.82rem;
        padding: 8px 16px;
    }

    .rq-back-after-result-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 0.88rem;
    }

    .rq-explanation {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE — SMALL MOBILE
   ════════════════════════════════════════════════════════ */

@media (max-width: 380px) {
    .title h1 {
        font-size: 1rem;
    }

    .level-item {
        font-size: 0.8rem;
        padding: 7px 10px;
    }

    .card-text,
    .card-count {
        font-size: 0.85rem;
    }

    .rq-score-stats {
        gap: 8px;
    }
}