/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --success-hover: #059669;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --share-color: #8b5cf6;
    --share-hover: #7c3aed;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
}

/* Header Styles */
header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 1rem;
}

.intro {
    font-size: 1rem;
    color: var(--text-color);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Question Container */
.question-container {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

.question-container.hidden {
    display: none;
}

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

.question-header {
    margin-bottom: 1.5rem;
}

.question-number {
    display: block;
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

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

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

/* Fieldset and Legend */
fieldset {
    border: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
}

legend {
    width: 100%;
    padding: 0;
    margin-bottom: 1rem;
}

legend h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    line-height: 1.4;
}

/* Radio Button Options */
.options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.options label {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    background-color: var(--card-bg);
}

.options label:hover {
    border-color: var(--primary-color);
    background-color: #eff6ff;
}

.options label:focus-within {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.options input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    cursor: pointer;
    accent-color: var(--primary-color);
    flex-shrink: 0;
}

.options input[type="radio"]:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.options span {
    flex: 1;
    font-size: 1rem;
    color: var(--text-color);
}

/* Navigation Buttons */
.question-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-prev {
    background-color: var(--secondary-color);
    color: white;
}

.btn-prev:hover {
    background-color: #475569;
}

.btn-prev:focus {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

.btn-next,
.btn-submit {
    background-color: var(--primary-color);
    color: white;
    margin-left: auto;
}

.btn-next:hover,
.btn-submit:hover {
    background-color: var(--primary-hover);
}

.btn-next:focus,
.btn-submit:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-submit {
    font-weight: 600;
}

/* Results Section */
.results-container {
    animation: fadeIn 0.5s ease-in;
}

.results-container.hidden {
    display: none;
}

.results-container h2 {
    font-size: 1.75rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.score-display {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--border-radius);
    color: white;
}

.score-value {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.score-label {
    font-size: 1.25rem;
    opacity: 0.9;
}

.interpretation {
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.interpretation.low-risk {
    background-color: #f0fdf4;
    border-color: var(--success-color);
    color: #166534;
}

.interpretation.hazardous {
    background-color: #fffbeb;
    border-color: var(--warning-color);
    color: #92400e;
}

.interpretation.dependence-moderate {
    background-color: #fef3c7;
    border-color: var(--warning-color);
    color: #78350f;
}

.interpretation.dependence-severe {
    background-color: #fee2e2;
    border-color: var(--danger-color);
    color: #991b1b;
}

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

.interpretation p {
    margin: 0;
    line-height: 1.6;
}

.recommendations {
    padding: 1.5rem;
    background-color: #f8fafc;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.recommendations h3 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.recommendations ul {
    margin-left: 1.5rem;
    color: var(--text-color);
}

.recommendations li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.disclaimer {
    padding: 1.5rem;
    background-color: #f1f5f9;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
}

.disclaimer h3 {
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.disclaimer p {
    margin-bottom: 0.75rem;
    color: var(--text-color);
    line-height: 1.6;
}

.disclaimer ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.disclaimer li {
    margin-bottom: 0.5rem;
}

.disclaimer a {
    color: var(--primary-color);
    text-decoration: underline;
}

.disclaimer a:hover {
    color: var(--primary-hover);
}

.disclaimer a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.btn-share,
.btn-email,
.btn-restart {
    width: 100%;
    color: white;
    padding: 1rem;
    font-size: 1.125rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

/* Primary CTA: Email My Results - Green (success/action) */
.btn-email {
    background-color: var(--success-color);
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.btn-email:hover {
    background-color: var(--success-hover);
    box-shadow: 0 6px 8px -1px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-email:focus {
    outline: 2px solid var(--success-color);
    outline-offset: 2px;
}

/* Secondary CTA: Share this Test - Purple (social/sharing) */
.btn-share {
    background-color: var(--share-color);
}

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

.btn-share:focus {
    outline: 2px solid var(--share-color);
    outline-offset: 2px;
}

/* Tertiary CTA: Take Test Again - Outlined style (less prominent) */
.btn-restart {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

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

.btn-restart:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Footer */
footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
}

footer p {
    margin-bottom: 0.5rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

footer a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 1.5rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    legend h2 {
        font-size: 1.125rem;
    }

    .options label {
        padding: 0.875rem;
    }

    .question-nav {
        flex-direction: column;
    }

    .btn-next,
    .btn-submit {
        margin-left: 0;
        width: 100%;
    }

    .btn-prev {
        width: 100%;
    }

    .score-value {
        font-size: 2.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .intro {
        font-size: 0.9rem;
    }

    legend h2 {
        font-size: 1rem;
    }

    .options label {
        padding: 0.75rem;
    }

    .options span {
        font-size: 0.9rem;
    }

    button {
        padding: 0.625rem 1.25rem;
        font-size: 0.9rem;
    }
}

/* Accessibility - Skip to content link (hidden but accessible) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        box-shadow: none;
    }

    .question-nav,
    .btn-restart {
        display: none;
    }
}

