/* Reader themes — Newspaper Edition */

:root {
    --bg: #FAF8F5;
    --text: #1A1A1A;
    --text-secondary: #6B6560;
    --replaced-text: #8B2500;
    --replaced-underline: rgba(139, 37, 0, 0.25);
    --border: #D6D0C8;
    --surface: #FFFFFF;
    --popup-shadow: rgba(0, 0, 0, 0.08);
}

[data-theme="warm"] {
    --bg: #F0E8D8;
    --text: #3D3529;
    --text-secondary: #8B7D6B;
    --replaced-text: #7A4A1A;
    --replaced-underline: rgba(122, 74, 26, 0.25);
    --border: #C8B898;
    --surface: #E8DEC8;
    --popup-shadow: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg: #171615;
    --text: #C8C4BE;
    --text-secondary: #7A7570;
    --replaced-text: #D4916A;
    --replaced-underline: rgba(212, 145, 106, 0.25);
    --border: #2E2C2A;
    --surface: #222120;
    --popup-shadow: rgba(0, 0, 0, 0.3);
}

.hl {
    color: var(--replaced-text);
}

.translated-sentence-block {
    cursor: pointer;
}

.translated-sentence-en {
    display: block;
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    font-size: 0.9em;
    color: var(--replaced-text);
    margin: 2px 0 4px 0;
    padding-left: 1em;
    border-left: 2px solid var(--replaced-underline);
    line-height: 1.5;
}

body.reader-body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'LXGW WenKai', 'Songti SC', serif;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s, color 0.3s;
    overflow: hidden;
    height: 100vh;
}

/* Pagination container */
.reader-paginator {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: text;
}

/* Replaced words — editorial annotation style */
.replaced-word {
    font-family: 'EB Garamond', Georgia, serif;
    font-style: italic;
    color: var(--replaced-text);
    border-bottom: 1px solid var(--replaced-underline);
    cursor: pointer;
    padding: 0;
    background: none;
    border-radius: 0;
    text-decoration: none;
    transition: border-color 0.15s;
}

.replaced-word-original {
    color: var(--text);
    background: none;
    border-bottom: none;
    font-style: normal;
    font-family: inherit;
}

.replaced-word:active {
    border-bottom-color: var(--replaced-text);
}

/* Reading content — CSS columns pagination */
.reader-content {
    height: 100%;
    column-fill: auto;
    letter-spacing: 0.03em;
    padding: 52px 20px 60px;
    box-sizing: border-box;
    transition: transform 0.3s ease;
}

.reader-content p {
    text-indent: 2em;
    margin-bottom: 0.8em;
    /* Prevent paragraphs from breaking across columns awkwardly */
    break-inside: auto;
    orphans: 2;
    widows: 2;
}

.reader-content.no-transition {
    transition: none !important;
}

.para-break {
    display: block;
    height: 0.5em;
}

/* Unified toolbar button */
.bar-btn {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 4px;
    text-decoration: none;
    transition: color 0.15s;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.bar-btn:active {
    color: var(--text);
}

.bar-btn-active {
    color: var(--replaced-text);
}

/* Word popup */
.word-popup {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 12px 16px;
    box-shadow: 0 2px 12px var(--popup-shadow);
    z-index: 100;
    min-width: 160px;
}

.word-popup-en {
    font-family: 'EB Garamond', Georgia, serif;
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--replaced-text);
}

.word-popup-cn {
    font-family: 'LXGW WenKai', serif;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.word-popup-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

.word-popup-btn {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 2px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.word-popup-btn-save {
    color: #8B2500;
    background: transparent;
    border: 1px solid #8B2500;
}

[data-theme="warm"] .word-popup-btn-save {
    color: #7A4A1A;
    border-color: #7A4A1A;
}

[data-theme="dark"] .word-popup-btn-save {
    color: #D4916A;
    border-color: #D4916A;
}

.word-popup-btn-memorize {
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
}

/* Top & bottom bars */
.reader-bar {
    background: var(--surface);
    border-color: var(--border);
    transition: transform 0.25s ease;
}

.reader-bar.hidden-bar {
    transform: translateY(-100%);
}

.bottom-bar.hidden-bar {
    transform: translateY(100%);
}

/* Search input */

/* Search input */
.search-input {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: var(--text);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 4px 0;
    outline: none;
}

.search-input:focus {
    border-bottom-color: var(--text);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

/* Search results */
.search-results-panel {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: 0 4px 16px var(--popup-shadow);
}

.search-result-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    cursor: pointer;
    transition: background 0.1s;
}

.search-result-item:active {
    background: var(--replaced-underline);
}

.search-result-chapter {
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--replaced-text);
    display: block;
    margin-bottom: 2px;
}

.search-result-snippet {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: block;
    line-height: 1.4;
}

/* TOC */
.toc-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.toc-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 10px 4px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: none;
    cursor: pointer;
    transition: background 0.1s;
}

.toc-item:active {
    background: var(--replaced-underline);
}

.toc-item.active .toc-chapter-name {
    color: var(--replaced-text);
}

.toc-index {
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 20px;
    text-align: right;
}

.toc-chapter-name {
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Progress slider bar */
.slider-bar {
    position: fixed;
    bottom: 56px;
    left: 0;
    right: 0;
    z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.slider-bar.hidden {
    display: none;
}

.progress-slider {
    width: 100%;
    accent-color: var(--replaced-text);
    cursor: pointer;
}

.slider-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 2px;
}

/* Settings bottom sheet */
.settings-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px var(--popup-shadow);
    padding: 0 20px 16px;
    max-width: 480px;
    margin: 0 auto;
}

/* Theme swatches */
.theme-swatch {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: border-color 0.15s;
}

.theme-swatch.active {
    border: 2px solid #8B2500;
}

[data-theme="warm"] .theme-swatch.active {
    border-color: #7A4A1A;
}

[data-theme="dark"] .theme-swatch.active {
    border-color: #D4916A;
}

/* Setting rows — label left, options right */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 0;
}

.setting-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 36px;
}

.setting-options {
    display: flex;
    gap: 8px;
    align-items: center;
}

.setting-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

/* Option buttons — generous touch targets */
.setting-opt {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    min-width: 44px;
    min-height: 36px;
    padding: 6px 12px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    text-align: center;
}

.setting-opt.active {
    color: var(--text);
    border-color: #8B2500;
}

[data-theme="warm"] .setting-opt.active {
    border-color: #7A4A1A;
}

[data-theme="dark"] .setting-opt.active {
    border-color: #D4916A;
}
