/* KunWay Mubu — Wall stylesheet
 * 沿 plans/2026-09-14-mubu-profile-wall.md §3.3-§3.5。
 * 設計：
 *   - 全頁 user-select: none（防君子）
 *   - 圖片 pointer-events: none + dragstart block
 *   - Watermark：4 corner tile，opacity 0.10（沿主席裁決改良）
 *   - 響應式 grid：CSS variable + slider 即時切
 */

:root {
    --mubu-per-row: 5;
    --mubu-card-gap: 12px;
    --mubu-watermark-text: 'kunway-mubu.snowky.me';
    --mubu-bg: #f8f9fa;
    --mubu-card-radius: 8px;
    --mubu-card-shadow: 0 1px 4px rgba(0,0,0,0.06);
    --mubu-card-shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
}

* {
    box-sizing: border-box;
}

html, body {
    background: var(--mubu-bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang HK', 'Microsoft JhengHei', sans-serif;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* === Anti-export (防君子不防小人) === */

img,
.mubu-card-avatar img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
    -webkit-touch-callout: none;
}

.mubu-card,
.mubu-card-avatar,
.mubu-card-body {
    -webkit-user-select: none;
    user-select: none;
}

/* === Watermark layer === */

.mubu-watermark-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.mubu-watermark-tile {
    position: absolute;
    color: rgba(0, 0, 0, 0.04);
    font-size: 14px;
    font-family: monospace;
    white-space: nowrap;
    transform: rotate(-30deg);
    user-select: none;
    pointer-events: none;
}

.mubu-card-watermark {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
    padding: 4px 6px;
    color: rgba(255, 255, 255, 0.55);
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
    font-size: 10px;
}

.mubu-card-wm-host {
    font-size: 8px;
    opacity: 0.7;
}

/* === Nav === */

.mubu-nav {
    background: #fff;
}

/* === Sidebar === */

.mubu-sidebar .card {
    position: sticky;
    top: 1rem;
}

.mubu-filter-section {
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding-bottom: 8px;
}

.mubu-section-body {
    margin-top: 6px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 220ms ease;
}

.mubu-filter-section.expanded > .mubu-section-body {
    max-height: 800px;
}

.mubu-chips {
    margin-top: 4px;
}

.mubu-chip {
    cursor: pointer;
    border: 1px solid transparent;
    padding: 4px 8px;
    font-weight: 400;
    transition: border-color 120ms ease, background 120ms ease;
}

.mubu-chip.active {
    background: #fff3cd !important;
    border-color: #fd7e14;
    color: #b75a00 !important;
}

.mubu-ns-group {
    background: rgba(0,0,0,0.02);
    padding: 4px 6px;
    border-radius: 4px;
}

/* === Grid === */

.mubu-grid {
    display: grid;
    grid-template-columns: repeat(var(--mubu-per-row), minmax(0, 1fr));
    gap: var(--mubu-card-gap);
    align-items: stretch;
}

@media (max-width: 992px) {
    .mubu-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .mubu-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .mubu-grid {
        grid-template-columns: 1fr;
    }
}

.mubu-card {
    background: #fff;
    border-radius: var(--mubu-card-radius);
    overflow: hidden;
    box-shadow: var(--mubu-card-shadow);
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease;
    outline: none;
}

.mubu-card:hover,
.mubu-card:focus {
    transform: translateY(-2px) scale(1.01);
    box-shadow: var(--mubu-card-shadow-hover);
}

.mubu-card-avatar {
    position: relative;
    aspect-ratio: 1 / 1;
    background: linear-gradient(135deg, #f0f3f7, #e6ebf2);
    overflow: hidden;
}

.mubu-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mubu-card-avatar-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c5cdd6;
    font-size: 64px;
}

.mubu-card-body {
    padding: 8px 10px;
}

.mubu-card-name {
    font-weight: 600;
    font-size: 14px;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mubu-card-meta {
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mubu-card-chips {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.mubu-gender-m { color: #0d6efd; }
.mubu-gender-f { color: #d63384; }

/* === Detail overlay — 覆蓋 Grid Wall，唔喺下方插入 === */

#mubuModalRoot:empty {
    display: none;
}

#mubuModalRoot:not(:empty) {
    position: fixed;
    inset: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    background: var(--mubu-bg);
    overflow: hidden;
}

body.mubu-detail-open {
    overflow: hidden;
}

.mubu-detail-sheet {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    overflow: hidden;
}

.mubu-detail-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    background: #fff;
}

.mubu-detail-toolbar .mubu-detail-back {
    flex: 0 0 auto;
}

.mubu-detail-toolbar .mubu-detail-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mubu-detail-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px 20px 32px;
}

.mubu-modal-tabs .nav-link {
    color: #495057;
}

.mubu-modal-tabs .nav-link.active {
    color: #0d6efd;
}

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

@media (max-width: 576px) {
    .mubu-modal-photos { grid-template-columns: repeat(2, 1fr); }
}

.mubu-modal-photo {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    background: #f0f3f7;
}

.mubu-modal-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mubu-modal-photo-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
}

.mubu-media-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.mubu-media-viewer img {
    max-width: 96vw;
    max-height: 96vh;
    object-fit: contain;
}

.mubu-media-viewer-watermark {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(-30deg,
            rgba(255,255,255,0.06) 0,
            rgba(255,255,255,0.06) 1px,
            transparent 1px,
            transparent 80px);
}

/* === Login === */

.mubu-login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.mubu-login-card {
    border-radius: 12px;
    border: none;
}

/* === Watermark per-card overlay === */

.mubu-watermark-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        repeating-linear-gradient(-30deg,
            rgba(255,255,255,0.10) 0,
            rgba(255,255,255,0.10) 1px,
            transparent 1px,
            transparent 60px);
}

/* === DevTools detected warning === */

.mubu-devtools-warn::before {
    content: '⚠️ DevTools detected';
    position: fixed;
    top: 8px;
    right: 12px;
    background: #dc3545;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 99999;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}