/* ======================================================
   聖書閲覧アプリ — 多言語版  style.css
   v4 デザイン踏襲 + 多言語対応 + デザインブラッシュアップ
   ====================================================== */

/* --- 基本設定と変数 --- */
:root {
    --primary-color: #2980b9;
    --primary-light: rgba(41, 128, 185, 0.10);
    --primary-gradient: linear-gradient(135deg, #2980b9 0%, #3498db 50%, #5dade2 100%);
    --secondary-color: #f4f6f8;
    --font-color: #2c3e50;
    --background-color: #f8f9fb;
    --border-color: #e8ecf1;
    --header-bg: rgba(255, 255, 255, 0.92);
    --header-color: #2c3e50;
    --highlight-bg: #fff38a;
    --highlight-color: #000;
    --furigana-color: #b8860b;
    --pinyin-color: #c2185b;
    --card-bg: rgba(255, 255, 255, 0.7);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --lang-jp-color: #2980b9;
    --lang-ch-color: #c0392b;
    --lang-en-color: #27ae60;
    --lang-kr-color: #8e44ad;
    --transition-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

body[data-theme='dark'] {
    --primary-color: #5dade2;
    --primary-light: rgba(93, 173, 226, 0.12);
    --primary-gradient: linear-gradient(135deg, #1a5276 0%, #2980b9 50%, #5dade2 100%);
    --secondary-color: #1e2a35;
    --font-color: #dfe6e9;
    --background-color: #14202b;
    --border-color: #2c3e50;
    --header-bg: rgba(20, 32, 43, 0.92);
    --header-color: #dfe6e9;
    --highlight-bg: #f1c40f;
    --highlight-color: #333;
    --furigana-color: #f0c040;
    --pinyin-color: #f48fb1;
    --card-bg: rgba(30, 42, 53, 0.7);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --lang-jp-color: #5dade2;
    --lang-ch-color: #e74c3c;
    --lang-en-color: #2ecc71;
    --lang-kr-color: #a569bd;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    overscroll-behavior-x: none;
    touch-action: manipulation;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--font-color);
    transition: background-color 0.4s ease, color 0.4s ease;
    -webkit-tap-highlight-color: transparent;
}

*::-webkit-scrollbar { display: none; }

/* --- アニメーション定義 --- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulseHighlight {
    0% { background-color: var(--highlight-bg); }
    100% { background-color: transparent; }
}

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

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- ヘッダー --- */
header {
    position: fixed; top: 0; left: 0; right: 0;
    display: flex; width: 100%; height: 52px;
    background: var(--header-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    color: var(--header-color);
    align-items: center; justify-content: space-between;
    padding: 0 8px;
    box-shadow: var(--shadow-sm);
    z-index: 1000;
    transition: background-color 0.3s ease;
    border-bottom: 1px solid var(--border-color);
}

.action-icon {
    font-size: 22px; cursor: pointer; padding: 10px; flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s;
    border-radius: var(--radius-sm);
}
.action-icon:hover { background-color: var(--primary-light); }
.action-icon:active { transform: scale(0.9); }

.header-controls {
    flex-grow: 1; display: flex; gap: 8px; padding: 0 5px; min-width: 0;
}
.header-controls select {
    width: 100%; background-color: var(--secondary-color);
    color: var(--font-color); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); padding: 8px 28px 8px 10px; font-size: 0.88em; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23999'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
.header-controls select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}
#book-select { flex-basis: 55%; }
#chapter-select { flex-basis: 22%; }
#verse-select { flex-basis: 23%; }

/* --- サイドバー --- */
.sidebar {
    height: 100%; width: 320px; max-width: 85vw; position: fixed;
    z-index: 2000; top: 0; background-color: var(--background-color);
    overflow-y: auto;
    transition: transform 0.4s var(--transition-smooth);
    padding: 24px; box-shadow: var(--shadow-lg);
}
.sidebar .close-btn {
    position: absolute; top: 8px; right: 16px; font-size: 32px; cursor: pointer;
    color: var(--font-color); transition: color 0.2s, transform 0.2s;
    opacity: 0.6;
}
.sidebar .close-btn:hover { color: var(--primary-color); transform: rotate(90deg); opacity: 1; }

#left-sidebar { left: 0; transform: translateX(-105%); }
#left-sidebar.open { transform: translateX(0); }
#right-sidebar { right: 0; transform: translateX(105%); }
#right-sidebar.open { transform: translateX(0); }

/* --- オーバーレイ --- */
.overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 1500;
    display: none; opacity: 0; transition: opacity 0.3s ease;
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.overlay.open { display: block; opacity: 1; }

/* --- メインコンテンツ --- */
main { padding: 64px 15px; min-height: 100vh; padding-bottom: 80px; }

.loader {
    text-align: center; color: #888; padding: 50px 20px;
    animation: fadeIn 0.5s ease;
    display: flex; flex-direction: column; align-items: center; gap: 15px;
}
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --- 聖句コンテナ --- */
.verse-container {
    margin-bottom: 6px; padding: 14px 12px;
    border-radius: var(--radius-md);
    opacity: 0;
    animation: fadeInUp 0.4s ease-out forwards;
    transition: background-color 0.2s ease;
}
.verse-container:hover {
    background-color: var(--primary-light);
}

.verse-ref {
    display: flex; align-items: center; color: var(--primary-color);
    font-weight: 700; margin-bottom: 6px; font-size: 0.75em;
    letter-spacing: 0.5px;
}

.highlight-target {
    animation: pulseHighlight 2s ease-out;
}

.verse-content {
    display: flex; flex-direction: row; gap: 16px; align-items: flex-start;
}

/* --- 言語ブロック --- */
.lang-block {
    flex: 1; min-width: 0; overflow-wrap: break-word; line-height: 1.85;
}

/* --- ルビ --- */
ruby { ruby-position: over; }
rt { font-size: 0.55em; font-weight: 400; }
rt.furigana { color: var(--furigana-color); }
rt.pinyin { color: var(--pinyin-color); font-style: italic; }

/* --- ボトムナビ --- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; width: 100%; height: 56px;
    background: var(--header-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 -1px 3px rgba(0,0,0,0.04);
    display: flex; justify-content: space-around; align-items: center; z-index: 1000;
    border-top: 1px solid var(--border-color);
}
.bottom-nav button {
    background: none; border: none; color: var(--primary-color);
    font-size: 1.4rem; font-weight: 700; cursor: pointer;
    padding: 10px 24px; border-radius: var(--radius-sm);
    transition: background-color 0.2s, transform 0.1s;
}
.bottom-nav button:hover { background-color: var(--primary-light); }
.bottom-nav button:active { transform: scale(0.95); }
.bottom-nav button:disabled { color: var(--border-color); cursor: not-allowed; transform: none; }

/* --- UIコンポーネント --- */
.sidebar h2 {
    margin-top: 32px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.control-group { margin-bottom: 18px; }

label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.9em; color: var(--font-color); }

select, input[type="search"], .action-btn {
    width: 100%; padding: 11px 12px; font-size: 15px;
    border: 1px solid var(--border-color);
    background-color: var(--secondary-color);
    color: var(--font-color); border-radius: var(--radius-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="search"]:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.action-btn {
    background: var(--primary-gradient); color: white; border: none;
    cursor: pointer; margin-top: 10px; font-weight: 700;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    letter-spacing: 0.3px;
}
.action-btn:hover {
    filter: brightness(1.08); transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.action-btn:active { transform: translateY(0); box-shadow: none; }

.secondary-btn {
    background: var(--secondary-color);
    color: var(--font-color);
    border: 1px solid var(--border-color);
}
.secondary-btn:hover {
    filter: brightness(0.96);
}

.divider {
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

/* --- 言語順序トグル --- */
.lang-order-container {
    margin-bottom: 18px;
}
.lang-order-toggle {
    margin-top: 5px;
}
.lang-order-container .action-btn {
    font-size: 13px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* --- 設定スイッチ --- */
.settings { margin-top: 20px; animation: fadeIn 0.4s ease; }
.switch-container {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.switch input { display: none; }
.slider-switch {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc; transition: .3s var(--transition-smooth); border-radius: 26px;
}
.slider-switch:before {
    position: absolute; content: "";
    height: 20px; width: 20px; left: 3px; bottom: 3px;
    background-color: white; transition: .3s var(--transition-smooth); border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input:checked + .slider-switch { background: var(--primary-gradient); }
input:checked + .slider-switch:before { transform: translateX(22px); }

/* スライダー */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; margin: 15px 0; background: transparent; }
input[type=range]:focus { outline: none; }
input[type=range]::-webkit-slider-runnable-track {
    width: 100%; height: 5px; cursor: pointer;
    background: var(--border-color); border-radius: 5px; border: none;
}
input[type=range]::-webkit-slider-thumb {
    height: 22px; width: 22px; border-radius: 50%;
    background: var(--primary-color); cursor: pointer;
    -webkit-appearance: none; margin-top: -9px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2); border: 2px solid #fff;
    transition: transform 0.15s var(--transition-smooth);
}
input[type=range]::-webkit-slider-thumb:active { transform: scale(1.15); }

/* ハイライト */
.highlight {
    background-color: var(--highlight-bg);
    color: var(--highlight-color);
    border-radius: 3px; padding: 0 2px;
}

/* --- 履歴/ブックマーク --- */
.user-data-section {
    margin-top: 28px; border-top: 1px solid var(--border-color); padding-top: 10px;
}
.tabs {
    display: flex; margin-bottom: 10px; border-radius: var(--radius-sm);
    overflow: hidden; border: 1px solid var(--border-color);
}
.tab-button {
    flex: 1; padding: 11px; background-color: var(--secondary-color); border: none;
    cursor: pointer; color: var(--font-color); transition: background-color 0.3s; font-weight: 600;
    font-size: 0.9em;
}
.tab-button.active { background: var(--primary-gradient); color: white; }
.tab-content { display: none; max-height: 300px; overflow-y: auto; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
.user-data-section ul { list-style: none; padding: 0; margin: 0; }
.user-data-section li {
    padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--border-color);
    font-size: 0.92em; transition: all 0.2s ease;
    border-radius: var(--radius-sm); margin-bottom: 2px;
}
.user-data-section li:last-child { border-bottom: none; }
.user-data-section li:hover { background-color: var(--primary-light); padding-left: 18px; }
.user-data-section .empty-message { padding: 20px; text-align: center; color: #888; font-size: 0.9em; }

.bookmark-icon {
    cursor: pointer; font-style: normal; color: var(--primary-color); margin-left: 8px;
    display: inline-block; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.bookmark-icon:hover { transform: scale(1.3); }

/* --- モーダル (共通) --- */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.5); z-index: 3000;
    justify-content: center; align-items: center;
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    opacity: 0; transition: opacity 0.3s ease;
}
.modal-overlay.open { display: flex; opacity: 1; }
.modal-content {
    background-color: var(--background-color);
    width: 90%; max-width: 640px; height: 80vh;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    position: relative; padding: 24px;
    display: flex; flex-direction: column;
    transform: scale(0.92);
    transition: transform 0.35s var(--transition-smooth);
}
.modal-overlay.open .modal-content { transform: scale(1); }

.modal-close-btn {
    position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold;
    color: #888; cursor: pointer; z-index: 10; transition: color 0.2s;
}
.modal-close-btn:hover { color: var(--font-color); }

/* --- 検索モーダル --- */
.search-modal-content { height: 85vh; }
.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px; margin-bottom: 15px;
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 1.2em; margin: 0; font-weight: 700; }
.modal-header .modal-close-btn { position: static; margin-left: auto; line-height: 1; }

.search-controls {
    display: flex; flex-direction: column; gap: 10px;
    padding-bottom: 15px; border-bottom: 1px solid var(--border-color);
}

.search-results-container {
    flex-grow: 1; overflow-y: auto; padding-top: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--secondary-color);
}

.search-result-item {
    padding: 14px; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); margin-bottom: 12px; cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--card-bg);
}
.search-result-item:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}
.search-result-item:active { transform: translateY(0); }
.search-result-item .verse-ref {
    color: var(--primary-color); font-size: 0.85em; margin-bottom: 6px; font-weight: 600;
}

/* --- データなしメッセージ --- */
.no-data-message {
    text-align: center;
    padding: 80px 20px;
    color: #888;
    animation: fadeIn 0.5s ease;
}
.no-data-message h3 {
    font-size: 1.2em;
    margin-bottom: 12px;
    color: var(--primary-color);
    font-weight: 700;
}
.no-data-message p {
    line-height: 1.7;
    font-size: 0.9em;
}

/* --- トースト --- */
#toast-container {
    position: fixed; bottom: 75px; left: 50%; transform: translateX(-50%);
    z-index: 5000; display: flex; flex-direction: column; align-items: center;
}
.toast {
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 10px 22px;
    border-radius: 50px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: fadeInUp 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    backdrop-filter: blur(4px);
}

