/**
 * study.css - 学習ダッシュボード・フラッシュカード・統合モード
 */

/* ==================== 学習ダッシュボード ==================== */

.study-dashboard {
    background: linear-gradient(135deg, #001f3f 0%, #003d5c 100%);  /* 濃紺グラデーション */
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    color: white;
}

.study-dashboard h3 {
    margin: 0 0 6px 0;
    font-size: 13px;
    opacity: 0.95;
}

.study-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 6px 4px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-number {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 1px;
}

.stat-label {
    font-size: 9px;
    opacity: 0.9;
}

/* 先取り学習カード */
.stat-card-early {
    background: rgba(255, 193, 7, 0.25);
    border: 1px solid rgba(255, 193, 7, 0.5);
}

/* ==================== インフォツールチップ ==================== */

.info-tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    color: white;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    margin-left: 6px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.info-icon:hover {
    background: var(--primary-color);
}

.info-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    white-space: normal;
    width: max-content;
    max-width: 280px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

.info-tooltip-wrapper.show-tooltip .info-tooltip {
    display: block;
}

/* スマホでの位置調整 */
@media (max-width: 400px) {
    .info-tooltip {
        left: auto;
        right: -10px;
        transform: none;
        max-width: 250px;
    }

    .info-tooltip::after {
        left: auto;
        right: 20px;
        transform: none;
    }
}

.stat-card-early .stat-number {
    color: #ffc107;
}

.stat-card-early .stat-label {
    color: rgba(255, 255, 255, 0.95);
}

/* 復習スケジュールの折りたたみ */
.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
    margin-bottom: 4px;
}

.schedule-header h4 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    opacity: 0.9;
}

.schedule-toggle {
    font-size: 16px;
    transition: transform 0.3s;
}

.schedule-toggle.expanded {
    transform: rotate(180deg);
}

.schedule-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.schedule-content.expanded {
    max-height: 500px;
}

.mastery-stats {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.mastery-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mastery-item:last-child {
    border-bottom: none;
}

.mastery-label {
    font-size: 14px;
}

.mastery-count {
    font-weight: bold;
}

/* ==================== 学習モード（フラッシュカード） ==================== */

.study-start-view {
    text-align: center;
    padding: var(--spacing-md);
}

.study-start-view h2 {
    margin-bottom: var(--spacing-lg);
}

.study-info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-lg);
}

.study-info-card p {
    margin-bottom: var(--spacing-sm);
}

.study-info-card p:last-child {
    margin-bottom: 0;
}

.study-content {
    padding: var(--spacing-md);
}

