/* ============================================================
   CRVENA PILULA — WIRE STUB (apex /vesti/ konzola, drop-in)
   Treća kolona desno uz urednički feed. Sirov RSS sloj —
   originali iz pratećih izvora, bez prevoda i bez sažetka.

   Učitava se POSLE vesti.css (oslanja se na njegove konzola tokene).
   Aktivira se klasom `with-wire` na body.page-vesti .shell.

   SCOPE: desktop. 3. kolona se dodaje SAMO na min-width:921px —
   ispod toga se override NE primenjuje (da ne dira live mobile
   pravila konzole), a stub se sakrije.
   ============================================================ */

:root { --wire-stub-w: 248px; }   /* poklapa se sa --rail-w */

/* GRID OVERRIDE — samo desktop. Specifičnost body.page-vesti .shell.with-wire
   (0,3,1) > live body.page-vesti .shell (0,2,1). Nasleđuje position/rows. */
@media (min-width: 921px) {
  body.page-vesti .shell.with-wire {
    /* treća kolona = ista širina kao levi rail na SVAKOM breakpoint-u
       (rail raste na FHD+/QHD/4K; var(--rail-w) prati to) */
    grid-template-columns: var(--rail-w) 1fr var(--rail-w);
    grid-template-areas:
      "hdr  hdr  hdr"
      "rail feed stub"
      "ftr  ftr  ftr";
  }
}

.wire-stub {
  grid-area: stub;
  background: var(--bg-rail);
  border-left: 1px solid var(--line);
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ---- HEADER ---- */
.wire-stub-head {
  flex-shrink: 0;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 9px;
}
.wire-stub-h {
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.22em; text-transform: uppercase; color: var(--u-brand-bright);
  display: flex; align-items: center; gap: 7px;
}
.wire-stub-h::before { content: "//"; color: var(--t-mute); }

/* Eyebrow red sa "osveži" dugmetom desno */
.wire-stub-htop { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wire-refresh {
  border: 0; background: transparent; cursor: pointer; padding: 2px 5px; margin: -2px -5px;
  color: var(--t-mute); font-family: var(--font-mono); font-size: 13px; line-height: 1;
  border-radius: 4px; transition: color 0.14s, background 0.14s;
}
.wire-refresh:hover { color: var(--u-brand-bright); background: rgba(255,255,255,0.05); }
html[data-theme="light"] .wire-refresh:hover { background: rgba(0,0,0,0.05); }
.wire-refresh.is-spinning { animation: wire-spin 0.6s ease; }
@keyframes wire-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wire-refresh.is-spinning { animation: none; } }

/* ---- Brojači (klikabilni → arhiva) ---- */
.wire-stub-counts {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line-dashed);
}
.wire-count {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
  padding: 4px 6px; margin: -4px -6px; border: 0; border-radius: 4px;
  background: transparent; cursor: pointer; text-align: left;
  transition: background 0.14s;
}
.wire-count:hover { background: rgba(255,255,255,0.04); }
html[data-theme="light"] .wire-count:hover { background: rgba(0,0,0,0.045); }
/* Aktivni brojač: bez pozadinske kutije — samo broj i labela u brend-crvenoj. */
.wire-count.is-active .num { color: var(--u-brand-bright); }
.wire-count.is-active .lbl { color: var(--u-brand-bright); }
.wire-stub-counts .lbl {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--t-mute);
}
.wire-stub-counts .num {
  font-family: var(--font-mono); font-size: 16px; font-weight: 500;
  color: var(--t-hi); font-feature-settings: 'tnum' 1, 'zero' 1; transition: color 0.14s;
}

/* ---- Pretraga (sopstveno polje) ---- */
.wire-search {
  display: flex; align-items: center; gap: 7px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--bg);
  transition: border-color 0.16s;
}
.wire-search:focus-within { border-color: var(--line-strong); }
.wire-search-p { color: var(--t-mute); font-size: 12px; line-height: 1; }
.wire-search-in {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  color: var(--t-hi); font-family: var(--font-sans); font-size: 12.5px; letter-spacing: -0.005em;
}
.wire-search-in::placeholder { color: var(--t-mute); }

