/* ── Public Timeline SPA Styles ────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    color: #333;
}

/* ── Canvas Container ─────────────────────────────── */
#timeline-container {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
}
#grid-canvas {
    position: absolute; top: 0; left: 0;
    display: block; width: 100%; height: 100%;
    pointer-events: none;
}
#timeline-canvas {
    position: absolute; top: 0; left: 0;
    display: block; width: 100%; height: 100%;
    cursor: grab;
}
#timeline-canvas.grabbing { cursor: grabbing; }
#timeline-canvas.pointer { cursor: pointer; }

/* ── Loading Screen ───────────────────────────────── */
#loading-screen {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    background: #fff; z-index: 100;
    transition: opacity 0.5s ease;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }
#loading-screen h1 { font-size: 28px; color: #222; margin-bottom: 16px; }
.progress-bar {
    width: 240px; height: 4px; background: #e0e0e0;
    border-radius: 2px; overflow: hidden;
}
.progress-fill {
    height: 100%; background: #4a90d9; width: 0%;
    transition: width 0.3s ease;
}
#loading-text { margin-top: 12px; font-size: 14px; color: #888; }

/* ── Error Screen ─────────────────────────────────── */
#error-screen {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    display: none; flex-direction: column;
    align-items: center; justify-content: center;
    background: #fff; z-index: 100;
}
#error-screen.active { display: flex; }
#error-screen h2 { color: #d32f2f; margin-bottom: 12px; }
#error-screen p { color: #666; max-width: 400px; text-align: center; }

/* ── Controls Overlay ─────────────────────────────── */
#controls {
    position: absolute; bottom: 24px; right: 24px;
    display: flex; gap: 8px; z-index: 50;
}
.ctrl-btn {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,0.9); border: 1px solid #ddd;
    color: #555; font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; backdrop-filter: blur(4px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.ctrl-btn:hover { background: #fff; color: #222; border-color: #bbb; }

/* ── Filter Bar ───────────────────────────────────── */
#filter-bar {
    position: absolute; top: 16px; left: 16px; right: 16px;
    display: flex; gap: 8px; align-items: center;
    z-index: 50; pointer-events: none;
}
#filter-bar > * { pointer-events: auto; }
#timeline-title {
    font-size: 18px; font-weight: 600; color: #222;
    background: rgba(255,255,255,0.9); padding: 8px 16px;
    border-radius: 10px; border: 1px solid #ddd;
    backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#search-input {
    padding: 8px 14px; border: 1px solid #ddd;
    border-radius: 10px; background: rgba(255,255,255,0.9);
    color: #333; font-size: 14px; outline: none;
    width: 200px; backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#search-input:focus { border-color: #4a90d9; }
#type-filter, #group-by {
    padding: 8px 12px; border: 1px solid #ddd;
    border-radius: 10px; background: rgba(255,255,255,0.9);
    color: #333; font-size: 13px; outline: none;
    backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#export-pdf {
    padding: 8px 14px; border: 1px solid #ddd;
    border-radius: 10px; background: rgba(255,255,255,0.9);
    color: #333; font-size: 13px; cursor: pointer;
    backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: all 0.2s; font-weight: 500;
}
#export-pdf:hover { border-color: #4a90d9; color: #4a90d9; }
#toggle-markers {
    padding: 8px 14px; border: 1px solid #ddd;
    border-radius: 10px; background: rgba(255,255,255,0.9);
    color: #333; font-size: 13px; cursor: pointer;
    backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    transition: all 0.2s; font-weight: 500;
}
#toggle-markers:hover { border-color: #4a90d9; color: #4a90d9; }
#toggle-markers.active { border-color: #4a90d9; color: #4a90d9; background: rgba(74,144,217,0.1); }

