/* Info button hover effect */
#info-button:hover {
    background-color: rgba(0,0,0,0.1) !important;
    transform: scale(1.1);
    transition: all 0.2s ease;
}

/* Close button hover effect */
#close-overlay:hover {
    color: #333 !important;
    transform: scale(1.1);
}

/* Overlay animation */
#help-overlay {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* D3 chart responsive height */
.d3-chart {
    height: 400px;
    max-height: 600px;
}
@media (max-width: 768px) {
    .d3-chart {
        height: 550px;
        max-height: 550px;
    }
}

/* D1 — main layout */
.d1-main-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;   /* sidebar fills full chart height */
}

/* Chart takes all remaining width */
.d1-chart-wrap {
    flex: 1;
    position: relative;   /* overlay is absolute inside here */
    min-width: 0;
}

/* Sidebar: legend at top, button pinned to bottom */
.d1-sidebar {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;   /* floor everything to bottom */
    align-items: flex-start;
    padding-left: 20px;
    min-width: 160px;
    flex-shrink: 0;
}

.d1-legend {
    margin-bottom: 16px;
}

/* D1 "What do these scores mean?" button */
.d1-info-btn {
    background-color: #F5F0DC;
    border: none;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 12px;
    color: #555555;
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.d1-info-btn:hover {
    background-color: #ede8ce;
}

/* Active state: overlay is open — light pink signals "click to close" */
.d1-info-btn--active {
    background-color: #FFD6D6;
}

.d1-info-btn--active:hover {
    background-color: #ffc5c5;
}

/* D1 explanation overlay — covers chart-wrap only, 80% opacity */
.d1-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.80);
    padding: 40px 52px;
    z-index: 10;
    overflow-y: auto;
    border: 1px dashed #cccccc;
    font-size: 14px;
    line-height: 1.6;
    animation: fadeIn 0.2s ease;
}

.d1-overlay.hidden {
    display: none;
}

.d1-overlay.visible {
    display: block;
}

/* Phone: stack sidebar below chart */
@media (max-width: 768px) {
    .d1-main-row {
        flex-direction: column;
    }

    .d1-sidebar {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        padding-left: 0;
        padding-top: 10px;
        gap: 20px;
        min-width: unset;
        width: 100%;
    }

    .d1-legend {
        display: flex;
        flex-direction: row;
        gap: 20px;
        margin-bottom: 0;
    }

    /* legend items: remove bottom margin when horizontal */
    .d1-legend > div {
        margin-bottom: 0;
    }

    .d1-info-btn {
        display: none;
    }
}

/* Help content styling */
.help-content h4 {
    margin-bottom: 10px;
    font-weight: 600;
}

.help-content ul {
    margin-bottom: 15px;
    padding-left: 20px;
}

.help-content li {
    margin-bottom: 5px;
}