@charset "UTF-8";

/* =========================================
   1. 基本設定 & テーマカラー定義
   ========================================= */
:root {
    --theme-color: #007aff;
    --theme-bg: rgba(0, 122, 255, 0.1);

    --bg-color: #f2f2f7;
    --card-bg: #ffffff;
    --text-main: #1c1c1e;
    --text-sub: #8e8e93;
    /* デフォルトのサブテキスト色 */
    --border-color: rgba(0, 0, 0, 0.1);

    --cloze-bg: #e5e5ea;
    --cloze-text: transparent;
    --cloze-revealed-bg: var(--theme-bg);
    --cloze-revealed-text: var(--theme-color);
}

/* 科目別カラー */
body.subject-math {
    --theme-color: #3f51b5;
    --theme-bg: rgba(63, 81, 181, 0.15);
}

body.subject-kokugo {
    --theme-color: #8e44ad;
    --theme-bg: rgba(142, 68, 173, 0.15);
}

body.subject-science {
    --theme-color: #008080;
    --theme-bg: rgba(0, 128, 128, 0.15);
}

body.subject-social {
    --theme-color: #d35400;
    --theme-bg: rgba(211, 84, 0, 0.15);
}

body.subject-info {
    --theme-color: #34495e;
    --theme-bg: rgba(52, 73, 94, 0.15);
}

/* ダークモード設定 */
body.dark-mode {
    --bg-color: #1c1c1e;
    --card-bg: #2c2c2e;
    --text-main: #f2f2f7;
    --text-sub: #aeaeb2;
    --border-color: rgba(255, 255, 255, 0.1);
    --cloze-bg: #3a3a3c;
    --cloze-revealed-bg: rgba(10, 132, 255, 0.2);
}

/* ★修正点: ダークモード時、AIが指定したインラインスタイル(color:#444など)を強制的に上書きして白くする */
body.dark-mode .card,
body.dark-mode .text-box,
body.dark-mode h3,
body.dark-mode p,
body.dark-mode div,
body.dark-mode span:not(.keyword):not(.cloze) {
    color: var(--text-main) !important;
}

/* ダークモード時のサブテキストの微調整 */
body.dark-mode small,
body.dark-mode .text-sub {
    color: var(--text-sub) !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    padding-bottom: 120px;
    /* スティッキーバー + リセットボタン分広めに */
    transition: background-color 0.3s, color 0.3s;
}

/* 国語用フォント */
body.subject-kokugo .text-box,
body.subject-kokugo h2,
body.subject-kokugo h3 {
    font-family: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", serif;
}

/* =========================================
   2. レイアウト & コンポーネント
   ========================================= */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
}

.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
    padding: 10px;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 15px;
}

body.dark-mode .app-header {
    background: rgba(28, 28, 30, 0.85);
}

