/* ============================================================
   IWantLearn Dict · 基础样式（延续 iwantlearn 金色主题）
   ============================================================ */

:root {
    --gold: #d4a017;
    --gold-light: #f5d76e;
    --gold-dark: #c4900e;
    --gold-bg: rgba(212, 160, 23, 0.08);

    --text: #2c3e50;
    --text-sub: #555;
    --text-muted: #888;
    --text-faint: #bbb;

    --bg: #fafafa;
    --card: #ffffff;
    --card-hover: #fffdf7;
    --border: #f0f0f0;
    --border-strong: #e6e2d6;
    --nav-bg: rgba(255, 255, 255, 0.92);
    --mark-bg: #fff1c2;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.07);
    --shadow-gold: 0 6px 20px rgba(212, 160, 23, 0.18);

    --nav-height: 64px;
    --container: 1120px;
    color-scheme: light;
}

html.dark-mode {
    --gold: #f5d76e;
    --gold-light: #ffe9a3;
    --gold-dark: #e8c85a;
    --gold-bg: rgba(245, 215, 110, 0.10);

    --text: #e8e8ec;
    --text-sub: #bbb;
    --text-muted: #8d8da6;
    --text-faint: #666;

    --bg: #1a1a2e;
    --card: #252545;
    --card-hover: #2a2a50;
    --border: #3a3a5c;
    --border-strong: #4a4a70;
    --nav-bg: rgba(26, 26, 46, 0.94);
    --mark-bg: rgba(245, 215, 110, 0.2);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.32);
    --shadow-gold: 0 6px 20px rgba(245, 215, 110, 0.12);
    color-scheme: dark;
}

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

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    padding-top: var(--nav-height);
    overflow-x: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC',
        'Noto Sans SC', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    transition: background-color .3s ease, color .3s ease;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { color: inherit; }
img, svg { display: block; }
::selection { background: rgba(212, 160, 23, 0.28); }

mark {
    background: var(--mark-bg);
    color: var(--gold-dark);
    padding: 0 2px;
    border-radius: 3px;
    font-weight: 600;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- 动画 ---------- */
@keyframes goldFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

main { animation: pageFadeIn .32s ease; }

.gold-text {
    background: linear-gradient(135deg, var(--gold), var(--gold-light), var(--gold), var(--gold-light));
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: goldFlow 5s ease infinite;
}

/* ---------- 顶部导航 ---------- */
#navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--nav-height);
    background: var(--nav-bg);
    -webkit-backdrop-filter: blur(14px) saturate(180%);
    backdrop-filter: blur(14px) saturate(180%);
    border-bottom: 1px solid var(--border);
}

.nav-container {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1280px;
    height: 100%;
    margin: 0 auto;
    padding: 0 24px;
}

.nav-brand {
    flex-shrink: 0;
    font-size: 1.32rem;
    font-weight: 800;
    letter-spacing: .5px;
    white-space: nowrap;
    background: linear-gradient(135deg, var(--gold), var(--gold-light), var(--gold), var(--gold-light));
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: goldFlow 5s ease infinite;
}

.brand-dot {
    display: inline-block;
    margin: 0 4px;
    font-weight: 400;
    opacity: .7;
}
.brand-short { display: none; }

/* 导航搜索：默认收起为图标，悬停/聚焦展开 */
.nav-search {
    position: relative;
    z-index: 1010;
    flex: 0 0 auto;
    width: 42px;
    min-width: 0;
    margin-left: auto;
    transition: width .3s cubic-bezier(.4, 0, .2, 1);
}
.nav-search:hover,
.nav-search:focus-within { width: min(430px, 36vw); }

.search-field {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50px;
    cursor: pointer;
    transition: background-color .2s ease, padding .3s ease;
}
.nav-search:hover .search-field,
.nav-search:focus-within .search-field {
    justify-content: flex-start;
    gap: 9px;
    padding: 0 12px 0 14px;
    background: var(--card);
}
.nav-search:hover .icon-search,
.search-field:focus-within .icon-search { color: var(--gold); }

.nav-search .search-field input {
    flex: 0 0 0;
    width: 0;
    opacity: 0;
    pointer-events: none;
}
.nav-search:hover .search-field input,
.nav-search:focus-within .search-field input {
    flex: 1 1 auto;
    width: auto;
    opacity: 1;
    pointer-events: auto;
}
.nav-search .search-kbd { display: none; }
.nav-search:hover .search-kbd,
.nav-search:focus-within .search-kbd { display: block; }

.icon-search {
    flex-shrink: 0;
    width: 17px;
    height: 17px;
    color: var(--text-muted);
    transition: color .2s ease;
}
.search-field:focus-within .icon-search { color: var(--gold); }

.search-field input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: .92rem;
}
.search-field input::placeholder { color: var(--text-faint); }
.search-field input::-webkit-search-cancel-button { display: none; }

.search-kbd {
    flex-shrink: 0;
    padding: 1px 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-faint);
    font-size: .7rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    line-height: 1.5;
}

/* 联想下拉 */
.suggest {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 1200;
    display: none;
    max-height: min(420px, 70vh);
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.suggest.open { display: block; animation: pageFadeIn .16s ease; }

.sug-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.sug-item:last-of-type { border-bottom: 0; }
.sug-item:hover, .sug-item.sel { background: var(--gold-bg); }
.sug-word {
    flex-shrink: 0;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 650;
    font-size: .92rem;
}
.sug-phon {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: .74rem;
    font-family: ui-monospace, Menlo, monospace;
}
.sug-brief {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--text-muted);
    font-size: .78rem;
}
.sug-empty { padding: 14px; color: var(--text-muted); font-size: .85rem; text-align: center; }
.sug-hint {
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    background: var(--gold-bg);
    color: var(--text-muted);
    font-size: .74rem;
    text-align: center;
}
.sug-hint b { color: var(--gold-dark); }

