/* 
  FORMAS.AI - Announcement Ticker Styles
  Professional stock market-style scrolling band
*/

:root {
  --ticker-height: 28px; /* Standard web ticker height - thinner bar */
  --ticker-gap: calc(var(--ticker-height) / 2); /* 50% thinner gap - single source of truth */
  --ticker-bg: rgba(180, 180, 180, 0.12); /* Transparent silvery grey glass - lighter background */
  --ticker-text: rgba(255, 255, 255, 0.75); /* Light grey text - elegant */
  --ticker-text-bold: rgba(232, 144, 60, 0.95); /* Orange-gold for bold text */
  --ticker-font-size: 12px; /* Slightly smaller font for thinner bar */
  --ticker-z-index: 10001; /* Above everything */
}

#formas-announcement-ticker {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--ticker-height);
  background: var(--ticker-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  color: var(--ticker-text);
  z-index: var(--ticker-z-index);
  display: flex;
  align-items: center;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-weight: 400;
  font-size: var(--ticker-font-size);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

#formas-announcement-ticker.closing {
  transform: translateY(calc(-1 * var(--ticker-height)));
  opacity: 0;
}

.ticker-wrap {
  flex-grow: 1;
  overflow: hidden;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

@media (min-width: 1025px) {
  .ticker-wrap {
    justify-content: center;
  }
}

.ticker-content-centered {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  white-space: nowrap;
}

/* Only show centered content on true desktop (above tablet breakpoint) */
@media (min-width: 1025px) {
  .ticker-content-centered {
    display: flex;
  }
}

.ticker-content-centered .ticker-item {
  padding-right: 0px !important;
  margin-right: 0px !important;
}

.ticker-content-centered .ticker-date-pill {
  margin-left: 0px !important;
  padding-left: 0px;
}

.ticker-content {
  display: none;
  white-space: nowrap;
  will-change: transform;
}

/* Show scrolling ticker on mobile AND tablets (iPad uses mobile JS detection via userAgent) */
@media (max-width: 1024px) {
  .ticker-content {
    display: inline-flex;
    animation: ticker-scroll linear infinite;
  }
}

/* On tablets, also hide the centered version since mobile HTML structure is rendered */
@media (min-width: 769px) and (max-width: 1024px) {
  .ticker-content-centered {
    display: none !important;
  }
}

@keyframes ticker-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    /* Move exactly one-third of the content width for seamless loop (since we have 3 copies) */
    transform: translateX(calc(-100% / 3));
  }
}

.ticker-item {
  display: inline-block;
  padding: 0 60px;
  line-height: var(--ticker-height);
  color: var(--ticker-text);
  animation: ticker-glow 8s ease-in-out infinite;
}

@media (max-width: 768px) {
  .ticker-item {
    padding: 0 30px; /* Tighter padding on mobile */
    font-size: var(--ticker-font-size);
  }
}

@keyframes ticker-glow {
  /* Continuous smooth sine wave glow throughout 8 seconds */
  /* sin(x) pattern: smooth oscillation from 0 to peak and back */
  0% {
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    opacity: 1;
  }
  3.125% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  6.25% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  9.375% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  12.5% {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.9), 0 0 40px rgba(255, 255, 255, 0.45);
    opacity: 1.25;
  }
  15.625% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  18.75% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  21.875% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  25% {
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    opacity: 1;
  }
  28.125% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  31.25% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  34.375% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  37.5% {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.9), 0 0 40px rgba(255, 255, 255, 0.45);
    opacity: 1.25;
  }
  40.625% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  43.75% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  46.875% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  50% {
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    opacity: 1;
  }
  53.125% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  56.25% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  59.375% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  62.5% {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.9), 0 0 40px rgba(255, 255, 255, 0.45);
    opacity: 1.25;
  }
  65.625% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  68.75% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  71.875% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  75% {
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    opacity: 1;
  }
  78.125% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  81.25% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  84.375% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  87.5% {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.9), 0 0 40px rgba(255, 255, 255, 0.45);
    opacity: 1.25;
  }
  90.625% {
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.8), 0 0 36px rgba(255, 255, 255, 0.4);
    opacity: 1.2;
  }
  93.75% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.7), 0 0 30px rgba(255, 255, 255, 0.35);
    opacity: 1.15;
  }
  96.875% {
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.25);
    opacity: 1.1;
  }
  100% {
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    opacity: 1;
  }
}

.ticker-item strong,
.ticker-item b {
  color: var(--ticker-text-bold);
  font-weight: 600;
}

.ticker-highlight {
  color: #FFD700;
  font-weight: 600;
  animation: ticker-highlight-glow 3s ease-in-out infinite;
  display: inline-block;
  position: relative;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4), 0 0 16px rgba(255, 165, 0, 0.2);
}

