/* stream.css: page-scoped rules for stream.html. Live indicator, chronology strip,
   facet rail and sheet, ledger expansion and density, states, responsive rules. Colour is read only
   through roles and --c (set by data attributes or identity tokens); no hue is named. */

/* ---- header ---- */
.stream__head { padding-bottom: var(--s5); }
.stream__status { margin-top: var(--s3); }
.stream__status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s5); font: 400 var(--fs-meta)/var(--lh-meta) var(--mono); color: var(--fg-muted); }
.stream__sources { margin: 0; }

/* ---- live indicator: label in --c-text, sits on --bg only ---- */
.live { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.live__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); border: 1px solid var(--mark-outline); flex: none; }
.live__label { color: var(--c-text); }
.live--fresh { --c: var(--c-good); }
.live--stale { --c: var(--c-mixed); --c-text-mix: 50%; }
.live--stalled { --c: var(--c-bad); }
.live--none .live__dot { background: var(--rule-strong); border-color: transparent; }
.live--none .live__label { color: var(--fg-muted); }

/* ---- layout: sticky rail, gutter, ledger ---- */
.stream__layout { display: grid; grid-template-columns: 260px minmax(0, 800px); column-gap: var(--gutter); align-items: start; border-top: var(--hairline); padding-top: var(--s5); }
.stream__main { min-width: 0; }
.stream__bar { display: none; }
.stream__results { font: 400 var(--fs-meta)/var(--lh-meta) var(--mono); color: var(--fg-muted); margin: 0 0 var(--s2); min-height: var(--lh-meta); }
.stream__sentinel { height: 1px; }

/* ---- facets rail ---- */
.facets { position: sticky; top: 56px; max-height: calc(100vh - 56px); overflow: auto; overscroll-behavior: contain; padding: 2px 6px var(--s6) 2px; scrollbar-width: thin; }
/* the empty state fades the filter controls */
.facets[aria-disabled="true"] .facet, .facets[aria-disabled="true"] .facets__bar { opacity: .55; pointer-events: none; }
.facets__bar { display: none; }
.facet { border: 0; margin: 0; padding: 0 0 var(--s4); min-width: 0; }
.facet + .facet { border-top: var(--hairline); padding-top: var(--s3); }
.facet__legend { display: block; padding: 0; margin: 0 0 var(--s2); color: var(--fg-muted); }
legend.facet__legend { float: left; width: 100%; }
.facet__options { display: flex; flex-wrap: wrap; gap: 6px; clear: both; }
.facet__options .chip { max-width: 100%; }
.facet__options .chip__text { overflow: hidden; text-overflow: ellipsis; }
.facet__select { width: 100%; appearance: none; -webkit-appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; text-overflow: ellipsis; }
.facet__search { position: relative; }
.facet__search .icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--fg-muted); pointer-events: none; }
.facet__search .input { width: 100%; padding-left: 31px; padding-right: 30px; text-overflow: ellipsis; }
.facet__search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font: 400 var(--fs-mono-xs)/16px var(--mono); color: var(--fg-muted); border: 1px solid var(--rule-strong); border-radius: var(--r-chip); padding: 0 5px; pointer-events: none; }
.facet--range .facet__row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); clear: both; }
.facet--range label { display: grid; gap: 4px; font: 400 var(--fs-meta)/var(--lh-meta) var(--sans); color: var(--fg-muted); min-width: 0; }
.facet--range .input { width: 100%; min-width: 0; padding: 5px 8px; font-family: var(--mono); font-size: var(--fs-meta); }
.facet__radios { display: inline-flex; border: 1px solid var(--control-border); border-radius: var(--r-chip); overflow: hidden; clear: both; }
.facet__radio { position: relative; display: inline-flex; }
.facet__radio + .facet__radio { border-left: 1px solid var(--control-border); }
.facet__radio input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.facet__radio span { display: inline-block; padding: 4px 10px; font: 500 var(--fs-meta)/var(--lh-meta) var(--sans); color: var(--fg); transition: background var(--t-hover); white-space: nowrap; }
.facet__radio:hover span { background: var(--bg-panel); }
.facet__radio input:checked + span { background: var(--fg); color: var(--bg); }
.facet__radio input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.facet__radio input:checked:focus-visible + span { outline-color: var(--bg); }

/* ---- active filters above the ledger ---- */
.facets__active { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 var(--s3); }
.facets__active:empty { display: none; }
.facets__active-item { display: inline-flex; }
.facets__active .chip__prefix { color: var(--fg-muted); font-weight: 400; margin-right: -2px; }
.facets__clear { margin-left: var(--s1); }

