/*!
 * Advanced Interactive US Map — Front-end styles
 */

#aium-wrapper {
    max-width: 1920px;
    min-width: 220px;
    margin: 0 auto;
    padding: 0;
    background-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    transition: opacity 0.25s ease-in-out;
}

#aium-labels {
    font-family: Arial, Helvetica, sans-serif;
    pointer-events: none; /* labels don't intercept clicks; the path does */
}

#aium-base svg {
    max-height: 100%;
    width: 100%;
    margin: 0;
}

#aium-states .aium-state {
    transition: fill 0.15s ease;
}

#aium-tooltip {
    font: 14px/1.4 "Trebuchet MS", Helvetica, Arial, sans-serif;
    display: none;
    max-width: 40%;
    padding: 8px 10px;
    visibility: visible;
    border: 1px solid #404040;
    color: #404040;
    z-index: 100000;
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    word-break: keep-all;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

#aium-tooltip:empty {
    padding: 0;
    visibility: hidden;
}

#aium-tooltip p {
    margin: 0 !important;
    color: #404040 !important;
}

#aium-tooltip img {
    float: left;
    padding: 3px;
    max-width: 100%;
}

.aium-clear { clear: both; }

@media screen and (max-width: 320px) {
    #aium-base svg { height: 140px; }
    #aium-tooltip { max-width: 60%; }
    #aium-tooltip img { max-width: 95%; }
}
@media screen and (min-width: 321px) and (max-width: 400px) {
    #aium-base svg { height: 180px; }
}
@media screen and (min-width: 401px) and (max-width: 480px) {
    #aium-base svg { height: 250px; }
}
@media screen and (min-width: 481px) and (max-width: 568px) {
    #aium-base svg { height: 290px; }
}
@media screen and (min-width: 569px) and (max-width: 685px) {
    #aium-base svg { height: 340px; }
}
@media screen and (min-width: 686px) and (max-width: 767px) {
    #aium-base svg { height: 420px; }
}
@media screen and (min-width: 768px) {
    #aium-base svg { height: 470px; }
}

/* ====================================================================
 * Click popup (info card) — additive; does not affect tooltip/map
 * ==================================================================== */
#aium-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100001;
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.22s ease;
}
#aium-popup-overlay.aium-popup-open {
    display: flex;
    opacity: 1;
}

#aium-popup {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    transform: translateY(14px) scale(0.97);
    opacity: 0;
    transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.26s ease;
    font-family: "Trebuchet MS", Helvetica, Arial, sans-serif;
}
#aium-popup.aium-popup-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.aium-popup-head {
    background: linear-gradient(135deg, #477CB2 0%, #2f5d8f 100%);
    padding: 22px 24px;
}
.aium-popup-title {
    margin: 0;
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1.2;
}

.aium-popup-body {
    padding: 8px 24px 22px;
}

.aium-popup-stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid #eef1f5;
}
.aium-popup-stat:last-child {
    border-bottom: none;
}
.aium-popup-stat-label {
    color: #6b7280;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.aium-popup-stat-value {
    color: #111827;
    font-size: 17px;
    font-weight: 700;
    text-align: right;
}

.aium-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    line-height: 28px;
    text-align: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    transition: background 0.15s ease;
}
.aium-popup-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

@media screen and (max-width: 480px) {
    #aium-popup { max-width: 100%; }
    .aium-popup-title { font-size: 19px; }
    .aium-popup-stat-value { font-size: 15px; }
}

/* ====================================================================
 * Franchise tier legend + tier-aware tooltip
 * ==================================================================== */
.aium-legend {
    font-family: "Trebuchet MS", Helvetica, Arial, sans-serif;
    margin: 18px auto 0;
    max-width: 940px;
    padding: 0 8px;
}
#aium-wrapper.aium-legend-above .aium-legend {
    margin: 0 auto 18px;
}

.aium-legend-title {
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #334155;
    text-align: center;
}

.aium-legend-items {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 22px;
}

.aium-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 0;
    padding: 7px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.aium-legend-item:hover,
.aium-legend-item:focus,
.aium-legend-item.aium-legend-active {
    background: rgba(15, 23, 42, 0.04);
    border-color: rgba(15, 23, 42, 0.12);
}

.aium-legend-swatch {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    border-radius: 4px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.aium-legend-text {
    display: flex;
    flex-direction: column;
    line-height: 1.35;
}
.aium-legend-label {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
}
.aium-legend-count {
    font-size: 12px;
    color: #6b7280;
}

/* Dimming applied while a legend entry is hovered or pinned */
#aium-states .aium-state.aium-dim,
#aium-labels .aium-label.aium-dim {
    opacity: 0.22;
    transition: opacity 0.18s ease;
}

/* Tooltip: region name on the first line, tier label underneath */
.aium-tip-name {
    display: block;
    font-weight: 700;
}
.aium-tip-tier {
    display: block;
    margin-top: 3px;
    font-size: 12.5px;
    font-weight: 600;
}

@media screen and (max-width: 600px) {
    .aium-legend-items { gap: 6px 12px; }
    .aium-legend-item { padding: 6px 8px; }
    .aium-legend-label { font-size: 13px; }
}
