/* TypeForm-Style Survey System - Glass Morphism Design
 * Optimized for adult gamers with high conversion rates
 * Follows The Smithy's brand aesthetic
 */

:root {
    /* Survey-specific timing variables */
    --survey-transition-enter: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    --survey-transition-exit: 0.4s cubic-bezier(0.5, 0, 0.75, 0);
    --survey-transition-slide: 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Progress bar colors */
    --progress-bg: rgba(255, 255, 255, 0.05);
    --progress-fill: linear-gradient(90deg, var(--brand-purple), var(--brand-blue), var(--brand-mint));
}

/* ==================== CONTAINER & LAYOUT ==================== */

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

.survey-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg,
        rgba(123, 68, 193, 0.3) 0%,
        rgba(20, 20, 30, 0.98) 20%,
        rgba(15, 15, 25, 0.98) 80%,
        rgba(30, 150, 252, 0.3) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    animation: fadeIn 0.6s ease-out forwards;
}

.survey-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-start; /* Align to top to respect padding */
    justify-content: center;
    padding: 2rem;
    padding-top: 5rem; /* Reduced padding now that cards use relative positioning */
    padding-bottom: 3rem; /* Space for mobile browser chrome */
    position: relative;
    overflow-y: auto; /* Allow scrolling for long questions */
    overflow-x: hidden;
}

.survey-question-container {
    width: 100%;
    max-width: 720px;
    position: relative;
    min-height: 400px;
}

/* ==================== PROGRESS BAR ==================== */

.survey-progress-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    right: 0; /* Full width for proper centering */
    z-index: 1001;
    /* Smokey glass effect matching dashboard-hero */
    background: linear-gradient(135deg,
        rgba(50, 48, 49, 0.35) 0%,
        rgba(30, 30, 30, 0.25) 50%,
        rgba(45, 45, 45, 0.35) 100%
    );
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    padding: 1rem 2rem;
    padding-right: 80px; /* Padding on right for close button space */
    border-bottom: none; /* Remove border as requested */
    box-shadow: 0 2px 16px 0 rgba(0, 0, 0, 0.3);
}

.survey-progress-bar-container {
    position: relative;
    height: 6px;
    background: var(--progress-bg);
    border-radius: 100px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.survey-progress-bar {
    height: 100%;
    background: var(--progress-fill);
    border-radius: 100px;
    transition: width var(--survey-transition-slide);
    position: relative;
    box-shadow: 0 0 20px rgba(154, 213, 202, 0.5);
}

.survey-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent);
    animation: shimmerProgress 2s infinite;
}

@keyframes shimmerProgress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.survey-progress-text {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--brand-cloud);
    opacity: 0.7;
    text-align: center;
    text-transform: lowercase;
}

/* ==================== QUESTION CARD ==================== */

.survey-question-card {
    /* Enhanced glass morphism from dashboard-hero */
    background: linear-gradient(135deg,
        rgba(50, 48, 49, 0.35) 0%,
        rgba(30, 30, 30, 0.25) 50%,
        rgba(45, 45, 45, 0.35) 100%
    );

    /* Improved backdrop filtering */
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);

    /* Enhanced border */
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 3rem 2.5rem;

    /* Multi-layered shadow for depth */
    box-shadow:
        0 8px 32px 0 rgba(31, 38, 135, 0.2),
        0 2px 16px 0 rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);

    /* Better text rendering on glass */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);

    /* Performance optimization */
    transform: translate3d(0, 0, 0) translateX(100px);
    will-change: backdrop-filter, transform, opacity;

    /* Force clear space from top */
    margin-top: 0;
    position: relative;
    width: 100%;
    opacity: 0;
    pointer-events: none;
    transition: all var(--survey-transition-enter);
}

.survey-question-card.active {
    opacity: 1;
    transform: translate3d(0, 0, 0) translateX(0);
    pointer-events: all;
}

.survey-question-card.exiting {
    opacity: 0;
    transform: translateX(-100px);
    transition: all var(--survey-transition-exit);
}

/* Entry animation variation */
.survey-question-card.entering-forward {
    transform: translateX(100px);
}

.survey-question-card.entering-backward {
    transform: translateX(-100px);
}

.survey-question-card.active.from-forward {
    animation: slideInFromRight var(--survey-transition-enter);
}

.survey-question-card.active.from-backward {
    animation: slideInFromLeft var(--survey-transition-enter);
}

@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== QUESTION HEADER ==================== */

