@import "shared-vars.css";

/* ── Eval mailing index — page-specific styles ───────────── */

/* ── Eval variables ──────────────────────────────────────── */

:root {
  --bar-passed: #f47171;
  --bar-bg: #2a3550;
}

/* ── Container ───────────────────────────────────────────── */

.subreddit,
.mailing-page {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 0.75rem;
}

.mailing-page > .breadcrumb-bar,
.mailing-page > .page-title {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

/* ── Filter bar ──────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: nowrap;
  margin-bottom: 1rem;
}

.search-wrap {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  cursor: text;
}

.search-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(169, 28, 33, 0.15);
}

.filter-search {
  flex: 1 1 60px;
  min-width: 40px;
  padding: 0.4rem 0.5rem;
  background: transparent;
  border: none;
  color: #ffffff;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
}
/* Shrink input to content width when it has text */
.filter-search.has-text {
  flex: 0 0 auto;
  min-width: 0;
  padding-left: 0.2rem;
  padding-right: 0;
}

.filter-search::placeholder {
  color: #4a5568;
}

.search-clear {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.15s;
  flex: 0 0 auto;
  order: 999;
}

.search-clear:hover {
  color: var(--text-primary);
}

.row-count {
  flex: 0 0 auto;
  min-width: 160px;
  text-align: right;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ── Table ────────────────────────────────────────────────── */

.eval-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: var(--bg-body);
  border: 1px solid var(--border-default);
  border-radius: 12px;
}

.eval-table thead th:first-child { border-radius: 12px 0 0 0; }
.eval-table thead th:last-child { border-radius: 0 12px 0 0; }
.eval-table tbody tr:last-child td:first-child { border-radius: 0 0 0 12px; }
.eval-table tbody tr:last-child td:last-child { border-radius: 0 0 12px 0; }

/* Fixed + flex column widths to prevent layout shift on filter */
.eval-table col.col-paper    { width: 8%; min-width: 5.5rem; }
.eval-table col.col-title    { width: 30%; }
.eval-table col.col-authors  { width: 26%; }
.eval-table col.col-audience { width: 16%; }
.eval-table col.col-findings { width: 8%; }

.eval-table thead th {
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.eval-table thead th::after {
  content: "";
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--text-muted);
}

.eval-table thead th.sort-asc::after {
  content: " \25B2";
  color: #e2e8f0;
}

.eval-table thead th.sort-desc::after {
  content: " \25BC";
  color: #e2e8f0;
}

.eval-table tbody tr {
  border-bottom: 1px solid rgba(42, 53, 80, 0.5);
  transition: background 0.15s;
}

.eval-table tbody tr:hover {
  background: var(--bg-hover);
}

/* ── Row audience stripe (primary visual signal) ── */
.eval-table tbody tr[data-audience-group="ewg"]  td:first-child { border-left: 3px solid var(--clr-ewg); }
.eval-table tbody tr[data-audience-group="lewg"] td:first-child { border-left: 3px solid var(--clr-lewg); }
.eval-table tbody tr[data-audience-group="cwg"]  td:first-child { border-left: 3px solid var(--clr-cwg); }
.eval-table tbody tr[data-audience-group="lwg"]  td:first-child { border-left: 3px solid var(--clr-lwg); }
.eval-table tbody tr[data-audience-group="sg"]   td:first-child { border-left: 3px solid var(--clr-sg); }
.eval-table tbody tr[data-audience-group="wg21"] td:first-child { border-left: 3px solid var(--clr-wg21); }

.eval-table tbody td {
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.eval-table tbody td:first-child {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.eval-table tbody td.col-title {
  position: relative;
  overflow: visible;
  text-overflow: clip;
}

.eval-table tbody td.col-authors,
.eval-table tbody td.col-audience {
  overflow: visible;
  position: relative;
}

/* Title hover tooltip — tight popover flush to the right of the title text */
.title-hover {
  position: relative;
  display: block;
}

/* Show full title at all widths; CSS text-overflow clips if needed.
   Mid-ellipsis version (.title-truncated) is hidden everywhere. */
.title-truncated { display: none; }
.title-full {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.title-tooltip {
  position: absolute;
  top: -10px;
  left: 100%;
  width: max-content;
  max-width: 280px;
  padding: 4px 8px;
  background: #1e2942;
  border: 1px solid rgba(100,116,139,0.4);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  white-space: normal;
  z-index: 100;
  font-size: 12px;
  color: var(--text-primary);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
@media (hover: hover) {
  .title-hover.is-clamped:hover .title-tooltip { opacity: 1; pointer-events: auto; }
}

.eval-table td.col-authors {
  color: var(--text-secondary);
}

.eval-table td a {
  color: var(--text-link);
  text-decoration: none;
  font-weight: 400;
  transition: color 0.2s;
}

.eval-table td:first-child a {
  color: var(--text-primary);
}

.author-link {
  cursor: pointer;
  transition: color 0.15s;
}

.author-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.col-authors .badge-overflow-wrap { margin-left: 4px; }
.col-authors .badge-overflow-popup {
  flex-direction: column;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  gap: 2px;
  font-size: 13px;
  line-height: 1.5;
  top: 0;
  left: 0;
  transform: none;
}


.eval-table td a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Audience column layout ──────────────────────────────── */

td.col-audience {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  overflow: visible;
  white-space: nowrap;
}

/* Audience overflow indicator + floating popup */
.badge-overflow-wrap { position: relative; display: inline-flex; align-items: stretch; }
.badge-overflow { background: rgba(100,116,139,0.10); color: var(--text-muted); border: 1px solid rgba(100,116,139,0.18); cursor: default; padding: 2px 5px; font-size: 11px; font-weight: 500; letter-spacing: 0.02em; }
.badge-overflow-popup {
  display: inline-flex;
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  padding: 5px 8px;
  background: #1e2942;
  border: 1px solid rgba(100,116,139,0.4);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  white-space: nowrap;
  z-index: 100;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}
/* Desktop (>1024px + hover-capable): hover opens the popup. */
@media (hover: hover) and (min-width: 1025px) {
  .badge-overflow-wrap:hover .badge-overflow-popup { opacity: 1; pointer-events: auto; }
  .badge-overflow-wrap:hover .badge-overflow { visibility: hidden; }
}

/* All viewports: click-to-toggle via JS `.is-open` class.
   On desktop this supplements hover; on tablet/mobile it's the only method. */
.badge-overflow { cursor: pointer; }
.badge-overflow-wrap.is-open .badge-overflow-popup {
  opacity: 1;
  pointer-events: auto;
}
.badge-overflow-wrap.is-open .badge-overflow {
  visibility: hidden;
}

/* Audience badge interaction */
.col-audience .badge { cursor: pointer; transition: opacity 0.15s, filter 0.15s; }
.col-audience .badge:hover { filter: brightness(1.3); }
.col-audience .badge.badge-dimmed { opacity: 0.35; }
.col-audience .badge.badge-active { filter: brightness(1.2); }

/* ── Filter chip ─────────────────────────────────────────── */

.filter-chip-area {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex-shrink: 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.04);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s;
}

.filter-chip:hover {
  background: rgba(255,255,255,0.08);
}

.filter-chip-x {
  font-size: 13px;
  line-height: 1;
  opacity: 0.6;
}

.filter-chip:hover .filter-chip-x {
  opacity: 1;
}

/* Inline suggestion chips shown while typing */
.filter-suggest-area {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  flex-shrink: 0;
}
.filter-suggest-area:empty {
  display: none;
}
.filter-suggest-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border: 1px dashed;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.02);
  white-space: nowrap;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.12s, background 0.12s;
}
.filter-suggest-chip:hover,
.filter-suggest-chip.filter-suggest-active {
  opacity: 1;
  background: rgba(255,255,255,0.08);
}

/* ── Findings ────────────────────────────────────────────── */

.findings-text {
  font-size: 13px;
  white-space: nowrap;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--accent);
}

@media (hover: hover) {
  .findings-text {
    text-decoration-color: rgba(244, 113, 113, 0.4);
    transition: text-decoration-color 0.15s;
  }
  .findings-text:hover {
    text-decoration-color: var(--accent);
  }
}

.eval-table td a.findings-zero {
  color: #22c55e;
}

/* ── Mailing list (root index) ───────────────────────────── */

.mailing-list {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1rem 0.75rem;
}

.mailing-list h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.mailing-list-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.mailing-list-disclaimer {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
}

.mailing-badge-latest {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
  vertical-align: middle;
  margin-left: 6px;
}

/* ── Mailing index list (quiet editorial) ────────────────── */

.mailing-index-list {
  display: flex;
  flex-direction: column;
}

.mailing-index-year {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0 0.25rem;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.mailing-index-year:first-child {
  margin-top: 0;
}

.mailing-index-year::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

.mailing-index-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.5rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid rgba(42, 53, 80, 0.5);
  transition: background 0.15s;
}

.mailing-index-item:last-child {
  border-bottom: none;
}

.mailing-index-item:hover {
  background: var(--bg-hover);
}

.mailing-index-item-id {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  transition: color 0.15s;
}

.mailing-index-item:hover .mailing-index-item-id {
  color: var(--accent);
}

.mailing-index-item-count {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.mailing-index-item-arrow {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: color 0.15s, transform 0.15s;
}

.mailing-index-item:hover .mailing-index-item-arrow {
  color: var(--text-primary);
  transform: translateX(2px);
}

/* ── Report buttons (stub) ───────────────────────────────── */

.report-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s, border-radius 0.15s;
  cursor: pointer;
}

.report-btn:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
  background: rgba(42, 53, 80, 0.7);
}

