/* OSINT Wire
   Colour is load-bearing here: every hue in the interface encodes provenance,
   nothing is decorative. The five bloc hues come from config.yaml and are the
   only saturated colours on the page, so a glance at the stripe column tells
   you who is talking before you read a word. */

:root {
  --ink:      #0A0E12;
  --panel:    #111921;
  --panel-2:  #16202A;
  --rule:     #1F2C38;
  --rule-hi:  #2C3E4E;
  --text:     #D9E2E9;
  --text-dim: #93A5B4;
  --muted:    #64798A;
  --flash:    #F0F6FA;

  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --cond: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --ar:   "IBM Plex Sans Arabic", "IBM Plex Sans", sans-serif;
  --he:   "IBM Plex Sans Hebrew", "IBM Plex Sans", sans-serif;

  --bar-h: 46px;
  --crawl-h: 30px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ header */

.bar {
  height: var(--bar-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 14px;
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
  position: sticky; top: 0; z-index: 30;
}

.brand { display: flex; align-items: center; gap: 9px; }

/* Four bars in the bloc hues — the legend and the logo are the same object. */
.mark {
  width: 16px; height: 18px; display: block;
  background:
    linear-gradient(#C4703A, #C4703A) 0 0/3px 100% no-repeat,
    linear-gradient(#4A82C4, #4A82C4) 4.3px 0/3px 70% no-repeat,
    linear-gradient(#4FA88A, #4FA88A) 8.6px 0/3px 45% no-repeat,
    linear-gradient(#B7A44B, #B7A44B) 13px 0/3px 85% no-repeat;
}

.wordmark {
  font-family: var(--cond);
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 15px;
}

.clock { font-family: var(--mono); font-size: 13px; color: var(--text-dim);
         font-variant-numeric: tabular-nums; }
.clock .z { color: var(--muted); font-size: 10px; margin-left: 5px;
            letter-spacing: .1em; }

.bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Same chip geometry as .conn — they read as one status cluster. */
.uptime {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; padding: 3px 8px;
  border: 1px solid var(--rule-hi); border-radius: 2px; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap; cursor: default;
}
/* Poll failed — hold the last value but make it visibly untrustworthy. */
.uptime[data-state="stale"] { opacity: .45; }
/* The process restarted while this page was open. Amber matches .conn[down]. */
.uptime[data-state="restarted"] {
  color: #E2894F; border-color: #57381F; cursor: pointer;
}

.conn {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; padding: 3px 8px;
  border: 1px solid var(--rule-hi); border-radius: 2px; color: var(--muted);
}
.conn[data-state="live"]  { color: #6FD3A5; border-color: #245140; }
.conn[data-state="live"]::before {
  content: ""; display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: #6FD3A5; margin-right: 6px; vertical-align: middle;
  animation: pulse 2.4s ease-in-out infinite;
}
.conn[data-state="down"] { color: #E2894F; border-color: #57381F; }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

.btn {
  background: transparent; border: 1px solid var(--rule-hi); border-radius: 2px;
  padding: 4px 10px; cursor: pointer; color: var(--text-dim);
  font-family: var(--cond); font-size: 12px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn[aria-pressed="true"] { background: var(--flash); color: var(--ink);
                            border-color: var(--flash); }

/* ------------------------------------------------------------------- crawl */

.crawl {
  height: var(--crawl-h); display: flex; align-items: stretch;
  border-bottom: 1px solid var(--rule); background: var(--panel-2);
  overflow: hidden; position: sticky; top: var(--bar-h); z-index: 29;
}
.crawl-label {
  flex: 0 0 auto; display: flex; align-items: center; padding: 0 11px;
  font-family: var(--cond); font-size: 11px; font-weight: 700;
  letter-spacing: .18em; background: var(--flash); color: var(--ink);
}
.crawl-window { flex: 1; overflow: hidden; position: relative; }
.crawl-track {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  will-change: transform; transform: translate3d(0,0,0);
  display: flex; align-items: center; height: 100%;
  font-size: 13px; color: var(--text-dim);
  /* No CSS animation: the offset is driven per-frame in JS so it survives
     content changes instead of restarting. */
}
/* Fade the leading edge so items enter and leave rather than popping. */
.crawl-window::after {
  content: ""; position: absolute; inset: 0 0 0 auto; width: 48px;
  background: linear-gradient(90deg, transparent, var(--panel-2));
  pointer-events: none;
}
.crawl:hover .crawl-track { opacity: .85; }
.crawl-item { padding: 0 26px; display: inline-flex; align-items: center; gap: 8px;
              flex: 0 0 auto; }
.crawl-item b { font-family: var(--cond); font-weight: 700; font-size: 11.5px;
                letter-spacing: .1em; text-transform: uppercase; }

/* -------------------------------------------------------------------- main */

main {
  display: grid; grid-template-columns: 232px 1fr;
  height: calc(100vh - var(--bar-h) - var(--crawl-h));
}

/* ------------------------------------------------------------------ roster */

.roster {
  border-right: 1px solid var(--rule); background: var(--panel);
  overflow-y: auto; padding-bottom: 24px;
}
.roster-head, .watch h2 {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 13px 13px 7px;
}
.roster h2, .watch h2 {
  margin: 0; font-family: var(--cond); font-size: 11px; font-weight: 700;
  letter-spacing: .19em; text-transform: uppercase; color: var(--muted);
}
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer;
           color: var(--muted); font-size: 11px; text-decoration: underline;
           text-underline-offset: 2px; }
.linkbtn:hover { color: var(--text); }

.bloc-group { margin-bottom: 4px; }
.bloc-title {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 13px 4px;
  font-family: var(--cond); font-size: 10.5px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim);
}
.bloc-swatch { width: 9px; height: 9px; flex: 0 0 auto; }

.src {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 5px 13px 5px 29px; background: none; border: 0; cursor: pointer;
  text-align: left; border-left: 2px solid transparent;
}
.src:hover { background: var(--panel-2); }
.src.off { opacity: .34; }
.src-name { flex: 1; font-size: 13px; color: var(--text); overflow: hidden;
            text-overflow: ellipsis; white-space: nowrap; }
.src-lang { font-family: var(--mono); font-size: 9.5px; color: var(--muted);
            text-transform: uppercase; letter-spacing: .06em; }
.src-n { font-family: var(--mono); font-size: 10.5px; color: var(--muted);
         font-variant-numeric: tabular-nums; }
.src.err .src-name { color: #E2894F; }
.src.err::after { content: "!"; font-family: var(--mono); color: #E2894F;
                  font-size: 11px; }

/* --- roster management -------------------------------------------------- */

.roster-actions { display: flex; gap: 10px; }
.linkbtn[aria-pressed="true"] { color: var(--flash); }

.src-row { display: flex; align-items: center; }
.src-row .src { flex: 1; min-width: 0; }
.src.paused .src-name { color: var(--muted); font-style: italic; }

.src-tools { display: flex; gap: 2px; padding-right: 8px; }
.tool {
  background: none; border: 0; cursor: pointer; color: var(--muted);
  font-size: 10px; line-height: 1; padding: 4px 5px; border-radius: 2px;
}
.tool:hover { background: var(--rule); color: var(--text); }
.tool.danger { font-size: 14px; }
.tool.danger:hover { background: #4A2018; color: #FF9E7A; }

.addsrc { padding: 4px 13px 14px; border-top: 1px solid var(--rule);
          margin-top: 8px; }
.add-open {
  width: 100%; background: none; border: 1px dashed var(--rule-hi);
  border-radius: 2px; padding: 7px; cursor: pointer; color: var(--text-dim);
  font-family: var(--cond); font-size: 12px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase; margin-top: 8px;
}
.add-open:hover { border-color: var(--muted); color: var(--text);
                  border-style: solid; }

.add-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.add-form label {
  display: flex; flex-direction: column; gap: 3px;
  font-family: var(--cond); font-size: 10px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.add-form input, .add-form select {
  background: var(--ink); border: 1px solid var(--rule-hi); border-radius: 2px;
  color: var(--text); padding: 5px 7px; font-size: 12.5px;
  font-family: var(--mono); text-transform: none; letter-spacing: 0;
}
.add-form input:focus, .add-form select:focus {
  outline: none; border-color: var(--muted);
}
.add-form .row { display: flex; gap: 8px; }
.add-form .row > * { flex: 1; min-width: 0; }
.btn.wide { width: 100%; text-align: center; padding: 6px; }
.btn.primary { background: var(--flash); color: var(--ink); border-color: var(--flash); }
.btn.primary:hover { background: #fff; }

.probe {
  font-size: 11.5px; line-height: 1.5; color: var(--text-dim);
  padding: 8px 9px; border-left: 2px solid var(--rule-hi); background: var(--ink);
}
.probe.ok { border-left-color: #6FD3A5; }
.probe.warn-box { border-left-color: #E2894F; }
.probe .warn { color: #E2894F; }
.probe .sample {
  margin-top: 6px; color: var(--muted); font-size: 11px;
  max-height: 48px; overflow: hidden;
}

.watch { margin-top: 14px; border-top: 1px solid var(--rule); padding-bottom: 6px; }
.watch .hint { margin: 0 13px 7px; font-size: 11px; color: var(--muted);
               line-height: 1.4; }
#watchInput {
  width: calc(100% - 26px); margin: 0 13px; background: var(--ink);
  border: 1px solid var(--rule-hi); border-radius: 2px; color: var(--text);
  padding: 6px 7px; font-family: var(--mono); font-size: 12px; resize: vertical;
}
#watchInput:focus { outline: 2px solid var(--rule-hi); outline-offset: 1px;
                    border-color: var(--muted); }
.watch-hits { padding: 8px 13px 0; display: flex; flex-wrap: wrap; gap: 5px; }
.hit-chip {
  font-family: var(--mono); font-size: 10.5px; padding: 2px 6px;
  border: 1px solid var(--rule-hi); border-radius: 2px; color: var(--text-dim);
}
.hit-chip b { color: var(--flash); }

/* -------------------------------------------------------------------- wire */

.wire { display: flex; flex-direction: column; overflow: hidden; }

.wire-head {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; border-bottom: 1px solid var(--rule); background: var(--panel);
}
#search {
  flex: 1; max-width: 400px; background: var(--ink);
  border: 1px solid var(--rule-hi); border-radius: 2px; padding: 5px 9px;
  font-size: 13px;
}
#search:focus { outline: 2px solid var(--rule-hi); outline-offset: 1px; }
.count { font-family: var(--mono); font-size: 11px; color: var(--muted);
         font-variant-numeric: tabular-nums; }

#feed { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1;
        scrollbar-gutter: stable; }

.post {
  display: grid; grid-template-columns: 4px 1fr;
  border-bottom: 1px solid var(--rule);
  transition: background .15s;
}
.post:hover { background: rgba(255,255,255,.014); }
.post.hidden { display: none; }
.stripe { background: var(--bloc); }
.post-body { padding: 14px 20px 15px 16px; min-width: 0; }

/* --- meta row ------------------------------------------------------------
   Source identity leads; everything else is secondary and right-aligned so the
   left edge stays a clean scannable column of who-is-speaking. */
.meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }

.src-tag {
  font-family: var(--cond); font-weight: 700; font-size: 13px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--bloc);
  white-space: nowrap;
}
.tier1 .src-tag::after {
  content: "OFFICIAL"; font-size: 8px; letter-spacing: .13em;
  margin-left: 7px; padding: 1px 4px; color: var(--ink); background: var(--bloc);
  vertical-align: 1.5px; font-weight: 700;
}

.pill {
  font-family: var(--mono); font-size: 9px; letter-spacing: .07em;
  border: 1px solid var(--rule-hi); padding: 1px 5px; border-radius: 2px;
  text-transform: uppercase; white-space: nowrap;
}
.pill.quiet { color: var(--muted); }
.pill.warn  { color: #E2894F; border-color: #57381F; }

.meta-right {
  margin-left: auto; display: flex; align-items: baseline; gap: 10px;
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  white-space: nowrap;
}
.meta-right .mt { letter-spacing: .04em; cursor: help;
                  border-bottom: 1px dotted var(--rule-hi); }
.stamp { font-variant-numeric: tabular-nums; cursor: help; color: var(--text-dim); }
.age { font-variant-numeric: tabular-nums; cursor: help; }
.meta-right .stamp + .age::before { content: "·"; margin-right: 9px; color: var(--rule-hi); }
.meta-right a { color: var(--muted); text-decoration: none; font-size: 12px; }
.meta-right a:hover { color: var(--text); }

/* --- body ----------------------------------------------------------------
   Measure capped near 76ch. Wire copy at 1000px+ per line is unreadable, and
   these posts are dense. */
.en {
  white-space: pre-wrap; overflow-wrap: anywhere;
  max-width: 76ch; line-height: 1.58; font-size: 15px;
}
.en .lede {
  display: block; font-weight: 600; font-size: 16px; line-height: 1.4;
  color: var(--flash); margin-bottom: 6px;
}
.en .rest { display: block; color: var(--text-dim); }
.en mark { background: rgba(240,246,250,.16); color: var(--flash);
           padding: 0 2px; border-radius: 1px; }

/* Emoji arrive at wildly different metrics from the surrounding type; pin them
   so a post opening with a red circle doesn't shove its own first line around. */
.en { font-variant-emoji: text; }

.post.clamped .en {
  max-height: 260px; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 72%, transparent 100%);
  mask-image: linear-gradient(#000 72%, transparent 100%);
}
.more {
  margin-top: 6px; background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text-dim); font-family: var(--cond); font-size: 11.5px;
  font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
}
.more:hover { color: var(--flash); }

.orig-toggle {
  margin-top: 9px; background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--muted); font-family: var(--mono); font-size: 10.5px;
}
.orig-toggle:hover { color: var(--text-dim); }
.orig {
  margin-top: 9px; padding: 10px 13px; border-left: 2px solid var(--rule-hi);
  background: var(--panel); white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 14.5px; line-height: 1.7; color: var(--text-dim); max-width: 76ch;
}
.orig[dir="rtl"] { text-align: right; }
.orig.ar, .orig.fa { font-family: var(--ar); }
.orig.he { font-family: var(--he); }

.post.new { animation: arrive .5s ease-out; }
@keyframes arrive {
  from { background: rgba(240,246,250,.07); transform: translateY(-3px); }
  to   { background: transparent; transform: none; }
}

.empty { padding: 40px 20px; color: var(--muted); font-size: 13px; text-align: center; }
.empty a { color: var(--text-dim); }
.empty.gone { display: none; }

/* ------------------------------------------------------------- responsive */

@media (max-width: 620px) {
  .bar { height: auto; padding: 7px 10px; gap: 10px; flex-wrap: wrap; }
  .clock { display: none; }
  .btn { padding: 3px 7px; font-size: 11px; letter-spacing: .05em; }
  .bar-right { gap: 6px; }
  .crawl { position: static; }
  .post-body { padding: 10px 12px 11px 11px; }
  .meta { gap: 7px; row-gap: 4px; }
  .meta a { margin-left: 0; }
}

@media (max-width: 820px) {
  main { grid-template-columns: 1fr; height: auto; }
  .bar, .crawl { position: static; }
  .roster { border-right: 0; border-bottom: 1px solid var(--rule);
            max-height: 240px; }
  #feed { overflow-y: visible; }
  .wire { overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .post.new { animation: none; }
  .conn[data-state="live"]::before { animation: none; }
  .crawl-track { transform: none !important; }
}

:focus-visible { outline: 2px solid var(--flash); outline-offset: 2px; }


/* --------------------------------------------------------------- login --
   Deliberately unlike the wire itself: centred, calm, no live chrome. You
   should never be unsure whether you're looking at the feed or a form. */

.login-page { display: block; background: var(--ink); }
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 340px; background: var(--panel);
  border: 1px solid var(--rule); border-radius: 3px; padding: 26px 24px 20px;
  display: flex; flex-direction: column; gap: 13px;
}
.login-brand {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--rule);
}
.login-card label {
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--cond); font-size: 10.5px; font-weight: 600;
  letter-spacing: .15em; text-transform: uppercase; color: var(--muted);
}
.login-card input {
  background: var(--ink); border: 1px solid var(--rule-hi); border-radius: 2px;
  color: var(--text); padding: 8px 9px; font-family: var(--mono); font-size: 13px;
  letter-spacing: 0;
}
.login-card input:focus { outline: none; border-color: var(--muted); }
.login-card .btn { margin-top: 4px; }
.login-card .err {
  margin: 0; padding: 8px 10px; font-size: 12px; color: #FF9E7A;
  background: rgba(226,137,79,.09); border-left: 2px solid #E2894F;
}
.login-note {
  margin: 4px 0 0; font-size: 11px; line-height: 1.5; color: var(--muted);
  text-align: center;
}

.bar-right .signout {
  font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  text-decoration: none; padding: 0 2px;
}
.bar-right .signout:hover { color: var(--text); }
