/* =============================================
   DESIGN SYSTEM — Badanie Reprodukcji Czasu
   ============================================= */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #06060f;
    --bg-secondary: #0c0c1a;
    --bg-card: rgba(14, 14, 28, 0.75);
    --bg-card-hover: rgba(20, 20, 40, 0.85);
    --border-card: rgba(124, 58, 237, 0.12);
    --border-subtle: rgba(255, 255, 255, 0.06);

    --text-primary: #eae8f2;
    --text-secondary: #9e9ab4;
    --text-muted: #5d5878;
    --text-heading: #f4f2ff;

    --accent-primary: #7c3aed;
    --accent-secondary: #6366f1;
    --accent-blue: #3b82f6;
    --accent-gradient: linear-gradient(135deg, #7c3aed 0%, #6366f1 50%, #3b82f6 100%);
    --accent-glow: rgba(124, 58, 237, 0.35);
    --accent-glow-soft: rgba(124, 58, 237, 0.10);

    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.3);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.08);
    --warning: #f59e0b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border-card);
    --shadow-glow: 0 0 40px var(--accent-glow-soft);
    --shadow-btn: 0 4px 20px rgba(124, 58, 237, 0.3);
    --shadow-btn-hover: 0 6px 30px rgba(124, 58, 237, 0.5);

    --transition-fast: 0.15s ease;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.65;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Animated Background ---------- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse 80% 60% at 20% 10%, rgba(124, 58, 237, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 80% at 80% 90%, rgba(59, 130, 246, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse 50% 50% at 50% 50%, rgba(99, 102, 241, 0.03) 0%, transparent 70%);
    z-index: -1;
    pointer-events: none;
    animation: bgShift 25s ease-in-out infinite alternate;
}

@keyframes bgShift {
    0%   { opacity: 0.8; transform: scale(1); }
    100% { opacity: 1;   transform: scale(1.05); }
}


/* ---------- Progress Bar ---------- */
#progress-bar-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.04);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

#progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent-gradient);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

#progress-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: -2px;
    width: 80px;
    height: 7px;
    background: var(--accent-primary);
    border-radius: 50%;
    filter: blur(6px);
    opacity: 0.7;
}

#progress-text {
    position: fixed;
    top: 14px;
    right: 28px;
    font-size: 0.7rem;
    color: var(--text-muted);
    z-index: 1000;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}


/* ---------- Sections ---------- */
.section {
    display: none;
    min-height: 100vh;
    padding: 60px 20px 40px;
    justify-content: center;
    align-items: center;
}

.section.active {
    display: flex;
}


/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    max-width: 560px;
    width: 100%;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.3), transparent);
}

.card-wide {
    max-width: 780px;
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    display: block;
    text-align: center;
    filter: drop-shadow(0 0 12px var(--accent-glow));
}


/* ---------- Typography ---------- */
h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-heading);
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 16px;
    text-align: center;
}

h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 10px;
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 28px;
    font-weight: 400;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 0.92rem;
    line-height: 1.7;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.footnote {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 24px;
    line-height: 1.6;
}


/* ---------- Info & Warning Boxes ---------- */
.info-box {
    background: rgba(124, 58, 237, 0.05);
    border: 1px solid rgba(124, 58, 237, 0.12);
    border-radius: var(--radius-md);
    padding: 24px 28px;
    margin: 24px 0;
    font-size: 0.92rem;
    line-height: 1.7;
}

.info-box p {
    margin-bottom: 12px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

.info-box ol {
    margin: 12px 0;
    padding-left: 24px;
}

.info-box ol li {
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.info-box ol li strong {
    color: var(--text-primary);
}

.warning-box {
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin: 16px 0;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

kbd {
    display: inline-block;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 2px 8px;
    font-family: var(--font);
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-primary);
}


/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.02em;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    padding: 14px 36px;
    box-shadow: var(--shadow-btn);
    margin-top: 16px;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-btn-hover);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
    filter: brightness(0.95);
}

.btn-large {
    padding: 18px 48px;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, transparent 50%);
    pointer-events: none;
}


/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 24px;
}

.form-group > label:first-child {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: 0.01em;
}

input[type="number"],
select {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

input[type="number"]:focus,
select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
    background: rgba(255, 255, 255, 0.06);
}

input[type="number"]::placeholder {
    color: var(--text-muted);
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239e9ab4' viewBox='0 0 16 16'%3E%3Cpath d='M1.5 5.5l6.5 6.5 6.5-6.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

select option {
    background: #1a1a2e;
    color: var(--text-primary);
}

.error-msg {
    display: block;
    color: var(--error);
    font-size: 0.8rem;
    margin-top: 6px;
    min-height: 1.2em;
    font-weight: 500;
}

input.input-error,
select.input-error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px var(--error-bg);
}


