/* ============================================================
   Smart Read Time + News Ticker — Frontend CSS v1.4.0
   ============================================================ */

/* Fallback defaults — overridden by html:root{} from wp_add_inline_style */
:root {
  --srt-bg: #111827;
  --srt-text: #ffffff;
  --srt-accent: #22c55e;
  --srt-progress: #22c55e;
  --srt-radius: 12px;
  --srt-font: 13px;
  --srt-ticker-height: 36px;
  --srt-px: 14px;
  --srt-py: 5px;
  --srt-speed: 28s;
  --srt-z: 999999;
}

/* ============================================================
   NEWS TICKER
   ============================================================ */
.srt-ticker {
  width: 100%;
  background: var(--srt-bg);
  color: var(--srt-text);
  overflow: hidden;
  z-index: var(--srt-z);
  position: relative;
  /* Fixed compact height — no extra space above/below */
  height: var(--srt-ticker-height, 36px);
  display: flex;
  align-items: center;
}

.srt-ticker.srt-sticky {
  position: fixed;
  /* --srt-header-offset: set by JS header detection
     --srt-top-offset: set by admin "Top offset" setting (default 0px) */
  top: calc(var(--srt-header-offset, 0px) + var(--srt-top-offset, 0px));
  left: 0;
  right: 0;
  width: 100%;
  z-index: var(--srt-z);
}

.srt-ticker-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--srt-px);
  position: relative;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}

/* Badge */
.srt-ticker-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--srt-accent);
  color: #0b1220;
  font-weight: 900;
  border-radius: 999px;
  padding: 3px 10px 3px 7px;
  letter-spacing: 0.5px;
  font-size: 10px;
  text-transform: uppercase;
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 1.4;
}

.srt-ticker-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #0b1220;
  opacity: 0.7;
  animation: srt-blink 1.2s ease-in-out infinite;
  display: inline-block;
  flex-shrink: 0;
}

@keyframes srt-blink {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 0.2; }
}

/* Track & Run */
.srt-ticker-track {
  overflow: hidden;
  width: 100%;
  flex: 1;
  min-width: 0;
  /* Must be flex so the run is baseline-free and truly centred */
  display: flex;
  align-items: center;
  height: 100%;
}

.srt-ticker-run {
  display: flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
  will-change: transform;
  /* Reset any inherited baseline offset */
  line-height: 1;
  vertical-align: middle;
}

/* Items */
.srt-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  font-size: var(--srt-font);
  font-weight: 600;
  padding: 0 20px 0 0;
  transition: opacity 0.15s ease;
  line-height: 1;
  vertical-align: middle;
  /* color is set inline per item for cycling */
}

.srt-ticker-item:hover {
  opacity: 0.8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.srt-ticker-sep {
  font-size: 7px;
  opacity: 0.6;
  margin-right: 1px;
  flex-shrink: 0;
}

.srt-ticker-title {
  /* inherits color from parent <a> */
}

.srt-ticker-date {
  font-size: 11px;
  opacity: 0.65;
  margin-left: 4px;
  font-weight: 400;
}

/* Fade-right edge */
.srt-ticker-fade-right {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 60px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--srt-bg));
}

/* RTL support */
body.rtl .srt-ticker-run {
  animation-direction: reverse;
}

/* Inside content area */
.entry-content .srt-ticker {
  border-radius: var(--srt-radius);
  margin: 14px 0;
  position: relative;
  left: auto;
  right: auto;
}
.entry-content .srt-ticker-fade-right {
  border-radius: 0 var(--srt-radius) var(--srt-radius) 0;
}

/* ---- TICKER ANIMATIONS ---- */
.srt-anim--marquee .srt-ticker-run {
  animation: srt-marquee var(--srt-speed) linear infinite;
}
.srt-anim--slide .srt-ticker-run {
  animation: srt-slide var(--srt-speed) ease-in-out infinite;
}
.srt-anim--fade .srt-ticker-run {
  animation: srt-fade var(--srt-speed) ease-in-out infinite;
}

@keyframes srt-marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
@keyframes srt-slide {
  0%   { transform: translateX(0); }
  50%  { transform: translateX(-25%); }
  100% { transform: translateX(-50%); }
}
@keyframes srt-fade {
  0%   { transform: translateX(0);    opacity: 1; }
  45%  {                               opacity: 1; }
  50%  {                               opacity: 0.15; }
  55%  {                               opacity: 1; }
  100% { transform: translateX(-50%); opacity: 1; }
}