.study-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.study-progress {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* フラッシュカード（通常モード） */
.flashcard-container {
    perspective: 1000px;
    margin-bottom: var(--spacing-lg);
    position: relative;
    z-index: 1;
    width: 100%;
}

.flashcard {
    width: 100%;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 300px;
    transition: transform 0.6s ease-in-out, min-height 0.3s ease;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: var(--spacing-lg);
    padding-bottom: calc(var(--spacing-lg) + 20px);
    display: flex;
    flex-direction: column;
}

.flashcard-front {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.flashcard-back {
    background: linear-gradient(135deg, #d4edda 0%, #a8d8b9 100%);
    transform: rotateY(180deg);
}

.flashcard-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.flashcard-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: var(--spacing-md);
}

.flashcard-body {
    font-size: 1rem;
    line-height: 1.6;
}

.flashcard-images {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.flashcard-images img {
    max-width: 100%;
    max-height: 150px;
    border-radius: var(--border-radius);
}

.flashcard-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: auto;
    padding-top: var(--spacing-md);
}

/* 学習フェーズの選択肢表示 - 統一デザイン */
.integrated-choices {
    margin-top: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.integrated-choice-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.integrated-choice-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.integrated-choice-text {
    flex: 1;
    line-height: 1.5;
    padding-top: 2px;
}

.flashcard-answer-section,
.flashcard-explanation-section {
    margin-bottom: var(--spacing-md);
}

.flashcard-answer-section h4,
.flashcard-explanation-section h4 {
    color: #155724;
    margin-bottom: var(--spacing-sm);
    font-size: 0.9rem;
}

.flashcard-answer {
    font-size: 1.2rem;
    font-weight: 600;
    color: #155724;
    padding: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius);
}

.flashcard-explanation {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ナビゲーション */
.study-nav {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: center;
    position: relative;
    z-index: 10;
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
}

.study-nav .btn {
    min-width: 100px;
}

/* 学習結果 */
.study-result {
    text-align: center;
    padding: var(--spacing-xl);
}

.study-result h2 {
    margin-bottom: var(--spacing-lg);
}

.study-result-stats {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
}

.result-stat-card {
    background: var(--card-bg);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    min-width: 100px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.result-stat-card.correct {
    background: #d4edda;
    border: 2px solid var(--success-color);
}

.result-stat-card.incorrect {
    background: #f8d7da;
    border: 2px solid var(--danger-color);
}

.result-stat-number {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: var(--spacing-xs);
}

.result-stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* スワイプアニメーション */
.flashcard.swiping-left {
    animation: swipeLeft 0.3s ease-out forwards;
}

.flashcard.swiping-right {
    animation: swipeRight 0.3s ease-out forwards;
}

@keyframes swipeLeft {
    to {
        transform: translateX(-100%) rotate(-10deg);
        opacity: 0;
    }
}

@keyframes swipeRight {
    to {
        transform: translateX(100%) rotate(10deg);
        opacity: 0;
    }
}

.flashcard.entering {
    animation: cardEnter 0.3s ease-out forwards;
}

@keyframes cardEnter {
    from {
        transform: translateX(50px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== 統合モード ==================== */

/* 統合モード設定 */
.integrated-mode-options {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.integrated-mode-options .radio-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s;
}

.integrated-mode-options .radio-label:hover {
    background: #e9ecef;
}

/* 統合モード: 学習フェーズコンテナ */
.integrated-learn-container {
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
    padding-bottom: 80px;
}

/* フェーズインジケーター */
.integrated-phase-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: var(--bg-color);
    border-radius: var(--border-radius);
}

.phase-badge {
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    background: #e9ecef;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.phase-badge.active {
    background: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.phase-badge.phase-learn {
    background: #d4edda;
    color: #155724;
}

.phase-badge.phase-learn.active {
    background: var(--success-color);
    color: white;
}

.phase-badge.phase-quiz {
    background: #cce5ff;
    color: #004085;
}

.phase-badge.phase-quiz.active {
    background: var(--primary-color);
    color: white;
}

.phase-badge.phase-typing {
    background: #fff3cd;
    color: #856404;
}

.phase-badge.phase-typing.active {
    background: var(--warning-color);
    color: #212529;
}

.phase-arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* 統合モード用フラッシュカード */
.integrated-flashcard {
    min-height: 200px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    position: relative;
}

.integrated-flashcard .flashcard-inner {
    position: relative;
    width: 100%;
    min-height: 200px;
    height: calc(100dvh - 260px);
    max-height: calc(100dvh - 260px);
}

/* スマホ向け調整（dvh非対応ブラウザ用フォールバック） */
@supports not (height: 100dvh) {
    .integrated-flashcard .flashcard-inner {
        height: calc(100vh - 260px);
        max-height: calc(100vh - 260px);
    }
}

.integrated-flashcard .flashcard-front,
.integrated-flashcard .flashcard-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease-in-out;
}

/* カードの初期状態（表面を表示） */
.integrated-flashcard:not(.flipped) .flashcard-front {
    z-index: 2;
    opacity: 1;
    pointer-events: auto;
}

.integrated-flashcard:not(.flipped) .flashcard-back {
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

/* フリップ時は裏面のみ表示 */
.integrated-flashcard.flipped .flashcard-front {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

.integrated-flashcard.flipped .flashcard-back {
    opacity: 1;
    pointer-events: auto;
    z-index: 2;
}

/* スクロール可能なコンテンツ領域 */
.integrated-flashcard .flashcard-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: var(--spacing-lg);
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Webkitブラウザ用スクロールバー */
.integrated-flashcard .flashcard-content::-webkit-scrollbar {
    width: 6px;
}

.integrated-flashcard .flashcard-content::-webkit-scrollbar-track {
    background: transparent;
}

.integrated-flashcard .flashcard-content::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* ヒント部分 */
.integrated-flashcard .flashcard-hint {
    flex-shrink: 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: var(--spacing-xs) var(--spacing-md);
    margin: 0;
    background: var(--card-bg);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    pointer-events: none;
}

/* フラッシュカード内の要素の余白調整 */
.integrated-flashcard .flashcard-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0 0 var(--spacing-md) 0;
}

.integrated-flashcard .flashcard-body {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: var(--spacing-md);
}

.integrated-flashcard .flashcard-images {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.integrated-flashcard .flashcard-images img {
    max-width: 100%;
    max-height: 150px;
    border-radius: var(--border-radius);
}

.integrated-flashcard .flashcard-answer-section,
.integrated-flashcard .flashcard-explanation-section {
    margin-bottom: var(--spacing-md);
}

.integrated-flashcard .flashcard-answer-section:last-child,
.integrated-flashcard .flashcard-explanation-section:last-child {
    margin-bottom: 0;
}

.integrated-flashcard .flashcard-answer-section h4,
.integrated-flashcard .flashcard-explanation-section h4 {
    color: #155724;
    margin: 0 0 var(--spacing-sm) 0;
    font-size: 0.9rem;
}

.integrated-flashcard .flashcard-answer {
    font-size: 1.2rem;
    font-weight: 600;
    color: #155724;
    padding: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius);
    margin-bottom: var(--spacing-sm);
}

.integrated-flashcard .flashcard-explanation {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* 統合モード: 学習フェーズのアクション */
.integrated-learn-actions {
    position: fixed;
    bottom: var(--nav-height);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-xl);
    padding: var(--spacing-md);
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    flex-wrap: nowrap;
}

.integrated-learn-actions .btn {
    min-width: 120px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
}

.integrated-learn-actions .speak-btn {
    min-width: 48px;
    width: 48px;
    padding: 0;
    flex-shrink: 0;
    margin: 0;
}

/* スマホ対応 */
@media (max-width: 600px) {
    .integrated-flashcard {
        max-width: 100%;
        padding: 0 var(--spacing-sm);
    }

    .integrated-learn-actions {
        padding: var(--spacing-sm);
        gap: var(--spacing-lg);
    }

    .integrated-learn-actions .btn {
        min-width: 100px;
        font-size: 0.9rem;
    }
}

/* ==================== 連続学習日数カード ==================== */

.streak-card {
    background: linear-gradient(135deg, #e8eef5 0%, #d0dce8 100%);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.streak-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.streak-header h3 {
    margin: 0;
    font-size: 13px;
    color: #2c3e50;
    font-weight: 600;
}

/* 週間カレンダー */
.streak-calendar {
    margin-bottom: 8px;
}

.streak-week {
    display: flex;
    justify-content: space-between;
    gap: 2px;
}

.streak-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.streak-day-label {
    font-size: 11px;
    color: #5c6a7a;
    font-weight: 500;
}

.streak-day-label.is-today {
    color: var(--primary-color);
    font-weight: 600;
}

.streak-day-status {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* 初学習バッジ（通知バッジ風） */
.streak-new-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    background: #e67e22;
    color: white;
    font-size: 9px;
    font-weight: 600;
    line-height: 14px;
    text-align: center;
    padding: 0 2px;
}

/* 学習なし - ×マーク */
.streak-day-status.no-study {
    color: #b8c4ce;
}

.streak-day-status.no-study::before {
    content: '×';
    font-size: 18px;
}

/* 今日 - まだ学習してない場合は空の丸 */
.streak-day-status.today-empty {
    border: 2px solid #b8c4ce;
    color: #b8c4ce;
    background: transparent;
}

/* 学習済み - 問題数を表示 */
.streak-day-status.studied {
    background: var(--primary-color);
    color: white;
}

/* 今日の学習数 */
.streak-today-count {
    text-align: center;
    padding: 6px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 6px;
    font-size: 12px;
    color: #5c6a7a;
}

.today-count-number {
    font-size: 14px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0 3px;
}

/* ストリーク統計 */
.streak-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.streak-stat-item {
    text-align: center;
}

.streak-number {
    font-size: 22px;
    font-weight: bold;
    color: #5c6a7a;
    line-height: 1;
}

.streak-unit {
    font-size: 10px;
    color: #8e9aab;
    margin-top: 0;
}

.streak-label {
    font-size: 9px;
    color: #8e9aab;
    margin-top: 2px;
}

.streak-fire {
    font-size: 24px;
    opacity: 0.6;
}

/* ストリークがある場合のアクティブ状態 */
.streak-card.has-streak .streak-number {
    color: #e67e22;
}

.streak-card.has-streak .streak-fire {
    opacity: 1;
    animation: fireGlow 1.5s ease-in-out infinite alternate;
}

@keyframes fireGlow {
    from {
        transform: scale(1);
    }
    to {
        transform: scale(1.1);
    }
}

/* スマホ対応 */
@media (max-width: 400px) {
    .streak-day-status {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }

    .streak-day-status.no-study::before {
        font-size: 16px;
    }

    .streak-new-badge {
        min-width: 12px;
        height: 12px;
        border-radius: 6px;
        font-size: 8px;
        line-height: 12px;
        top: -3px;
        right: -5px;
    }

    .streak-number {
        font-size: 20px;
    }

    .streak-fire {
        font-size: 24px;
    }

    .streak-day-label {
        font-size: 10px;
    }
}