/* Basic Reset & Font Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif, Arial, Helvetica;
    line-height: 1.7;
    color: #333;
    background-color: #f8f9fa; /* Lighter grey background */
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #e9ecef; /* Light border */
    padding-bottom: 20px;
    position: relative;
}

.author-portrait {
    display: block;
    max-width: 150px; /* 이미지 크기 조정 */
    height: auto;
    border-radius: 8px; /* 둥근 모서리 */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin: 0 auto 20px auto;
    border: 1px solid #dee2e6;
}

header h1 {
    font-family: 'Noto Serif KR', serif, Georgia, Times;
    font-size: 2.4em; /* 제목 크기 조정 */
    color: #2c3e50; /* 진한 남색 계열 */
    margin-bottom: 10px;
}

header .intro {
    font-size: 1.1em;
    color: #555;
    margin-bottom: 15px;
    max-width: 800px; /* 소개글 너비 제한 */
    margin-left: auto;
    margin-right: auto;
}

.source-info {
    margin-top: 15px;
    margin-bottom: 20px;
    font-size: 0.85em; /* 약간 작게 */
    color: #6c757d;
    text-align: center;
    line-height: 1.6;
    background-color: #f0f3f5; /* 연한 배경색 추가 */
    padding: 10px;
    border-radius: 4px;
}

.source-info em {
    font-style: italic;
    color: #495057;
}

.source-info .translation-info {
    color: #007bff; /* 파란색 계열 */
    font-weight: 500;
}

.source-info .bookstore-link {
    color: #0d6efd;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.source-info .bookstore-link:hover {
    color: #0a58ca;
}

.search-container {
    margin-top: 20px; /* 간격 조정 */
    position: relative;
    display: inline-block;
    width: 90%; /* 너비 조정 */
    max-width: 600px; /* 최대 너비 조정 */
}

#searchInput {
    width: 100%;
    padding: 12px 40px 12px 20px; /* 패딩 조정 */
    font-size: 1em;
    border: 1px solid #ced4da;
    border-radius: 25px; /* 더 둥글게 */
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#searchInput:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

#clearSearchBtn {
    position: absolute;
    top: 50%;
    right: 15px; /* 위치 조정 */
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.5em; /* 아이콘 크기 */
    color: #aaa;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    display: none; /* JS로 제어 */
}

#clearSearchBtn:hover {
    color: #555;
}

/* Main Content Layout */
.main-content {
    display: flex;
    gap: 30px;
}

.alphabet-nav {
    width: 80px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    padding-right: 10px;
    background-color: #fff;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 10px 5px 10px 10px;
}

.alphabet-nav::-webkit-scrollbar { width: 8px; }
.alphabet-nav::-webkit-scrollbar-track { background: #f1f1f1; }
.alphabet-nav::-webkit-scrollbar-thumb { background: #888; border-radius: 4px; }
.alphabet-nav::-webkit-scrollbar-thumb:hover { background: #555; }

.alphabet-nav ul { list-style: none; }
.alphabet-nav li a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    font-weight: bold;
    color: #0d6efd;
    border-radius: 4px;
    transition: background-color 0.2s ease, color 0.2s ease;
    text-align: center;
    font-size: 1.1em;
}
.alphabet-nav li a:hover,
.alphabet-nav li a:focus {
    background-color: #e7f1ff;
    color: #0a58ca;
}

.glossary-content {
    flex-grow: 1;
    background-color: #fff;
    padding: 25px 35px; /* 패딩 증가 */
    border: 1px solid #e9ecef;
    border-radius: 5px;
    min-height: 500px;
}

.glossary-content section {
    margin-bottom: 40px;
}

.glossary-content section h2 { /* 용어 해설 섹션의 H2 */
    font-family: 'Noto Serif KR', serif, Georgia, Times;
    font-size: 1.8em;
    color: #2c3e50;
    margin-top: 30px; /* 첫 H2 상단 마진 추가 */
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
    scroll-margin-top: 20px; /* 스크롤 시 헤더에 가려지지 않도록 */
}
.glossary-content section:first-of-type h2 { /* 첫번째 용어해설 H2는 마진을 좀 더 */
    margin-top: 0;
}


#table-of-contents {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f0f3f5;
    border: 1px solid #e0e5e9;
    border-radius: 5px;
}

#table-of-contents h2 { /* 목차의 H2 */
    font-size: 1.7em; /* 크기 조정 */
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ced4da;
    color: #34495e;
    margin-top: 0; /* 목차 H2는 상단 마진 제거 */
}

#table-of-contents ul {
    list-style: none;
    padding-left: 0;
    line-height: 1.8;
}
#table-of-contents li { margin-bottom: 8px; }
#table-of-contents a {
    color: #0056b3;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}
#table-of-contents a:hover {
    color: #003d80;
    text-decoration: underline;
}
#table-of-contents ul ul {
    margin-top: 5px;
    margin-left: 20px;
    list-style-type: disc; /* 기본 disc로 변경 */
    padding-left: 20px;
}
#table-of-contents ul ul li {
    font-size: 0.95em;
}


hr {
    border: 0;
    height: 1px;
    background-color: #dee2e6;
    margin-top: 0;
    margin-bottom: 40px;
}

dl { margin-bottom: 0; }
.glossary-entry {
     margin-bottom: 25px;
     padding-bottom: 15px;
     border-bottom: 1px dashed #eee;
}
.glossary-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

dt {
    font-family: 'Noto Serif KR', 'Noto Serif', serif, Georgia, Times;
    font-size: 1.25em; /* 약간 크게 */
    font-weight: 600;
    color: #34495e;
    margin-bottom: 8px;
}

