/* Cabinhub News — Following / watchlist surface (frontend/js/watchlist.js).
   Part of the newsroom stylesheet set; tokens.css owns every colour.

   The brief: a quiet marker on followed stories, a Following view, and a
   small watchlist panel carrying the latest story per instrument. It must
   read as part of the paper — a hairline and a small mark, never a badge
   library, never a coloured pill, never a dashboard.

   Two rules this file enforces:
     1. Colour comes only from a token. Light and dark are the same rules
        because they are the same variables (tokens.css: --paper, --ink,
        --accent, --rule, --canvas).
     2. Every control has a 44px hit box on touch (--tap) and its own focus
        ring (--focus), because the panel is dense and thumb-driven on a
        phone. */

/* ============================================================ shell ==== */

/* The shell is a sibling of the feed's own .shell, so it repeats that
   measure exactly: same page width, same gutters. Without this the switcher
   and the panel run the full width of a 1440 screen while the paper sits in
   a column, which reads as a different product. */
.wl-shell {
  max-width: var(--page);
  /* The switcher is the LAST control row of the toolbar stack, and the gap that
     follows it belongs to the feed shell's own top padding (.shell, feed.css).
     Measured 1440 before this: 30px here + 24px there = 55px of white between
     the watchlist hairline and "Latest first", reading as a missing row rather
     than breathing room. One owner for the gap: the shell. */
  margin: 0 auto;
  padding: 0 var(--pad-r) 0 var(--pad-l);
}

/* A panel row is read, not scanned: keep it inside a text measure even when
   the page is wide, and let the remove control sit at that measure's end. */
.wl-panel__body { max-width: 46rem; }

/* The panel body is a focus target, not a control: opening the panel moves
   focus into it so a screen reader starts reading the list. Base.css already
   rules that a container target draws no ring ("a ring around a full-page
   container says nothing a reader can act on"), and this body is that same
   class — measured 2026-11-11 on the keyboard path (Tab to the Watchlist
   toggle, Enter): the global ring painted a 2px accent rectangle around the
   whole opened panel. */
.wl-panel__body:focus,
.wl-panel__body:focus-visible { outline: none; }

/* The switcher row: two words and the list control, on the same baseline as
   the app's own standing head, with the same hairline under it. */
.wl-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-5);
  flex-wrap: wrap;
  /* The filters row above ends on a hairline and this row begins on it, so it
     needs NO extra top space beyond its own inner padding: the control stack
     (toolbar -> categories -> Following/Watchlist) is deliberately one
     hairline-separated column, not three floating bands. -8px = the row's
     bottom padding, so the two sides of the hairline are balanced. */
  padding: var(--sp-2) 0;
  border-bottom: 1px solid var(--rule);
}

.wl-switch { display: flex; align-items: baseline; gap: 0.15rem; margin-left: calc(var(--sp-2) * -1); }

.wl-switch__btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.35rem var(--sp-2);
  min-height: 36px;
  border-radius: var(--r-sm);
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  font-weight: 500;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.wl-switch__btn[aria-pressed="true"] { color: var(--ink); font-weight: 600; background: var(--paper-2); }
@media (hover: hover) and (pointer: fine) {
  .wl-switch__btn:hover { color: var(--ink); }
}

.wl-bar__right { display: flex; align-items: center; gap: var(--sp-3); }

/* The list control is a door, not a badge: the word, then a plain count. */
.wl-panel-toggle {
  appearance: none;
  background: none;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 0.3rem 0.7rem;
  min-height: 36px;
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
.wl-panel-toggle[aria-expanded="true"] { color: var(--ink); border-color: var(--rule-strong); background: var(--canvas); }
.wl-panel-toggle__count {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
@media (hover: hover) and (pointer: fine) {
  .wl-panel-toggle:hover { color: var(--ink); border-color: var(--rule-strong); }
}

/* ============================================================ panel ====
   A sheet that opens under the bar. It is not a modal: the paper stays
   readable behind it, and it closes on its own button. */

.wl-panel {
  margin-top: var(--sp-3);
  padding: var(--sp-4) 0 var(--sp-2);
  border-bottom: 1px solid var(--rule);
}
.wl-panel[hidden] { display: none; }

.wl-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: 0.15rem;
}
.wl-panel__title {
  font-family: var(--font-display);
  font-size: var(--fs-sub);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
.wl-panel__close {
  appearance: none;
  background: none;
  border: 0;
  padding: 0 var(--sp-2);
  min-width: 36px;
  min-height: 36px;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  border-radius: var(--r-sm);
}
.wl-panel__close:hover { color: var(--ink); background: var(--paper-2); }

.wl-panel__note {
  margin: 0 0 var(--sp-4);
  max-width: 46rem;
  font-size: var(--fs-meta);
  line-height: 1.55;
  color: var(--ink-faint);
}
.wl-panel__empty {
  margin: 0 0 var(--sp-4);
  max-width: var(--measure-tight);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-soft);
}

.wl-panel__label {
  margin: var(--sp-4) 0 var(--sp-1);
  font-family: var(--font-ui);
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-faint);
}

