/* ========================================
   AI news UI
   - Top LIVE banner (landing)
   - Floating ticker (bottom-right)
   Fed by /api/ai-news/latest
   ======================================== */

/* ---------- Top LIVE news banner ---------- */
.live-news-banner {
  --lnb-height: 36px;
  --lnb-red: #ff3b30;
  --lnb-text: #ffffff;
  --lnb-muted: rgba(255, 255, 255, 0.76);
  --lnb-bg: #172130;
  --lnb-border: rgba(255, 255, 255, 0.16);
  --lnb-side: 88px;

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  height: var(--lnb-height);
  display: grid;
  grid-template-columns: var(--lnb-side) minmax(0, 1fr) var(--lnb-side);
  align-items: center;
  column-gap: 12px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(110deg, #172130, #27384f 52%, #16202d);
  border-bottom: 1px solid var(--lnb-border);
  color: var(--lnb-text);
  font-family: var(--font-primary, 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif);
}

.live-news-banner::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 12, 20, 0.76), rgba(7, 12, 20, 0.56) 48%, rgba(7, 12, 20, 0.72)),
    linear-gradient(180deg, rgba(8, 14, 23, 0.08), rgba(8, 14, 23, 0.28));
  pointer-events: none;
}

.live-news-banner-image {
  position: absolute;
  z-index: 0;
  inset: -18px 0;
  background-position: center 38%;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0;
  filter: saturate(0.9) contrast(1.04);
  transform: scale(1.02);
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.live-news-banner-image.has-image {
  opacity: 1;
}

.live-news-banner[hidden] {
  display: none !important;
}

.live-news-banner-live {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  z-index: 2;
}

.live-news-banner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lnb-red);
  box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.45);
  animation: live-news-dot-pulse 1.4s ease-out infinite;
}

.live-news-banner-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  color: var(--lnb-red);
}

/* Centered story: title + time, linked to learn_more_url */
.live-news-banner-story {
  --lnb-accent: #0071e3;
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
  justify-self: center;
  text-align: center;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.live-news-banner-story:hover,
.live-news-banner-story:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transform: translateY(-0.5px);
}

.live-news-banner-story:active {
  transform: translateY(0);
  background: rgba(255, 255, 255, 0.18);
}

.live-news-banner-story:hover .live-news-banner-title,
.live-news-banner-story:focus-visible .live-news-banner-title {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.live-news-banner-story:hover .live-news-banner-time,
.live-news-banner-story:focus-visible .live-news-banner-time {
  color: #ffffff;
  opacity: 0.9;
}

.live-news-banner-story::after {
  content: '↗';
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: rgba(255, 255, 255, 0.9);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.live-news-banner-story:hover::after,
.live-news-banner-story:focus-visible::after {
  opacity: 0.9;
  transform: translateX(0);
}

.live-news-banner-title {
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--lnb-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    color 0.18s ease,
    opacity 0.25s ease,
    transform 0.25s ease,
    text-decoration-color 0.18s ease;
}

.live-news-banner-time {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--lnb-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color 0.18s ease, opacity 0.25s ease;
}

/* Balances the left LIVE pill so the story sits truly centered */
.live-news-banner-spacer {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 1px;
  pointer-events: none;
}

.live-news-banner.is-updating .live-news-banner-title,
.live-news-banner.is-updating .live-news-banner-time {
  opacity: 0;
  transform: translateY(2px);
}

/* Push fixed header + main content down when the banner is present */
body.has-live-news-banner {
  --live-news-banner-height: 36px;
}

body.has-live-news-banner .header {
  top: var(--live-news-banner-height);
}

body.has-live-news-banner .main-content {
  padding-top: calc(72px + var(--live-news-banner-height));
}

@keyframes live-news-dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.5);
    opacity: 1;
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255, 59, 48, 0);
    opacity: 0.85;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0);
    opacity: 1;
  }
}

@media (max-width: 720px) {
  .live-news-banner {
    --lnb-side: 64px;
    column-gap: 8px;
  }
}

