﻿/* File: wwwroot/css/wiki.css */

/* ------------------------------------------------------------
   Wiki theme hooks (override these later to retheme)
   ------------------------------------------------------------ */
:root {
    --wiki-accent: var(--bs-primary);
    --wiki-accent-bg: rgba(var(--bs-primary-rgb), 0.08);
    --wiki-border: var(--bs-border-color, #dee2e6);
    --wiki-surface: var(--bs-body-bg);
    --wiki-surface-alt: var(--bs-tertiary-bg, #f8f9fa);
    --wiki-text: var(--bs-body-color);
    --wiki-muted: var(--bs-secondary-color);
    --wiki-radius-lg: 10px;
    --wiki-radius-md: 8px;
    --wiki-shadow-hover: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* ------------------------------------------------------------
   Shared shell layout (Index/All/People/Families/Recent pages)
   ------------------------------------------------------------ */
.wiki-shell {
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .wiki-shell {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
}

.wiki-shell-nav,
.wiki-shell-main {
    min-width: 0;
}

/* ------------------------------------------------------------
   Index portal (header/search/tiles/stats)
   ------------------------------------------------------------ */
.wiki-portal-header h1 {
    font-size: 2rem;
    color: var(--wiki-text);
}

.wiki-portal-search {
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.wiki-tile {
    display: flex;
    gap: 1rem;
    align-items: center;
    background: var(--wiki-surface);
    border: 1px solid var(--wiki-border);
    border-radius: var(--wiki-radius-lg);
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .wiki-tile:hover {
        transform: translateY(-1px);
        box-shadow: var(--wiki-shadow-hover);
        text-decoration: none;
    }

.wiki-tile-icon {
    font-size: 1.8rem;
    color: var(--wiki-accent);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wiki-accent-bg);
    border-radius: var(--wiki-radius-lg);
}

.wiki-tile-title {
    font-weight: 700;
}

.wiki-tile-sub {
    font-size: 0.9rem;
    color: var(--wiki-muted);
}

.stat-card {
    background: var(--wiki-surface);
    border: 1px solid var(--wiki-border);
    border-radius: var(--wiki-radius-md);
    padding: 1.25rem;
    text-align: center;
}

.stat-icon {
    font-size: 1.6rem;
    color: var(--wiki-accent);
    margin-bottom: 0.4rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--wiki-text);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--wiki-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ------------------------------------------------------------
   View page layout
   ------------------------------------------------------------ */
.wiki-page-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 2rem;
}

@media (max-width: 992px) {
    .wiki-page-container {
        padding: 1rem;
    }
}

.wiki-page-header {
    width: 100%;
    max-width: none;
    margin-bottom: 2rem;
}

/* Breadcrumb row + actions */
.breadcrumb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-breadcrumb {
    font-size: 0.9rem;
    color: var(--wiki-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

    .page-breadcrumb .separator {
        margin: 0 0.25rem;
    }

    .page-breadcrumb a {
        text-decoration: none;
        color: var(--wiki-accent);
    }

        .page-breadcrumb a:hover {
            text-decoration: underline;
        }

    .page-breadcrumb .badge {
        font-size: 0.85rem;
        padding: 0.35em 0.65em;
    }

.page-actions-inline {
    display: flex;
    gap: 0.5rem;
    margin-top: 0;
}

.page-title-section h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--wiki-text);
}

.page-summary {
    font-size: 1.2rem;
    color: var(--wiki-muted);
    margin-bottom: 1rem;
}

/* Main single-column article layout */
.wiki-page-content-wrapper {
    display: block !important;
    width: 100%;
    max-width: none;
    grid-template-columns: none !important;
    gap: 0 !important;
}

.wiki-page-single-column {
    display: block !important;
    width: 100%;
    max-width: none;
    margin: 0;
}

.wiki-main-content {
    width: 100%;
    max-width: none;
    background: var(--wiki-surface);
    border: 1px solid var(--wiki-border);
    border-radius: var(--wiki-radius-md);
    padding: 2rem;
    min-width: 0;
}

.wiki-main-content-full {
    width: 100%;
    max-width: none;
    grid-column: 1 / -1;
}

@media (max-width: 992px) {
    .wiki-main-content {
        padding: 1rem;
    }

    .page-actions-inline {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ------------------------------------------------------------
   After-article sections: linked entities + categories
   ------------------------------------------------------------ */
.wiki-after-content-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--wiki-border);
}

.wiki-after-content-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

    .wiki-after-content-heading h2 {
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--wiki-text);
        margin: 0;
        display: flex;
        align-items: center;
        gap: 0.45rem;
    }

.linked-entities-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.linked-entity-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    max-width: 100%;
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: var(--wiki-surface-alt);
    border: 1px solid var(--wiki-border);
    color: var(--wiki-text);
    text-decoration: none;
    transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

    .linked-entity-chip:hover {
        color: var(--wiki-text);
        text-decoration: none;
        background: var(--wiki-accent-bg);
        border-color: rgba(var(--bs-primary-rgb), 0.25);
        transform: translateY(-1px);
    }

    .linked-entity-chip.is-primary {
        background: var(--wiki-accent-bg);
        border-color: rgba(var(--bs-primary-rgb), 0.3);
    }

.linked-entity-name {
    font-weight: 600;
    line-height: 1.2;
}

.linked-entity-label {
    color: var(--wiki-muted);
    font-size: 0.85rem;
    line-height: 1.2;
}

/* ------------------------------------------------------------
   Categories badges
   ------------------------------------------------------------ */
.category-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.category-tags-horizontal {
    margin-top: 0;
}

.category-tags .badge {
    font-size: 0.85rem;
    padding: 0.4em 0.8em;
}

.category-badge {
    text-decoration: none;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

    .category-badge:hover {
        filter: brightness(0.97);
        border-color: rgba(0, 0, 0, 0.18);
        text-decoration: none;
    }

/* ------------------------------------------------------------
   Article typography (content)
   ------------------------------------------------------------ */
.wiki-article {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--wiki-text);
}

    .wiki-article p {
        margin-bottom: 1rem;
    }

    .wiki-article ul,
    .wiki-article ol {
        margin-bottom: 1rem;
        padding-left: 2rem;
    }

    .wiki-article h2 {
        margin-top: 2rem;
        margin-bottom: 1rem;
        font-size: 1.8rem;
        color: var(--wiki-text);
        border-bottom: 2px solid var(--wiki-border);
        padding-bottom: 0.5rem;
    }

    .wiki-article h3 {
        margin-top: 1.5rem;
        margin-bottom: 0.75rem;
        font-size: 1.4rem;
        color: var(--wiki-text);
    }

/* ------------------------------------------------------------
   Comments section (view page)
   ------------------------------------------------------------ */
.comments-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid var(--wiki-border);
}

/* ------------------------------------------------------------
   Wiki media helpers (used by your renderer)
   ------------------------------------------------------------ */
.wiki-media {
    margin: 1rem 0;
}

    .wiki-media img {
        max-width: 100%;
        height: auto;
        border-radius: 6px;
    }

.wiki-media-left {
    float: left;
    margin-right: 1rem;
    max-width: 45%;
}

.wiki-media-right {
    float: right;
    margin-left: 1rem;
    max-width: 45%;
}

.wiki-media-center {
    text-align: center;
}

.wiki-media-caption {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

.wiki-embed-locked,
.wiki-embed-error {
    color: var(--wiki-muted);
    font-style: italic;
}

/* ------------------------------------------------------------
   Media popup preview + lightbox
   ------------------------------------------------------------ */
.wiki-media-pop {
    position: relative;
    display: inline-block;
}

.wiki-media-pop-link {
    text-decoration: underline;
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
}

@media (hover: hover) and (pointer: fine) {
    .wiki-media-preview {
        display: none;
        position: absolute;
        left: 0;
        top: 1.4em;
        z-index: 2000;
        padding: 6px;
        background: rgba(0, 0, 0, 0.85);
        border-radius: 6px;
        max-width: 360px;
        transform-origin: top left;
    }

        .wiki-media-preview.is-right {
            left: auto;
            right: 0;
            transform-origin: top right;
        }

        .wiki-media-preview img {
            display: block;
            max-width: 340px;
            height: auto;
            border-radius: 4px;
        }

    .wiki-media-pop:hover .wiki-media-preview {
        display: block;
    }
}

.wiki-media-icon {
    display: inline-flex;
    width: 1em;
    height: 1em;
    vertical-align: -0.12em;
}

    .wiki-media-icon svg {
        width: 1em;
        height: 1em;
        fill: currentColor;
    }

.wiki-lightbox-backdrop {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.wiki-lightbox {
    position: relative;
    width: min(960px, 96vw);
    max-height: 92vh;
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

    .wiki-lightbox img {
        display: block;
        width: 100%;
        height: auto;
        max-height: 78vh;
        object-fit: contain;
        background: #000;
    }

.wiki-lightbox-caption {
    padding: 10px 12px;
    color: #eee;
    font-size: 0.95rem;
}

.wiki-lightbox-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 22px;
    line-height: 36px;
    cursor: pointer;
}

    .wiki-lightbox-close:active {
        transform: scale(0.98);
    }

/* ------------------------------------------------------------
   Thumbnail mode (Playwright)
   ------------------------------------------------------------ */
body[data-thumb="1"] .wiki-page-header,
body[data-thumb="1"] .wiki-after-content-section,
body[data-thumb="1"] .comments-section,
body[data-thumb="1"] .page-actions,
body[data-thumb="1"] #deleteModal {
    display: none !important;
}

body[data-thumb="1"] .wiki-page-container {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

body[data-thumb="1"] .wiki-page-content-wrapper {
    display: block !important;
}

body[data-thumb="1"] .wiki-main-content {
    width: 1200px;
    height: 630px;
    margin: 0 auto;
    border: none;
    border-radius: 0;
    padding: 32px;
    overflow: hidden;
}

body[data-thumb="1"] .wiki-article {
    line-height: 1.5;
    max-height: 560px;
    overflow: hidden;
}

/* ------------------------------------------------------------
   Small QoL: prevent long text from blowing out grids
   ------------------------------------------------------------ */
.wiki-page-container a,
.wiki-page-container .text-muted,
.wiki-page-container small,
.wiki-shell-main a,
.wiki-shell-main .text-muted,
.wiki-shell-main small {
    word-break: break-word;
}

/* Tables: allow horizontal scroll on small screens */
@media (max-width: 576px) {
    .wiki-page-container .table,
    .wiki-shell-main .table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ------------------------------------------------------------
   Wiki left nav (/_WikiNav.cshtml)
   ------------------------------------------------------------ */
.wiki-nav {
    position: sticky;
    top: 2rem;
    align-self: start;
    background: var(--wiki-surface, #fff);
    border: 1px solid var(--wiki-border, #dee2e6);
    border-radius: var(--wiki-radius-md, 8px);
    padding: 1rem;
}

.wiki-nav-section + .wiki-nav-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.wiki-nav-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--wiki-muted, #6c757d);
    margin-bottom: 0.5rem;
}

.wiki-nav-link {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0.6rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--wiki-text, #212529);
}

    .wiki-nav-link:hover {
        background: var(--wiki-surface-alt, #f8f9fa);
        text-decoration: none;
    }

    .wiki-nav-link i {
        color: var(--wiki-accent, var(--bs-primary));
    }

/* ─────────────────────────────────────────────
   Timeline (robust grid layout)
   ───────────────────────────────────────────── */
.wiki-timeline {
    --tl-x: 14px;
    --tl-dot: 14px;
    position: relative;
}

.timeline-item {
    display: grid;
    grid-template-columns: var(--tl-x) 1fr;
    column-gap: 1.25rem;
    align-items: start;
    margin: 0 0 1rem 0;
}

.timeline-rail {
    position: relative;
    display: flex;
    justify-content: center;
}

    .timeline-rail::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        width: 2px;
        background: rgba(0, 0, 0, .08);
    }

.timeline-marker {
    width: var(--tl-dot);
    height: var(--tl-dot);
    border-radius: 999px;
    background: #6c757d;
    border: 2px solid #fff;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, .04);
    margin-top: 1.05rem;
}

.timeline-item:first-child .timeline-rail::before {
    top: .95rem;
}

.timeline-item:last-child .timeline-rail::before {
    bottom: .95rem;
}

.timeline-content {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: .6rem;
    padding: .75rem 1rem;
    transition: transform .12s ease, box-shadow .12s ease;
}

    .timeline-content:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
    }

.timeline-date {
    font-weight: 700;
    font-size: .9rem;
    color: #495057;
    margin-bottom: .25rem;
}

.wiki-timeline a {
    text-decoration: none;
}

    .wiki-timeline a:hover {
        text-decoration: underline;
    }

/* ─────────────────────────────────────────────
   Marker colors
   ───────────────────────────────────────────── */
.timeline-marker.event {
    background: #6c757d;
}

.timeline-marker.birth {
    background: #198754;
}

.timeline-marker.child {
    background: #20c997;
}

.timeline-marker.death {
    background: #6c757d;
}

.timeline-marker.marriage {
    background: #dc3545;
}

.timeline-marker.divorce {
    background: #6f42c1;
}

.timeline-marker.residence {
    background: #0d6efd;
}

.timeline-marker.travel {
    background: #0d6efd;
}

.timeline-marker.occupation {
    background: #fd7e14;
}

.timeline-marker.education {
    background: #0dcaf0;
}

.timeline-marker.military {
    background: #198754;
}

.timeline-marker.religion {
    background: #795548;
}

.timeline-marker.record {
    background: #adb5bd;
}

.timeline-marker.property {
    background: #fd7e14;
}
