/**
 * Survey runtime styles
 * Styles for the survey taking interface
 */

:root {
    --survey-bg: var(--eggshell-white, #F5F3EB);
    --survey-text: var(--street-asphalt, #2C2C2C);
    --survey-primary: var(--bridge-green, #00FF99);
    --survey-primary-dark: var(--deep-truss-green, #00775C);
    --survey-border: #e0e0e0;
    --survey-error: var(--traffic-light-red, #D94F4F);
    --survey-layout-max: 1400px;
}

body:has(.survey-container) {
    padding: 1rem;
}

.survey-container {
    min-height: calc(100vh - 2rem);
    background: var(--survey-bg);
    width: 100%;
    max-width: var(--survey-layout-max);
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.survey-header {
    margin-bottom: 1.25rem;
}

.survey-title {
    margin: 0 0 0.35rem;
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 700;
    color: var(--survey-text);
    line-height: 1.2;
}

.survey-description {
    margin: 0;
    color: var(--survey-text);
    opacity: 0.75;
    line-height: 1.5;
}

.survey-shell {
    display: flex;
    gap: 1rem;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

.survey-rail-wrap {
    position: relative;
    flex: 0 0 clamp(200px, 22vw, 260px);
    width: clamp(200px, 22vw, 260px);
    align-self: stretch;
}

.survey-rail {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: 1rem;
    border: 1px solid var(--survey-border);
    border-radius: 8px;
    background: white;
    scrollbar-gutter: stable;
}

.survey-rail-list {
    display: grid;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.survey-rail-step {
    width: 100%;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--survey-text);
    font: inherit;
    font-size: 0.88rem;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
}

.survey-rail-step span {
    width: 1.5rem;
    height: 1.5rem;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--survey-border);
    border-radius: 50%;
    font-size: 0.82rem;
    flex: 0 0 auto;
    margin-top: 0.05rem;
}

.survey-rail-step.is-current {
    background: rgba(0, 119, 92, 0.1);
    font-weight: 800;
}

.survey-rail-step.is-current span {
    border-color: var(--survey-primary-dark);
    background: var(--survey-primary-dark);
    color: white;
}

.survey-rail-step:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.survey-main {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
    border: 1px solid var(--survey-border);
    border-radius: 8px;
    background: white;
}

.survey-mobile-step {
    display: none;
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.75rem 0.875rem;
    font: inherit;
    font-size: 1rem;
    border: 2px solid var(--survey-border);
    border-radius: 8px;
    background: white;
    color: var(--survey-text);
}

.survey-progress {
    width: 100%;
    margin: 0 0 1.25rem;
}

.progress-bar {
    height: 0.55rem;
    background: var(--survey-border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.35rem;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--survey-primary-dark);
    transition: width 0.3s ease;
    border-radius: inherit;
}

.progress-text {
    font-size: 0.9rem;
    color: var(--survey-text);
    opacity: 0.75;
}

.question-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    min-height: 0;
    transition: opacity 0.15s ease;
}

.question-wrapper {
    width: 100%;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
}

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

.question-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--survey-text);
    line-height: 1.4;
}

.required-indicator {
    color: var(--survey-error);
}

.question-body {
    /* Specific styles in question type sections */
}

.input-container {
    margin-bottom: 1rem;
}

.question-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    border: 2px solid var(--survey-border);
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.question-input:focus {
    outline: none;
    border-color: var(--survey-primary);
}

.question-input.invalid {
    border-color: var(--survey-error);
    border-width: 2px;
    background-color: rgba(217, 79, 79, 0.05);
    animation: shake 0.4s ease-in-out;
}

.question-input.invalid:focus {
    border-color: var(--survey-error);
    box-shadow: 0 0 0 3px rgba(217, 79, 79, 0.1);
}

.question-input-textarea {
    resize: vertical;
    min-height: 120px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.option-wrapper {
    display: flex;
    align-items: center;
    padding: 1rem;
    border: 2px solid var(--survey-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-wrapper:hover {
    border-color: var(--survey-primary);
    background: rgba(0, 255, 153, 0.05);
}

.option-radio,
.option-checkbox {
    margin-right: 0.75rem;
    cursor: pointer;
}

.option-radio:checked + .option-label,
.option-checkbox:checked + .option-label {
    font-weight: 600;
    color: var(--survey-primary-dark);
}

.option-label {
    flex: 1;
    cursor: pointer;
    margin: 0;
}

.option-other-input {
    margin-left: 1rem;
    padding: 0.5rem;
    border: 1px solid var(--survey-border);
    border-radius: 4px;
    flex: 1;
}

.yes-no-container {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn-yes-no {
    flex: 1;
    padding: 1.25rem 2rem;
    font-size: 1.125rem;
    font-weight: 600;
    border: 2px solid var(--survey-border);
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-yes-no:hover {
    border-color: var(--survey-primary);
    background: rgba(0, 255, 153, 0.05);
}

.btn-yes-no.selected {
    border-color: var(--survey-primary);
    background: var(--survey-primary);
    color: var(--survey-text);
}

.validation-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(217, 79, 79, 0.1);
    border-left: 3px solid var(--survey-error);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    color: var(--survey-error);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    pointer-events: none;
}

.validation-error.show {
    opacity: 1;
    transform: translateY(0);
}

.validation-error-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    color: var(--survey-error);
    display: inline-block;
}

.validation-error-icon::before {
    content: '⚠';
    font-size: 1.25rem;
    line-height: 1;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .validation-error {
        transition: opacity 0.1s ease-out;
        transform: none;
    }
    
    .validation-error.show {
        transform: none;
    }
    
    .question-input.invalid {
        animation: none;
    }
}

.navigation-container {
    width: 100%;
    margin-top: 1.25rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-back {
    background: transparent;
    border: 2px solid var(--survey-border);
    color: var(--survey-text);
}

.btn-back:hover:not(:disabled) {
    border-color: var(--survey-primary);
}

.btn-next {
    background: var(--survey-primary);
    color: var(--survey-text);
    margin-left: auto;
}

.btn-next:hover:not(:disabled) {
    background: var(--neon-glow, #00D4B0);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 153, 0.3);
}

.thank-you-container {
    text-align: center;
    padding: 4rem 2rem;
}

.thank-you-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--survey-primary-dark);
    margin-bottom: 1rem;
}

.thank-you-message {
    font-size: 1.25rem;
    color: var(--survey-text);
    opacity: 0.8;
    margin-bottom: 2rem;
}

.btn-home {
    display: inline-block;
    margin-top: 2rem;
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
    background: var(--survey-primary);
    color: var(--survey-text);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-home:hover {
    background: var(--neon-glow, #00D4B0);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 153, 0.3);
}

/* Mobile responsive */
@media (max-width: 820px) {
    body:has(.survey-container) {
        padding: 0.75rem;
    }

    .survey-container {
        min-height: calc(100vh - 1.5rem);
    }

    .survey-shell {
        display: block;
    }

    .survey-rail-wrap {
        display: none;
    }

    .survey-main {
        padding: 1rem;
    }

    .survey-mobile-step {
        display: block;
    }

    .navigation-container {
        justify-content: stretch;
    }

    .navigation-container .btn {
        flex: 1;
    }

    .thank-you-container {
        padding-top: 4rem;
        padding-bottom: 4rem;
        padding-left: var(--page-gutter-left);
        padding-right: var(--page-gutter-right);
    }
    
    .question-wrapper {
        padding: 2rem 1.5rem;
    }
    
    .question-title {
        font-size: 1.5rem;
    }
    
    .yes-no-container {
        flex-direction: column;
    }
}
