/* ============================================================
 * articles-home.css — magazine-style listing for the in-portal
 * Articles "Home" view (pages/articles.html?view=home).
 *
 * Mirrors the .idx-* layout used by the static-publish listing
 * (server/lib/article-static.css lines 321-606, kept as the
 * canonical source for the published bundle). Tokens that the
 * static publish defines locally are mapped to portal equivalents
 * here so dark/light mode tracks the portal theme:
 *   --accent     → var(--primary)
 *   --paper      → var(--bg)
 *   --shadow-md  → var(--shadow-card)
 *
 * If you change the .idx-* layout, update BOTH this file AND
 * server/lib/article-static.css. The dedup-into-one-file refactor
 * is parked in ROADMAP (UI consistency).
 * ============================================================ */

/* ----- MASTER INDEX ----- */
.idx-wrap { max-width: 1180px; margin: 0 auto; padding: 48px 24px 80px; }

/* Hero — title + tagline + stats stacked at full width. The featured
   card lives below this in its own horizontal strip, NOT to the
   right of the hero (anchoring it to a side-column at 360px wide
   left a giant dead-space rectangle on the left whenever the
   tagline + stats didn't fill the card's height — which is most of
   the time, especially when the Authors stat hides at ≤1). */
.idx-hero {
  margin: 0 0 24px;
}

.idx-title-main {
  font: 800 36px/1.2 inherit; color: var(--text);
  margin: 0 0 8px; letter-spacing: -0.02em;
}
.idx-tagline {
  font: 400 16px/1.5 inherit; color: var(--text-3);
  margin: 0 0 28px; max-width: 52ch;
}

/* Stats row — 3-up grid of icon + number + label blocks. Lightly
   tinted bg gives the contrast the title doesn't compete with. */
.idx-stats {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 0;
}
.idx-stats.is-hidden { display: none; }
.idx-stat {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  white-space: nowrap;
}
.idx-stat.is-hidden { display: none; }
.idx-stat-icon {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--primary);
}
.idx-stat-num   { font: 700 17px/1 var(--font-sans); color: var(--text); }
.idx-stat-label { font: 500 13px/1 var(--font-sans); color: var(--text-2); }

/* Featured card — full-width horizontal strip sitting between the
   stats row and the search toolbar. Cover image is anchored to the
   left half of the card; title + summary + byline + CTA fill the
   right half. Height is content-driven (no min-height); a bottom-
   anchored CTA absorbs vertical slack via margin-top:auto, so short
   summaries don't leave dead space below the byline. */
.idx-featured-strip { margin: 0 0 32px; }
.idx-featured .idx-featured-card {
  flex-direction: row;            /* override .idx-card column-stack */
  align-items: stretch;
  padding: 0;
}
/* Cover slot — positioned wrapper that owns the 46% flex width and
   stretches vertically to match the text column's content height
   (align-items: stretch on the card). The img inside is absolutely
   positioned to fill the slot so its intrinsic aspect ratio CAN'T
   push the layout — fixes the overlap bug where tall/portrait
   covers grew the card and the byline+CTA collided with the image
   bottom edge. */
.idx-featured .idx-cover-slot {
  flex: 0 0 46%;
  position: relative;
  overflow: hidden;
  background: var(--bg-alt);
}
.idx-featured .idx-cover-slot .idx-cover {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.idx-featured .idx-card-body {
  flex: 1 1 auto; min-width: 0;
  padding: 56px 32px 32px;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.idx-featured-title { font: 800 26px/1.25 inherit; letter-spacing: -0.015em; margin: 0 0 10px; }
.idx-featured .idx-summary { font: 400 15px/1.55 inherit; color: var(--text-2); margin: 0 0 14px; max-width: 60ch; }
/* FEATURED badge — chrome at the top-right of the card, sitting
   immediately left of the share button. Tinted-accent pill so it
   reads as a position marker, NOT as another category eyebrow
   (which is what plain accent-uppercase text would suggest). The
   pill shape + position outside the article body's text flow makes
   the semantic distinction unambiguous. */
.idx-featured-badge {
  position: absolute; top: 14px; right: 52px; z-index: 2;
  display: inline-flex; align-items: center;
  height: 28px; padding: 0 12px;
  font: 700 10.5px/1 var(--font-sans);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--primary); background: var(--accent-50);
  border-radius: 999px;
  pointer-events: none;
}

/* Featured-card byline — three semantic registers (name → role →
   timestamp). Mono+uppercase tracked-out tail is the editorial
   "data label" convention from News Editorial / Minimalist
   Monochrome typography systems. Each row reads as a different
   KIND of info — fixes the flatness that one-color-step + 1.5px
   size difference couldn't. Segregated from the article body
   above by a hairline border. */
.idx-featured-byline {
  display: flex; align-items: flex-start; gap: 14px;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.idx-byline-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
  background-color: var(--ink-200);
}
.idx-byline-avatar--initials {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff;
  font: 700 13px/1 var(--font-sans); letter-spacing: 0.04em;
}
.idx-byline-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.idx-byline-name { font: 700 15px/1.25 inherit; color: var(--text); }
.idx-byline-role { font: 500 13.5px/1.35 inherit; color: var(--text-2); }
.idx-byline-stamp {
  font: 500 11px/1.2 ui-monospace, 'JetBrains Mono', monospace;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* CTA — bottom-anchored visual cue inside the card link. Not a
   separate clickable element (the whole card is already wrapped
   in <a>); margin-top:auto pushes it to the bottom of the flex
   column so vertical slack is absorbed here, not left as dead
   space. Underline on parent card hover for affordance. */
.idx-featured-cta {
  margin-top: auto; padding-top: 22px;
  font: 600 13.5px/1 inherit; color: var(--primary);
  display: inline-flex; align-items: center; gap: 6px;
  align-self: flex-start;
}
.idx-featured-cta span { transition: transform 160ms ease; display: inline-block; }
.idx-featured-card:hover .idx-featured-cta { text-decoration: underline; text-underline-offset: 3px; }
.idx-featured-card:hover .idx-featured-cta span { transform: translateX(2px); }

/* Eyebrow row — wraps the primary tag + NEW chip (or FEATURED + NEW
   on the featured card) so they sit on the same baseline above the
   title. */
.idx-eyebrow-row {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px;
}
.idx-eyebrow-row .idx-tag { margin: 0; }

/* NEW chip — filled accent pill. Differentiated from the plain-text
   primary-tag eyebrow + the FEATURED eyebrow by its fill so all three
   can sit on the same row without confusion. */
.idx-new-chip {
  display: inline-flex; align-items: center;
  height: 18px; padding: 0 8px;
  font: 700 9.5px/1 var(--font-sans);
  letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--primary); color: #fff;
  border-radius: 999px;
}

/* Narrow viewport — featured strip stacks to vertical (cover on top,
   content below) so the card stays scannable on phones. */
@media (max-width: 760px) {
  .idx-featured .idx-featured-card {
    flex-direction: column;
    min-height: 0;
  }
  .idx-featured .idx-cover-slot {
    flex: 0 0 auto;
    width: 100%;
    height: 200px;
  }
  .idx-featured .idx-card-body { padding: 20px 22px; }
  .idx-featured-title { font-size: 22px; }
}

/* Toolbar — search input + tag-chip filter on the master listing. */
.idx-toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 0 0 24px; }
.idx-search-wrap {
  position: relative; flex: 1 1 280px; min-width: 240px;
}
.idx-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.idx-search-wrap input {
  width: 100%; padding: 10px 14px 10px 36px;
  font: 400 14px var(--font-sans); color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  outline: none; transition: border-color 120ms ease, box-shadow 120ms ease;
}
.idx-search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--accent-50);
}

