/* ============================================================
   Health & Gentrification ABM – Styles (compact viewport)
   ============================================================ */

:root {
    --area-a: #2ecc71;
    --area-b: #3498db;
    --area-c: #f39c12;
    --area-d: #e74c3c;
    --bg: #fafafa;
    --text: #222;
    --muted: #666;
    --card-bg: #fff;
    --border: #ddd;
    --accent: #8e44ad;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.4;
    max-width: 840px;
    margin: 0 auto;
    padding: 0.5rem 0.75rem;
}

/* --- Header ------------------------------------------------ */
header {
    text-align: center;
    margin-bottom: 0.5rem;
}
header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}
.subtitle {
    color: var(--muted);
    font-size: 0.82rem;
}

/* --- Viz container ----------------------------------------- */
#viz-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    justify-content: center;
    align-items: flex-start;
}
.viz-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    text-align: center;
}
.viz-panel h2 {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.viz-panel canvas {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

/* --- Info bar (total health + step + narration) ------------- */
#info-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: #fffbea;
    border: 1px solid #f0e0a0;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    flex-wrap: wrap;
}
#info-bar .label {
    font-weight: 600;
}
#total-health-value {
    font-size: 1rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    margin: 0 0.2rem;
}
#total-health-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    background: #e8f8f0;
    color: #27ae60;
}
.info-divider {
    width: 1px;
    height: 1rem;
    background: #ccc;
}
#step-display {
    font-variant-numeric: tabular-nums;
}
#narration-text {
    flex: 1;
    min-width: 150px;
    text-align: center;
}

/* --- Bottom bar (tracked agents + controls) ---------------- */
#bottom-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

/* Tracked agent cards */
#tracked-agents-cards {
    display: flex;
    gap: 0.5rem;
}
.agent-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    line-height: 1.35;
    white-space: nowrap;
}
.agent-card .agent-name {
    font-weight: 700;
    font-size: 0.8rem;
}
.agent-card .agent-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #333;
    vertical-align: middle;
    margin-right: 0.2rem;
}
.agent-card .agent-detail {
    color: var(--muted);
}
.agent-card .agent-area-change {
    font-weight: 600;
}

/* Controls */
#controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}
#buttons {
    display: flex;
    gap: 0.35rem;
}
#buttons button {
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 5px;
    cursor: pointer;
    background: var(--card-bg);
    font-weight: 600;
    transition: background 0.15s;
}
#buttons button:hover {
    background: #eee;
}
#btn-play.playing {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
#sliders {
    display: flex;
    gap: 0.75rem;
}
.slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.72rem;
    gap: 0.05rem;
}
.slider-label-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.slider-group label {
    font-weight: 600;
}
.info-btn {
    width: 14px;
    height: 14px;
    font-size: 0.55rem;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, serif;
    line-height: 14px;
    text-align: center;
    padding: 0;
    border: 1px solid #aaa;
    border-radius: 50%;
    background: #fff;
    color: #666;
    cursor: pointer;
    flex-shrink: 0;
}
.info-btn:hover {
    background: #eee;
    border-color: #888;
}

/* Info popover */
#info-popover {
    position: absolute;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.4;
    padding: 0.4rem 0.65rem;
    border-radius: 5px;
    max-width: 220px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    pointer-events: none;
}
#info-popover.hidden {
    display: none;
}
.slider-group input[type="range"] {
    width: 90px;
    accent-color: var(--accent);
}

/* --- Footer ------------------------------------------------ */
footer {
    text-align: center;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78rem;
}

/* --- Guide section ----------------------------------------- */
#guide {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    background: #f5f5f5;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.55;
}
#guide h3 {
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 700;
    margin-top: 0.8rem;
    margin-bottom: 0.25rem;
}
#guide h3:first-child {
    margin-top: 0;
}
#guide p {
    margin-bottom: 0.5rem;
}
#guide ul {
    margin: 0.25rem 0 0.5rem 1.2rem;
}
#guide li {
    margin-bottom: 0.3rem;
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 700px) {
    #viz-container { flex-direction: column; align-items: center; }
    .viz-panel canvas { width: 100%; }
    #bottom-bar { flex-direction: column; align-items: stretch; }
    #controls { flex-direction: column; align-items: center; }
    #sliders { flex-direction: column; }
}