.report-btn-block {
  display: flex;
  width: 100%;
  padding: 0.55rem 0.9rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.report-btn-block:last-child {
  margin-bottom: 0;
}

.report-btn-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color 0.15s;
}

.report-btn:hover .report-btn-icon {
  color: var(--text-primary);
}

/* ── Report row (inline label + format icons) ────────────── */

.report-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.report-row-label {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Per-committee label color, mirrors the audience badge palette */
.report-row-label-lewg { color: #6ea8fe; }
.report-row-label-lwg  { color: #a78bfa; }
.report-row-label-ewg  { color: #14b8a6; }
.report-row-label-cwg  { color: #f0a050; }

.report-row-count {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.report-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(26, 32, 53, 0.85);
  border: 1px solid var(--border-default);
  color: #ffffff;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  cursor: pointer;
}

.report-icon-btn:hover {
  border-color: var(--text-secondary);
  color: #ffffff;
  background: rgba(42, 53, 80, 0.9);
}

.report-icon-btn[aria-disabled="true"] {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Brand-colored icon button (Acrobat PDF) — same hover bg, keeps its own icon color */
.report-icon-btn-brand:hover {
  border-color: var(--text-secondary);
  background: rgba(42, 53, 80, 0.9);
}

/* ── Content layout with sidebar ─────────────────────────── */

.mailing-list .content-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.mailing-list .post-list {
  flex: 1;
  min-width: 0;
}

.mailing-list .sidebar {
  width: 260px;
  min-width: 260px;
  flex-shrink: 0;
}

.mailing-list .sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  margin-bottom: 1rem;
}

.mailing-list .sidebar-card-header {
  background: var(--bg-card);
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-default);
  border-radius: 12px 12px 0 0;
}

.mailing-list .sidebar-card-body {
  padding: 0.9rem 1rem 1rem;
}

.mailing-list .sidebar-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
  .mailing-list .content-layout {
    flex-direction: column;
    align-items: stretch;
  }
  .mailing-list .sidebar {
    width: 100%;
    min-width: 0;
  }
}

/* ── Tablet breakpoint — column redistribution ─────────── */
/* At <1024px the 5-column table gets tight. Give title more
   room by shrinking authors/audience. Switch the title to a
   CSS text-overflow clamp (using .title-full) so it clips
   gracefully instead of spilling into the authors column. */

@media (max-width: 1024px) {
  .eval-table col.col-paper    { width: 8%; min-width: 5.5rem; }
  .eval-table col.col-title    { width: 36%; }
  .eval-table col.col-authors  { width: 20%; }
  .eval-table col.col-audience { width: 16%; }
  .eval-table col.col-findings { width: 8%; }

  /* Swap to CSS-truncated full title (no mid-ellipsis) so
     the clamp adapts to the actual column width. */
  .title-truncated { display: none; }
  .title-full {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
  }
  .title-tooltip { display: none; }
  .title-hover { display: block; }

  /* Clip paper IDs that are too wide for the narrow column */
  .eval-table tbody td:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Clip the author-names wrapper so long pairs like
     "Author1, Author2" truncate as "Author1, Aut…" instead of
     spilling into the audience column. For >2-author papers the
     badge sits outside the wrapper at natural width. */
  .col-authors-names {
    display: inline-block;
    max-width: calc(100% - 40px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* Restyle the +N badge as an inline "…" — no pill chrome, just
     a subtle text continuation that's tappable. The existing
     click-to-toggle popup opens on tap showing remaining authors. */
  .col-authors .badge-overflow {
    font-size: 0;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
  }
  .col-authors .badge-overflow::after {
    content: '\2026';
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
  }
}

/* ── Mobile card breakpoint ──────────────────────────────── */

@media (max-width: 768px) {
  .filter-bar {
    flex-wrap: wrap;
  }

  .filter-search {
    flex: 1 1 100%;
  }

  .row-count {
    flex: 1 1 100%;
    text-align: center;
  }

  .eval-table {
    background: none;
    border: none;
  }

  .eval-table thead {
    display: none;
  }

  .eval-table,
  .eval-table tbody {
    display: block;
  }

  /* Mobile list layout — each row is a 2-column grid:
     Paper id and Notes share the top line; title, authors, and audience
     each take their own wrapping line below. */
  .eval-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "paper    notes"
      "title    title"
      "authors  authors"
      "audience audience";
    row-gap: 4px;
    column-gap: 12px;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(42, 53, 80, 0.5);
    border-radius: 0;
    margin: 0;
    padding: 8px 0 8px 12px;
  }

  .eval-table tbody tr:last-child {
    border-bottom: none;
  }

  /* Row audience stripe — thin accent on the left edge of each list item */
  .eval-table tbody tr[data-audience-group="ewg"]  { border-left: 3px solid var(--clr-ewg); }
  .eval-table tbody tr[data-audience-group="lewg"] { border-left: 3px solid var(--clr-lewg); }
  .eval-table tbody tr[data-audience-group="cwg"]  { border-left: 3px solid var(--clr-cwg); }
  .eval-table tbody tr[data-audience-group="lwg"]  { border-left: 3px solid var(--clr-lwg); }
  .eval-table tbody tr[data-audience-group="sg"]   { border-left: 3px solid var(--clr-sg); }
  .eval-table tbody tr[data-audience-group="wg21"] { border-left: 3px solid var(--clr-wg21); }

  .eval-table tbody td {
    padding: 0;
    border: none;
    display: block;
  }

  .eval-table tbody td::before {
    display: none;
  }

  /* Remove desktop row border on mobile */
  .eval-table tbody tr[data-audience-group] td:first-child {
    border-left: none;
  }

  .eval-table tbody td[data-label="Paper"]    { grid-area: paper; font-weight: 600; }
  .eval-table tbody td[data-label="Title"]    { grid-area: title; font-size: 13px; color: var(--text-secondary); white-space: normal; overflow: visible; text-overflow: clip; }
  .eval-table tbody td[data-label="Authors"]  { grid-area: authors; font-size: 13px; color: var(--text-secondary); }
  .eval-table tbody td[data-label="Audience"] { grid-area: audience; }
  .eval-table tbody td[data-label="Notes"]    { grid-area: notes; text-align: right; font-size: 13px; }

  /* Reset the desktop text-overflow clamp on .title-full so the title
     wraps freely across lines on mobile. */
  .title-truncated { display: none; }
  .title-full {
    display: inline;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }
  .title-tooltip { display: none; }

  td.col-audience {
    gap: 4px;
  }
  .col-authors {
    display: block;
  }
}