/* One row per followed entry: name, time + source, the latest headline. */
.wl-rows { display: grid; gap: 0; }
.wl-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 0.65rem 0;
  border-top: 1px solid var(--rule-soft);
}
.wl-row:first-child { border-top: 0; }
.wl-row__main { flex: 1 1 auto; min-width: 0; }

.wl-row__name {
  /* Measured 2026-11-11 (n3_overlay oN50): this link's line box was 23.6px —
     below the 24px WCAG 2.5.8 floor on a mouse and far below a thumb's 44.
     The row is a dense list, so the floor is taken with a box the type sits
     inside rather than with margin, which would open the row's rhythm. */
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  font-family: var(--font-ui);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0;
  border-bottom: 1px solid transparent;
}
.wl-row__name:hover { border-bottom-color: var(--rule-strong); }
.wl-row__name[aria-disabled="true"] { color: var(--ink-soft); cursor: default; }

.wl-row__meta {
  margin: 0.1rem 0 0;
  font-size: var(--fs-micro);
  color: var(--ink-faint);
  line-height: 1.5;
}
.wl-row__meta time { font-variant-numeric: tabular-nums; }
.wl-dot { padding: 0 0.3rem; }

.wl-row__story {
  /* One measure: a wrapped headline is 2 line boxes (42px at 390), a short
     one is 21 — both under a thumb's 44. Same floor, same technique as the
     row name above. */
  display: flex;
  align-items: center;
  min-height: 24px;
  margin-top: 0.2rem;
  font-family: var(--font-display);
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--ink);
  text-decoration: none;
}
.wl-row__story:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.wl-row__empty { margin: 0.2rem 0 0; font-size: var(--fs-micro); color: var(--ink-faint); }

