/* ============================================
   PriceONN — Breaking News Alert System
   Bloomberg TV-style breaking news bar

   Requires a container with position:relative.
   Inject .bn-flash-overlay + .bn-bar inside it.
   ============================================ */

/* ============================================
   FLASH OVERLAY — Red screen flash
   ============================================ */
.bn-flash-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(211, 47, 47, 0.45) 0%, rgba(183, 28, 28, 0.25) 50%, rgba(139, 0, 0, 0.08) 80%, transparent 100%);
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    border-radius: inherit;
}
.bn-flash-overlay.active {
    animation: bnFlashPulse 5.5s ease-out forwards;
}

@keyframes bnFlashPulse {
    0%   { opacity: 0; }
    3%   { opacity: 1; }
    6%   { opacity: 0.4; }
    9%   { opacity: 0.9; }
    12%  { opacity: 0.3; }
    15%  { opacity: 0.75; }
    22%  { opacity: 0.2; }
    30%  { opacity: 0.55; }
    40%  { opacity: 0.15; }
    52%  { opacity: 0.4; }
    65%  { opacity: 0.25; }
    80%  { opacity: 0.12; }
    92%  { opacity: 0.06; }
    100% { opacity: 0; }
}

/* ============================================
   BREAKING NEWS BAR
   ============================================ */
.bn-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 10;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #b71c1c 0%, #d32f2f 30%, #c62828 60%, #b71c1c 100%);
    background-size: 300% 100%;
    border-top: 2px solid rgba(255,255,255,0.15);
    box-shadow: 0 -4px 30px rgba(183, 28, 28, 0.5), 0 -1px 0 rgba(255,255,255,0.1);
    transform: translateY(100%);
    opacity: 0;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

/* Lens flare effect */
.bn-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.03) 20%,
        rgba(255,255,255,0.15) 45%,
        rgba(255,255,255,0.3) 50%,
        rgba(255,255,255,0.15) 55%,
        rgba(255,255,255,0.03) 80%,
        transparent 100%
    );
    z-index: 2;
    pointer-events: none;
    transform: skewX(-15deg);
}

/* Top edge — accent line with shimmer */
.bn-bar::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        rgba(255,120,120,0.3),
        rgba(255,200,180,0.7) 25%,
        rgba(255,255,255,0.9) 50%,
        rgba(255,200,180,0.7) 75%,
        rgba(255,120,120,0.3)
    );
    background-size: 200% 100%;
    box-shadow: 0 0 6px 1px rgba(255,160,140,0.4), 0 0 15px 2px rgba(255,80,60,0.15);
    z-index: 3;
}
.bn-bar.visible::before {
    animation: bnEdgeShimmer 4s ease-in-out infinite;
}
.bn-bar.entering::before {
    animation: bnEdgeShimmer 4s ease-in-out infinite;
}

/* ---- ENTRY ---- */
.bn-bar.entering {
    animation: bnSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.bn-bar.entering::after {
    animation: bnLensFlare 1.8s 0.3s ease-in-out forwards;
}
.bn-bar.entering .bn-bar__gradient {
    animation: bnGradientPulse 2s ease-in-out 2;
}

/* ---- VISIBLE ---- */
.bn-bar.visible {
    transform: translateY(0);
    opacity: 1;
}
.bn-bar.visible .bn-bar__gradient {
    animation: bnSubtleShift 8s ease-in-out infinite;
}

/* ---- EXIT ---- */
.bn-bar.exiting {
    animation: bnSlideDown 1s cubic-bezier(0.4, 0, 1, 1) forwards;
}

/* Animated gradient layer */
.bn-bar__gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #b71c1c 0%, #d32f2f 30%, #c62828 60%, #b71c1c 100%);
    background-size: 300% 100%;
    z-index: 0;
}

/* ============================================
   BADGE PANEL
   ============================================ */
.bn-badge {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 0 16px;
    height: 100%;
    border-right: 1px solid rgba(255,255,255,0.12);
    white-space: nowrap;
    transform: scale(0);
    transform-origin: left center;
}

/* Live dot + heartbeat rings */
.bn-badge__dot {
    position: relative;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}
.bn-badge__dot::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 10px; height: 10px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 6px 2px rgba(255,255,255,0.5);
    z-index: 2;
}
.bn-badge__dot::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
    opacity: 0;
}
.bn-bar.visible .bn-badge__dot::after {
    animation: bnHeartbeat 2s ease-out infinite;
}
.bn-badge__ring2 {
    position: absolute;
    top: 50%; left: 50%;
    width: 0; height: 0;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.4);
    opacity: 0;
    pointer-events: none;
}
.bn-bar.visible .bn-badge__ring2 {
    animation: bnHeartbeat 2s 0.4s ease-out infinite;
}