/* 导航菜单 */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
    flex-shrink: 0;
}
.nav-menu a {
    display: block;
    padding: 7px 13px;
    border-radius: 8px;
    color: var(--text-sub);
    font-size: .88rem;
    font-weight: 500;
    transition: color .2s ease, background-color .2s ease;
}
.nav-menu a:hover, .nav-menu a.active {
    color: var(--gold-dark);
    background: var(--gold-bg);
}

.theme-btn {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--gold);
    cursor: pointer;
    transition: background-color .2s ease;
}
.theme-btn:hover { background: var(--gold-bg); }
.theme-btn svg { width: 20px; height: 20px; }
.theme-btn .icon-moon { display: none; }
html.dark-mode .theme-btn .icon-moon { display: block; }
html.dark-mode .theme-btn .icon-sun { display: none; }

.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}
.hamburger span {
    width: 21px;
    height: 2px;
    border-radius: 2px;
    background: var(--text-sub);
    transition: transform .25s ease, opacity .25s ease;
}
.hamburger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- 页脚 ---------- */
footer {
    margin-top: 64px;
    padding: 34px 0 30px;
    background: var(--card);
    border-top: 1px solid var(--border);
    text-align: center;
}
.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 22px;
    margin-bottom: 12px;
}
.footer-links a {
    color: var(--text-muted);
    font-size: .84rem;
    transition: color .2s ease;
}
.footer-links a:hover { color: var(--gold); }
.footer-copy { color: var(--text-faint); font-size: .8rem; }
.footer-sep { margin: 0 6px; opacity: .6; }
.footer-note { margin-top: 4px; color: var(--text-faint); font-size: .74rem; }

/* ---------- 回到顶部 ---------- */
.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 30px;
    z-index: 900;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-gold);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
}
.back-to-top.show { opacity: 1; visibility: visible; transform: none; }
.back-to-top svg { width: 20px; height: 20px; fill: currentColor; }

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 78px;
    left: 50%;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transform: translateX(-50%);
    pointer-events: none;
}
.toast {
    max-width: min(90vw, 420px);
    padding: 9px 20px;
    border-radius: 50px;
    background: var(--gold);
    color: #fff;
    font-size: .84rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
    animation: toastIn .26s ease;
}
.toast.error { background: #d9534f; }
.toast.hide { animation: toastOut .26s ease forwards; }

/* ---------- 通用控件 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 22px;
    border: 0;
    border-radius: 50px;
    font-size: .86rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: box-shadow .2s ease, transform .2s ease, background-color .2s ease;
}
.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    color: #fff;
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(212, 160, 23, .32); }
.btn-primary:active { transform: scale(.97); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--gold);
    color: var(--gold-dark);
}
.btn-outline:hover { background: var(--gold-bg); }
.btn-sm { padding: 6px 15px; font-size: .78rem; }

.badge {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 50px;
    background: var(--gold-bg);
    color: var(--gold-dark);
    font-size: .7rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge.muted { background: var(--border-soft); color: var(--text-muted); }
html.dark-mode .badge.muted { background: #2d2d52; }

.loading {
    width: 26px;
    height: 26px;
    margin: 0 auto 12px;
    border: 3px solid var(--gold-bg);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.page-loading { padding: 80px 24px; text-align: center; color: var(--text-muted); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 50px;
    background: var(--card);
    color: var(--text-sub);
    font-size: .78rem;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.icon-btn:hover { border-color: var(--gold); color: var(--gold-dark); background: var(--gold-bg); }

button:focus-visible, a:focus-visible, input:focus-visible, summary:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

/* ---------- 响应式导航 ---------- */
@media (max-width: 980px) {
    .nav-menu {
        position: fixed;
        top: var(--nav-height);
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 8px 16px 14px;
        background: var(--nav-bg);
        -webkit-backdrop-filter: blur(14px);
        backdrop-filter: blur(14px);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
    }
    .nav-menu.open { display: flex; }
    .nav-menu a { padding: 11px 12px; }
    .hamburger { display: flex; }
}

@media (max-width: 720px) {
    :root { --nav-height: 60px; }
    .nav-container { gap: 8px; padding: 0 14px; }
    .nav-brand { flex: 0 0 auto; font-size: 1.02rem; letter-spacing: 0; }
    .brand-full { display: none; }
    .brand-short { display: inline; }
    .nav-search { width: 38px; }
    .nav-search:hover,
    .nav-search:focus-within { width: min(48vw, 210px); }
    .theme-btn, .hamburger { flex-shrink: 0; }
    .search-kbd { display: none !important; }
    .search-field { height: 38px; }
    .search-field input { font-size: .85rem; }
    .theme-btn { width: 34px; }
    .container { padding: 0 16px; }
    .back-to-top { right: 16px; bottom: 20px; width: 40px; height: 40px; }
    .toast-container { top: 70px; }
}

@media (max-width: 360px) {
    .nav-container { gap: 6px; padding: 0 10px; }
    .nav-brand { font-size: .92rem; }
    .nav-search { width: 34px; }
    .nav-search:hover,
    .nav-search:focus-within { width: min(44vw, 150px); }
    .theme-btn { width: 30px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