/* --- 疑問バッジ --- */
.verse-q-indicator {
    display: inline-block;
    background: #e74c3c;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    vertical-align: middle;
}
.verse-q-indicator:hover {
    transform: scale(1.05);
    background: #c0392b;
}

/* --- 間違い報告モーダル iframe --- */
#report-modal .modal-content {
    height: 80vh;
}

/* --- レスポンシブ: スマホ --- */
@media (max-width: 600px) {
    .verse-content {
        flex-direction: row;
        gap: 6px;
    }

    main {
        padding: 56px 10px;
        padding-bottom: 68px;
    }
    header {
        height: 48px;
        padding: 0 4px;
    }
    .header-controls {
        gap: 4px;
    }
    .header-controls select {
        padding: 6px 22px 6px 6px;
        font-size: 0.82em;
    }
    #book-select { flex-basis: 50%; }
    #chapter-select { flex-basis: 22%; }
    #verse-select { flex-basis: 28%; }
    .bottom-nav { height: 50px; }
    .bottom-nav button { font-size: 1.2rem; padding: 8px 16px; }
}

/* --- レスポンシブ: PC / タブレット --- */
@media (min-width: 601px) {
    .verse-content {
        gap: 20px;
    }

    .verse-container {
        padding: 16px 14px;
    }
}