.survey-question-number {
    font-size: 0.875rem;
    color: var(--brand-mint);
    margin-bottom: 1rem;
    text-transform: lowercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.survey-question-number::before {
    content: '';
    width: 24px;
    height: 2px;
    background: linear-gradient(90deg, var(--brand-mint), transparent);
}

.survey-question-title {
    font-size: 2rem;
    font-weight: 700;
    color: #EBEBEB;
    margin-bottom: 0.75rem;
    line-height: 1.3;
    text-transform: lowercase;
}

.survey-question-subtitle {
    font-size: 1rem;
    color: rgba(235, 235, 235, 0.7);
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* ==================== ANSWER OPTIONS ==================== */

.survey-answers {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Multiple Choice Options */
.survey-option {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    color: #EBEBEB;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-transform: lowercase;
}

.survey-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--brand-mint);
    transform: scaleY(0);
    transition: transform var(--transition-normal);
}

.survey-option:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(154, 213, 202, 0.4);
    transform: translateX(8px);
    box-shadow: 0 4px 16px rgba(154, 213, 202, 0.15);
}

.survey-option:hover::before {
    transform: scaleY(1);
}

.survey-option.selected {
    background: rgba(154, 213, 202, 0.1);
    border-color: var(--brand-mint);
    box-shadow: 0 4px 20px rgba(154, 213, 202, 0.25);
}

.survey-option.selected::before {
    transform: scaleY(1);
    background: linear-gradient(180deg, var(--brand-mint), var(--brand-blue));
}

.survey-option-indicator {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all var(--transition-normal);
}

.survey-option.selected .survey-option-indicator {
    border-color: var(--brand-mint);
    background: var(--brand-mint);
    box-shadow: 0 0 12px rgba(154, 213, 202, 0.6);
}

.survey-option.selected .survey-option-indicator::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--brand-charcoal);
    font-size: 14px;
    font-weight: 700;
}

.survey-option-text {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 500;
}

/* Keyboard hint for power users */
.survey-option-key {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.4);
    font-family: 'Monaco', 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== SCALE/RATING INPUTS ==================== */

.survey-scale-container {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 2rem 0;
}

.survey-scale-option {
    flex: 1;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--brand-cloud);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.survey-scale-option:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(154, 213, 202, 0.4);
    transform: scale(1.1);
}

.survey-scale-option.selected {
    background: var(--brand-mint);
    border-color: var(--brand-mint);
    color: var(--brand-charcoal);
    box-shadow: 0 4px 20px rgba(154, 213, 202, 0.4);
    transform: scale(1.15);
}

.survey-scale-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: 0.875rem;
    color: rgba(235, 235, 235, 0.6);
    text-transform: lowercase;
}

/* ==================== TEXT INPUT ==================== */

.survey-text-input,
.survey-textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    color: var(--brand-cloud);
    font-size: 1.125rem;
    font-family: inherit;
    transition: all var(--transition-normal);
    resize: none;
}

.survey-text-input:focus,
.survey-textarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--brand-mint);
    box-shadow: 0 0 0 4px rgba(154, 213, 202, 0.15);
}

.survey-text-input::placeholder,
.survey-textarea::placeholder {
    color: rgba(235, 235, 235, 0.4);
}

.survey-textarea {
    min-height: 120px;
    line-height: 1.6;
}

.survey-char-count {
    text-align: right;
    font-size: 0.875rem;
    color: rgba(235, 235, 235, 0.5);
    margin-top: 0.5rem;
}

/* Input with prefix/suffix (for pricing questions) */
.input-with-affix {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.input-prefix,
.input-suffix {
    font-size: 1.125rem;
    color: rgba(235, 235, 235, 0.7);
    font-weight: 500;
    flex-shrink: 0;
}

.input-with-affix .survey-text-input {
    flex: 1;
    min-width: 0;
}

/* ==================== MATRIX/GRID QUESTIONS ==================== */

.survey-matrix {
    margin: 2rem 0;
    overflow-x: auto;
}

.survey-matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0.5rem;
}

.survey-matrix-header {
    text-align: center;
    font-size: 0.875rem;
    color: var(--brand-mint);
    padding: 0.75rem;
    text-transform: lowercase;
}

.survey-matrix-row-label {
    color: var(--brand-cloud);
    padding: 1rem;
    font-weight: 500;
    text-transform: lowercase;
}

.survey-matrix-cell {
    text-align: center;
}

.survey-matrix-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.survey-matrix-option:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(154, 213, 202, 0.4);
    transform: scale(1.15);
}

.survey-matrix-option.selected {
    background: var(--brand-mint);
    border-color: var(--brand-mint);
    box-shadow: 0 4px 16px rgba(154, 213, 202, 0.4);
}

/* ==================== NAVIGATION BUTTONS ==================== */

.survey-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2.5rem;
    gap: 1rem;
}

