/* Alcohol Quiz Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Playfair+Display:wght@400;700&display=swap');

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

:root {
    --primary-color: #D8949E;
    --secondary-color: #c47d88;
    --secondary-accent: #415364;
    --accent-color: #e67e22;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --text-dark: #2D2424;
    --text-light: #6B5C5C;
    --bg-light: #FAFAFA;
    --bg-white: #ffffff;
    --border-color: #E8E2DC;
}

/* Smooth scrolling behavior (respects user preferences) */
html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
    padding: 20px;
}

.quiz-container {
    max-width: 680px;
    margin: 0 auto;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.quiz-header {
    background: #3D5068;
    color: #F0ECE8;
    padding: 32px 24px;
    text-align: center;
}

.quiz-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    margin-bottom: 10px;
    font-weight: 600;
}

.quiz-header .subtitle {
    font-size: 0.9em;
    opacity: 0.9;
}

.quiz-header .info-panel h3 {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
}

.quiz-header .info-panel p {
    font-size: 0.9em;
    opacity: 0.9;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 60px 30px;
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Error State */
.error {
    background-color: #fee;
    border: 2px solid var(--danger-color);
    border-radius: 8px;
    padding: 30px;
    margin: 30px;
    text-align: center;
    color: var(--danger-color);
}

/* Quiz Form */
.quiz-form {
    padding: 30px;
}

/* Section Headers */
.section-header {
    background-color: var(--bg-white);
    padding: 20px;
    margin: 30px -30px 20px -30px;
    border-left: 4px solid #9B7B7B;

    /* Animation preparation */
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.section-header.visible {
    opacity: 1;
    transform: translateX(0);
}

.section-header h3 {
    font-family: 'Playfair Display', serif;
    color: #9B7B7B;
    font-size: 18px;
    font-weight: 700;
}

.section-header:first-child {
    margin-top: 0;
}

/* Accessibility: Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
    .section-header {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* Question Blocks */
.question-block {
    margin-bottom: 35px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--border-color);
}

.question-block:last-child {
    border-bottom: none;
}

/* Progressive Section Reveal - Hidden Questions */
.question-block.section-hidden {
    display: none;
}

.question-title {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 15px;
    color: var(--text-dark);
    line-height: 1.5;
}

.question-number {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    margin-right: 10px;
}

/* Options Container */
.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-label {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    font-size: 14px;
    background-color: var(--bg-white);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-label:hover {
    border-color: var(--secondary-color);
    background-color: #f8fbfd;
}

.option-label input[type="radio"] {
    margin-right: 15px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.option-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--primary-color);
}

.option-label:has(input:checked) {
    border-color: var(--primary-color);
    background-color: #e8f4f8;
}

/* Likert Scale Specific */
.options-container.likert {
    gap: 8px;
}

.options-container.likert .option-label {
    padding: 10px 14px;
    font-size: 14px;
}

/* Navigation Buttons */
.navigation-buttons {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
    text-align: center;
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 12px 40px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.submit-btn:active {
    transform: translateY(0);
}

/* Results Container */
.results-container {
    padding: 40px 30px;
}

.results-header {
    text-align: center;
    margin-bottom: 40px;
}

.results-header h2 {
    font-size: 2em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

/* Primary Type Display */
.primary-type {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
    margin-bottom: 40px;
}

.type-badge {
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 10px;
}

.type-percentage {
    font-size: 1.5em;
    margin-bottom: 15px;
    opacity: 0.9;
}

.type-description {
    font-size: 1.05em;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0.95;
}

/* Type Breakdown */
.type-breakdown {
    margin-bottom: 40px;
}

.type-breakdown h3 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.type-row {
    display: grid;
    grid-template-columns: 200px 1fr 60px;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
    padding: 12px;
    background-color: var(--bg-light);
    border-radius: 8px;
}

.type-label {
    font-weight: 600;
    color: var(--text-dark);
}

.type-bar-container {
    height: 30px;
    background-color: var(--bg-white);
    border-radius: 15px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.type-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--primary-color));
    border-radius: 15px;
    transition: width 0.5s ease;
}

.type-value {
    font-weight: 700;
    color: var(--primary-color);
    text-align: right;
}

/* Impact Score */
.impact-score {
    margin-bottom: 40px;
    padding: 30px;
    background-color: var(--bg-light);
    border-radius: 12px;
}

.impact-score h3 {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.impact-level {
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.impact-level.great {
    background-color: #d5f4e6;
    border: 2px solid var(--success-color);
}

.impact-level.good {
    background-color: #d4edda;
    border: 2px solid #28a745;
}

.impact-level.medium {
    background-color: #fff3cd;
    border: 2px solid var(--warning-color);
}

.impact-level.high {
    background-color: #ffe5d0;
    border: 2px solid var(--accent-color);
}

.impact-label {
    font-size: 1.8em;
    font-weight: 700;
    margin-bottom: 10px;
}

.impact-level.great .impact-label {
    color: var(--success-color);
}

.impact-level.good .impact-label {
    color: #28a745;
}

.impact-level.medium .impact-label {
    color: var(--warning-color);
}

.impact-level.high .impact-label {
    color: var(--accent-color);
}

.impact-value {
    font-size: 1.2em;
    margin-bottom: 10px;
}

.impact-description {
    font-size: 1.05em;
    margin-top: 15px;
    line-height: 1.6;
}

/* Outcome */
.outcome {
    background: white;
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.outcome h3 {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.outcome-text {
    color: #555;
    font-size: 1em;
    line-height: 1.6;
}

/* Warning/Flags Box */
.warning-box {
    background-color: #fff3cd;
    border: 2px solid var(--warning-color);
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
}

.warning-box h3 {
    color: #856404;
    font-size: 1.4em;
    margin-bottom: 15px;
}

.warning-box p {
    font-size: 1.05em;
    line-height: 1.6;
    margin-bottom: 20px;
}

.resources {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
}

.resources h4 {
    margin-bottom: 10px;
    color: var(--text-dark);
}

.resources ul {
    list-style: none;
    padding-left: 0;
}

.resources li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.resources li:last-child {
    border-bottom: none;
}

.resources strong {
    color: var(--primary-color);
}

/* Results Actions */
.results-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.btn-secondary {
    background-color: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 12px 30px;
    font-size: 1em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Summary Section */
.summary-section {
    background: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.summary-content {
    color: #2c3e50;
    line-height: 1.8;
    font-size: 1em;
    white-space: pre-line;
}

/* Type Card - Option 5 Layout */
.type-card {
    background: white;
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.type-card.collapsed {
    padding-bottom: 12px;
}

.type-card.expanded {
    padding-bottom: 15px;
}

/* Type Header - Name and Percentage */
.type-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.type-name {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary-color);
}

.type-percentage {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 60px;
    text-align: right;
}

/* Bar - Full Width */
.type-bar-wrapper {
    width: 100%;
    height: 24px;
    background: #ecf0f1;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.type-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 14px;
    transition: width 0.5s ease;
}

.impact-bar {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

/* Impact Card - matches type card styling */
.impact-card {
    background: white;
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.impact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.impact-label {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary-color);
}

.impact-score {
    font-size: 1.3em;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 60px;
    text-align: right;
}

.impact-bar-wrapper {
    width: 100%;
    height: 24px;
    background: #ecf0f1;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 8px;
}

.impact-description {
    color: #555;
    font-size: 1em;
    line-height: 1.6;
    margin-top: 8px;
}

/* Goal Card - matches type card styling */
.goal-card {
    background: white;
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.goal-header {
    margin-bottom: 8px;
}

.goal-title {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary-color);
}

.goal-content p {
    color: #555;
    font-size: 1em;
    line-height: 1.6;
    margin: 0;
}

/* Pathway Card - matches type card styling */
.pathway-card {
    background: white;
    padding: 12px 18px;
    border-radius: 10px;
    margin-bottom: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.pathway-header {
    margin-bottom: 8px;
}

.pathway-title {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary-color);
}

.pathway-content p {
    color: #555;
    font-size: 1em;
    line-height: 1.6;
    margin: 0;
}

/* Consumption segmented bar */
.consumption-bar-container {
    position: relative;
    margin-bottom: 8px;
}

.consumption-bar-wrapper {
    width: 100%;
    height: 24px;
    display: flex;
    gap: 2px;
    border-radius: 12px;
    overflow: hidden;
}

.consumption-segment {
    flex: 1;
    height: 100%;
    cursor: pointer;
    position: relative;
    opacity: 0.8;
}

.consumption-segment.active {
    opacity: 1;
}

.consumption-callout {
    width: 100%;
    height: 24px;
    margin-top: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: background-color 0.3s ease;
}

.consumption-callout-arrow {
    position: absolute;
    top: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid inherit;
    transform: translateX(-50%);
    transition: left 0.3s ease;
}

.consumption-callout-arrow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid currentColor;
}

.consumption-callout-label {
    color: white;
    font-weight: 600;
    font-size: 0.8em;
    text-align: center;
    padding: 0 12px;
    line-height: 1.3;
}

.consumption-info {
    font-size: 0.9em;
    color: #666;
    line-height: 1.6;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

/* Toggle Button */
.detail-toggle {
    width: 100%;
    text-align: left;
    padding: 6px 12px;
    background: transparent;
    border: none;
    font-size: 0.9em;
    font-weight: 600;
    color: var(--primary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}

.detail-toggle:hover {
    color: var(--secondary-color);
}

.toggle-icon {
    font-size: 0.8em;
    transition: transform 0.3s;
}

.toggle-text {
    font-size: 0.9em;
}

/* Collapsible Details */
.type-details {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.4s ease, margin-top 0.4s ease;
}

.type-card.collapsed .type-details {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.type-card.expanded .type-details {
    max-height: 2000px;
    opacity: 1;
    margin-top: 15px;
}

.short-desc {
    color: #555;
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
}

.ai-content {
    color: #2c3e50;
    line-height: 1.7;
    font-size: 0.98em;
}

/* Impact Separator */
.impact-separator {
    height: 40px;
    position: relative;
    margin: 30px 0;
}

.impact-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to right, transparent, #dfe6e9, transparent);
}

.impact-section h3 {
    margin-bottom: 20px;
}

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

    .quiz-header h1 {
        font-size: 22px;
    }
    
    .quiz-form {
        padding: 20px;
    }
    
    .section-header {
        margin-left: -20px;
        margin-right: -20px;
        padding: 15px;
    }
    
    .question-title {
        font-size: 15px;
    }

    .option-label {
        padding: 10px 14px;
    }
    
    .type-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .type-value {
        text-align: left;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .btn-secondary {
        width: 100%;
    }

    .summary-section {
        padding: 20px;
    }

    .loading-animation {
        padding: 30px 10px;
    }

    .loading-rings {
        gap: 20px;
    }

    .ring-container {
        width: 60px;
        height: 60px;
    }

    .ring-number {
        font-size: 18px;
    }

    .loading-text {
        font-size: 15px;
        padding: 0 10px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .quiz-container {
        box-shadow: none;
    }
    
    .results-actions {
        display: none;
    }
    
    .type-bar {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* Loading Animation - Three Ring Progress */
.loading-animation {
    text-align: center;
    padding: 40px 20px;
    white-space: normal;
}

.loading-rings {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.ring-container {
    position: relative;
    width: 80px;
    height: 80px;
}

.ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 8;
}

.ring-fill {
    fill: none;
    stroke: #667eea;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
}

.ring-number {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    font-weight: 600;
    color: #667eea;
}

.loading-text {
    font-size: 18px;
    color: #333;
    opacity: 0;
    margin-top: 10px;
}

/* Stage 1: Ring 1 fills, text shows */
.ring-1 {
    animation: fillRing 2s ease-out forwards;
}

.loading-text.stage-1 {
    animation: showText 2s ease-out forwards;
}

/* Stage 2: Ring 2 fills, text shows (delayed) */
.ring-2 {
    animation: fillRing 2s ease-out 2s forwards;
}

.loading-text.stage-2 {
    animation: showText 2s ease-out 2s forwards;
}

/* Stage 3: Ring 3 fills, text shows and pulses (delayed) */
.ring-3 {
    animation: fillRing 2s ease-out 4s forwards, pulseRing 1.5s ease-in-out 6s infinite;
}

.loading-text.stage-3 {
    animation: showText 2s ease-out 4s forwards, pulseText 1.5s ease-in-out 6s infinite;
}

/* Keyframe Animations */
@keyframes fillRing {
    from {
        stroke-dashoffset: 283;
    }
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes showText {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes hideText {
    to {
        opacity: 0;
    }
}

@keyframes pulseText {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.2;
    }
}

@keyframes pulseRing {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

/* Validation Error Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.validation-error {
    animation: fadeIn 0.3s ease-in;
}

/* Progress Ring (HIDDEN mode section reveals) */
.progress-ring-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.progress-ring-overlay:not(.hidden) {
    opacity: 1;
}

.progress-ring-container {
    position: relative;
    width: 120px;
    height: 120px;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.2);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292; /* 2 * π * 54 */
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 0.8s ease-out;
}

.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.progress-ring-text span {
    font-size: 24px;
    font-weight: 700;
    color: white;
}

/* Progress ring gradient (brand colors) */
svg {
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

@media (prefers-reduced-motion: reduce) {
    .progress-ring-fill {
        transition: none;
    }
}