@media (max-width: 480px) {
  .live-news-banner {
    --lnb-height: 34px;
    --lnb-side: 52px;
    column-gap: 6px;
    padding: 0 12px;
  }

  body.has-live-news-banner {
    --live-news-banner-height: 34px;
  }

  body.has-live-news-banner .main-content {
    padding-top: calc(60px + var(--live-news-banner-height));
  }

  .live-news-banner-story {
    gap: 6px;
    padding: 3px 8px;
  }

  .live-news-banner-story::after {
    font-size: 11px;
  }

  .live-news-banner-title {
    font-size: 12px;
  }

  .live-news-banner-time {
    font-size: 11px;
  }

  .live-news-banner-label {
    font-size: 10px;
    letter-spacing: 0.1em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live-news-banner-dot {
    animation: none;
  }

  .live-news-banner-title,
  .live-news-banner-time,
  .live-news-banner-image {
    transition: none;
  }
}

/* ---------- Floating AI news ticker (bottom-right) ---------- */
.news-ticker {
  --nt-size: 56px;
  --nt-gap: 12px;
  --nt-shadow: 0 10px 30px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.06);
  --nt-border: rgba(0, 0, 0, 0.08);
  /* Both floating surfaces use 30% white fill: exactly 70% transparent. */
  --nt-bg: rgba(255, 255, 255, 0.3);
  --nt-card-bg: rgba(255, 255, 255, 0.3);
  --nt-text: #1d1d1f;
  --nt-muted: #6e6e73;
  --nt-accent: #0071e3;

  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 1100;
  display: flex;
  align-items: flex-end;
  gap: var(--nt-gap);
  font-family: var(--font-primary, 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s;
}

/* Keep the utility available without letting it cover the cinematic opening. */
.landing-page:not(.is-past-cosmic-hero) .news-ticker {
  visibility: hidden;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.news-ticker * {
  pointer-events: auto;
}

/* Teaser card: title + thumbnail */
.news-ticker-card {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(280px, calc(100vw - var(--nt-size) - 48px));
  padding: 8px 10px 8px 8px;
  border-radius: 16px;
  background: var(--nt-card-bg);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08), 0 1px 4px rgba(15, 23, 42, 0.04);
  /* The ambient particles are only 1–3px wide. Backdrop blur erased them even
     though the white fill was transparent, so this glass stays optically clear. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  text-decoration: none;
  color: inherit;
  transform: translateY(6px);
  opacity: 0;
  transition:
    opacity 0.35s ease,
    transform 0.35s cubic-bezier(0.25, 0.1, 0.25, 1),
    box-shadow 0.2s ease;
}

.news-ticker-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.news-ticker-card.is-updating {
  opacity: 0;
  transform: translateY(4px);
}

.news-ticker-card:hover,
.news-ticker-card:focus-visible {
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
  outline: none;
}

.news-ticker[hidden] {
  display: none !important;
}

.news-ticker-thumb {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  background: #eef1f5;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.news-ticker-thumb.is-empty::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(0, 113, 227, 0.12), rgba(0, 113, 227, 0.04));
}

.news-ticker-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.news-ticker-thumb img[hidden] {
  display: none !important;
}

.news-ticker-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.news-ticker-kicker {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--nt-accent);
  line-height: 1.2;
}

.news-ticker-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--nt-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Circular newspaper launcher */
.news-ticker-btn {
  position: relative;
  flex: 0 0 var(--nt-size);
  width: var(--nt-size);
  height: var(--nt-size);
  border: 1px solid var(--nt-border);
  border-radius: 50%;
  background: var(--nt-bg);
  box-shadow: var(--nt-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--nt-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    background 0.2s ease;
}

.news-ticker-btn:hover,
.news-ticker-btn:focus-visible {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
  outline: none;
}

.news-ticker-btn:active {
  transform: translateY(0) scale(0.98);
}

.news-ticker-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

/* Soft "new story" pulse on the badge */
.news-ticker-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--nt-accent);
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.45);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.news-ticker-badge.is-on {
  opacity: 1;
  transform: scale(1);
  animation: news-ticker-pulse 1.8s ease-out infinite;
}

@keyframes news-ticker-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.45);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(0, 113, 227, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 113, 227, 0);
  }
}

@media (max-width: 480px) {
  .news-ticker {
    --nt-size: 50px;
    --nt-gap: 10px;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .news-ticker-card {
    max-width: min(220px, calc(100vw - var(--nt-size) - 36px));
    padding: 7px 9px 7px 7px;
    border-radius: 14px;
  }

  .news-ticker-thumb {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }

  .news-ticker-title {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .news-ticker-card,
  .news-ticker-btn,
  .news-ticker-badge {
    transition: none;
  }

  .news-ticker-badge.is-on {
    animation: none;
  }
}
