/**
 * でんけんマッスル 対話式講座 共通CSS
 * Version: 1.1.0
 * 
 * ※ サイト共通のヘッダー・サイドバーがある構造に対応
 */

/* ==================== */
/* リセット & ベース */
/* ==================== */
* {
    box-sizing: border-box;
}

/* ==================== */
/* 講座コンテナ（.container1） */
/* ==================== */
.container1 {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 100px;
    background: #fff;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* ==================== */
/* 講座ヘッダー（.header1） */
/* ==================== */
.header1 {
    text-align: center;
    padding: 25px 0;
    border-bottom: 3px solid var(--primary-color, #e94560);
    margin-bottom: 25px;
}

.header1 .unit-badge {
    display: inline-block;
    background: var(--primary-color, #e94560);
    color: #fff;
    padding: 4px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    margin-bottom: 10px;
}

.header1 h1 {
    font-size: 1.6em;
    color: #333;
    margin-bottom: 8px;
}

.header1 .subtitle {
    color: #888;
    font-size: 0.9em;
}

/* ==================== */
/* プログレスバー */
/* ==================== */
.progress-bar {
    background: #e9ecef;
    border-radius: 10px;
    height: 10px;
    margin-bottom: 25px;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, var(--primary-color, #e94560), var(--primary-light, #ff6b6b));
    height: 100%;
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 10px;
}

.progress-text {
    text-align: right;
    font-size: 0.85em;
    color: #666;
    margin-bottom: 5px;
}

/* ==================== */
/* ルートインジケーター */
/* ==================== */
.route-indicator {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.75em;
    margin-bottom: 12px;
    font-weight: bold;
}

.route-main { background: var(--primary-color, #e94560); color: #fff; }
.route-support { background: #3498db; color: #fff; }
.route-advanced { background: #9b59b6; color: #fff; }

/* ==================== */
/* チャットエリア */
/* ==================== */
.chat-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 15px;
    animation: fadeIn 0.4s ease;
}

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

/* ==================== */
/* アバター */
/* ==================== */
.avatar {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #e94560), var(--primary-light, #ff6b6b));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(233, 69, 96, 0.3);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar.support {
    background: linear-gradient(135deg, #3498db, #5dade2);
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}

.avatar.advanced {
    background: linear-gradient(135deg, #9b59b6, #bb8fce);
    box-shadow: 0 3px 10px rgba(155, 89, 182, 0.3);
}

/* ==================== */
/* 吹き出し */
/* ==================== */
.bubble {
    background: #fff;
    border-radius: 15px;
    padding: 20px 25px;
    max-width: calc(100% - 75px);
    border: 2px solid var(--primary-color, #e94560);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.bubble.support {
    border-color: #3498db;
    background: #f8fbff;
}

.bubble.advanced {
    border-color: #9b59b6;
    background: #faf8ff;
}

.bubble p {
    margin-bottom: 15px;
}

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

/* ==================== */
/* 公式ボックス */
/* ==================== */
.formula-box {
    background: linear-gradient(135deg, #fff5f7, #fff);
    border: 2px solid var(--primary-color, #e94560);
    border-radius: 12px;
    padding: 18px 22px;
    margin: 18px 0;
    text-align: center;
}

.formula-box .formula {
    color: var(--primary-color, #e94560);
    font-weight: bold;
    font-size: 1.4em;
    margin-bottom: 8px;
}

.formula-box .desc {
    color: #666;
    font-size: 0.85em;
}

/* ==================== */
/* ハイライト */
/* ==================== */
.highlight {
    color: var(--primary-color, #e94560);
    font-weight: bold;
}

.highlight-blue {
    color: #3498db;
    font-weight: bold;
}

.highlight-purple {
    color: #9b59b6;
    font-weight: bold;
}

/* ==================== */
/* 重要ボックス */
/* ==================== */
.important {
    background: #fff5f7;
    border-left: 4px solid var(--primary-color, #e94560);
    padding: 15px 18px;
    margin: 15px 0;
    border-radius: 0 10px 10px 0;
}

.important.blue {
    background: #f0f8ff;
    border-left-color: #3498db;
}

.important.purple {
    background: #f8f0ff;
    border-left-color: #9b59b6;
}

/* ==================== */
/* ボタンエリア */
/* ==================== */
.btn-area {
    margin-top: 22px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ==================== */
/* ボタン */
/* ==================== */
.btn {
    background: linear-gradient(135deg, var(--primary-color, #e94560), var(--primary-light, #ff6b6b));
    color: #fff;
    border: none;
    padding: 16px 28px;
    border-radius: 30px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #fff;
    color: var(--primary-color, #e94560);
    border: 2px solid var(--primary-color, #e94560);
    box-shadow: none;
}

.btn-secondary:hover {
    background: #fff5f7;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.2);
}

.btn-support {
    background: linear-gradient(135deg, #3498db, #5dade2);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-support:hover {
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.btn-advanced {
    background: linear-gradient(135deg, #9b59b6, #bb8fce);
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.3);
}

.btn-advanced:hover {
    box-shadow: 0 6px 20px rgba(155, 89, 182, 0.4);
}

/* ==================== */
/* 選択肢ボタン */
/* ==================== */
.btn-choice {
    background: #fff;
    border: 2px solid #ddd;
    color: #333;
    text-align: left;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: none;
    font-weight: normal;
}

.btn-choice:hover {
    border-color: var(--primary-color, #e94560);
    background: #fff5f7;
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.1);
}

.btn-choice:disabled {
    cursor: default;
}

.btn-choice:disabled:hover {
    transform: none;
}

.btn-choice.correct {
    background: #e8f8f0;
    border-color: #2ecc71;
    color: #27ae60;
    animation: pulse 0.5s ease;
}

.btn-choice.wrong {
    background: #fdf2f2;
    border-color: #e74c3c;
    color: #c0392b;
    animation: shake 0.5s ease;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

a.next-lesson {
    text-decoration: none;
    color: inherit;
}
/* ==================== */
/* フィードバック */
/* ==================== */
.feedback {
    padding: 18px;
    border-radius: 12px;
    margin-top: 18px;
    animation: fadeIn 0.3s ease;
}

.feedback.correct {
    background: #e8f8f0;
    border: 2px solid #2ecc71;
    color: #27ae60;
}

.feedback.wrong {
    background: #fdf2f2;
    border: 2px solid #e74c3c;
    color: #c0392b;
}

/* ==================== */
/* 非表示 */
/* ==================== */
.hidden {
    display: none !important;
}

/* ==================== */
/* ステップ */
/* ==================== */
.step {
    display: none;
    scroll-margin-top: 180px; /* ★ヘッダー分のスクロール余白 */
}

.step.active {
    display: block;
}

/* ==================== */
/* テーブル */
/* ==================== */
.ratio-table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-size: 0.95em;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.ratio-table th, .ratio-table td {
    border: 1px solid #e9ecef;
    padding: 14px;
    text-align: center;
}

.ratio-table th {
    background: var(--primary-color, #e94560);
    color: #fff;
    font-weight: bold;
}

.ratio-table td {
    background: #fff;
}

.ratio-table tr:nth-child(even) td {
    background: #f8f9fa;
}

/* ==================== */
/* 問題ボックス */
/* ==================== */
.thinking-box {
    background: #f8f9fa;
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 22px;
    margin: 18px 0;
}

.thinking-box .label {
    color: var(--primary-color, #e94560);
    font-weight: bold;
    margin-bottom: 12px;
    font-size: 1.05em;
}

.thinking-box.advanced {
    border-color: #9b59b6;
    background: #faf8ff;
}

.thinking-box.advanced .label {
    color: #9b59b6;
}

/* ==================== */
/* 計算ステップ */
/* ==================== */
.calc-step {
    background: #f1f3f4;
    padding: 12px 18px;
    margin: 10px 0;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    line-height: 1.8;
    border-left: 4px solid var(--primary-color, #e94560);
}

.calc-step.blue {
    border-left-color: #3498db;
}

.calc-step.purple {
    border-left-color: #9b59b6;
}

/* ==================== */
/* スコア表示 */
/* ==================== */
.score-display {
    text-align: center;
    padding: 35px;
    background: linear-gradient(135deg, #fff5f7, #fff);
    border-radius: 20px;
    margin-top: 25px;
    border: 2px solid var(--primary-color, #e94560);
}

.score-display .score {
    font-size: 3.5em;
    color: var(--primary-color, #e94560);
    font-weight: bold;
}

.score-display .label {
    color: #888;
    margin-top: 10px;
    font-size: 0.95em;
}

.completion-badge {
    background: linear-gradient(135deg, var(--primary-color, #e94560), var(--primary-light, #ff6b6b));
    border-radius: 50%;
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5em;
    margin: 0 auto 25px;
    box-shadow: 0 5px 20px rgba(233, 69, 96, 0.3);
}

/* ==================== */
/* 統計グリッド */
/* ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 25px 0;
}

.stat-box {
    background: #f8f9fa;
    padding: 18px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #e9ecef;
}

.stat-box .value {
    font-size: 1.8em;
    font-weight: bold;
    color: var(--primary-color, #e94560);
}

.stat-box .label {
    font-size: 0.8em;
    color: #888;
    margin-top: 5px;
}

.stat-box.support .value { color: #3498db; }
.stat-box.advanced .value { color: #9b59b6; }

/* ==================== */
/* 次の講座リンク */
/* ==================== */
.next-lesson {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-top: 25px;
    text-align: center;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.3s ease;
}

.next-lesson:hover {
    border-color: var(--primary-color, #e94560);
    box-shadow: 0 2px 10px rgba(233, 69, 96, 0.1);
}

.next-lesson .label {
    color: #888;
    font-size: 0.85em;
    margin-bottom: 10px;
}

.next-lesson .title {
    color: var(--primary-color, #e94560);
    font-weight: bold;
    font-size: 1.1em;
}

/* ==================== */
/* レスポンシブ */
/* ==================== */
@media (max-width: 600px) {
    .container1 { padding: 15px; }
    .header1 h1 { font-size: 1.3em; }
    .bubble { padding: 15px 18px; }
    .formula-box .formula { font-size: 1.2em; }
    .avatar { width: 45px; height: 45px; font-size: 1.3em; }
    .stats-grid { grid-template-columns: 1fr; }
    .btn { padding: 14px 24px; }
    
    /* モバイル時のスクロール余白調整 */
    .step {
        scroll-margin-top: 100px;
    }
}

/* PC画面での幅拡大 */
@media (min-width: 768px) {
      .bubble {
        max-width: none;    /* 幅制限を解除 */
        flex: 1;            /* 残りスペースを全部使う */
        padding: 22px 28px;
    }
    .container1 {
        padding: 25px 35px;
    }
    
    .message {
        gap: 18px;
    }
}

/* ==================== */
/* 単元別カラーテーマ */
/* ==================== */

/* 誘導機（グリーン） */
.theme-induction {
    --primary-color: #4caf50;
    --primary-light: #81c784;
}

/* 直流機（オレンジ） */
.theme-dc {
    --primary-color: #e67e22;
    --primary-light: #f39c12;
}

/* 変圧器（緑） */
.theme-transformer {
    --primary-color: #27ae60;
    --primary-light: #2ecc71;
}

/* 同期機（青紫） */
.theme-synchronous {
    --primary-color: #8e44ad;
    --primary-light: #9b59b6;
}