/* ══════════════════════════════════════════════════════════════════════
   Flood Sentinel — Contextual Help Tooltips
   CSS-only tooltips using data-tooltip attribute
   ══════════════════════════════════════════════════════════════════════ */

/* Help icon button */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(66, 133, 244, 0.12);
    color: var(--accent-primary, #4285f4);
    font-size: 0.65rem;
    font-weight: 700;
    cursor: help;
    border: 1px solid rgba(66, 133, 244, 0.25);
    position: relative;
    vertical-align: middle;
    margin-left: 4px;
    transition: all 0.15s ease;
    line-height: 1;
    flex-shrink: 0;
}
.help-icon:hover {
    background: rgba(66, 133, 244, 0.22);
    border-color: rgba(66, 133, 244, 0.45);
    transform: scale(1.1);
}

/* Tooltip container — uses ::after for the text, ::before for the arrow */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.95);
    background: var(--bg-card, #1e2127);
    color: var(--text-primary, #e8eaed);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    width: max-content;
    max-width: 300px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.08));
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 10000;
    text-transform: none;
    letter-spacing: normal;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--bg-card, #1e2127);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 10001;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

[data-tooltip]:hover::before,
[data-tooltip]:focus::before {
    opacity: 1;
    visibility: visible;
}

/* Position variant: tooltip below */
[data-tooltip-pos="bottom"]::after {
    bottom: auto;
    top: calc(100% + 8px);
}
[data-tooltip-pos="bottom"]::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--bg-card, #1e2127);
}

/* Position variant: tooltip to the right */
[data-tooltip-pos="right"]::after {
    bottom: auto;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%) scale(0.95);
}
[data-tooltip-pos="right"]:hover::after {
    transform: translateY(-50%) scale(1);
}
[data-tooltip-pos="right"]::before {
    bottom: auto;
    left: calc(100% + 2px);
    top: 50%;
    transform: translateY(-50%);
    border-top-color: transparent;
    border-right-color: var(--bg-card, #1e2127);
}

/* Light theme overrides */
[data-theme="light"] [data-tooltip]::after {
    background: #1a1d23;
    color: #f0f0f0;
    border-color: rgba(0, 0, 0, 0.12);
}
[data-theme="light"] [data-tooltip]::before {
    border-top-color: #1a1d23;
}
[data-theme="light"] [data-tooltip-pos="bottom"]::before {
    border-top-color: transparent;
    border-bottom-color: #1a1d23;
}

/* Mobile: larger touch target for help icons */
@media (max-width: 768px) {
    .help-icon {
        width: 24px;
        height: 24px;
        font-size: 0.72rem;
    }
    [data-tooltip]::after {
        max-width: 260px;
        font-size: 0.82rem;
    }
}
