/**
 * Hamming Simulator - Teaching Version
 *
 * Focus: Make the binary fingerprint insight visible
 */

.hamming-sim {
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
    max-width: 580px;
    margin: 2rem auto;
    padding: 2rem;
    background: var(--surface-primary, #ffffff);
    border-radius: 16px;
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
}

/* Instruction */
.instruction {
    text-align: center;
    font-size: 1.125rem;
    color: var(--text-secondary, #666);
    margin-bottom: 1.5rem;
}

.instruction strong {
    color: var(--text-primary, #1d1d1f);
}

/* Data Input */
.data-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.data-label {
    font-size: 0.875rem;
    color: var(--text-tertiary, #888);
}

.data-inputs {
    display: flex;
    gap: 0.5rem;
}

.data-bit {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border, #ddd);
    border-radius: 8px;
    background: var(--surface-secondary, #f5f5f7);
    font-size: 1.125rem;
    font-weight: 600;
    font-family: var(--font-mono, 'SF Mono', Monaco, monospace);
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-secondary, #666);
}

.data-bit:hover {
    border-color: var(--color-primary, #007aff);
}

.data-bit.on {
    background: var(--color-primary, #007aff);
    border-color: var(--color-primary, #007aff);
    color: white;
}

.reset-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text-tertiary, #888);
    border: 1px solid var(--border, #ddd);
    border-radius: 8px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.reset-btn:hover {
    background: var(--surface-secondary, #f5f5f7);
    color: var(--text-primary, #1d1d1f);
}

/* Encode Arrow */
.encode-arrow {
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-tertiary, #999);
    margin-bottom: 1rem;
}

/* Bit Visualization */
.bit-visualization {
    background: var(--surface-secondary, #f9f9fb);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.bit-row {
    display: flex;
    justify-content: center;
    gap: 0.625rem;
}

.bit-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

/* Binary address - the key insight */
.binary-label {
    font-size: 0.6875rem;
    font-family: var(--font-mono, 'SF Mono', Monaco, monospace);
    color: var(--text-tertiary, #aaa);
    letter-spacing: 0.05em;
}

.bit-circle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono, 'SF Mono', Monaco, monospace);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface-primary, #fff);
}

.bit-circle.parity {
    border-color: #8e8e93;
    color: #8e8e93;
}

.bit-circle.data {
    border-color: #007aff;
    color: #007aff;
}

.bit-circle:hover {
    transform: scale(1.08);
}

/* Positions covered by failing checks */
.bit-circle.in-group {
    background: #ff95001a;
    border-color: #ff9500;
}

/* The error position */
.bit-circle.error-found {
    background: #ff3b30;
    border-color: #ff3b30;
    color: white;
    animation: pulse 0.6s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.pos-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary, #999);
}

/* Detective Section - the teaching moment */
.detective-section {
    background: linear-gradient(135deg, #f0f7ff 0%, #fff5f0 100%);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid rgba(0, 122, 255, 0.15);
}

.detective-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    margin-bottom: 0.75rem;
}

.detective-clues {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.clue {
    font-size: 0.875rem;
    font-family: var(--font-mono, 'SF Mono', Monaco, monospace);
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    background: white;
}

.clue.failed {
    background: #ff3b3015;
    color: #cc2f27;
}

.clue.passed {
    background: #34c75915;
    color: #248a3d;
}

.check-name {
    font-weight: 700;
}

/* Conclusion */
.detective-conclusion {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 2px solid #007aff;
}

.conclusion-arrow {
    font-size: 1.25rem;
    color: #007aff;
}

.conclusion-text {
    font-size: 0.9375rem;
    color: var(--text-primary, #1d1d1f);
}

.conclusion-text strong {
    color: #007aff;
}

.binary-proof {
    font-family: var(--font-mono, 'SF Mono', Monaco, monospace);
    font-size: 0.8125rem;
    color: var(--text-tertiary, #888);
    margin-left: 0.25rem;
}

.binary-proof sub {
    font-size: 0.625rem;
}

/* Fix Button */
.correct-btn {
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: #34c759;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.correct-btn:hover {
    background: #2da44e;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .hamming-sim {
        background: #1c1c1e;
        border-color: #38383a;
    }

    .bit-visualization {
        background: #2c2c2e;
    }

    .data-bit {
        background: #3a3a3c;
        border-color: #48484a;
        color: #fff;
    }

    .bit-circle {
        background: #2c2c2e;
    }

    .bit-circle.error-found {
        background: #ff3b30;
    }

    .bit-circle.in-group {
        background: #ff950030;
    }

    .reset-btn {
        border-color: #48484a;
    }

    .detective-section {
        background: linear-gradient(135deg, #1a2a3a 0%, #2a1a1a 100%);
        border-color: rgba(0, 122, 255, 0.3);
    }

    .clue {
        background: #2c2c2e;
    }

    .clue.failed {
        background: #ff3b3025;
        color: #ff6961;
    }

    .clue.passed {
        background: #34c75925;
        color: #4cd964;
    }

    .detective-conclusion {
        background: #2c2c2e;
        border-color: #0a84ff;
    }

    .conclusion-arrow {
        color: #0a84ff;
    }

    .conclusion-text strong {
        color: #0a84ff;
    }
}

/* Responsive */
@media (max-width: 500px) {
    .hamming-sim {
        padding: 1.25rem 1rem;
        margin: 1rem;
    }

    .data-section {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .bit-circle {
        width: 38px;
        height: 38px;
        font-size: 1.125rem;
    }

    .bit-row {
        gap: 0.375rem;
    }

    .binary-label {
        font-size: 0.5625rem;
    }

    .clue {
        font-size: 0.75rem;
    }

    .detective-conclusion {
        flex-direction: column;
        text-align: center;
    }

    .conclusion-arrow {
        display: none;
    }
}