/* ---- TICKER TEMPLATES ---- */
.srt-ticker--minimal {
  background: transparent;
  color: #111827;
  border-top: 1px solid rgba(17,24,39,.12);
  border-bottom: 1px solid rgba(17,24,39,.12);
}
.srt-ticker--minimal .srt-ticker-badge {
  background: #111827;
  color: #fff;
}
.srt-ticker--minimal .srt-ticker-badge-dot {
  background: #fff;
}
.srt-ticker--minimal .srt-ticker-fade-right {
  background: linear-gradient(to right, transparent, #fff);
}

.srt-ticker--glass {
  background: rgba(17,24,39,.65);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
}

.srt-ticker--bold {
  background: var(--srt-accent);
  color: #0b1220;
}
.srt-ticker--bold .srt-ticker-badge {
  background: #0b1220;
  color: #fff;
}
.srt-ticker--bold .srt-ticker-badge-dot {
  background: #fff;
}
.srt-ticker--bold .srt-ticker-fade-right {
  background: linear-gradient(to right, transparent, var(--srt-accent));
}

/* ============================================================
   READING TIME
   ============================================================ */
.srt-readtime {
  margin: 12px 0;
  font-size: var(--srt-font);
  /* Block so it sits in the normal content flow, not floating sidebar */
  display: block;
  color: #374151;
  /* Clear any floats the theme might have applied */
  clear: both;
  float: none !important;
}

/* Inner wrapper centres the icon + text horizontally */
.srt-readtime-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.srt-readtime-icon {
  display: inline-flex;
  align-items: center;
  color: var(--srt-accent);
  flex-shrink: 0;
}

.srt-readtime--badge .srt-readtime-inner {
  background: color-mix(in srgb, var(--srt-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--srt-accent) 30%, transparent);
  padding: 8px 14px;
  border-radius: 10px;
}

.srt-readtime--pill .srt-readtime-inner {
  background: rgba(17,24,39,.05);
  border: 1px solid rgba(17,24,39,.1);
  padding: 7px 14px;
  border-radius: 999px;
}

.srt-readtime--inline .srt-readtime-inner {
  background: transparent;
  border: 0;
  padding: 0;
}

/* ============================================================
   VOICE PLAYER
   ============================================================ */
.srt-voice {
  margin: 14px 0;
}

.srt-player {
  border: 1px solid rgba(17,24,39,.1);
  border-radius: var(--srt-radius);
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

.srt-player-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.srt-player-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--srt-bg);
  color: var(--srt-text);
  flex-shrink: 0;
}

.srt-player-title {
  font-weight: 700;
  font-size: var(--srt-font);
  color: #111827;
  flex: 1;
}

.srt-voice-status {
  font-size: 12px;
  color: #6b7280;
  font-weight: 500;
}

/* Progress bar */
.srt-progress {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(17,24,39,.08);
  overflow: hidden;
  margin-bottom: 12px;
}

.srt-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--srt-progress, var(--srt-accent));
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Controls */
.srt-player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.srt-ctrl-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(17,24,39,.15);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  color: #374151;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}

.srt-ctrl-btn:hover {
  background: rgba(17,24,39,.05);
  border-color: rgba(17,24,39,.25);
}

.srt-ctrl-play {
  background: var(--srt-bg);
  color: var(--srt-text);
  border-color: transparent;
}

.srt-ctrl-play:hover {
  opacity: 0.88;
}

.srt-ctrl-icon {
  padding: 7px 10px;
}

.srt-ctrl-stop {
  color: #ef4444;
  border-color: rgba(239,68,68,.25);
}

.srt-ctrl-stop:hover {
  background: rgba(239,68,68,.06);
  border-color: rgba(239,68,68,.4);
}

/* ---- VOICE PLAYER TEMPLATES ---- */
.srt-player--minimal {
  border: 0;
  background: transparent;
  padding: 0;
  box-shadow: none;
}

.srt-player--minimal .srt-progress {
  display: none;
}

.srt-player--glass {
  background: rgba(17,24,39,.06);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border: 1px solid rgba(17,24,39,.1);
}