/* ---- Telo (scroll) ---- */
.wire-stub-body {
  flex: 1; overflow-y: auto; padding: 4px 0 14px; position: relative;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.wire-stub-body::-webkit-scrollbar { width: 8px; }
.wire-stub-body::-webkit-scrollbar-track { background: transparent; }
.wire-stub-body::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 4px; border: 2px solid var(--bg-rail);
}
.wire-stub-body::-webkit-scrollbar-thumb:hover { background: var(--u-brand-bright); }

/* ---- Stavka ---- */
.wire-row {
  display: block; padding: 18px 22px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; transition: background 0.16s;
}
.wire-row:last-child { border-bottom: 0; }
.wire-row:hover { background: rgba(255,255,255,0.022); }
html[data-theme="light"] .wire-row:hover { background: rgba(0,0,0,0.025); }
.wire-row-title {
  display: block; font-size: 13.5px; line-height: 1.42; font-weight: 500;
  color: var(--t-hi); letter-spacing: -0.005em; margin: 0 0 8px; text-wrap: pretty; transition: color 0.14s;
}
.wire-row .ext {
  display: inline-block; margin-left: 4px; color: var(--t-mute); font-family: var(--font-mono);
  opacity: 0; transform: translateX(-3px); transition: opacity 0.14s, transform 0.14s, color 0.14s;
}
.wire-row:hover .ext { opacity: 1; transform: translateX(0); color: var(--u-brand-bright); }
.wire-row-meta {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 8px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--t-lo);
}
.wire-row-src { font-weight: 500; color: var(--t-md); }
.wire-row-src::before { content: "↳ "; color: var(--t-mute); }
.wire-row-ago { color: var(--t-mute); flex-shrink: 0; }
.wire-row-snip {
  margin: 0; font-family: var(--font-sans); font-size: 12.5px; line-height: 1.5; color: var(--t-lo);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-wrap: pretty;
}
.wire-row.is-new .wire-row-src::before { content: "● "; color: var(--u-brand-bright); }

/* ---- Pilula "novi signali" ---- */
.wire-newpill {
  position: sticky; top: 6px; z-index: 3; margin: 6px 14px 2px; padding: 7px 12px;
  display: none; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
  width: calc(100% - 28px); text-align: left; border: 1px solid var(--line-strong);
  border-radius: 4px; background: var(--bg-rail); font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.02em; color: var(--t-md); transition: background 0.16s, border-color 0.16s;
}
.wire-newpill.is-visible { display: flex; }
.wire-newpill:hover { background: rgba(197,40,40,0.06); border-color: var(--u-brand-bright); }
.wire-newpill b { color: var(--t-hi); font-weight: 600; }
.wire-newpill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--u-brand-bright); flex-shrink: 0; animation: wire-pulse 2.4s infinite; }
.wire-newpill .arr { margin-left: auto; color: var(--t-mute); }
@keyframes wire-pulse { 0%{box-shadow:0 0 0 0 rgba(197,40,40,0.45)} 70%{box-shadow:0 0 0 6px rgba(197,40,40,0)} 100%{box-shadow:0 0 0 0 rgba(197,40,40,0)} }
@media (prefers-reduced-motion: reduce) { .wire-newpill .dot { animation: none; } }