.wl-remove {
  appearance: none;
  background: none;
  border: 0;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  font-size: 1.05rem;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.wl-remove:hover { color: var(--accent); background: var(--accent-soft); }

/* ---- add + move ---- */

.wl-add {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}
.wl-add__label { flex: 1 1 auto; min-width: 0; }
.wl-add__input,
.wl-io__code,
.wl-io__paste {
  width: 100%;
  min-height: 38px;
  background: var(--paper-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  padding: 0.35rem 0.65rem;
  appearance: none;
}
.wl-add__input::placeholder,
.wl-io__paste::placeholder { color: var(--ink-faint); opacity: 1; }
.wl-add__input:focus,
.wl-io__code:focus,
.wl-io__paste:focus {
  background: var(--canvas);
  border-color: var(--rule-strong);
  outline: none;
}
.wl-add__input:focus-visible,
.wl-io__code:focus-visible,
.wl-io__paste:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.wl-add__btn,
.wl-io__btn {
  appearance: none;
  flex: none;
  min-height: 38px;
  padding: 0 0.85rem;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  font-weight: 500;
  cursor: pointer;
}
.wl-add__btn:hover,
.wl-io__btn:hover { border-color: var(--rule-strong); }
.wl-io__btn:disabled { color: var(--ink-faint); cursor: default; }

.wl-io { margin-top: var(--sp-4); border-top: 1px solid var(--rule-soft); padding-top: var(--sp-3); }
.wl-io__summary {
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: var(--fs-meta);
  font-weight: 500;
  color: var(--ink-soft);
  min-height: 32px;
}
.wl-io__summary:hover { color: var(--ink); }
.wl-io__note { margin: var(--sp-2) 0; max-width: var(--measure-tight); font-size: var(--fs-micro); line-height: 1.55; color: var(--ink-faint); }
.wl-io__row { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.wl-io__code { font-family: var(--font-mono); font-size: var(--fs-micro); }
.wl-io__paste { resize: vertical; margin-bottom: var(--sp-2); font-family: var(--font-mono); font-size: var(--fs-micro); }

.wl-status {
  margin: var(--sp-3) 0 0;
  font-size: var(--fs-meta);
  line-height: 1.5;
  color: var(--ink-soft);
}
.wl-status--ok { color: var(--success); }
.wl-status--warn { color: var(--warning); }
.wl-status--bad { color: var(--danger); }

/* ======================================================== following ====
   The second view of the front page. It replaces nothing: the feed is still
   one switch away, so it uses the paper's own list rhythm. */

.wl-following { display: none; }
html[data-wl-view="following"] .wl-following { display: block; }
html[data-wl-view="following"] [data-root] { display: none; }

.wl-following__head { margin-bottom: var(--sp-3); }
.wl-following__title {
  font-family: var(--font-display);
  font-size: var(--fs-sub);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.2rem;
  color: var(--ink);
}
.wl-following__note { margin: 0; font-size: var(--fs-meta); color: var(--ink-faint); line-height: 1.55; max-width: var(--measure-deck); }
.wl-following__empty {
  margin: var(--sp-4) 0;
  max-width: var(--measure-deck);
  font-size: var(--fs-small);
  line-height: 1.6;
  color: var(--ink-soft);
}

.wl-following__items { list-style: none; margin: 0; padding: 0; }
.wl-following__item { border-top: 1px solid var(--rule-soft); }
.wl-following__item:first-child { border-top: 0; }
.wl-following__link {
  display: block;
  padding: 0.85rem 0 0.95rem;
  text-decoration: none;
  color: var(--ink);
}
.wl-following__meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.25rem;
  font-size: var(--fs-label);
  color: var(--ink-faint);
}
.wl-following__meta time { font-variant-numeric: tabular-nums; }
.wl-following__cat { color: var(--ink-soft); font-weight: 500; }
.wl-following__tags { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; margin-left: 0.15rem; }
.wl-tag {
  font-size: var(--fs-micro);
  color: var(--accent);
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 1px;
}
.wl-following__hed {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.006em;
  margin: 0 0 0.2rem;
}
.wl-following__deck {
  margin: 0;
  max-width: var(--measure-deck);
  font-size: var(--fs-small);
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ========================================================= markers ====
   The quiet marker. One small dot in the accent and the word, at meta size,
   in the line the card already draws. No pill, no colour block. */

.wl-flag {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  font-size: var(--fs-label);
  color: var(--accent);
  white-space: nowrap;
}
.wl-flag__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
  flex: none;
}
.wl-flag__text { letter-spacing: 0; }

/* A followed card keeps its own typography; only the marker is added. A very
   quiet inset rule on the lead reads as "this one is in your list" without a
   second colour. */
a[data-wl-hit] .card__title,
a[data-wl-hit] .article__title { text-decoration-color: var(--accent-soft); }

.wl-detail-flag { margin-top: var(--sp-2); }

/* ========================================================== follow ====
   The control on an article: a plus, then the word. It sits inline in the
   byline and beside an entity, so it is deliberately the smallest control in
   the product. */

.wl-follow {
  appearance: none;
  background: none;
  border: 0;
  padding: 0.1rem 0.25rem;
  margin: 0 0 0 -0.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  /* 2.5.8 AA is 24x24 for a control that is not a link inside a sentence.
     This one sits beside an entity value, so it owns its hit box: 24px of
     height at every pointer, the full 44px tap token on touch (below). */
  min-height: 24px;
  font-family: var(--font-ui);
  font-size: var(--fs-label);
  font-weight: 500;
  color: var(--ink-faint);
  cursor: pointer;
  border-radius: var(--r-xs);
  transition: color var(--dur-1) var(--ease), background-color var(--dur-1) var(--ease);
}
/* The glyph is the state, not decoration: "+" becomes a check on the same line when the
   follow lands, so the control answers where the reader is looking. One short settle
   makes that change legible instead of a swap that can be missed at 14px; it is pure
   transform and opacity, so it cannot move the sentence it sits in. */
.wl-follow__glyph {
  font-weight: 600;
  line-height: 1;
  display: inline-block;
  transform-origin: 50% 55%;
}
@media (prefers-reduced-motion: no-preference) {
  .wl-follow.is-on .wl-follow__glyph { animation: wl-follow-set 180ms var(--ease) both; }
  @keyframes wl-follow-set {
    from { transform: scale(0.72); opacity: 0.45; }
    to { transform: none; opacity: 1; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .wl-follow.is-on .wl-follow__glyph { animation: none; }
}
.wl-follow:hover { color: var(--ink); background: var(--paper-2); }
.wl-follow.is-on { color: var(--accent); }
.wl-follow:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
/* Forced colours drop the accent, so the glyph weight has to carry "on" by itself. */
@media (forced-colors: active) {
  .wl-follow.is-on { text-decoration: underline; }
}

.wl-gap { display: inline-block; width: 0.35rem; }

/* Entities read as a plain list; the follow control rides beside each value
   rather than turning the value into a chip. */
.entities__val { display: inline-flex; align-items: baseline; flex-wrap: wrap; }

/* Touch: every control gets a real hit box, and the dense rows get air. */
@media (pointer: coarse) {
  .wl-follow { min-height: var(--tap); padding-top: 0.55rem; padding-bottom: 0.55rem; }
  .wl-switch__btn,
  .wl-panel-toggle { min-height: var(--tap); }
  .wl-remove { width: var(--tap); height: var(--tap); }
  /* The panel's own controls, measured at 390 on 2026-11-11 (n3_overlay oN50):
     close 36px, add/copy/apply 38px, the code field 38px, the "move this list"
     summary 32px — every one a thumb target the mouse-sized CSS skipped. The
     rows above get the same floor so a followed story is one thumb-width tall
     wherever it is pressed, not only at its first line box. */
  .wl-panel__close,
  .wl-add__input,
  .wl-add__btn,
  .wl-io__summary,
  .wl-io__code,
  .wl-io__paste,
  .wl-io__btn,
  .wl-row__name,
  .wl-row__story { min-height: var(--tap); min-width: var(--tap); }
}

@media (max-width: 640px) {
  /* Switcher and Watchlist fit one 358px row at 390 (210px + 100px + gap);
     forcing the right group onto its own full-width row added a second blank
     band before the lead. It only wraps if the locale makes it too long. */
  .wl-bar { gap: var(--sp-2); flex-wrap: wrap; }
  .wl-io__row { flex-direction: column; }
  .wl-add { flex-wrap: wrap; }
  .wl-add__label { flex-basis: 100%; }
}
