/**
 * 파일명: style.css
 * 파일경로: /home/mbible/public_html/assets/css/
 * 기능: 모바일성경 커스텀 스타일 + 다크모드
 * 작성일: 2026-02-25
 * 수정일: 2026-02-25
 */

/* ── CSS 변수 (라이트 모드 기본) ── */
:root {
    --mb-bg: #ffffff;
    --mb-text: #212529;
    --mb-text-muted: #6c757d;
    --mb-nav-bg: #1a1a2e;
    --mb-nav-text: #ffffff;
    --mb-card-bg: #f8f9fa;
    --mb-card-border: #e9ecef;
    --mb-verse-hover: #f0f4f8;
    --mb-highlight: #fff3cd;
    --mb-accent: #0d6efd;
    --mb-footer-bg: #f8f9fa;
    --mb-verse-num: #0d6efd;
    --mb-divider: #dee2e6;
}

/* ── 다크 모드 ── */
[data-bs-theme="dark"] {
    --mb-bg: #121212;
    --mb-text: #e0e0e0;
    --mb-text-muted: #9e9e9e;
    --mb-nav-bg: #1a1a2e;
    --mb-nav-text: #ffffff;
    --mb-card-bg: #1e1e1e;
    --mb-card-border: #333333;
    --mb-verse-hover: #2a2a2a;
    --mb-highlight: #3d3520;
    --mb-accent: #6ea8fe;
    --mb-footer-bg: #1a1a1a;
    --mb-verse-num: #6ea8fe;
    --mb-divider: #333333;
}

/* ── 기본 ── */
body {
    background: var(--mb-bg);
    color: var(--mb-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    -webkit-font-smoothing: antialiased;
    padding-bottom: env(safe-area-inset-bottom);
}

/* ── PC 레이아웃 (중앙 정렬, 최대 너비 제한) ── */
.mb-wrapper {
    max-width: 720px;
    margin: 0 auto;
}

/* ── 글자 크기 (3단계) ── */
.font-small  { font-size: 14px; }
.font-medium { font-size: 16px; }
.font-large  { font-size: 19px; }

.font-small .verse-text  { line-height: 1.7; }
.font-medium .verse-text { line-height: 1.8; }
.font-large .verse-text  { line-height: 1.9; }

/* ── 상단 네비게이션 ── */
.mb-nav {
    background: var(--mb-nav-bg);
    padding: 8px 0;
    z-index: 1030;
}

.mb-nav .container-fluid {
    max-width: 720px;
    margin: 0 auto;
}

.mb-nav .navbar-brand {
    font-size: 1rem;
    color: var(--mb-nav-text);
    display: flex;
    align-items: center;
}

/* ── 브레드크럼 ── */
.mb-breadcrumb {
    font-size: 0.78em;
    color: var(--mb-text-muted);
    padding: 10px 0 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--mb-card-bg);
    border: 1px solid var(--mb-card-border);
    border-radius: 8px;
    padding: 6px 12px;
    margin-top: 8px;
}
.mb-breadcrumb a {
    color: var(--mb-accent);
    text-decoration: none;
    transition: color 0.15s;
}
.mb-breadcrumb a:hover {
    color: var(--mb-text);
}
.mb-breadcrumb-home {
    display: flex;
    align-items: center;
}
.mb-breadcrumb-home svg {
    width: 14px;
    height: 14px;
}
.mb-breadcrumb-sep {
    width: 16px !important;
    height: 16px !important;
    color: var(--mb-text-muted);
    flex-shrink: 0;
    stroke-width: 2.5;
}
.mb-breadcrumb-current {
    color: var(--mb-text);
    font-weight: 600;
}

/* ── 성경 읽기 영역 ── */
.bible-header {
    background: var(--mb-card-bg);
    border-bottom: 1px solid var(--mb-card-border);
    padding: 10px 12px;
    position: sticky;
    top: 48px;
    z-index: 1020;
    max-width: 720px;
    margin: 0 auto;
}

.bible-selector select {
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--mb-card-border);
    background: var(--mb-bg);
    color: var(--mb-text);
}

