/* ────────────────────────────────────────────────────────────────
 * Matter "At a glance" + "Key dates"  — Phase 2 (re-arch brief §4)
 * ────────────────────────────────────────────────────────────────
 * Lightweight document-intelligence surface that sits at the very
 * top of #matter-overview, ABOVE the Ask Matter composer. Pure
 * SELECT against document_intelligence — no LLM call, no embedding,
 * no edge function. The lawyer's first frame on opening a matter.
 *
 * Stacks under 1100px per [[feedback-multi-column-ui]].
 */

#matter-glance-panel {
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#matter-glance-panel:empty {
  display: none;
}

/* Shared card chrome — both "At a glance" and "Key dates" use it. */
.glance-card,
.glance-keydates {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.7rem 0.9rem 0.75rem;
}

.glance-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}
.glance-card-title {
  font-family: var(--font-serif, 'EB Garamond', serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
}
.glance-card-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── "At a glance" grid (key/value rows) ── */
.glance-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.25rem 0.9rem;
}
@media (min-width: 720px) {
  .glance-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.glance-row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.78rem;
  min-width: 0;
}
.glance-row-label {
  color: var(--text-muted);
  font-weight: 500;
  flex: 0 0 auto;
  width: 4.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.glance-row-value {
  color: var(--text);
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* Parties row inside .glance-row-value — chips. */
.glance-party {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.1rem 0.45rem;
  margin: 0.1rem 0.3rem 0.1rem 0;
  background: var(--bg-muted);
  border-radius: 999px;
  font-size: 0.72rem;
}
.glance-party-role {
  color: var(--text-muted);
  font-size: 0.66rem;
  text-transform: lowercase;
}
.glance-party-more {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Footer counts row. */
.glance-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  margin-top: 0.55rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.glance-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── "Key dates" list ── */
.glance-date-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 18rem;
  overflow-y: auto;
}
.glance-date {
  display: grid;
  grid-template-columns: 6.2rem 1fr auto;
  gap: 0.4rem 0.6rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
  border-radius: var(--r-sm, 6px);
  font-size: 0.78rem;
  transition: background 0.12s;
}
.glance-date:hover {
  background: var(--bg-muted);
}
.glance-date-ymd {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
  font-size: 0.74rem;
}
.glance-date-desc {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.glance-date-source {
  grid-column: 2 / 3;
  grid-row: 2;
  color: var(--text-muted);
  font-size: 0.66rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.glance-date-add {
  grid-row: 1 / 3;
  grid-column: 3;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
}
.glance-date-add:hover:not(:disabled) {
  background: var(--gold-soft, #f3e8c4);
  color: var(--gold-dark, #8a6b1f);
  border-color: var(--gold, #d9a541);
}
.glance-date-add.added {
  background: rgba(58, 145, 90, 0.12);
  color: #2f6b46;
  border-color: rgba(58, 145, 90, 0.28);
  cursor: default;
}
.glance-date-add:disabled {
  opacity: 0.75;
  cursor: progress;
}

.glance-empty,
.glance-loading {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.4rem 0;
}

/* ── Stack under 1100px (matches Ask Matter rule). At narrow widths
 * the date row keeps the add-to-calendar button on its own line so
 * the description doesn't truncate. */
@media (max-width: 720px) {
  .glance-date {
    grid-template-columns: 5.4rem 1fr;
  }
  .glance-date-add {
    grid-column: 1 / -1;
    grid-row: auto;
    justify-self: start;
    margin-top: 0.2rem;
  }
  .glance-date-source {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}
