/* Base quiz styles with CSS custom properties for theming */

:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: rgba(79, 70, 229, 0.1);
    --color-secondary: #0ea5e9;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-success: #22c55e;
    --color-error: #ef4444;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.12);
    --max-width: 640px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.quiz-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* When hero image is present, go full width */
.quiz-container.has-hero {
    max-width: 100%;
    padding: 0;
}

/* --- Intro screen (no hero) --- */
.quiz-intro {
    text-align: center;
    padding: 3rem 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.quiz-intro h1 {
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.quiz-intro-description {
    color: var(--color-text-muted);
    font-size: 1.05rem;
    margin-bottom: 2rem;
    max-width: 480px;
}

.quiz-intro-description p {
    margin-bottom: 0.5rem;
}

.quiz-intro-description a {
    color: var(--color-primary);
}

/* --- Intro screen with hero image (split layout) --- */
.quiz-intro-split {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.quiz-intro-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem 4rem;
    max-width: 50%;
}

.quiz-intro-content h1 {
    font-size: 2.25rem;
    font-weight: 400;
    margin-bottom: 0.75rem;
    letter-spacing: -0.02em;
}

.quiz-intro-content .quiz-intro-description {
    color: var(--color-text-muted);
    font-size: 1.05rem;
    margin-bottom: 2rem;
}

.quiz-intro-content .quiz-intro-description p {
    margin-bottom: 0.5rem;
}

.quiz-intro-content .quiz-intro-description a {
    color: var(--color-primary);
}

.quiz-intro-hero {
    flex: 1;
    max-width: 50%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Start button */
.btn-start {
    display: inline-block;
    padding: 0.875rem 2.5rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    align-self: flex-start;
}

.btn-start:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

/* Progress bar */
.quiz-progress {
    margin-bottom: 2rem;
}

.progress-bar {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Question card */
.quiz-question {
    flex: 1;
}

.question-card {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    animation: fadeSlideIn 0.4s ease;
}

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

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

.question-card.exiting {
    animation: fadeSlideOut 0.3s ease forwards;
}

.question-text {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.question-description {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.question-description p {
    margin-bottom: 0.35rem;
}

.question-description a {
    color: var(--color-primary);
}

/* Answer buttons */
.answers-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.answer-btn {
    display: block;
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: calc(var(--border-radius) - 2px);
    text-align: left;
    font-size: 1rem;
    font-family: inherit;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), transform var(--transition);
    line-height: 1.4;
}

.answer-btn:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}

.answer-btn:active {
    transform: scale(0.98);
}

.answer-btn.selected {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    font-weight: 500;
}

/* Back button */
.quiz-nav {
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-back {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem 0;
    font-family: inherit;
    transition: color var(--transition);
}

.btn-back:hover {
    color: var(--color-text);
}

.btn-back::before {
    content: "\2190\00a0";
}

/* Results screen */
.quiz-results {
    animation: fadeSlideIn 0.5s ease;
}

.result-hero {
    text-align: center;
    padding: 2rem 1rem;
    margin-bottom: 1.5rem;
}

.result-hero h2 {
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 0.25rem;
}

.result-hero-description {
    color: var(--color-text-muted);
    font-size: 1rem;
    margin-top: 0.5rem;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

.result-hero-description p {
    margin-bottom: 0.35rem;
}

.result-hero-description a {
    color: var(--color-primary);
}

.result-card {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    margin-bottom: 1rem;
}

.result-card.primary {
    border-top: 4px solid var(--color-primary);
}

.result-card h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.result-card .result-description {
    color: var(--color-text-muted);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.result-card .result-description p {
    margin-bottom: 0.5rem;
}

.result-card .result-description a {
    color: var(--color-primary);
}

.result-highlights {
    list-style: none;
    padding: 0;
    margin-bottom: 1.5rem;
}

.result-highlights li {
    padding: 0.4rem 0 0.4rem 1.5rem;
    position: relative;
    color: var(--color-text);
}

.result-highlights li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--color-success);
    font-weight: 700;
}

.btn-cta {
    display: inline-block;
    padding: 0.75rem 2rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: calc(var(--border-radius) - 2px);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition);
}

.btn-cta:hover {
    background: var(--color-primary-hover);
}

/* Alternatives */
.alternatives-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin: 2rem 0 1rem;
}

.result-card.alternative {
    opacity: 0.85;
}

.result-card.alternative h3 {
    font-size: 1.1rem;
}

.alternatives-accordion {
    margin-top: 2rem;
    border-top: 1px solid var(--color-border, #e2e8f0);
}

.alternatives-accordion > summary {
    list-style: none;
    cursor: pointer;
    padding: 1rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.alternatives-accordion > summary::-webkit-details-marker {
    display: none;
}

.alternatives-accordion > summary::after {
    content: "›";
    margin-left: auto;
    font-size: 1.5rem;
    line-height: 1;
    transition: transform .2s ease;
    transform: rotate(90deg);
}

.alternatives-accordion[open] > summary::after {
    transform: rotate(-90deg);
}

.alternatives-accordion-body {
    padding-top: .25rem;
}

/* Score bar */
.score-bar-container {
    margin-bottom: 1rem;
}

.score-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.score-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.8s ease;
}

.result-card.alternative .score-bar-fill {
    background: var(--color-secondary);
}

/* Share & restart */
.result-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-secondary {
    padding: 0.65rem 1.5rem;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: calc(var(--border-radius) - 2px);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--transition);
}

.btn-secondary:hover {
    border-color: var(--color-primary);
}

/* Loading state */
.quiz-loading {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-text-muted);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Error state */
.quiz-error {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-error);
}

/* Brand logo */
.brand-logo {
    text-align: center;
    margin-bottom: 1rem;
}

.brand-logo img {
    max-height: 48px;
    width: auto;
}

.quiz-intro-content .brand-logo {
    text-align: left;
}

/* Hidden utility */
.hidden { display: none !important; }

/* Mobile */
@media (max-width: 768px) {
    .quiz-intro-split {
        flex-direction: column-reverse;
    }
    .quiz-intro-content {
        max-width: 100%;
        padding: 2rem 1.5rem;
        text-align: center;
        align-items: center;
    }
    .quiz-intro-content .btn-start {
        align-self: center;
    }
    .quiz-intro-content .brand-logo {
        text-align: center;
    }
    .quiz-intro-hero {
        max-width: 100%;
        height: 40vh;
        min-height: 200px;
    }
    .quiz-container.has-hero {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .quiz-container {
        padding: 1rem 0.75rem;
    }
    .quiz-intro h1,
    .quiz-intro-content h1 {
        font-size: 1.5rem;
    }
    .question-text {
        font-size: 1.15rem;
    }
    .question-card {
        padding: 1.5rem;
    }
    .result-card {
        padding: 1.5rem;
    }
}