.verse-row {
    padding: 8px 12px;
    border-bottom: 1px solid transparent;
    transition: background 0.15s;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.verse-row:active {
    background: var(--mb-verse-hover);
}

.verse-num {
    color: var(--mb-verse-num);
    font-weight: 700;
    font-size: 0.8em;
    min-width: 28px;
    text-align: right;
    padding-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.verse-text {
    flex: 1;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.verse-highlight {
    background: var(--mb-highlight);
    border-radius: 4px;
}

/* ── 대조 읽기 ── */
.compare-wrapper {
    display: flex;
    gap: 0;
}

.compare-col {
    flex: 1;
    min-width: 0;
}

.compare-col + .compare-col {
    border-left: 1px solid var(--mb-divider);
}

.compare-verse {
    padding: 6px 10px;
    font-size: 0.9em;
    border-bottom: 1px solid var(--mb-card-border);
}

.compare-label {
    font-size: 0.7em;
    font-weight: 700;
    color: var(--mb-text-muted);
    text-transform: uppercase;
}

/* ── 장 네비게이션 ── */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-top: 1px solid var(--mb-divider);
    background: var(--mb-card-bg);
    position: sticky;
    bottom: 0;
    z-index: 1010;
    max-width: 720px;
    margin: 0 auto;
}

.chapter-nav a,
.chapter-nav span {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.9em;
    text-decoration: none;
}

/* ── 장 선택 그리드 ── */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
}

.chapter-grid a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    border-radius: 6px;
    background: var(--mb-card-bg);
    border: 1px solid var(--mb-card-border);
    color: var(--mb-text);
    text-decoration: none;
    font-size: 0.85em;
}

.chapter-grid a:active,
.chapter-grid a.active {
    background: var(--mb-accent);
    color: #fff;
    border-color: var(--mb-accent);
}

/* ── 검색 ── */
.search-result-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--mb-card-border);
}

.search-result-item .ref {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--mb-accent);
}

.search-keyword {
    background: var(--mb-highlight);
    padding: 0 2px;
    border-radius: 2px;
}

/* ── 카드 공통 ── */
.mb-card {
    background: var(--mb-card-bg);
    border: 1px solid var(--mb-card-border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}

/* ── 이어서 읽기 카드 (배경 차별화) ── */
.mb-card-lastread {
    background: #eef3f8;
    border-color: #d4dfe9;
}

[data-bs-theme="dark"] .mb-card-lastread {
    background: #1a2332;
    border-color: #2a3a4e;
}

/* ── 오늘의 말씀 카드 ── */
.today-verse-card {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #ffffff;
    border-radius: 12px;
    padding: 24px 20px;
    text-align: center;
}

[data-bs-theme="dark"] .today-verse-card {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 100%);
}

.today-verse-card .verse-content {
    font-size: 1.1em;
    line-height: 1.8;
    margin: 16px 0;
    word-break: keep-all;
}

.today-verse-card .verse-reference {
    font-size: 0.85em;
    opacity: 0.8;
}

/* ── 읽기 플랜 ── */
.plan-progress {
    height: 6px;
    border-radius: 3px;
    background: var(--mb-card-border);
    overflow: hidden;
}

.plan-progress-bar {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, #1a1a2e, #2d3a5c);
    transition: width 0.3s;
}

[data-bs-theme="dark"] .plan-progress-bar {
    background: linear-gradient(90deg, #e2b93b, #d4a72c);
}

/* ── 읽기 플랜 섹션 타이틀 ── */
.plan-section-title {
    font-size: 1em;
    font-weight: 800;
    color: var(--mb-text);
    padding: 16px 0 8px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ── 읽기 플랜 그룹 헤더 ── */
.plan-group-header {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--mb-nav-bg);
    padding: 10px 4px 6px;
    margin-top: 8px;
    border-bottom: 2px solid var(--mb-nav-bg);
    margin-bottom: 12px;
}

[data-bs-theme="dark"] .plan-group-header {
    color: #e2b93b;
    border-bottom-color: #e2b93b;
}

/* ── 맞춤 플랜 책 선택 그리드 ── */
.book-select-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
    gap: 6px;
}

.book-select-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    border-radius: 6px;
    background: var(--mb-card-bg);
    border: 1px solid var(--mb-card-border);
    color: var(--mb-text);
    font-size: 0.78em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    padding: 0 4px;
    white-space: nowrap;
}

.book-select-btn:hover {
    border-color: var(--mb-accent);
    color: var(--mb-accent);
}

.book-select-btn.active {
    background: var(--mb-nav-bg);
    color: #fff;
    border-color: var(--mb-nav-bg);
}

[data-bs-theme="dark"] .book-select-btn.active {
    background: #e2b93b;
    color: #1a1a2e;
    border-color: #e2b93b;
}

/* ── 맞춤 플랜 단계 라벨 ── */
.step-label {
    font-size: 0.88em;
    font-weight: 700;
    color: var(--mb-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.step-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--mb-nav-bg);
    color: #fff;
    font-size: 0.72em;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

[data-bs-theme="dark"] .step-badge {
    background: #e2b93b;
    color: #1a1a2e;
}

.book-select-summary {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--mb-text);
    background: var(--mb-card-bg);
    border: 1px solid var(--mb-card-border);
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
}

