/* Top-centred water lens: positioning is independent of entrance animations. */
#rain-alert-box {
    --ra-accent: #087f59;
    --ra-soft: rgba(16,185,129,.12);
    --ra-text: #153047;
    --ra-muted: #496174;
    position: fixed;
    box-sizing: border-box;
    left: 50%;
    right: auto;
    translate: -50% 0;
    transform: none;
    top: max(16px, env(safe-area-inset-top));
    width: min(420px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    min-width: 0;
    max-width: none;
    padding: 17px 18px;
    gap: 13px;
    border: 1px solid rgba(255,255,255,.85);
    border-radius: 24px;
    background: transparent !important;
    color: var(--ra-text);
    box-shadow: 0 12px 36px rgba(17,43,61,.16), inset 0 1px 0 rgba(255,255,255,.75);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    isolation: auto;
}
#rain-alert-box::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(255,255,255,.36), rgba(255,255,255,.04) 45%, rgba(220,242,250,.13)), rgba(243,251,255,.58);
    backdrop-filter: var(--ra-refraction, blur(6px)) saturate(1.2);
    -webkit-backdrop-filter: blur(6px) saturate(1.2);
    box-shadow: inset 1px 1px 0 rgba(255,255,255,.8), inset -1px -1px 0 rgba(255,255,255,.25);
    z-index: 0;
}
/* Keep the backdrop plane directly beneath content, without a stacking isolate. */
#rain-alert-box > * { position: relative; z-index: 1; }
#rain-alert-box.warning { --ra-accent: #a45608; --ra-soft: rgba(245,158,11,.15); }
#rain-alert-box.danger { --ra-accent: #c52b36; --ra-soft: rgba(239,68,68,.13); }
#rain-alert-box.loading { --ra-accent: #2563eb; --ra-soft: rgba(59,130,246,.12); }
#rain-alert-box.loading #rain-alert-icon {
    display: block;
    width: 22px;
    height: 22px;
    box-sizing: border-box;
    border: 2px solid var(--ra-soft);
    border-top-color: var(--ra-accent);
    border-radius: 50%;
    animation: radarAssessmentLoading .8s linear infinite;
}
@keyframes radarAssessmentLoading { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    #rain-alert-box.loading #rain-alert-icon { animation: none; }
}
#rain-alert-box .rain-alert-card-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: var(--ra-soft);
    font-size: 26px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.5);
    align-self: flex-start;
    margin-top: 19px;
}
#rain-alert-box .rain-alert-card-content { min-width: 0; padding-right: 22px; }
#rain-alert-box .rain-alert-card-badge {
    color: var(--ra-accent);
    background: var(--ra-soft);
    font-size: 10px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 7px;
    letter-spacing: 0;
}
#rain-alert-box .rain-alert-card-title { color: var(--ra-text); font-size: 16px; line-height: 1.4; margin-top: 5px; font-weight: 600; }
#rain-alert-box .rain-alert-card-msg { color: var(--ra-text); opacity: 1; font-size: 12px; line-height: 1.5; margin-top: 4px; overflow-wrap: anywhere; }
#rain-alert-box .rain-alert-card-detail { color: var(--ra-muted); opacity: 1; font-size: 11px; line-height: 1.55; margin-top: 7px; white-space: pre-line; overflow-wrap: anywhere; max-height: 28dvh; overflow: auto; }
#rain-alert-box .rain-alert-card-close {
    position: absolute;
    z-index: 2;
    top: 9px;
    right: 9px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--ra-muted);
    background: rgba(126,158,181,.12);
    font-size: 23px;
    pointer-events: auto;
    touch-action: manipulation;
}
#rain-alert-box .rain-alert-card-close:hover { background: rgba(126,158,181,.22); }
#rain-alert-box .rain-alert-card-close:focus-visible { outline: 2px solid var(--ra-accent); outline-offset: 2px; }
#rain-alert-box .rain-alert-card-msg:empty,
#rain-alert-box .rain-alert-card-detail:empty { display: none; }
[data-theme='dark'] #rain-alert-box {
    --ra-text: #edf7ff;
    --ra-muted: #c0d4e3;
    --ra-accent: #6ee7b7;
    border-color: rgba(224,245,255,.5);
}
[data-theme='dark'] #rain-alert-box::before { background: linear-gradient(135deg, rgba(224,245,255,.17), transparent 50%, rgba(180,228,255,.06)), rgba(15,36,54,.66); }
[data-theme='dark'] #rain-alert-box.warning { --ra-accent: #fcd68a; }
[data-theme='dark'] #rain-alert-box.danger { --ra-accent: #fda4af; }
[data-theme='dark'] #rain-alert-box.loading { --ra-accent: #93c5fd; }
@media (max-width: 600px) {
    #rain-alert-box { top: max(12px, env(safe-area-inset-top)); padding: 14px; border-radius: 21px; gap: 10px; }
    #rain-alert-box .rain-alert-card-icon { width: 38px; height: 38px; font-size: 23px; border-radius: 13px; }
    #rain-alert-box .rain-alert-card-title { font-size: 14px; }
    #rain-alert-box .rain-alert-card-content { padding-right: 20px; }
    #rain-alert-box .rain-alert-card-detail { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { #rain-alert-box { animation: none !important; } }
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
    #rain-alert-box::before { background: rgba(246,251,255,.97); backdrop-filter: none; -webkit-backdrop-filter: none; }
    [data-theme='dark'] #rain-alert-box::before { background: rgba(15,36,54,.97); }
}

/* No opacity animation on the lens shell: it must keep sampling the map. */
@keyframes alertCardIn {
    from { transform: translateY(-20px) scale(.95); }
    to { transform: translateY(0) scale(1); }
}
@keyframes alertIn {
    from { transform: translateY(-20px) scale(.95); }
    to { transform: translateY(0) scale(1); }
}
#rain-alert-box.safe { animation: alertCardIn .4s cubic-bezier(.16,1,.3,1) backwards; }
#rain-alert-box.warning,
#rain-alert-box.danger { animation: alertIn .3s ease-out backwards; }