.idx-tag-filter { display: flex; flex-wrap: wrap; gap: 6px; flex: 2 1 auto; }
.idx-tag-chip {
  font: 600 12px/1 var(--font-sans); color: var(--text-2);
  background: transparent; border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.idx-tag-chip:hover { background: var(--bg-alt); color: var(--text); }
.idx-tag-chip.is-active {
  background: var(--primary); border-color: var(--primary); color: #fff;
}

.idx-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}

/* Card wrap — positioned-relative parent of the link + the floating
   share button. The button sits on top of the card via absolute
   positioning so the anchor's semantics stay clean. */
.idx-card-wrap { position: relative; }
.idx-card-wrap[hidden] { display: none; }
.idx-card {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; text-decoration: none; color: var(--text);
  transition: transform 160ms ease, box-shadow 160ms ease;
  display: flex; flex-direction: column;
}
.idx-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.idx-cover { width: 100%; height: 180px; object-fit: cover; display: block; background: var(--bg-alt); }
.idx-cover-placeholder { background: var(--bg-alt); }
.idx-card-body { padding: 16px 18px 18px; }
.idx-tag { display: inline-block; font: 600 10.5px/1 inherit; letter-spacing: 0.12em; text-transform: uppercase; color: var(--primary); margin: 0 0 8px; }
.idx-title { font: 700 18px/1.3 inherit; color: var(--text); margin: 0 0 8px; }
.idx-summary { font: 400 14px/1.5 inherit; color: var(--text-2); margin: 0 0 12px; }
.idx-meta { font: 400 12.5px inherit; color: var(--text-3); }
.idx-empty { color: var(--text-3); padding: 60px 0; text-align: center; grid-column: 1 / -1; }

/* Share button — sits on the card's top-right corner. Default state
   is subdued; brightens on card hover. */
.idx-share-btn {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; opacity: 0.85;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease, transform 120ms ease;
}
.idx-card-wrap:hover .idx-share-btn { opacity: 1; }
.idx-share-btn:hover { background: var(--primary); border-color: var(--primary); color: #fff; transform: scale(1.05); }
.idx-share-btn[aria-expanded="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Radial share menu — injected into the card-wrap as a sibling of
   the share button when clicked. Each option is positioned absolutely
   via its --dx / --dy custom properties (set inline by JS based on
   the 6-step arc). Opens with a small fan-out animation. */
.idx-share-menu {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 0; height: 0; pointer-events: none;
}
.idx-share-menu.is-open { pointer-events: auto; }
.idx-share-opt {
  position: absolute;
  top: 16px; right: 16px; /* centred on the share button's centre */
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); color: var(--primary);
  cursor: pointer; text-decoration: none;
  transform: translate(50%, -50%) scale(0.3);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.22, 1.32, 0.55, 1.18), opacity 180ms ease, background 120ms ease, color 120ms ease;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.idx-share-opt > svg { width: 13px; height: 13px; }
.idx-share-menu.is-open .idx-share-opt {
  transform: translate(calc(var(--dx) + 50%), calc(var(--dy) - 50%)) scale(1);
  opacity: 1;
}
.idx-share-opt:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.idx-share-opt.is-copied { background: #10b981; color: #fff; border-color: #10b981; }
@media (prefers-reduced-motion: reduce) {
  .idx-share-opt { transition: opacity 80ms ease; }
}