@keyframes ticker-highlight-glow {
  /* Faster sine wave: 3 seconds, smooth continuous glow */
  /* sin(x) pattern: 0 -> 1 -> 0 -> -1 -> 0 */
  0% {
    color: #FFD700;
    filter: brightness(1);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 165, 0, 0.25), 0 0 30px rgba(255, 200, 50, 0.15);
  }
  6.25% {
    color: #FFBC40;
    filter: brightness(1.15);
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.7), 0 0 28px rgba(255, 165, 0, 0.35), 0 0 42px rgba(255, 200, 50, 0.2);
  }
  12.5% {
    color: #FFA500;
    filter: brightness(1.3);
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.85), 0 0 36px rgba(255, 165, 0, 0.45), 0 0 54px rgba(255, 200, 50, 0.25);
  }
  18.75% {
    color: #FFD700;
    filter: brightness(1.4);
    text-shadow: 0 0 22px rgba(255, 215, 0, 0.95), 0 0 44px rgba(255, 165, 0, 0.5), 0 0 66px rgba(255, 200, 50, 0.3);
  }
  25% {
    color: #FFBC40;
    filter: brightness(1.3);
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.85), 0 0 36px rgba(255, 165, 0, 0.45), 0 0 54px rgba(255, 200, 50, 0.25);
  }
  31.25% {
    color: #FFA500;
    filter: brightness(1.15);
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.7), 0 0 28px rgba(255, 165, 0, 0.35), 0 0 42px rgba(255, 200, 50, 0.2);
  }
  37.5% {
    color: #FFD700;
    filter: brightness(1);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 165, 0, 0.25), 0 0 30px rgba(255, 200, 50, 0.15);
  }
  43.75% {
    color: #FFBC40;
    filter: brightness(1.15);
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.7), 0 0 28px rgba(255, 165, 0, 0.35), 0 0 42px rgba(255, 200, 50, 0.2);
  }
  50% {
    color: #FFA500;
    filter: brightness(1.3);
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.85), 0 0 36px rgba(255, 165, 0, 0.45), 0 0 54px rgba(255, 200, 50, 0.25);
  }
  56.25% {
    color: #FFD700;
    filter: brightness(1.4);
    text-shadow: 0 0 22px rgba(255, 215, 0, 0.95), 0 0 44px rgba(255, 165, 0, 0.5), 0 0 66px rgba(255, 200, 50, 0.3);
  }
  62.5% {
    color: #FFBC40;
    filter: brightness(1.3);
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.85), 0 0 36px rgba(255, 165, 0, 0.45), 0 0 54px rgba(255, 200, 50, 0.25);
  }
  68.75% {
    color: #FFA500;
    filter: brightness(1.15);
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.7), 0 0 28px rgba(255, 165, 0, 0.35), 0 0 42px rgba(255, 200, 50, 0.2);
  }
  75% {
    color: #FFD700;
    filter: brightness(1);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 165, 0, 0.25), 0 0 30px rgba(255, 200, 50, 0.15);
  }
  81.25% {
    color: #FFBC40;
    filter: brightness(1.15);
    text-shadow: 0 0 14px rgba(255, 215, 0, 0.7), 0 0 28px rgba(255, 165, 0, 0.35), 0 0 42px rgba(255, 200, 50, 0.2);
  }
  87.5% {
    color: #FFA500;
    filter: brightness(1.3);
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.85), 0 0 36px rgba(255, 165, 0, 0.45), 0 0 54px rgba(255, 200, 50, 0.25);
  }
  93.75% {
    color: #FFD700;
    filter: brightness(1.4);
    text-shadow: 0 0 22px rgba(255, 215, 0, 0.95), 0 0 44px rgba(255, 165, 0, 0.5), 0 0 66px rgba(255, 200, 50, 0.3);
  }
  100% {
    color: #FFD700;
    filter: brightness(1);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 165, 0, 0.25), 0 0 30px rgba(255, 200, 50, 0.15);
  }
}

.ticker-item a {
  color: var(--ticker-text);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
  animation: ticker-glow 8s ease-in-out infinite;
}

.ticker-item a:hover {
  color: rgba(255, 255, 255, 1);
  opacity: 1;
}

.ticker-date-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 20px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ticker-text);
  transition: all 0.2s ease;
  white-space: nowrap;
  user-select: none;
  line-height: 1.2;
}

.ticker-calendar-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  opacity: 0.8;
  stroke: currentColor;
  fill: none;
}

.ticker-date-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.9);
  color: rgba(255, 255, 255, 1);
  transform: scale(1.02);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3), inset 0 0 8px rgba(255, 255, 255, 0.1);
}

.ticker-date-pill:hover .ticker-calendar-icon {
  opacity: 1;
  stroke: rgba(255, 255, 255, 1);
}

.ticker-separator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 10px;
  opacity: 0.6;
}

.ticker-separator svg {
  width: 14px;
  height: 14px;
  display: block;
}