.bn-badge__label {
    font-weight: 900;
    font-size: 13px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 0 12px rgba(255,255,255,0.3);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bn-badge__label[data-len="long"] {
    font-size: 11px;
    letter-spacing: 1px;
}

/* Entry animation */
.bn-bar.entering .bn-badge {
    animation: bnBadgeIn 0.5s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.bn-bar.visible .bn-badge {
    transform: scale(1);
    animation: none;
}
.bn-bar.visible .bn-badge__label {
    animation: bnLabelGlow 3s ease-in-out infinite;
}

/* ============================================
   NEWS TEXT
   ============================================ */
.bn-text {
    position: relative;
    z-index: 5;
    flex: 1;
    overflow: hidden;
    min-width: 0;
}
.bn-title {
    display: inline-block;
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 8px rgba(0,0,0,0.4), 0 0 20px rgba(255,255,255,0.1);
    white-space: nowrap;
    padding-right: 40px;
}
.bn-title.marquee {
    animation: bnMarquee var(--bn-marquee-duration, 15s) linear infinite;
}

/* ============================================
   TIME BADGE
   ============================================ */
.bn-time {
    position: relative;
    z-index: 5;
    margin: 0 16px;
    flex-shrink: 0;
}
.bn-time__inner {
    position: relative;
    display: inline-block;
    padding: 6px 16px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.85);
    background: linear-gradient(135deg, #c62828 0%, #e53935 40%, #b71c1c 70%, #d32f2f 100%);
    background-size: 250% 250%;
    color: #fff;
    font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4px;
    white-space: nowrap;
    overflow: hidden;
    transform: scale(0);
    animation: none;
}
.bn-time__inner::after {
    content: '';
    position: absolute;
    top: 0; left: -100%; bottom: 0;
    width: 60%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.08) 30%,
        rgba(255,255,255,0.22) 50%,
        rgba(255,255,255,0.08) 70%,
        transparent 100%
    );
    transform: skewX(-20deg);
    pointer-events: none;
}
.bn-bar.visible .bn-time__inner {
    transform: scale(1);
    animation: bnTimePop 0.4s 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
               bnTimeGradient 6s 1s ease-in-out infinite;
}
.bn-bar.visible .bn-time__inner::after {
    animation: bnTimeShimmer 3s 1s ease-in-out infinite;
}
.bn-bar.entering .bn-time__inner {
    animation: bnTimePop 0.4s 1.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.bn-time__inner.pop {
    animation: bnTimeRepop 0.35s ease-out;
}

/* ============================================
   KEYFRAMES
   ============================================ */
@keyframes bnSlideUp {
    0%   { transform: translateY(100%); opacity: 0; }
    40%  { opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
}
@keyframes bnSlideDown {
    0%   { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(100%); opacity: 0; }
}
@keyframes bnLensFlare {
    0%   { left: -100%; }
    100% { left: 200%; }
}
@keyframes bnGradientPulse {
    0%   { background-position: 0% 50%; filter: brightness(1); }
    50%  { background-position: 100% 50%; filter: brightness(1.3); }
    100% { background-position: 0% 50%; filter: brightness(1); }
}
@keyframes bnSubtleShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 50% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes bnBadgeIn {
    0%   { transform: scaleX(0); opacity: 0; }
    60%  { transform: scaleX(1.04); opacity: 1; }
    100% { transform: scaleX(1); opacity: 1; }
}
@keyframes bnHeartbeat {
    0%   { transform: scale(1); opacity: 0.8; }
    60%  { transform: scale(3); opacity: 0; }
    100% { transform: scale(3); opacity: 0; }
}
@keyframes bnLabelGlow {
    0%, 100% { text-shadow: 0 0 12px rgba(255,255,255,0.3); }
    50%      { text-shadow: 0 0 20px rgba(255,255,255,0.6), 0 0 40px rgba(255,200,200,0.2); }
}
@keyframes bnMarquee {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
@keyframes bnEdgeShimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes bnTimePop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}
@keyframes bnTimeRepop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}
@keyframes bnTimeGradient {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes bnTimeShimmer {
    0%   { left: -100%; }
    40%  { left: 150%; }
    100% { left: 150%; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .bn-bar { height: 52px; }
    .bn-badge { padding: 0 16px 0 12px; }
    .bn-badge__label { font-size: 11px; letter-spacing: 1.5px; }
    .bn-title { font-size: 15px; }
}
@media (max-width: 768px) {
    .bn-bar { height: 48px; }
    .bn-badge { padding: 0 12px 0 10px; gap: 7px; }
    .bn-badge__label { font-size: 10px; letter-spacing: 1px; }
    .bn-badge__dot { width: 8px; height: 8px; }
    .bn-title { font-size: 14px; }
    .bn-time { margin: 0 10px; }
    .bn-time__inner { font-size: 10px; padding: 4px 10px; font-weight: 700; }
}

/* ============================================
   RTL SUPPORT (Arabic)
   ============================================ */
[dir="rtl"] .bn-bar {
    flex-direction: row-reverse;
}
[dir="rtl"] .bn-badge {
    padding: 0 16px 0 20px;
    border-right: none;
    border-left: 1px solid rgba(255,255,255,0.12);
    transform-origin: right center;
    flex-direction: row-reverse;
}
[dir="rtl"] .bn-title {
    padding-right: 0;
    padding-left: 40px;
    direction: rtl;
}
[dir="rtl"] .bn-title.marquee {
    animation-direction: reverse;
}
[dir="rtl"] .bn-time {
    margin: 0 16px;
}
[dir="rtl"] .bn-time__inner::after {
    transform: skewX(20deg);
}
[dir="rtl"] .bn-bar::after {
    transform: skewX(15deg);
}
[dir="rtl"] .bn-bar::before {
    animation-direction: reverse;
}