/* ---- facets toggle and sheet (below 1024) ---- */
.facets__toggle { display: none; }
.facets__scrim { position: fixed; inset: 0; background: var(--scrim); z-index: calc(var(--z-sheet) - 1); }

/* ---- chronology strip ---- */
.chronology { margin: 0 0 var(--s4); position: relative; }
.chronology svg { display: block; width: 100%; height: 72px; overflow: visible; }
.chronology__col { cursor: pointer; outline-offset: 1px; }
.chronology__hit { fill: transparent; transition: fill var(--t-hover); }
.chronology__col:hover .chronology__hit, .chronology__col:focus-visible .chronology__hit { fill: var(--bg-panel); }
.chronology__bar { fill: var(--c); stroke: var(--bg); stroke-width: 1; }   /* a 1 px --bg seam between stacked polarity segments */
.chronology__tick { fill: var(--rule-strong); }
.chronology__base { stroke: var(--rule); stroke-width: 1; }
.chronology__current { fill: var(--fg); display: none; }
.chronology__col.is-current .chronology__current { display: block; }
.chronology__label { font: 400 var(--fs-mono-xs)/1 var(--mono); fill: var(--fg-muted); }
.chronology__year { font: 500 var(--fs-caps)/1 var(--sans); letter-spacing: var(--ls-caps); text-transform: uppercase; fill: var(--fg-muted); }
/* the month select is the one keyboard stop of the strip: visible on phones, visually hidden until focused above 767 */
.chronology__jump { display: block; width: 100%; }
@media (min-width: 768px) {
  .chronology__jump:not(:focus) { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .chronology__jump:focus { position: static; max-width: 280px; margin-top: var(--s2); }
}
.chronology--bare svg { height: 24px; }

/* ---- ledger: sticky month heads, expansion, density ---- */
.ledger { border-top: var(--hairline); }
.ledger .ledger__month { position: sticky; top: 56px; z-index: var(--z-rail); background: var(--bg); font: 400 var(--fs-h3)/var(--lh-h3) var(--serif); font-style: normal; padding: var(--s3) 0 var(--s2); border-bottom: var(--hairline); margin-top: var(--s2); }
.ledger .ledger__month:first-child { margin-top: 0; }
.ledger .ledger__month .num { font-size: var(--fs-meta); }
.ledger__row { scroll-margin-top: 112px; transition: background var(--t-hover); }
.ledger__row.is-expanded { background: var(--bg-panel); box-shadow: 0 0 0 var(--s3) var(--bg-panel); }
.ledger__row.is-expanded .ledger__title { -webkit-line-clamp: unset; }
.ledger__title a:focus-visible { outline-offset: 3px; }
.ledger__title .icon--ext { color: var(--fg-muted); }
.ledger__class .chip--sub { max-width: 100%; }
.ledger__class .chip--sub .chip__text { overflow: hidden; text-overflow: ellipsis; }
.ledger__more { color: var(--fg-muted); border-color: transparent; }
.ledger__more:hover, .ledger__row.is-expanded .ledger__more { color: var(--fg); border-color: var(--rule-strong); }
/* field 6, visible on expand only */
.ledger__extra { display: grid; gap: var(--s2); margin-top: var(--s3); padding-top: var(--s3); border-top: var(--hairline); font: 400 var(--fs-meta)/var(--lh-meta) var(--sans); color: var(--fg-muted); }
.ledger__extra p { margin: 0; }
.ledger__extra a:not(.chip):not(.btn) { color: var(--fg); }
.ledger__related { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ledger__related .ledger__paper { max-width: 100%; }
.ledger__related .ledger__paper .chip__text { overflow: hidden; text-overflow: ellipsis; }
.ledger__related .ledger__paper .mono { font-size: var(--fs-mono-s); }
.ledger__extra-label { color: var(--fg-muted); margin-right: 2px; }
.ledger__verified { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--fg); }
.ledger__verified .icon { color: var(--c-text); width: 16px; height: 16px; }
.ledger__pending { color: var(--fg); border: 1px solid var(--rule-strong); border-radius: var(--r-chip); padding: 0 6px; }
.ledger__note { max-width: var(--measure); }
.ledger__note summary { cursor: pointer; list-style: none; display: inline; }
.ledger__note summary::-webkit-details-marker { display: none; }
.ledger__note summary .ledger__note-more { color: var(--fg); text-decoration: underline 1px var(--link-underline); text-underline-offset: 3px; margin-left: 4px; white-space: nowrap; }
.ledger__note[open] summary .ledger__note-more { display: none; }
.ledger__note[open] summary .ledger__note-first { display: none; }
.ledger__note > p { margin-top: 2px; }
.ledger__tags { font: 400 var(--fs-mono-s)/18px var(--mono); }
.ledger__actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s1); }
.ledger__actions .btn .icon { width: 14px; height: 14px; }
/* deep-link flash: the dash blinks once */
.ledger__row.is-flash .ledger__dash { animation: ledger-flash 900ms var(--ease) 1; }
@keyframes ledger-flash { 0%, 100% { box-shadow: none; } 35% { box-shadow: 0 0 0 4px var(--c-tint), 0 0 0 6px var(--c); } }
/* compact density: date, dash and kind, one-line title; about 40 px */
.ledger--compact .ledger__row:not(.is-expanded) { padding: var(--s2) 0; contain-intrinsic-size: 0 40px; align-items: center; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__date { padding-top: 3px; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__date .new { display: inline-block; margin: 0 0 0 6px; vertical-align: 1px; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__body { display: grid; grid-template-columns: 136px minmax(0, 1fr); column-gap: var(--s3); align-items: center; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__kind { margin: 0; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__title { font-size: 17px; line-height: 22px; -webkit-line-clamp: 1; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__summary, .ledger--compact .ledger__row:not(.is-expanded) .ledger__class { display: none; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__more { width: 28px; height: 28px; position: relative; }
.ledger--compact .ledger__row:not(.is-expanded) .ledger__more::before { content: ""; position: absolute; inset: -8px; }

/* ---- states ---- */
.stream__skeleton .skeleton__row { height: 108px; }
.stream__skeleton .skeleton__row + .skeleton__row { margin-top: var(--s3); }
#state .empty, #state .error { border-top: var(--hairline); }
#state .empty__actions .btn .icon, #state .error__retry .btn .icon { width: 16px; height: 16px; }

/* ---- responsive ---- */
@media (max-width: 1439px) {
  .stream__layout { grid-template-columns: 240px minmax(0, 1fr); }
}
@media (max-width: 1023px) {
  .stream__layout { grid-template-columns: minmax(0, 1fr); padding-top: var(--s4); }
  .stream__bar { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
  .facets__toggle { display: inline-flex; min-height: 44px; }
  .facets__toggle .icon { width: 16px; height: 16px; }
  .facet__search kbd { display: none; }
  /* the rail becomes a bottom sheet */
  .facets { position: fixed; top: auto; left: 0; right: 0; bottom: 0; max-height: 86dvh; z-index: var(--z-sheet); background: var(--bg); border-top: var(--hairline-strong); box-shadow: var(--shadow-float); padding: 0 var(--margin) var(--s6); transform: translateY(100%); visibility: hidden; transition: transform var(--t-drawer) var(--ease), visibility 0s linear var(--t-drawer); }
  .facets.is-open { transform: none; visibility: visible; transition: transform var(--t-drawer) var(--ease); }
  .facets__bar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1; background: var(--bg); padding: var(--s3) 0; margin-bottom: var(--s3); border-bottom: var(--hairline); color: var(--fg-muted); }
  .facets__bar .caps { color: var(--fg); }
  .facets .chip { min-height: 36px; padding-inline: 12px; }
  .facet__radio span { padding: 8px 14px; }
  .facets .input { padding-top: 9px; padding-bottom: 9px; }
  body.stream--sheet-open { overflow: hidden; }
  .chronology svg { height: 56px; }
  .ledger .ledger__month { font-size: 20px; line-height: 26px; }
}
@media (max-width: 767px) {
  .chronology svg { display: none; }
  .chronology__jump { display: block; }
  .ledger__row { scroll-margin-top: 104px; }
  .ledger--compact .ledger__row:not(.is-expanded) .ledger__body { grid-template-columns: minmax(0, 1fr); row-gap: 2px; }
  .ledger__row.is-expanded { box-shadow: 0 0 0 var(--s2) var(--bg-panel); }
  .ledger__row:not(.is-expanded) .ledger__class :is([data-kind="op"], [data-kind="req"]) { display: none; }
  .facet--range .facet__row { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .ledger__row.is-flash .ledger__dash { animation: none; }
  .facets { transition: none; }
}
@media print {
  .facets, .facets__toggle, .chronology, .ledger__more { display: none !important; }
  .stream__layout { display: block; }
}
/* verification note: first sentence collapsed, the full note behind "Show full note" (added with the review fixes) */
.ledger__note-less { display: none; color: var(--fg); text-decoration: underline 1px var(--link-underline); text-underline-offset: 3px; }
.ledger__note[open] .ledger__note-less { display: inline; }