.ticker-separator line {
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.ticker-close {
  width: 40px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
  flex-shrink: 0;
  pointer-events: auto;
  z-index: 1;
  position: relative;
}

@media (max-width: 768px) {
  .ticker-close {
    width: 34px; /* 30% smaller than 48px */
  }
  
  .ticker-close svg {
    width: 13px;
    height: 13px;
  }
}

.ticker-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ticker-close svg {
  width: 14px;
  height: 14px;
  stroke: var(--ticker-text);
  stroke-width: 2;
  opacity: 0.7;
}

.ticker-close:hover svg {
  opacity: 1;
  stroke: var(--ticker-text-bold);
}

/* Adjust layout when ticker is present - NO body padding, everything positioned below */
body.has-ticker {
  padding-top: 0; /* No padding - everything positioned absolutely */
}

/* Position sidebar below ticker - no gap */
body.has-ticker .sidebar {
  top: var(--ticker-height) !important;
  height: calc(100vh - var(--ticker-height)) !important;
  height: calc(100dvh - var(--ticker-height)) !important;
  height: calc(100svh - var(--ticker-height)) !important;
}

/* Position header right below ticker - sticky positioning with no gap */
body.has-ticker .navbar, 
body.has-ticker .main-header {
  top: var(--ticker-height) !important;
  margin-top: 0 !important;
}

/* Ensure fullscreen overlays account for ticker */
body.has-ticker .module-fullscreen-overlay {
  top: var(--ticker-height) !important;
}

/* Instant Narratives topbar: keep below main header + ticker */
body.has-ticker .in-topbar {
  top: calc(var(--ticker-height) + var(--topbar-height, 60px) + 16px) !important;
}

/* Freeform top pills: keep below ticker */
body.has-ticker #canvasPillsLeft {
  top: calc(20px + var(--ticker-height)) !important;
}

body.has-ticker #canvasPills {
  top: calc(20px + var(--ticker-height)) !important;
}

body.has-ticker #qualityDropdown {
  top: calc(60px + var(--ticker-height)) !important;
}

/* Editor top-right pills: keep below ticker */
body.has-ticker .editor-quality-pill {
  top: calc(var(--editor-top-right-top, 71px) + var(--ticker-height) + env(safe-area-inset-top, 0px)) !important;
}

body.has-ticker .editor-quality-dropdown {
  top: calc(var(--editor-top-right-top, 71px) + var(--ticker-height) + env(safe-area-inset-top, 0px) + 40px) !important;
}

body.has-ticker .editor-close-btn {
  top: calc(var(--editor-top-right-top, 71px) + var(--ticker-height) + env(safe-area-inset-top, 0px)) !important;
}

/* Private Gallery top buttons: keep below ticker */
body.has-ticker .pg-toolbar,
body.has-ticker .pg-filters {
  top: calc(10px + var(--ticker-height)) !important;
}

/* Sidebar overlay should also account for ticker */
body.has-ticker .sidebar-overlay {
  top: var(--ticker-height) !important;
  height: calc(100vh - var(--ticker-height)) !important;
}

@media (max-width: 768px) {
  :root {
    --ticker-height: 34px; /* 30% smaller than 48px */
    --ticker-gap: calc(34px / 2); /* Mobile gap - single source of truth */
  }
  #formas-announcement-ticker {
    height: var(--ticker-height);
    --ticker-font-size: 15px; /* 30% smaller than 22px */
    background: rgba(40, 40, 40, 0.85); /* Darker grey on mobile */
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
  }
  body.has-ticker {
    padding-top: 0; /* No padding on mobile either */
  }
  body.has-ticker .sidebar {
    top: var(--ticker-height) !important;
    height: calc(100svh - var(--ticker-height)) !important;
  }
  body.has-ticker .navbar,
  body.has-ticker .main-header {
    top: var(--ticker-height) !important;
  }
  body.has-ticker .sidebar-overlay {
    top: var(--ticker-height) !important;
    height: calc(100svh - var(--ticker-height)) !important;
  }

  body.has-ticker .in-topbar {
    top: calc(var(--ticker-height) + var(--topbar-height-mobile, 56px) + 12px) !important;
  }

  body.has-ticker #canvasPillsLeft {
    top: calc(16px + var(--ticker-height)) !important;
  }

  body.has-ticker #canvasPills {
    top: calc(16px + var(--ticker-height)) !important;
  }

  body.has-ticker #qualityDropdown {
    top: calc(56px + var(--ticker-height)) !important;
  }

  body.has-ticker .editor-quality-pill {
    top: calc(var(--editor-top-right-top, 71px) + var(--ticker-height) + env(safe-area-inset-top, 0px)) !important;
  }

  body.has-ticker .editor-quality-dropdown {
    top: calc(var(--editor-top-right-top, 71px) + var(--ticker-height) + env(safe-area-inset-top, 0px) + 40px) !important;
  }

  body.has-ticker .editor-close-btn {
    top: calc(var(--editor-top-right-top, 71px) + var(--ticker-height) + env(safe-area-inset-top, 0px)) !important;
  }

  body.has-ticker .pg-toolbar,
  body.has-ticker .pg-filters {
    top: calc(8px + var(--ticker-height)) !important;
  }
}