/* ============================================================
   TICKER DECORATIVE END BLOCK
   ============================================================ */
.srt-ticker-endblock {
  pointer-events: none;
  z-index: 2;
  flex-shrink: 0;
}

/* Subtle shimmer line along the bottom of the ticker */
.srt-ticker::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    to right,
    transparent 0%,
    var(--srt-accent) 30%,
    var(--srt-accent) 70%,
    transparent 100%
  );
  opacity: 0.5;
  pointer-events: none;
}

/* Subtle shimmer line along the top */
.srt-ticker::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(255,255,255,0.15) 30%,
    rgba(255,255,255,0.15) 70%,
    transparent 100%
  );
  pointer-events: none;
}

/* ============================================================
   LIVE CLOCK — seconds in accent color
   ============================================================ */
.srt-clock-hm {
  color: inherit;
  font-weight: 700;
}

.srt-clock-sep {
  opacity: 0.5;
  font-weight: 400;
  margin: 0 1px;
}

.srt-clock-sec {
  color: var(--srt-accent);
  font-weight: 900;
  font-size: 0.95em;
  opacity: 0.95;
}

/* Clock colon blink */
@keyframes srtClockBlink {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.1; }
}
.srt-clock-sep {
  animation: srtClockBlink 1s step-end infinite;
}
/* ============================================================
   ARTICLE VIEW COUNTER  (module — only loaded when enabled)
   ============================================================ */
.srt-viewcount {
  margin: 12px 0;
  font-size: var(--srt-font);
  display: block;
  color: #374151;
  clear: both;
  float: none !important;
}

.srt-viewcount-inner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.srt-viewcount-icon {
  display: inline-flex;
  align-items: center;
  color: var(--srt-accent);
  flex-shrink: 0;
}

.srt-viewcount--badge .srt-viewcount-inner {
  background: color-mix(in srgb, var(--srt-accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--srt-accent) 30%, transparent);
  padding: 8px 14px;
  border-radius: 10px;
}

.srt-viewcount--pill .srt-viewcount-inner {
  background: rgba(17,24,39,.05);
  border: 1px solid rgba(17,24,39,.1);
  padding: 7px 14px;
  border-radius: 999px;
}

.srt-viewcount--inline .srt-viewcount-inner {
  background: transparent;
  border: 0;
  padding: 0;
}

/* ============================================================
   TRENDING CONTENT ENGINE  (module — only loaded when enabled)
   ============================================================ */
.srt-trending {
  font-size: var(--srt-font, 13px);
  color: #374151;
}

.srt-trending-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 1.05em;
  margin-bottom: 10px;
  color: #111827;
}

.srt-trending-fire {
  display: inline-flex;
  color: var(--srt-accent);
}

.srt-trending-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.srt-trending-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(17,24,39,.07);
}

.srt-trending-item:last-child {
  border-bottom: 0;
}

.srt-trending-rank {
  font-weight: 900;
  font-size: 0.85em;
  min-width: 18px;
  color: var(--srt-accent);
  flex-shrink: 0;
  line-height: 1;
}

.srt-trending-link {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  text-decoration: none;
  color: #111827;
  line-height: 1.4;
  transition: color 0.12s ease;
  overflow-wrap: break-word;
}