/* ── 공유 팝업 ── */
.share-popup {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--mb-card-bg);
    border-top: 1px solid var(--mb-card-border);
    border-radius: 16px 16px 0 0;
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    z-index: 1050;
}

.share-popup.show {
    transform: translateY(0);
}

.share-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1040;
    display: none;
}

.share-popup-backdrop.show {
    display: block;
}

.share-btn-group {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.share-btn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--mb-text);
    font-size: 0.8em;
    cursor: pointer;
    border: none;
    background: none;
    padding: 8px;
}

.share-btn-item .icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── 하단 푸터 ── */
.mb-footer {
    background: var(--mb-footer-bg);
    border-top: 1px solid var(--mb-divider);
}

.mb-footer .text-center {
    max-width: 720px;
    margin: 0 auto;
}

/* ── PC 배경 구분 (넓은 화면에서 양쪽 여백 구분) ── */
@media (min-width: 768px) {
    body {
        background: #f0f0f0;
    }
    [data-bs-theme="dark"] body,
    body[class*="font-"]:is([data-bs-theme="dark"] *) {
        background: #0a0a0a;
    }
    [data-bs-theme="dark"] {
        background: #0a0a0a;
    }

    .mb-wrapper {
        background: var(--mb-bg);
        min-height: 100vh;
        box-shadow: 0 0 20px rgba(0,0,0,0.08);
    }

    .mb-nav {
        border-bottom: none;
    }
}

/* ── 홈 책 목록 ── */
.book-list-section h3 {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--mb-text-muted);
    margin-bottom: 8px;
}

.book-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--mb-card-bg);
    border: 1px solid var(--mb-card-border);
    color: var(--mb-text);
    text-decoration: none;
    font-size: 0.82em;
    white-space: nowrap;
    position: relative;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.book-badge:hover {
    background: var(--mb-nav-bg);
    color: #fff;
    border-color: var(--mb-nav-bg);
}

.book-badge:active {
    background: var(--mb-accent);
    color: #fff;
    border-color: var(--mb-accent);
}

/* 풀네임 툴팁 (CSS) */
.book-badge::after {
    content: attr(data-title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #1a1a2e;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 100;
}

/* 말풍선 꼬리 */
.book-badge::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a1a2e;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 100;
}

.book-badge:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.book-badge:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ── Scroll to Top 버튼 ── */
#scrollTopBtn {
    position: fixed;
    bottom: 28px;
    right: 24px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    z-index: 990;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

#scrollTopBtn.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scrollTopBtn:hover {
    transform: translateY(-3px);
}

.scroll-top-bg {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #1a1a2e;
    box-shadow: 0 4px 16px rgba(26, 26, 46, 0.28);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

#scrollTopBtn:hover .scroll-top-bg {
    background: #16213e;
    box-shadow: 0 6px 22px rgba(26, 26, 46, 0.4);
}

.scroll-progress-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.scroll-progress-track {
    fill: none;
    stroke: rgba(255, 255, 255, 0.18);
    stroke-width: 3;
}

.scroll-progress-fill {
    fill: none;
    stroke: #e2b93b;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 113.1;
    stroke-dashoffset: 113.1;
    transition: stroke-dashoffset 0.12s linear;
}

.scroll-top-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    pointer-events: none;
    user-select: none;
}

.scroll-top-arrow {
    width: 14px;
    height: 14px;
    color: rgba(255, 255, 255, 0.95);
    stroke-width: 2.8;
    display: block;
}

#scrollTopBtn:hover .scroll-top-arrow {
    animation: arrowBounce 0.45s ease forwards;
}

@keyframes arrowBounce {
    0%   { transform: translateY(0); }
    35%  { transform: translateY(-4px); }
    65%  { transform: translateY(-1px); }
    100% { transform: translateY(-2px); }
}

.scroll-top-pct {
    font-size: 9px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1;
    letter-spacing: -0.3px;
}

/* ── 스크롤바 (웹킷) ── */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-thumb {
    background: var(--mb-text-muted);
    border-radius: 2px;
}

/* ── 토스트 알림 ── */
.mb-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.85em;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1060;
    pointer-events: none;
}

.mb-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── 모바일 터치 최적화 ── */
@media (max-width: 576px) {
    .bible-header {
        top: 46px;
    }
    .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }
}

/* ── 안전 영역 (노치 대응) ── */
@supports (padding: env(safe-area-inset-bottom)) {
    .chapter-nav {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* ── 모바일 Scroll to Top 위치 조정 ── */
@media (max-width: 768px) {
    #scrollTopBtn {
        bottom: 64px;
    }
}