/* ============================================================================
   Feed card — the single card every FeedItem-backed feed renders.
   Paired with core_data/js/feed_card.js, which emits exactly this markup.

   Two rules keep this working; break either and the drift starts again:

   1. Style the CARD, never the container. No `.lawsndocs-feed article.card`.
      The appearance travels with the markup, so a card renders identically in
      its panel, inside the "Förstora" modal (which copies innerHTML into a
      shared modal body) and anywhere else it is moved. Container-scoped rules
      are exactly what broke Förstora before this file existed.

   2. Colour lives on one token, --fc-accent, set by a .fc-d-* domain class.
      Variation comes from the item's data, never from the page it sits on.

   Values come from design-tokens.css (loaded globally via
   styling_dependencies.html); the fallbacks after each var() keep the card
   intact on any page that somehow misses it.
   ========================================================================= */

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.feedcard {
  --fc-accent: var(--brand-color-accent, #0f88f2);

  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;

  background: var(--brand-color-surface, #ffffff);
  border: 1px solid var(--brand-color-border, rgba(18, 32, 51, 0.12));
  border-left: 3px solid var(--fc-accent);
  border-radius: 10px;
  padding: 0.85rem 0.95rem;

  /* Border first, shadow only on hover. --brand-shadow-soft is a 40px panel
     blur; twenty cards each casting it turns a feed into mush. */
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.feedcard:hover {
  border-color: rgba(18, 32, 51, 0.22);
  box-shadow: 0 4px 14px rgba(22, 50, 79, 0.07);
}

.feedcard:focus-within {
  border-color: var(--fc-accent);
  box-shadow: 0 0 0 3px var(--brand-color-accent-soft, rgba(15, 136, 242, 0.12));
}

/* ── Meta row: who it came from, and when ──────────────────────────────── */
.fc-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  font-size: 0.72rem;
  line-height: 1.3;
}

.fc-source {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fc-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fc-source::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--fc-accent);
}

/* Right-aligned and tabular so the column stays straight down a long list. */
.fc-time {
  margin-left: auto;
  white-space: nowrap;
  color: var(--brand-color-text-muted, #5d6c80);
  font-variant-numeric: tabular-nums;
}

/* ── Title — the link. The CARD is never an <a>. ───────────────────────── */
.fc-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--brand-color-heading, #0b1627);
}

.fc-title a {
  color: inherit;
  text-decoration: none;
}

.fc-title a:hover,
.fc-title a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Description — clamped in CSS, not truncated on the server ─────────── */
.fc-desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--brand-color-text-muted, #5d6c80);

  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Chips carry the variable data. Always neutral: if the party badge, the
      type badge and the source are all coloured, none of them is a signal. ─ */
.fc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.fc-chip {
  padding: 0.06rem 0.42rem;
  border: 1px solid var(--brand-color-border, rgba(18, 32, 51, 0.12));
  border-radius: 20px;
  background: var(--brand-color-surface-muted, #f5f8fc);
  color: var(--brand-color-text-muted, #5d6c80);
  font-size: 0.69rem;
  font-weight: 500;
  line-height: 1.5;
}

/* ── Actions ───────────────────────────────────────────────────────────── */
.fc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.2rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--brand-color-border, rgba(18, 32, 51, 0.12));
}

.fc-actions:empty {
  display: none;
}

.fc-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.24rem 0.6rem;
  border: 1px solid var(--brand-color-border, rgba(18, 32, 51, 0.12));
  border-radius: 6px;
  background: var(--brand-color-surface, #ffffff);
  color: var(--brand-color-text, #122033);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
}

.fc-btn:hover {
  background: var(--brand-color-surface-muted, #f5f8fc);
  border-color: rgba(18, 32, 51, 0.24);
  color: var(--brand-color-text, #122033);
}

.fc-btn.is-primary {
  color: var(--fc-accent);
  border-color: rgba(18, 32, 51, 0.18);
}

/* Pushes the save button to the right, so the bookmark sits in the same spot
   on every card in the product. */
.fc-spacer {
  margin-left: auto;
}

/* ── Empty / error / loading states, so every feed says it the same way ─── */
.fc-state {
  padding: 1.75rem 1rem;
  color: var(--brand-color-text-muted, #5d6c80);
  text-align: center;
  font-size: 0.88rem;
}

.fc-state.is-error {
  color: var(--brand-color-danger, #b4453c);
}

.fc-more {
  display: flex;
  justify-content: center;
  padding: 0.75rem 0;
}

/* ── Domain accents ────────────────────────────────────────────────────────
   Matched lightness and saturation so no domain shouts louder than another in
   a mixed feed, and all dark enough to pass contrast as label text on white. */
.fc-d-politik   { --fc-accent: orange; }
.fc-d-ekonomi   { --fc-accent: #1f5fae; }
.fc-d-sakerhet  { --fc-accent: red; }
.fc-d-regionalt { --fc-accent: orange; }
.fc-d-myndighet { --fc-accent: grey; }

/* ── Inside the Förstora modal ─────────────────────────────────────────────
   The card needs no overrides — that is the point of styling the class. Only
   the list gains room, since the modal is much wider than a panel. */
#feedExpandModalBody .feed-list {
  gap: 0.75rem;
}

@media (min-width: 992px) {
  #feedExpandModalBody .feed-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .feedcard {
    transition: none;
  }
}