dd {
    margin-left: 20px;
    font-size: 1em;
    color: #495057;
    font-family: 'Noto Serif KR', 'Noto Serif', serif, Georgia, Times; /* 본문과 통일 */
    line-height: 1.8;
}

dd p em, span.related-terms {
    display: block;
    margin-top: 8px;
    font-style: italic;
    color: #5a6a7a;
    font-size: 0.95em;
}
dd p em + br + span.related-terms { margin-top: 0; }

/* Source Reference Style */
dd .source-ref {
    font-style: italic;
    color: #6c757d;
    font-size: 0.9em;
    transition: color 0.3s ease, font-style 0.3s ease;
}
dd .source-ref.active-filter-ref { /* JS로 필터링 시 부모 컨테이너 스타일 */
    font-style: normal;
    /* color: #90EE90; /* 연한 녹색 계열 */
}
dd .source-ref.active-filter-ref .highlight-section { /* JS로 필터링 시 실제 참조부분 */
    font-weight: bold;
    color: #2E8B57; /* 진한 녹색 계열 */
}
.source-ref-section-item { /* JS로 생성되는 클릭 가능한 참조 아이템 */
    cursor: pointer;
    color: inherit;
    padding: 0 1px;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}
.source-ref-section-item:hover {
    text-decoration: underline;
    color: #0d6efd;
}
.internal-link {
    color: #0056b3;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease;
}
.internal-link:hover {
    color: #003d80;
    text-decoration: underline;
}

/* Bible Verses Section Styles */
#bible-verses h2 { /* 성경 구절 목록 전체 H2 */
    font-family: 'Noto Serif KR', serif, Georgia, Times;
    font-size: 2em; /* 목차 H2와 통일 */
    color: #2c3e50;
    margin-bottom: 25px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.bible-verse-category {
    margin-bottom: 30px;
    padding: 15px;
    border: 1px solid #e0e5e9;
    border-radius: 4px;
    background-color: #f9f9f9;
}
.bible-verse-category h3 { /* 각 장별 소제목 H3 */
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 1.4em;
    color: #34495e;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px dotted #ccc;
}
#bible-verses ul {
    list-style: none;
    padding-left: 0;
}
#bible-verses li {
    margin-bottom: 8px;
    padding: 5px 0;
    font-size: 0.95em;
    color: #555;
    line-height: 1.6;
}
#bible-verses li:not(:last-child) {
    border-bottom: 1px dotted #eee;
}
#bible-verses li.highlight-verse { /* JS로 특정 구절 하이라이트 시 */
    background-color: #fff3cd; /* 연한 노란색 */
    font-weight: bold;
    padding-left: 10px; /* 약간 들여쓰기 */
    border-left: 3px solid #ffc107; /* 노란색 테두리 */
}


footer {
    margin-top: 50px;
    text-align: center;
    font-size: 0.9em;
    color: #6c757d;
    border-top: 1px solid #e9ecef;
    padding-top: 20px;
}
footer a {
    color: #0d6efd;
    text-decoration: none;
}
footer a:hover {
    text-decoration: underline;
}

#scrollToTopBtn {
    opacity: 0; visibility: hidden;
    position: fixed; bottom: 30px; right: 30px;
    z-index: 999; border: none; outline: none;
    background-color: rgba(0, 0, 0, 0.6);
    color: white; cursor: pointer;
    padding: 10px 15px; border-radius: 50%;
    font-size: 18px; line-height: 1;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, background-color 0.3s;
}
#scrollToTopBtn.show { opacity: 1; visibility: visible; }
#scrollToTopBtn:hover { background-color: rgba(0, 0, 0, 0.8); }

/* Visually Hidden Class for Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


@media (max-width: 992px) {
    .author-portrait { max-width: 120px; }
    header h1 { font-size: 2.1em; }
}

@media (max-width: 768px) {
    .main-content { flex-direction: column; }
    .alphabet-nav {
        position: static; width: 100%;
        max-height: none; overflow-y: visible;
        padding-right: 10px; margin-bottom: 20px;
        border-bottom: 1px solid #e9ecef;
        padding-bottom: 15px;
    }
    .alphabet-nav ul {
        display: flex; flex-wrap: wrap;
        justify-content: center; gap: 5px;
    }
    .alphabet-nav li { flex-basis: calc(100% / 8); min-width: 35px; } /* 칸 수 조정 */
    .alphabet-nav li a { padding: 5px 8px; font-size: 1em; }

    .glossary-content { padding: 15px 20px; }
    .glossary-content section h2, #bible-verses h2 { font-size: 1.6em; scroll-margin-top: 10px; }
    #table-of-contents h2 { font-size: 1.5em; }
    .bible-verse-category h3 { font-size: 1.2em; }
    dt { font-size: 1.15em; }
    dd { font-size: 0.95em; margin-left: 10px; }
    #searchInput { padding-right: 30px; }
    .search-container { width: 95%; }
}

@media (max-width: 480px) {
    .alphabet-nav li { flex-basis: calc(100% / 6); } /* 칸 수 조정 */
    .glossary-content { padding: 10px 15px; }
    header h1 { font-size: 1.8em; }
    dt { font-size: 1.1em; }
    dd { font-size: 0.9em; }
    #table-of-contents { padding: 15px; }
    #table-of-contents h2 { font-size: 1.3em; }
    .bible-verse-category h3 { font-size: 1.1em; }
    #bible-verses li { font-size: 0.9em; }
}