/* ---------- Custom Radio Buttons ---------- */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.radio-label:hover {
    background: rgba(124, 58, 237, 0.06);
    border-color: rgba(124, 58, 237, 0.15);
    color: var(--text-primary);
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: all var(--transition-fast);
}

.radio-label input[type="radio"]:checked + .radio-custom {
    border-color: var(--accent-primary);
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-glow);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.radio-label:has(input[type="radio"]:checked) {
    background: rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.25);
    color: var(--text-primary);
}


/* ---------- Questionnaire Questions ---------- */
.question-block {
    margin-bottom: 24px;
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.question-block:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

.question-block.answered {
    border-color: rgba(16, 185, 129, 0.15);
    background: rgba(16, 185, 129, 0.03);
}

.question-text {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 14px;
    line-height: 1.6;
}

.question-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--accent-gradient);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    margin-right: 10px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* ASRS-style options (horizontal chips) */
.options-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.option-chip {
    flex: 1;
    min-width: 80px;
}

.option-chip input[type="radio"] {
    display: none;
}

.option-chip label {
    display: block;
    text-align: center;
    padding: 10px 6px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.3;
}

.option-chip label:hover {
    background: rgba(124, 58, 237, 0.06);
    border-color: rgba(124, 58, 237, 0.15);
    color: var(--text-secondary);
}

.option-chip input[type="radio"]:checked + label {
    background: rgba(124, 58, 237, 0.15);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.15);
    font-weight: 600;
}

/* Zwlekanie numeric scale (1-5) */
.scale-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.scale-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.scale-option {
    position: relative;
}

.scale-option input[type="radio"] {
    display: none;
}

.scale-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.scale-option label:hover {
    background: rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.2);
    color: var(--text-secondary);
}

.scale-option input[type="radio"]:checked + label {
    background: var(--accent-gradient);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.3);
}

.part-label {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-primary);
    margin: 28px 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.15);
    text-align: left;
}

.part-label:first-child {
    margin-top: 8px;
}


/* ---------- Experiment ---------- */
.experiment-fullscreen {
    padding: 0 !important;
    background: #030308;
    position: relative;
    flex-direction: column;
}

#experiment-progress {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

#trial-counter {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 20px;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

#experiment-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    position: relative;
}

.exp-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    position: absolute;
    inset: 0;
    animation: fadeInExp 0.4s ease;
}

@keyframes fadeInExp {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

.exp-message {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-heading);
    letter-spacing: -0.01em;
    text-align: center;
}

.exp-hint {
    font-size: 1rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 400;
}

.exp-hint kbd {
    font-size: 0.9em;
}

/* Get Ready dots animation */
.exp-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
    opacity: 0.3;
}

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

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* Stimulus circle */
#stimulus-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: var(--accent-gradient);
    box-shadow: 0 0 60px var(--accent-glow), 0 0 120px rgba(124, 58, 237, 0.15);
    animation: stimulusAppear 0.3s ease;
}

@keyframes stimulusAppear {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 1; transform: scale(1); }
}

/* Reproducing ring */
#reproducing-ring {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 4px solid var(--accent-primary);
    background: transparent;
    position: relative;
    animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(124, 58, 237, 0.2), inset 0 0 20px rgba(124, 58, 237, 0.05);
    }
    50% {
        box-shadow: 0 0 40px rgba(124, 58, 237, 0.4), inset 0 0 30px rgba(124, 58, 237, 0.1);
    }
}

/* Trial complete check */
.exp-check {
    font-size: 4rem;
    color: var(--success);
    text-shadow: 0 0 30px var(--success-glow);
    animation: checkPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes checkPop {
    from { opacity: 0; transform: scale(0.3); }
    to   { opacity: 1; transform: scale(1); }
}


/* ---------- Results Summary ---------- */
.results-summary {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 24px;
    margin: 24px 0;
    font-size: 0.9rem;
}

.results-summary h4 {
    color: var(--text-heading);
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.results-summary p {
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.results-summary .result-value {
    color: var(--accent-primary);
    font-weight: 700;
}

/* Save status messages */
.save-status {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    margin: 12px 0;
    text-align: center;
}

.save-success {
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.save-error {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

/* ---------- Animations ---------- */
.fade-in {
    animation: fadeIn 0.6s ease;
}

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

.section.transitioning-out {
    animation: fadeOut 0.3s ease forwards;
}

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


/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}


/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .card {
        padding: 32px 20px;
        border-radius: var(--radius-lg);
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .options-row {
        flex-direction: column;
    }

    .option-chip {
        min-width: auto;
    }

    .scale-legend {
        flex-direction: column;
        gap: 4px;
    }

    #stimulus-circle,
    #reproducing-ring {
        width: 140px;
        height: 140px;
    }

    .exp-message {
        font-size: 1.5rem;
    }
}

/* ---------- Hide progress bar during experiment ---------- */
.experiment-active #progress-bar-container,
.experiment-active #progress-text {
    display: none;
}

/* Number input arrows removal */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}
