/* =========================================================
   Apple-inspired plain UI for Buddhist Dictionary
   ========================================================= */

:root {
    --radius: 14px;
    --radius-lg: 18px;
}

*, *::before, *::after { -webkit-tap-highlight-color: transparent; }

html, body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Hide scrollbars on tabs */
.scrollbar-hide::-webkit-scrollbar { display: none; }
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* Subtle scrollbar elsewhere */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 999px; }
.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); }

/* ===== Card (Apple-style) ===== */
.ios-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0,0,0,0.06);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.03);
    transition: box-shadow .25s ease;
}
.dark .ios-card {
    background: #1c1c1e;
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 1px 2px rgba(0,0,0,0.5), 0 4px 24px rgba(0,0,0,0.3);
}

/* ===== Tabs (segmented-style scroll) ===== */
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: #6e6e73;
    white-space: nowrap;
    transition: all .2s ease;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
}
.tab-btn:hover { background: rgba(0,0,0,0.04); }
.dark .tab-btn { color: #98989d; }
.dark .tab-btn:hover { background: rgba(255,255,255,0.06); }
.tab-btn.active {
    background: #ffffff;
    color: #1d1d1f;
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.dark .tab-btn.active {
    background: #2c2c2e;
    color: #f5f5f7;
    border-color: rgba(255,255,255,0.08);
}

/* ===== Stat cards ===== */
.ios-stat {
    border-radius: var(--radius);
    padding: 14px 16px;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.ios-stat-l { font-size: 12px; opacity: .85; letter-spacing: .02em; }
.ios-stat-v { font-size: 28px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.ios-stat-s { font-size: 11px; opacity: .75; margin-top: 2px; }

/* ===== Inputs / checkbox ===== */
.ios-check {
    appearance: none;
    width: 16px; height: 16px;
    border: 1.5px solid #c7c7cc;
    border-radius: 5px;
    position: relative;
    cursor: pointer;
    transition: all .2s;
    background: #fff;
}
.dark .ios-check { background: #1c1c1e; border-color: #48484a; }
.ios-check:checked { background: #0071e3; border-color: #0071e3; }
.ios-check:checked::after {
    content: '';
    position: absolute;
    top: 1px; left: 4px;
    width: 4px; height: 8px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ===== Autocomplete dropdown ===== */
.ac-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    transition: background .15s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.selected {
    background: rgba(0,113,227,0.08);
}
.dark .ac-item { border-bottom-color: rgba(255,255,255,0.06); }
.dark .ac-item.selected, .dark .ac-item:hover { background: rgba(0,113,227,0.18); }

mark.search-match {
    background: #ffec99;
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 600;
}
.dark mark.search-match { background: #856300; color: #fff5d0; }

/* ===== Result cards ===== */
.result-card {
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
    animation: fadeUp .35s ease both;
}
.result-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}
.dark .result-card { background: #2c2c2e; border-color: rgba(255,255,255,0.06); }
.dark .result-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.4); }

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

/* ===== Tag chips ===== */
.tag-chip {
    display: inline-block;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(0,113,227,0.08);
    color: #0071e3;
    cursor: pointer;
    transition: all .2s;
    border: 1px solid transparent;
}
.tag-chip:hover { background: rgba(0,113,227,0.16); border-color: rgba(0,113,227,0.3); }
.dark .tag-chip { background: rgba(10,132,255,0.18); color: #64b5ff; }
.dark .tag-chip:hover { background: rgba(10,132,255,0.3); }

/* ===== Letter pills ===== */
.letter-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    font-family: 'Noto Serif TC', serif;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
}
.letter-pill:hover { background: rgba(0,113,227,0.06); }
.letter-pill.active {
    background: #0071e3; color: #fff; border-color: #0071e3;
}
.dark .letter-pill { background: #2c2c2e; border-color: rgba(255,255,255,0.08); color: #f5f5f7; }
.dark .letter-pill.active { background: #0071e3; color: #fff; }

/* ===== Browse items ===== */
.browse-item {
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
}
.browse-item:hover { background: rgba(0,0,0,0.04); }
.dark .browse-item:hover { background: rgba(255,255,255,0.06); }

/* ===== Cross reference link ===== */
.xref-link {
    color: #0071e3;
    cursor: pointer;
    border-bottom: 1px dotted rgba(0,113,227,0.5);
    transition: all .15s;
    padding: 0 1px;
    border-radius: 3px;
}
.xref-link:hover {
    background: rgba(0,113,227,0.1);
    border-bottom-color: #0071e3;
}
.dark .xref-link { color: #64b5ff; border-bottom-color: rgba(100,181,255,0.5); }
.dark .xref-link:hover { background: rgba(100,181,255,0.15); }

/* ===== Highlight on selection ===== */
.highlight.active {
    background: linear-gradient(transparent 60%, #ffeb3b 60%);
    transition: background .3s;
}
.dark .highlight.active {
    background: linear-gradient(transparent 60%, #fbbf24 60%);
    color: #1d1d1f;
}

/* ===== Char cloud ===== */
.cloud-word {
    font-family: 'Noto Serif TC', serif;
    font-weight: 600;
    cursor: pointer;
    transition: transform .2s, opacity .2s;
    line-height: 1.2;
    padding: 2px 4px;
}
.cloud-word:hover { transform: scale(1.18); opacity: .85; }

/* ===== Modal action buttons ===== */
.modal-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid rgba(0,0,0,0.08);
    font-size: 13px;
    font-weight: 500;
    color: #1d1d1f;
    cursor: pointer;
    transition: all .15s;
}
.modal-action:hover { background: rgba(0,113,227,0.06); border-color: rgba(0,113,227,0.3); }
.modal-action:active { transform: scale(0.97); }
.dark .modal-action { background: #2c2c2e; border-color: rgba(255,255,255,0.08); color: #f5f5f7; }
.dark .modal-action:hover { background: rgba(10,132,255,0.16); border-color: rgba(10,132,255,0.4); }

.modal-action.is-active {
    background: #fff7e0;
    border-color: #f5c518;
    color: #8a6300;
}
.dark .modal-action.is-active {
    background: rgba(245,197,24,0.18);
    border-color: rgba(245,197,24,0.5);
    color: #fbbf24;
}

/* ===== Detail modal show ===== */
#detailModal:not(.hidden) { display: flex; }

/* ===== Font scaling ===== */
body[data-fontsize="1"] #modalContent { font-size: 14px; }
body[data-fontsize="2"] #modalContent { font-size: 16px; }
body[data-fontsize="3"] #modalContent { font-size: 18px; }
body[data-fontsize="4"] #modalContent { font-size: 20px; }

/* ===== D3 network ===== */
.network-link { stroke: #c7c7cc; stroke-opacity: 0.6; stroke-width: 1.2px; }
.dark .network-link { stroke: #48484a; }
.network-node text {
    font-family: 'Noto Serif TC', serif;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 3px;
    stroke-linejoin: round;
}
.dark .network-node text { stroke: #1c1c1e; }

/* ===== utility ===== */
.line-clamp-1 { display:-webkit-box; -webkit-line-clamp:1; -webkit-box-orient:vertical; overflow:hidden; }
.line-clamp-2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.line-clamp-3 { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.font-serif-tc { font-family: 'Noto Serif TC', serif; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .ios-stat-v { font-size: 22px; }
    .modal-action span:not(.material-icons-round) { display: none; }
}