.nav-btn {
    border: none;
    background: none;
    font-weight: bold;
    color: var(--text-sub);
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.nav-btn.active {
    color: var(--theme-color);
    border-bottom-color: var(--theme-color);
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    margin-top: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* カード: 「覚えた」状態 */
.card.mastered {
    /* opacity: 0.6;  ← ★修正点: 薄くしない */
    border: 3px solid #34c759;
    /* 緑枠を太くして分かりやすく */
    position: relative;
    background-color: rgba(52, 199, 89, 0.05);
    /* ほんのり緑背景 */
}

.card.mastered::after {
    content: "✅ 習得済み";
    position: absolute;
    top: -12px;
    right: 20px;
    font-size: 0.85rem;
    background: #34c759;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
}

.text-box {
    background-color: rgba(128, 128, 128, 0.05);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    line-height: 2.0;
}

.keyword {
    font-weight: bold;
    color: var(--theme-color);
}

/* =========================================
   3. 学習機能 UI
   ========================================= */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cloze {
    display: inline-block;
    min-width: 60px;
    padding: 2px 8px;
    margin: 0 2px;
    background-color: var(--cloze-bg);
    color: var(--cloze-text);
    border-radius: 4px;
    border-bottom: 2px solid #ccc;
    cursor: pointer;
    font-weight: bold;
    user-select: none;
    text-align: center;
    transition: all 0.2s;
}

.cloze:hover {
    filter: brightness(0.95);
}

.cloze.revealed {
    background-color: var(--cloze-revealed-bg);
    color: var(--cloze-revealed-text);
    border-bottom-color: var(--theme-color);
    cursor: default;
}

/* 赤シートモード */
body.red-sheet-active .cloze.revealed {
    color: transparent !important;
    background-color: #ffcccc;
    border-bottom-color: #ff3b30;
}

body.red-sheet-active .cloze.revealed:hover {
    color: #ff3b30 !important;
}

.answer-area {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border-color);
}

.btn-toggle-answer {
    background: transparent;
    border: 1px solid var(--theme-color);
    color: var(--theme-color);
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: 0.2s;
}

.btn-toggle-answer:hover {
    background: var(--theme-bg);
}

.answer-content {
    display: none;
    margin-top: 10px;
    background: rgba(128, 128, 128, 0.05);
    padding: 10px;
    border-radius: 8px;
    font-size: 0.95rem;
}

.answer-content.visible {
    display: block;
}

/* =========================================
   4. スティッキー操作バー
   ========================================= */
.sticky-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 30px;
    padding: 8px 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: space-around;
    /* 均等配置 */
    align-items: center;
    z-index: 1000;
}

body.dark-mode .sticky-bar {
    background: rgba(44, 44, 46, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.65rem;
    /* 少し文字を小さくして収める */
    opacity: 0.8;
    min-width: 50px;
}

.control-btn:hover {
    opacity: 1;
    color: var(--theme-color);
}

.control-btn span {
    font-size: 1.3rem;
    margin-bottom: 2px;
    display: block;
}

.timer-display {
    font-family: monospace;
    font-size: 1.0rem;
    font-weight: bold;
    color: var(--theme-color);
    display: block;
}

/* --- 以下、index.html (ポータル) 用のスタイルを追加 --- */

/* ダッシュボードヘッダー（進捗表示など） */
.dashboard-header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--bg-color) 100%);
    border-radius: 0 0 20px 20px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.progress-summary {
    display: inline-block;
    background: var(--theme-bg);
    color: var(--theme-color);
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 10px;
}

/* 教科グリッド */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    /* レスポンシブ */
    gap: 20px;
    padding: 0 10px;
}

/* 教科カード */
.portal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    padding: 30px 20px;
    border-radius: 20px;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.portal-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

/* アイコン装飾 */
.portal-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    background: rgba(128, 128, 128, 0.1);
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

/* 教科別の色指定（CSS変数を活用） */
/* 英語 */
.portal-card.subject-english .portal-icon {
    background: rgba(0, 122, 255, 0.1);
    color: #007aff;
}

.portal-card.subject-english h3 {
    color: #007aff;
}

/* 数学 */
.portal-card.subject-math .portal-icon {
    background: rgba(63, 81, 181, 0.1);
    color: #3f51b5;
}

.portal-card.subject-math h3 {
    color: #3f51b5;
}

/* 国語 */
.portal-card.subject-kokugo .portal-icon {
    background: rgba(142, 68, 173, 0.1);
    color: #8e44ad;
}

.portal-card.subject-kokugo h3 {
    color: #8e44ad;
}

/* 理科 */
.portal-card.subject-science .portal-icon {
    background: rgba(0, 128, 128, 0.1);
    color: #008080;
}

.portal-card.subject-science h3 {
    color: #008080;
}

/* 社会 */
.portal-card.subject-social .portal-icon {
    background: rgba(211, 84, 0, 0.1);
    color: #d35400;
}

.portal-card.subject-social h3 {
    color: #d35400;
}

.portal-card h3 {
    margin: 0;
    font-size: 1.1rem;
}

.portal-card p {
    margin: 5px 0 0;
    font-size: 0.8rem;
    color: var(--text-sub);
}