/* Narrative Map public viewer + builder chrome */

html, body {
    overflow-x: hidden;
}

.nm-shell {
    display: flex;
    height: calc(100vh - 56px);
    min-height: 0;
    overflow: hidden;
    background: #fff;
    position: relative;
}

.nm-stage {
    flex: 2 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.nm-map {
    flex: 1 1 auto;
    min-height: 0;
}

.nm-map #map {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    z-index: 0;
}

.nm-timeline {
    flex: 0 0 auto;
    height: 272px;
    border-top: 1px solid #d7dce3;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.nm-narrative {
    flex: 1 1 0;
    min-width: 280px;
    max-width: 35%;
    background: rgba(255, 255, 255, 0.95);
    border-left: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 28px 30px 48px;
    align-self: stretch;
    position: relative;
    z-index: 2;
    scrollbar-width: thin;
    scrollbar-color: rgba(15, 23, 42, 0.28) transparent;
}

.nm-narrative::-webkit-scrollbar {
    width: 8px;
}

.nm-narrative::-webkit-scrollbar-track {
    background: transparent;
}

.nm-narrative::-webkit-scrollbar-thumb {
    background-color: rgba(15, 23, 42, 0.22);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
}

.nm-narrative::-webkit-scrollbar-thumb:hover {
    background-color: rgba(15, 23, 42, 0.38);
    background-clip: padding-box;
}

.nm-title {
    font-size: 1.7rem;
    font-weight: 600;
    margin: 0 0 18px;
    color: #1f2937;
    background: transparent;
}

.nm-subtitle {
    color: #4b5563;
    margin: -6px 0 20px;
    background: transparent;
}

.nm-text {
    font-size: 16px;
    line-height: 1.9;
    color: #1f2937;
    background: transparent;
}

.nm-text p,
.nm-text h1,
.nm-text h2,
.nm-text h3,
.nm-text h4,
.nm-text h5,
.nm-text h6,
.nm-text div,
.nm-text ul,
.nm-text ol,
.nm-text li,
.nm-text blockquote,
.nm-text pre {
    background: transparent;
}

/* Quill often persists the editor's opaque white onto spans/blocks. */
.nm-text :not(mark)[style*="background-color: rgb(255, 255, 255)"],
.nm-text :not(mark)[style*="background-color:rgb(255, 255, 255)"],
.nm-text :not(mark)[style*="background-color: rgb(255,255,255)"],
.nm-text :not(mark)[style*="background-color:#ffffff"],
.nm-text :not(mark)[style*="background-color: #ffffff"],
.nm-text :not(mark)[style*="background-color:#fff"],
.nm-text :not(mark)[style*="background-color: #fff"],
.nm-text :not(mark)[style*="background-color: white"],
.nm-text :not(mark)[style*="background-color:white"] {
    background-color: transparent !important;
}

.nm-text mark.ann {
    background-color: rgba(59, 130, 246, 0.18);
    padding: 1px 3px;
    border-radius: 3px;
    cursor: pointer;
    border-bottom: 2px solid #3b82f6;
}

.nm-text mark.ann:hover,
.nm-text mark.ann.is-active {
    background-color: rgba(59, 130, 246, 0.34);
}

.nm-text mark.ann.flash {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

.nm-popup {
    position: absolute;
    top: 16px;
    left: 16px;
    width: min(380px, calc(100% - 32px));
    max-width: 420px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
    z-index: 20;
    overflow: hidden;
}

.nm-popup.hidden {
    display: none;
}

.nm-popup__media {
    margin: 8px 0;
}

.nm-popup__media img {
    display: block;
    width: 100%;
    max-height: 160px;
    object-fit: cover;
    border-radius: 8px;
}

.nm-popup__body {
    padding: 12px 14px 14px;
}

.nm-popup__title {
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0 0 4px;
}

.nm-popup__caption,
.nm-popup__meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.nm-popup__desc {
    font-size: 14px;
    color: #374151;
    margin-bottom: 10px;
}

.nm-popup__desc p {
    margin: 0 0 0.65em;
}

.nm-popup__desc p:last-child {
    margin-bottom: 0;
}

.nm-popup__desc ul,
.nm-popup__desc ol {
    margin: 0 0 0.65em;
    padding-left: 1.2em;
}

.nm-popup__desc a {
    color: #1d4ed8;
}

.nm-popup__close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: 0;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    line-height: 1;
}

#timelineTopBar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 13px;
}

.tl-btn {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #fff;
    border-radius: 6px;
    padding: 2px 8px;
    cursor: pointer;
}

.tl-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

#timelineViewport,
[data-tl-viewport] {
    position: relative;
    height: 216px;
    overflow: auto;
    padding-left: 120px;
}

[data-tl-lanes] {
    position: relative;
    min-width: 1400px;
}

.tl-lane {
    position: relative;
    height: 34px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.tl-lane:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.02);
}

.tl-lane-label {
    position: absolute;
    left: -120px;
    width: 110px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    font-weight: 700;
    opacity: 0.75;
    padding-left: 10px;
    font-size: 12px;
}

.tl-event {
    position: absolute;
    top: 6px;
    height: 22px;
    border-radius: 6px;
    background: rgba(34, 197, 94, 0.25);
    border: 1px solid rgba(34, 197, 94, 0.45);
    padding: 2px 8px;
    font-size: 12px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: 360px;
    line-height: 18px;
}

.tl-event:hover {
    background: rgba(34, 197, 94, 0.35);
}

.tl-event.active-emphasized {
    background: rgba(59, 130, 246, 0.4) !important;
    border-color: rgba(59, 130, 246, 0.8) !important;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

[data-tl-cursor] {
    /* Replaced by the shared .tl-playhead line. */
}

[data-tl-fallback] {
    display: none;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    flex: 1;
    padding: 8px 10px;
}

.timeline-step {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 170px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
}

.timeline-step.active,
.timeline-step.active-emphasized {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.10);
}

body:has(.gx-viewer-header) .nm-shell {
    height: calc(100vh - var(--gx-viewer-header-height, 42px));
}

@media (max-width: 900px) {
    .nm-shell {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 56px);
        overflow: visible;
    }

    .nm-stage {
        flex: none;
        width: 100%;
        min-height: 62vh;
    }

    .nm-map {
        position: relative;
        min-height: 42vh;
    }

    .nm-timeline {
        height: 232px;
    }

    .nm-map #map {
        position: relative;
        inset: auto;
        width: 100%;
        height: 100%;
        z-index: auto;
    }

    .nm-timeline,
    .nm-narrative {
        z-index: auto;
    }

    .nm-narrative {
        flex: none;
        width: 100%;
        max-width: none;
        min-width: 0;
        border-left: 0;
        border-top: 0;
        overflow-y: visible;
    }

    .nm-popup {
        width: calc(100% - 24px);
        max-width: none;
        left: 12px;
        right: 12px;
    }
}