/* ---- Arhiva: traka "← uživo" ---- */
.wire-archive-head {
  position: sticky; top: 0; z-index: 3; display: flex; align-items: center;
  justify-content: space-between; gap: 10px; padding: 12px 22px;
  background: var(--bg-rail); border-bottom: 1px solid var(--line);
}
.wire-back {
  border: 0; background: transparent; cursor: pointer; padding: 0;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--t-md); transition: color 0.14s;
}
.wire-back:hover { color: var(--u-brand-bright); }
.wire-archive-meta {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.04em; color: var(--t-mute);
  text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wire-archive-meta b { color: var(--t-md); font-weight: 600; }

/* "Učitaj još" (paging u arhivi) */
.wire-more {
  display: block; width: calc(100% - 28px); margin: 10px 14px 8px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 4px; background: transparent; cursor: pointer;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; color: var(--t-md);
  transition: background 0.14s, border-color 0.14s, color 0.14s;
}
.wire-more:hover { background: rgba(255,255,255,0.04); border-color: var(--line-strong); color: var(--t-hi); }
html[data-theme="light"] .wire-more:hover { background: rgba(0,0,0,0.04); }
.wire-more[disabled] { opacity: 0.55; cursor: default; }

/* ---- Prazno / greška / učitavanje ---- */
.wire-state { padding: 22px; font-family: var(--font-sans); font-size: 12.5px; line-height: 1.5; color: var(--t-mute); text-wrap: pretty; }
.wire-state .mono { display: block; margin-bottom: 6px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--t-lo); }

/* ---- Glavni feed scrollbar — malo tamniji thumb (zahtev) + FF standardni props.
   Override živog vesti.css (učitava se posle). Dark: var(--line) (#232320, korak
   tamnije od line-strong); light ostaje na line-strong da se ne ispere. ---- */
body.page-vesti .feed-body {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
body.page-vesti .feed-body::-webkit-scrollbar-thumb { background: var(--line); }
body.page-vesti[data-theme="light"] .feed-body { scrollbar-color: var(--line-strong) transparent; }
body.page-vesti[data-theme="light"] .feed-body::-webkit-scrollbar-thumb { background: var(--line-strong); }

/* ---- Responsive guard: ispod 921px WIRE se gasi, override se NE primenjuje ---- */
@media (max-width: 920px) {
  body.page-vesti .wire-stub { display: none; }
}

/* ============================================================
   Mobilni prekidač izvora (<=767px): urednicki sazeci (.feed) <-> sirov RSS
   feed (.wire-stub). Desktop (>=921px) prikazuje obe kolone; tablet (768-920)
   ostaje urednicki. Reuse postojeci .wire-stub + wire.js (vec mount-ovan).
   Drzano <=767 jer je tu .shell display:block (prirodni flow) — grid se ne dira.
   ============================================================ */
.vfeed-tabs { display: none; }

@media (max-width: 767px) {
  :root { --vfeed-h: 36px; }

  /* Prekidac — sticky dvotab tacno ispod sticky hedera (.hdr top:0). */
  .vfeed-tabs {
    display: flex;
    position: sticky;
    top: var(--hdr-h);
    z-index: 8;                /* iznad rail-a (z6), ispod hedera (z90) */
    height: var(--vfeed-h);
    background: var(--bg);
    border-bottom: 1px solid var(--line-strong);
  }
  .vfeed-tab {
    flex: 1 1 50%;
    display: flex; align-items: center; justify-content: center;
    appearance: none; -webkit-appearance: none;
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;       /* preklopi donji border kontejnera */
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--t-mute);
    cursor: pointer;
  }
  .vfeed-tab + .vfeed-tab { border-left: 1px solid var(--line); }
  .vfeed-tab.on { color: var(--t-hi); border-bottom-color: var(--u-brand-bright); }

  /* Rail (search+cipovi) se spusta ispod prekidaca (vidljiv u urednickom modu). */
  body.page-vesti .rail { top: calc(var(--hdr-h) + var(--vfeed-h)); }

  /* Mod "RSS feed": sakrij editorial feed + rail, prikazi WIRE punom sirinom. */
  body.page-vesti[data-vfeed="wire"] .feed,
  body.page-vesti[data-vfeed="wire"] .rail { display: none; }
  body.page-vesti[data-vfeed="wire"] .wire-stub {
    display: flex;
    border-left: 0;
  }
  /* WIRE telo tece prirodno (bez ugnjezdenog scroll-a) u block shell-u. */
  body.page-vesti[data-vfeed="wire"] .wire-stub-body {
    overflow: visible;
    height: auto;
    max-height: none;
  }
}
