/* ═══════════════════════════════════════════════════════════════════
   alert-ticker.css — canonical, self-contained alert-ticker shell.
   Paired with js/alert-ticker.js (MagnaAlertTicker.mount). Renders the
   shared .er-alert-pill component (styled in alert-system.css), so every
   surface — dashboard, signals, any page — shows identical canonical pills
   fed by AlertRegistry. This file owns ONLY the rail chrome (frame, marquee,
   badge, panel); the pills themselves come from alert-system.css.
   No dependency on earth-report.css variables — uses theme tokens w/ fallbacks.
   ═══════════════════════════════════════════════════════════════════ */

.alert-ticker {
    --atk-accent: #f97316;                 /* WARNING default */
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;  /* badge · marquee · chevron */
    align-items: center;
    gap: 8px;
    margin: 8px 14px 6px;
    padding: 5px 12px;
    border-radius: 14px;
    overflow: hidden;
    background: var(--th-bg-surface, rgba(20, 20, 28, 0.72));
    border: 1px solid var(--th-border, rgba(255, 255, 255, 0.10));
    backdrop-filter: blur(12px) saturate(1.3);
    -webkit-backdrop-filter: blur(12px) saturate(1.3);
    isolation: isolate;
}
.alert-ticker[hidden] { display: none; }
.alert-ticker[data-level="critical"] { --atk-accent: #ef4444; }
.alert-ticker[data-level="warning"]  { --atk-accent: #f97316; }
.alert-ticker[data-level="elevated"] { --atk-accent: var(--th-color-globe, #38bdf8); }

/* Soft accent breath along the top edge */
.alert-ticker::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: radial-gradient(140% 90% at 18% -10%,
        color-mix(in srgb, var(--atk-accent) 16%, transparent), transparent 55%);
    opacity: 0.5;
    z-index: 0;
    animation: atkEdgePulse 3.4s ease-in-out infinite;
}
@keyframes atkEdgePulse { 0%,100% { opacity: 0.38; } 50% { opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .alert-ticker::before { animation: none; } }

/* Badge / state well (also the expand toggle) */
.alert-ticker-badge {
    position: relative;
    z-index: 1;
    appearance: none;
    border: none;
    background: transparent;
    color: inherit;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 10px 4px 12px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}
.alert-ticker-badge::before {
    content: '';
    width: 3px;
    align-self: stretch;
    border-radius: 999px;
    background: var(--atk-accent);
    box-shadow: 0 0 10px var(--atk-accent);
    animation: atkEdgePulse 2.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .alert-ticker-badge::before { animation: none; } }
.alert-ticker-badge:hover { background: rgba(255,255,255,0.04); }
.alert-ticker-level {
    font-family: var(--font-mono, monospace);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--atk-accent);
    text-shadow: 0 0 12px color-mix(in srgb, var(--atk-accent) 55%, transparent);
}
.alert-ticker-count {
    font-family: var(--font-mono, monospace);
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--atk-accent) 22%, rgba(0,0,0,0.4));
    color: #fff;
    border: 1px solid color-mix(in srgb, var(--atk-accent) 40%, transparent);
}
.alert-ticker-domain {
    font-family: var(--font-mono, monospace);
    font-size: 0.55rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--th-text-secondary, rgba(232, 228, 218, 0.62));
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Marquee */
.alert-ticker-marquee {
    position: relative;
    z-index: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    min-width: 0;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 48px, #000 calc(100% - 48px), transparent 100%);
}
.alert-ticker-track {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    white-space: nowrap;
    will-change: transform;
    animation: atkScroll var(--atk-duration, 90s) linear infinite;
}
.alert-ticker:hover .alert-ticker-track,
.alert-ticker-marquee:focus-within .alert-ticker-track { animation-play-state: paused; }
@keyframes atkScroll {
    0%   { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-50%, 0, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .alert-ticker-track { animation: none; overflow-x: auto; }
    .alert-ticker-marquee { overflow-x: auto; }
}

/* Chevron — expand/collapse the full panel */
.alert-ticker-chev {
    position: relative;
    z-index: 1;
    appearance: none;
    background: transparent;
    border: none;
    color: var(--th-text-secondary, rgba(232,228,218,0.7));
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    font-size: 0.8rem;
}
.alert-ticker-chev:hover { background: rgba(255,255,255,0.05); color: #fff; }

/* Expanded panel — full list of active alerts */
.alert-ticker-panel {
    grid-column: 1 / -1;
    z-index: 1;
    margin-top: 6px;
    max-height: 46vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid var(--th-border, rgba(255,255,255,0.08));
}
.alert-ticker-panel[hidden] { display: none; }
.alert-ticker-panel .er-alert-pill { width: 100%; text-align: left; }

/* NEAR YOU tag — user-specific geo relevance (pinned pills) */
.er-alert-pill__near {
    font-family: var(--font-mono, monospace);
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 1px 5px;
    border-radius: 999px;
    color: var(--th-color-globe, #38bdf8);
    background: color-mix(in srgb, var(--th-color-globe, #38bdf8) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--th-color-globe, #38bdf8) 40%, transparent);
    flex: none;
}
.er-alert-pill--near { background: color-mix(in srgb, var(--th-color-globe, #38bdf8) 6%, transparent); }

/* Empty / quiet state */
.alert-ticker-empty {
    font-family: var(--font-mono, monospace);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--th-text-secondary, rgba(232,228,218,0.55));
    padding: 4px 10px;
}

@media (max-width: 640px) {
    .alert-ticker { margin: 4px 8px; padding: 4px 8px; }
    .alert-ticker-domain { display: none; }
}

/* Shared frequency control (MagnaFreqControl) label */
.afreq-label {
    font-family: var(--font-mono, monospace);
    font-size: 0.52rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--th-text-secondary, rgba(232,228,218,0.55));
    margin-right: 8px;
}
.afreq { --domain-color: var(--th-color-globe, #38bdf8); }
.afreq .er-prefs-cap-pill__opt:active { transform: scale(0.94); }