.srt-trending-link:hover {
  color: var(--srt-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.srt-trending-vc {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Compact variant — tighter spacing */
.srt-trending--compact .srt-trending-item {
  padding: 5px 0;
}

.srt-trending--compact .srt-trending-link {
  font-size: 0.95em;
}

/* Widget wrapper inherits theme widget styles */
.srt-trending-widget .srt-trending {
  margin: 0;
}

/* ============================================================
   BADGE NEW TEMPLATES — card, strip, outline
   (applies to both .srt-readtime and .srt-viewcount)
   ============================================================ */

/* ── Card template ── */
.srt-readtime--card .srt-readtime-inner,
.srt-viewcount--card .srt-viewcount-inner {
  background: #fff;
  border: 1px solid rgba(17,24,39,.1);
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  gap: 12px;
}
.srt-readtime--card .srt-readtime-icon,
.srt-viewcount--card .srt-viewcount-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--srt-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.srt-readtime--card .srt-readtime-text,
.srt-viewcount--card .srt-viewcount-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: var(--srt-badge-font, 12px);
}
.srt-readtime--card .srt-readtime-text strong,
.srt-viewcount--card .srt-viewcount-text strong {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #9ca3af;
}

/* ── Strip template ── */
.srt-readtime--strip .srt-readtime-inner,
.srt-viewcount--strip .srt-viewcount-inner {
  background: linear-gradient(90deg, var(--srt-accent) 0%, color-mix(in srgb, var(--srt-accent) 70%, #000) 100%);
  padding: var(--srt-badge-py, 8px) var(--srt-badge-px, 16px);
  border-radius: 8px;
  color: #fff;
  border: none;
  font-weight: 700;
  letter-spacing: .3px;
  gap: 8px;
}
.srt-readtime--strip .srt-readtime-icon,
.srt-viewcount--strip .srt-viewcount-icon { color: #fff; }
.srt-readtime--strip .srt-readtime-text strong,
.srt-viewcount--strip .srt-viewcount-text strong { color: rgba(255,255,255,.75); }

/* ── Outline template ── */
.srt-readtime--outline .srt-readtime-inner,
.srt-viewcount--outline .srt-viewcount-inner {
  background: transparent;
  border: 2px solid var(--srt-accent);
  padding: var(--srt-badge-py, 6px) var(--srt-badge-px, 14px);
  border-radius: 8px;
  color: var(--srt-accent);
  font-weight: 700;
}
.srt-readtime--outline .srt-readtime-icon,
.srt-viewcount--outline .srt-viewcount-icon { color: var(--srt-accent); }

/* ── Badge size CSS variables (injected inline from PHP settings) ── */
:root {
  --srt-badge-font: 12px;
  --srt-badge-py:   6px;
  --srt-badge-px:   12px;
  --srt-badge-icon: 13px;
}
.srt-readtime-inner,
.srt-viewcount-inner {
  font-size: var(--srt-badge-font);
  padding: var(--srt-badge-py) var(--srt-badge-px);
}
.srt-readtime-icon svg,
.srt-viewcount-icon svg {
  width:  var(--srt-badge-icon);
  height: var(--srt-badge-icon);
}

/* Template picker in admin — visual radio buttons */
.srt-tpl-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.srt-tpl-opt {
  cursor: pointer;
  border: 2px solid rgba(17,24,39,.1);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  transition: border-color .15s;
  background: #fff;
  max-width: 260px;
}
.srt-tpl-opt input[type="radio"] { display: none; }
.srt-tpl-opt.is-active { border-color: #22c55e; background: rgba(34,197,94,.04); }
.srt-tpl-opt:hover { border-color: rgba(34,197,94,.5); }
.srt-tpl-label {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* ============================================================
   VOICE READER — INLINE READING HIGHLIGHT
   Sentence highlight + word highlight while reading
   ============================================================ */

/* ── Sentence/paragraph currently being read ── */
.srt-reading-now {
  background: rgba(34, 197, 94, 0.08) !important;
  outline: 2px solid rgba(34, 197, 94, 0.30) !important;
  outline-offset: 3px !important;
  border-radius: 4px !important;
  transition: background 0.3s ease, outline 0.3s ease !important;
  scroll-margin-top: 120px; /* ensures auto-scroll doesn't hide it under fixed headers */
}

/* Heading currently being read — slightly stronger highlight */
h1.srt-reading-now,
h2.srt-reading-now,
h3.srt-reading-now,
h4.srt-reading-now,
h5.srt-reading-now,
h6.srt-reading-now {
  background: rgba(34, 197, 94, 0.12) !important;
  outline-color: rgba(34, 197, 94, 0.45) !important;
}

/* ── Individual word currently being spoken ── */
.srt-word {
  display: inline;
  border-radius: 2px;
  transition: background 0.1s ease, color 0.1s ease;
}

.srt-word-active {
  background: rgba(34, 197, 94, 0.35) !important;
  color: inherit !important;
  border-radius: 3px !important;
  padding: 0 1px !important;
}

/* ── Reduce motion: respect user preference ── */
@media (prefers-reduced-motion: reduce) {
  .srt-reading-now,
  .srt-word,
  .srt-word-active {
    transition: none !important;
  }
}
