/* Event Journal — light reading overlay (scoped) */

body.event-journal-open {
    overflow: hidden;
}

.event-journal {
    position: fixed;
    inset: 0;
    z-index: 3500;
    display: flex;
    align-items: stretch;
    justify-content: center;
    font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    color: #1a1f28;
}

.event-journal[hidden] {
    display: none;
}

.event-journal {
    --ej-bg: #f7f8fa;
    --ej-surface: #ffffff;
    --ej-text: #1a1f28;
    --ej-muted: #5c6573;
    --ej-border: #e2e6ed;
    --ej-accent: #4a6fa5;
    --ej-radius: 10px;
    --ej-max: 720px;
    --ej-block-gap: 32px;
    --ej-section-title-gap: 16px;
}

.ej-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 20, 30, 0.45);
}

.ej-panel {
    position: relative;
    z-index: 1;
    width: min(900px, 100%);
    height: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background: var(--ej-bg);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
}

.ej-header {
    position: sticky;
    top: 0;
    z-index: 2;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--ej-surface);
    border-bottom: 1px solid var(--ej-border);
}

.ej-back {
    margin-right: auto;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ej-accent);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    max-width: calc(100% - 96px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ej-back:hover {
    background: var(--ej-bg);
}

.ej-close {
    flex: 0 0 auto;
    margin-left: auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--ej-muted);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.ej-close:hover {
    background: var(--ej-bg);
    color: var(--ej-text);
}

.ej-loading {
    margin-right: auto;
    color: var(--ej-muted);
    font-size: 14px;
}

.ej-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.ej-page {
    max-width: var(--ej-max);
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.ej-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--ej-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.ej-title {
    margin: 0 0 8px;
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.ej-meta,
.ej-muted {
    color: var(--ej-muted);
    font-size: 14px;
    margin: 0 0 32px;
}

.ej-hero {
    margin: 0 0 var(--ej-block-gap);
    border-radius: var(--ej-radius);
    overflow: hidden;
    background: var(--ej-surface);
    border: 1px solid var(--ej-border);
}

.ej-hero-image .ej-hero-img-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
}

.ej-hero-img {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: cover;
}

.ej-hero-map .ej-map,
.ej-map-block .ej-map {
    width: 100%;
    height: 280px;
    background: #e8ecf2;
}

.ej-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin: 0 0 var(--ej-block-gap);
}

.ej-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    padding: 16px 12px;
    background: var(--ej-surface);
    border: 1px solid var(--ej-border);
    border-radius: var(--ej-radius);
    text-align: center;
}

.ej-stat-value {
    display: flex;
    align-items: baseline;
    justify-content: center;
    min-height: 1.8rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ej-text);
    line-height: 1.2;
    white-space: nowrap;
}

.ej-stat-num {
    font-variant-numeric: tabular-nums;
}

.ej-stat-unit {
    font-size: 1.125rem;
    font-weight: 600;
}

.ej-stat-label {
    margin-top: 6px;
    font-size: 11px;
    color: var(--ej-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.3;
}

.ej-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 var(--ej-block-gap);
}

.ej-fact {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid #e8ecf2;
    border-radius: 6px;
    font-size: 12px;
}

.ej-fact-label {
    color: var(--ej-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.ej-fact-value {
    color: var(--ej-text);
    font-weight: 500;
}

.ej-refs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 var(--ej-block-gap);
}

.ej-ref {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--ej-border);
    border-radius: 8px;
    background: var(--ej-surface);
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.ej-ref:hover {
    border-color: var(--ej-accent);
}

.ej-ref-label {
    color: var(--ej-muted);
    font-size: 12px;
}

.ej-ref-value {
    font-weight: 500;
    color: var(--ej-accent);
}

.ej-ref-inline {
    display: inline-block;
    width: auto;
    margin: 4px 0;
}

.ej-prose {
    font-size: 16px;
    line-height: 1.65;
    color: var(--ej-text);
    margin: 0 0 var(--ej-block-gap);
}

.ej-prose p {
    margin: 0 0 1em;
}

.ej-prose p:last-child {
    margin-bottom: 0;
}

.ej-intro {
    font-size: 17px;
}

.ej-section {
    margin: var(--ej-block-gap) 0;
}

.ej-section-title {
    margin: 0 0 var(--ej-section-title-gap);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ej-muted);
}

.ej-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ej-timeline-note,
.ej-timeline-media {
    padding: 0;
}

.ej-timeline-time {
    display: block;
    font-size: 12px;
    color: var(--ej-muted);
    margin-bottom: 8px;
}

.ej-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.ej-gallery-thumb {
    display: block;
    padding: 0;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    cursor: zoom-in;
    background: var(--ej-border);
    aspect-ratio: 4/3;
}

.ej-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ej-gallery-files,
.ej-related {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ej-media-file,
.ej-related-item {
    padding: 12px 16px;
    border: 1px solid var(--ej-border);
    border-radius: 8px;
    background: var(--ej-surface);
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.ej-media-file:hover,
.ej-related-item:hover {
    border-color: var(--ej-accent);
}

.ej-related-title {
    display: block;
    font-weight: 500;
}

.ej-related-type {
    font-size: 12px;
    color: var(--ej-muted);
}

.ej-body-block {
    margin: 0 0 var(--ej-block-gap);
}

.ej-body-label {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ej-text);
}

.ej-group-row {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ej-border);
}

.ej-group-row:last-child {
    border-bottom: none;
}

.ej-group-row-num {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ej-border);
    color: var(--ej-muted);
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ej-group-row-body {
    flex: 1;
    min-width: 0;
}

.ej-inline-stat,
.ej-inline-fact {
    margin: 4px 0;
    font-size: 14px;
}

.ej-toc {
    margin-top: calc(var(--ej-block-gap) + 16px);
    padding-top: var(--ej-block-gap);
    border-top: 1px solid var(--ej-border);
}

.ej-toc-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ej-toc-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--ej-border);
    border-radius: var(--ej-radius);
    background: var(--ej-surface);
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: inherit;
    transition: border-color 0.15s ease;
}

.ej-toc-row:hover:not(.ej-toc-failed) {
    border-color: var(--ej-accent);
}

.ej-toc-failed {
    cursor: default;
    opacity: 0.7;
}

.ej-toc-title {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
}

.ej-toc-meta {
    flex: 0 1 auto;
    font-size: 13px;
    color: var(--ej-muted);
    white-space: nowrap;
}

.ej-toc-chevron {
    flex: 0 0 auto;
    color: var(--ej-muted);
    font-size: 16px;
}

.ej-error {
    padding: 48px 24px;
    text-align: center;
    color: #b33;
}

@media (max-width: 600px) {
    .ej-page {
        padding: 24px 16px 48px;
    }

    .ej-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .ej-toc-row {
        flex-wrap: wrap;
    }

    .ej-toc-meta {
        flex: 1 1 100%;
        white-space: normal;
        order: 3;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ej-stat-num {
        transition: none !important;
    }
}