/* ── Entity Card (Desktop: sidebar, Mobile: popup) ── */
#entity-card {
    position: fixed; top: 0; right: 0; display: none;
    background: #fff; border: 1px solid #ddd;
    border-radius: 16px 0 0 16px; padding: 0; z-index: 200;
    width: 380px; height: 100vh; overflow: hidden;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    animation: slideIn 0.25s ease;
}
#entity-card.visible { display: block; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.card-image {
    width: 100%; height: 180px; object-fit: cover;
    border-radius: 0;
}
.card-body { padding: 20px; overflow-y: auto; max-height: calc(100vh - 180px); }
.card-title { font-size: 20px; font-weight: 600; color: #222; margin-bottom: 6px; }
.card-date { font-size: 13px; color: #4a90d9; margin-bottom: 12px; }
.card-type { display: inline-block; margin-bottom: 12px; }
.card-desc { font-size: 14px; line-height: 1.6; color: #555; margin-bottom: 12px; }
.card-desc p { margin-bottom: 8px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tag {
    padding: 3px 10px; background: rgba(74,144,217,0.1);
    color: #4a90d9; border-radius: 12px; font-size: 12px;
}
.card-close {
    position: absolute; top: 12px; right: 12px;
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(0,0,0,0.4); border: none;
    color: #fff; font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.card-close:hover { background: rgba(0,0,0,0.6); }

/* ── Zoom Label ───────────────────────────────────── */
#zoom-label {
    position: absolute; bottom: 24px; left: 24px;
    background: rgba(255,255,255,0.9); padding: 6px 14px;
    border-radius: 8px; border: 1px solid #ddd;
    font-size: 13px; color: #888; z-index: 50;
    backdrop-filter: blur(4px); box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ── Minimap ──────────────────────────────────────── */
#minimap {
    position: absolute; bottom: 80px; right: 24px;
    width: 200px; height: 40px;
    background: rgba(26,26,46,0.9); border: 1px solid #2a2a4a;
    border-radius: 8px; z-index: 50; overflow: hidden;
    backdrop-filter: blur(4px);
}
#minimap canvas { width: 100%; height: 100%; }
.minimap-viewport {
    position: absolute; top: 0; height: 100%;
    background: rgba(108,159,255,0.15); border: 1px solid rgba(108,159,255,0.4);
    pointer-events: none;
}

/* ── Home Screen ─────────────────────────────────── */
#home-screen {
    position: relative; z-index: 150;
    min-height: 100vh; background: #fafafa;
}
.home-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 24px 32px; border-bottom: 1px solid #e5e5e5;
    background: #fff;
}
.home-header h1 { font-size: 24px; color: #222; font-weight: 700; }
.home-admin-link {
    font-size: 13px; color: #888; text-decoration: none;
    padding: 6px 14px; border: 1px solid #ddd; border-radius: 8px;
    transition: all 0.2s;
}
.home-admin-link:hover { color: #4a90d9; border-color: #4a90d9; }
.home-content { max-width: 720px; margin: 0 auto; padding: 32px 24px; }
.home-list { display: flex; flex-direction: column; gap: 12px; }
.home-loading { text-align: center; color: #999; padding: 40px 0; font-size: 15px; }
.home-empty { text-align: center; color: #999; padding: 40px 0; }
.home-empty p { font-size: 15px; margin-bottom: 8px; }
.home-card {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; background: #fff; border: 1px solid #e5e5e5;
    border-radius: 12px; text-decoration: none; color: inherit;
    transition: all 0.2s; cursor: pointer;
}
.home-card:hover { border-color: #4a90d9; box-shadow: 0 2px 12px rgba(74,144,217,0.1); }
.home-card-info h3 { font-size: 17px; font-weight: 600; color: #222; margin-bottom: 4px; }
.home-card-info p { font-size: 13px; color: #999; }
.home-card-arrow { font-size: 18px; color: #ccc; transition: color 0.2s; }
.home-card:hover .home-card-arrow { color: #4a90d9; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
    #entity-card {
        position: absolute; top: 10% !important; left: 5vw !important;
        width: 90vw; height: auto; max-height: 80vh;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.15);
        animation: cardIn 0.2s ease;
    }
    @keyframes cardIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
    .card-image { border-radius: 16px 16px 0 0; }
    .card-body { max-height: calc(80vh - 180px); }
    #filter-bar { flex-wrap: wrap; }
    #search-input { width: 100%; }
    #controls { bottom: 16px; right: 16px; }
    #zoom-label { bottom: 16px; left: 16px; }
    #minimap { display: none; }
    .home-header { padding: 16px 20px; }
    .home-content { padding: 20px 16px; }
    .home-card { padding: 16px 18px; }
}