.survey-btn {
    padding: 0.875rem 2rem;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    text-transform: lowercase;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.survey-btn-back {
    background: transparent;
    color: var(--brand-cloud);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.survey-btn-back:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateX(-4px);
}

.survey-btn-next,
.survey-btn-submit {
    background: var(--brand-mint);
    color: var(--brand-charcoal);
    border: 2px solid var(--brand-mint);
    margin-left: auto;
    box-shadow: 0 4px 16px rgba(154, 213, 202, 0.3);
}

.survey-btn-next:hover,
.survey-btn-submit:hover {
    background: #7DCBB8;
    transform: translateX(4px);
    box-shadow: 0 6px 24px rgba(154, 213, 202, 0.5);
}

.survey-btn-next:disabled,
.survey-btn-submit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.survey-btn-skip {
    background: transparent;
    color: rgba(235, 235, 235, 0.5);
    border: none;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    text-decoration: underline;
}

.survey-btn-skip:hover {
    color: var(--brand-cloud);
}

/* ==================== COMPLETION SCREEN ==================== */

.survey-complete {
    text-align: center;
    padding: 3rem 2rem;
}

.survey-complete-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    animation: scaleInBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scaleInBounce {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.survey-complete-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--brand-cloud);
    margin-bottom: 1rem;
    text-transform: lowercase;
}

.survey-complete-subtitle {
    font-size: 1.25rem;
    color: rgba(235, 235, 235, 0.7);
    margin-bottom: 2rem;
}

.survey-complete-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 2rem 0;
}

.survey-stat {
    text-align: center;
}

.survey-stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--brand-mint);
    display: block;
}

.survey-stat-label {
    font-size: 0.875rem;
    color: rgba(235, 235, 235, 0.6);
    text-transform: lowercase;
}

.survey-complete-cta {
    background: var(--brand-purple);
    color: var(--brand-cloud);
    border: 2px solid var(--brand-cloud);
    padding: 1rem 3rem;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: 0 4px 20px rgba(123, 68, 193, 0.4);
    text-transform: lowercase;
    display: inline-block;
    text-decoration: none;
}

.survey-complete-cta:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 32px rgba(123, 68, 193, 0.6);
    background: linear-gradient(to bottom,
        var(--gradient-blue-start) 5%,
        var(--gradient-purple-start) 100%);
}

/* ==================== CLOSE BUTTON ==================== */

.survey-close {
    position: fixed;
    top: 1rem;
    right: 1.5rem;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1002;
    color: #EBEBEB;
    font-size: 1.5rem;
    font-weight: 300;
}

.survey-close:hover {
    background: rgba(255, 59, 48, 0.2);
    border-color: rgba(255, 59, 48, 0.4);
    transform: rotate(90deg);
}

/* ==================== LOADING STATE ==================== */

.survey-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.survey-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--brand-mint);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== MOBILE RESPONSIVE ==================== */

@media (max-width: 768px) {
    .survey-progress-wrapper {
        padding: 0.75rem 1rem;
        padding-right: 70px; /* Smaller gap on mobile */
    }

    .survey-close {
        top: 0.75rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .survey-wrapper {
        padding: 1rem;
        padding-top: 6rem; /* Extra space for progress bar on mobile */
        padding-bottom: 6rem; /* Extra space for iOS chrome bar */
        align-items: flex-start; /* Align to top instead of center */
    }

    .survey-question-card {
        padding: 2rem 1.5rem;
        min-height: auto;
        position: relative; /* Override absolute positioning on mobile */
    }

    .survey-question-title {
        font-size: 1.5rem;
    }

    .survey-option {
        padding: 1rem;
    }

    .survey-option-text {
        font-size: 1rem;
    }

    .survey-option-key {
        display: none; /* Hide keyboard shortcuts on mobile */
    }

    .survey-scale-container {
        gap: 0.25rem;
    }

    .survey-scale-option {
        font-size: 1.25rem;
    }

    .survey-complete-stats {
        flex-direction: column;
        gap: 1.5rem;
    }

    .survey-navigation {
        flex-direction: column-reverse;
        gap: 0.75rem;
    }

    .survey-btn {
        width: 100%;
        justify-content: center;
    }

    .survey-btn-next {
        margin-left: 0;
    }

    .survey-matrix {
        overflow-x: scroll;
    }
}

/* ==================== ACCESSIBILITY ==================== */

/* Keyboard focus states */
.survey-option:focus-visible,
.survey-scale-option:focus-visible,
.survey-btn:focus-visible {
    outline: 3px solid var(--brand-mint);
    outline-offset: 3px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .survey-question-card,
    .survey-option,
    .survey-btn,
    .survey-progress-bar {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* ==================== ENGAGEMENT MICRO-INTERACTIONS ==================== */

/* Confetti effect for completion */
.survey-confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--brand-mint);
    opacity: 0;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

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

.survey-question-card.validation-error {
    animation: shake 0.5s;
    border-color: rgba(255, 59, 48, 0.5);
}

/* Pulse animation for CTA */
@keyframes ctaPulse {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(123, 68, 193, 0.4);
    }
    50% {
        box-shadow: 0 4px 32px rgba(123, 68, 193, 0.7);
    }
}

.survey-complete-cta {
    animation: ctaPulse 2s infinite;
}

/* Typing indicator for text inputs */
.survey-typing-indicator {
    display: inline-flex;
    gap: 4px;
    margin-left: 0.5rem;
}

.survey-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--brand-mint);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.survey-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.survey-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}
