/* Wiki styles */
.wiki-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.wiki-search-wrap {
    flex: 1;
}

.wiki-search {
    width: 100%;
    padding: 10px 16px;
    font-family: var(--font-serif);
    font-size: 15px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-card-bg);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s ease;
}

.wiki-search:focus {
    border-color: var(--color-accent);
}

.wiki-view-toggle {
    display: flex;
    gap: 4px;
    background: var(--color-surface);
    border-radius: 8px;
    padding: 3px;
}

.wiki-view-btn {
    padding: 6px 14px;
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.wiki-view-btn.active {
    background: var(--color-card-bg);
    color: var(--color-text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Wiki grid & cards */
.wiki-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding-bottom: 72px;
}

.wiki-card {
    text-decoration: none;
    color: inherit;
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 20px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.wiki-card:hover {
    border-color: var(--color-accent);
    box-shadow: 0 4px 16px rgba(139,37,0,0.06);
    transform: translateY(-1px);
}

.wiki-card-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.wiki-card-title {
    font-family: var(--font-serif);
    font-size: 17px;
    font-weight: 700;
}

.wiki-card-type {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}

.wiki-card-type.type-person {
    background: #f0f0f0;
    color: #1a1a1a;
}

.wiki-card-type.type-company {
    background: #fbe8e4;
    color: #8b2500;
}

.wiki-card-excerpt {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wiki-card-links {
    display: inline-block;
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-accent);
    font-weight: 500;
}

/* === Graph Section === */
.wiki-graph-section {
    padding-bottom: 72px;
}

/* Graph layout: main with overlay detail */
.graph-layout {
    position: relative;
}

.graph-main {
    width: 100%;
    position: relative;
    border: 1px solid #E8E1D8;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
}

#wiki-graph {
    display: block;
    width: 100%;
}

.graph-zoom-controls {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 10;
}

.graph-zoom-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #E8E1D8;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    padding: 0;
    line-height: 1;
}

.graph-zoom-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.graph-zoom-reset {
    font-size: 14px;
}

.graph-tooltip {
    position: absolute;
    display: none;
    font-size: 12px;
    color: var(--color-text);
    background: #fff;
    border: 1px solid #E8E1D8;
    border-radius: 6px;
    padding: 5px 10px;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    z-index: 10;
    white-space: nowrap;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Detail panel - overlays graph */
.graph-detail {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 300px;
    background: var(--color-card-bg);
    border: 1px solid #E8E1D8;
    border-radius: 12px;
    overflow-y: auto;
    max-height: calc(100% - 24px);
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transform: translateX(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.graph-detail.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.graph-detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--color-surface);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
}

.graph-detail-close:hover {
    background: var(--color-border);
    color: var(--color-text);
}

/* Detail panel content */
.detail-header {
    margin-bottom: 16px;
    padding-right: 32px;
}

.detail-type-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    margin-bottom: 8px;
}

.detail-type-badge.type-person {
    background: #f0f0f0;
    color: #1a1a1a;
}

.detail-type-badge.type-company {
    background: #fbe8e4;
    color: #8b2500;
}

.detail-name {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 700;
    line-height: 1.3;
}

.detail-desc {
    font-size: 13px;
    color: var(--color-text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}

.detail-section {
    margin-bottom: 16px;
}

.detail-section h4 {
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.detail-neighbors {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-neighbor-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 13px;
    transition: background 0.15s ease;
    cursor: pointer;
}

.detail-neighbor-item:hover {
    background: var(--color-surface);
}

.detail-nb-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.detail-nb-dot.type-person { background: #1a1a1a; }
.detail-nb-dot.type-company { background: #8b2500; }

.detail-nb-name {
    flex: 1;
    font-weight: 500;
}

.detail-nb-type {
    font-size: 11px;
    color: var(--color-text-secondary);
}

.detail-visit-btn {
    display: block;
    text-align: center;
    padding: 10px 16px;
    margin-top: 16px;
    background: var(--color-accent);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s ease;
}

.detail-visit-btn:hover {
    opacity: 0.85;
}

/* Wiki body */
.wiki-body .wiki-link {
    color: var(--color-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.wiki-body .wiki-link:hover {
    border-bottom-color: var(--color-accent);
}

.wiki-body .wiki-link-broken {
    color: var(--color-text-secondary);
    font-style: italic;
}

/* === Responsive === */
@media (max-width: 768px) {
    .wiki-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .wiki-view-toggle {
        align-self: flex-start;
    }

    .wiki-grid {
        grid-template-columns: 1fr;
    }

    .graph-detail {
        left: 12px;
        width: calc(100% - 24px);
    }
}

