/* 第4章専用スタイル */

/* ビット演算計算機 */
.bit-calculator {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}

.bit-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.bit-input-group label {
    font-weight: 600;
    color: var(--text-primary);
}

.bit-input-group input {
    padding: var(--spacing-sm);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.1rem;
    font-family: var(--font-mono);
}

.bit-display {
    display: flex;
    gap: 4px;
    padding: var(--spacing-sm);
    background: var(--bg-card);
    border-radius: 8px;
    justify-content: center;
    font-family: var(--font-mono);
}

.bit-cell-mini {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-weight: bold;
    transition: all var(--transition-fast);
}

.bit-cell-mini.on {
    background: var(--accent-success);
    color: white;
    border-color: var(--accent-success);
}

/* 演算結果 */
.bit-operations {
    margin-top: var(--spacing-lg);
}

.bit-operations h4 {
    margin-bottom: var(--spacing-md);
}

.operation-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: var(--spacing-xs);
}

.op-label {
    font-family: var(--font-mono);
    font-weight: 600;
}

.op-value {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    font-family: var(--font-mono);
    font-weight: bold;
}

/* ビットマスクツール */
.bitmask-tool {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.current-value {
    text-align: center;
}

.current-value label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.dec-display {
    margin-top: var(--spacing-sm);
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

.mask-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-sm);
}

.bit-selector {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.bit-selector label {
    font-weight: 600;
}

.bit-selector select {
    padding: var(--spacing-sm);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
}

/* LEDボード */
.led-board {
    background: #2a2a2a;
    padding: var(--spacing-xl);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.led-row {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.led-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
}

.led {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #333;
    border: 3px solid #555;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.led::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    right: 10%;
    bottom: 10%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.led.on {
    background: #ff4444;
    border-color: #ff6666;
    box-shadow: 
        0 0 20px #ff4444,
        0 0 40px #ff4444,
        0 0 60px #ff4444,
        inset 0 0 20px rgba(255, 255, 255, 0.3);
}

.led.on::before {
    opacity: 1;
}

.led:hover {
    transform: scale(1.1);
}

.led-label {
    color: #999;
    font-size: 0.85rem;
    font-family: var(--font-mono);
}

.led-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: var(--spacing-lg);
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
}

.info-item span {
    color: #999;
    font-size: 0.9rem;
}

.info-item strong {
    color: #fff;
    font-size: 1.3rem;
    font-family: var(--font-mono);
}

.led-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: var(--spacing-sm);
}

/* コードブロック */
pre {
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: 8px;
    overflow-x: auto;
    border-left: 4px solid var(--accent-primary);
}

code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .led-row {
        gap: var(--spacing-sm);
    }
    
    .led {
        width: 45px;
        height: 45px;
    }
    
    .led-label {
        font-size: 0.75rem;
    }
    
    .bit-calculator {
        grid-template-columns: 1fr;
    }
    
    .mask-controls,
    .led-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .led {
        width: 35px;
        height: 35px;
    }
    
    .bit-cell-mini {
        width: 25px;
        height: 25px;
        font-size: 0.85rem;
    }
}