/* reports-history-grid.css — visual surface for the Reports history zone.
   Tokens inherit from shared.css. The grid responds at 1280 / 960 / 640 px.
   Tiles use a 4:3 thumbnail letterbox + two-line title clamp + meta row. */

.rhg {
  font-family: 'Inter', 'DM Sans', system-ui, -apple-system, sans-serif;
  width: 100%;
}

.rhg-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
@media (max-width: 1280px) { .rhg-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 960px)  { .rhg-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .rhg-grid { grid-template-columns: repeat(1, 1fr); } }

/* ── Tile ──────────────────────────────────────────────────────────── */

.rhg-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md, 8px);
  overflow: visible;
  cursor: pointer;
  transition:
    border-color var(--transition-fast, 120ms ease),
    box-shadow   var(--transition-fast, 120ms ease),
    transform    var(--transition-fast, 120ms ease);
  outline: none;
}
.rhg-tile:hover {
  border-color: var(--accent-border, rgba(68,84,225,0.20));
  box-shadow: 0 4px 16px rgba(44, 48, 80, 0.06);
}
.rhg-tile:focus-visible {
  border-color: var(--accent);
  box-shadow: var(--shadow-focus, 0 0 0 3px rgba(68,84,225,0.25));
}
.rhg-tile--processing { cursor: default; }
.rhg-tile--processing:hover { box-shadow: none; border-color: var(--border-default); }
.rhg-tile--failed { cursor: default; }

/* Thumbnail: 4:3 aspect, object-fit cover, fixed corners. */
.rhg-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-bg);
  border-radius: var(--radius-md, 8px) var(--radius-md, 8px) 0 0;
  overflow: hidden;
  flex-shrink: 0;
}
.rhg-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rhg-thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.rhg-thumb-fallback svg { width: 32px; height: 32px; stroke-width: 1.2; }

/* Body */
.rhg-tile-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px 14px;
}

.rhg-tile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.rhg-tile-title {
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-word;
}

.rhg-tile-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  color: var(--text-secondary);
}
.rhg-tile-sep { color: var(--text-muted); }

/* Actions trigger (⋮) */
.rhg-actions-btn {
  flex-shrink: 0;
  height: 26px;
  width: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  border-radius: var(--radius, 4px);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  padding: 0;
}
.rhg-actions-btn:hover { background: var(--surface-bg); color: var(--text-primary); }
.rhg-actions-btn svg { width: 16px; height: 16px; stroke-width: 1.6; }

/* Actions menu */
.rhg-menu {
  position: absolute;
  top: calc(100% - 14px);
  right: 10px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  background: var(--page-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 10px 28px rgba(44, 48, 80, 0.14);
  z-index: 50;
}
.rhg-menu[hidden] { display: none; }

.rhg-menu-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  border-radius: var(--radius, 4px);
  cursor: pointer;
}
.rhg-menu-item:hover { background: var(--surface-bg); }
.rhg-menu-item svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.5;
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.rhg-menu-item--danger { color: var(--negative); }
.rhg-menu-item--danger:hover { background: rgba(255, 96, 92, 0.08); }
.rhg-menu-item--danger svg { color: var(--negative); }

/* Inline badges (processing / failed) — sit inside the meta row. */
.rhg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full, 9999px);
  font-size: 10.5px;
  line-height: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-left: auto;
}
.rhg-badge svg { width: 11px; height: 11px; stroke-width: 1.6; }
.rhg-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: rhg-pulse-dot 1.4s ease-in-out infinite;
}
.rhg-badge--processing {
  background: rgba(68, 84, 225, 0.10);
  color: var(--accent);
}
.rhg-badge--failed {
  background: rgba(255, 96, 92, 0.10);
  color: var(--negative);
}

/* Inline Retry button for failed tiles. */
.rhg-tile-retry {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  height: 26px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius, 4px);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.rhg-tile-retry:hover { background: rgba(68, 84, 225, 0.14); border-color: var(--accent); }
.rhg-tile-retry svg { width: 12px; height: 12px; stroke-width: 1.6; }

/* ── Loading: free-floating dot-loader (no panel, no border) ──────── */

.rhg-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-tertiary);
}

/* ── State panels (empty / error) ─────────────────────────────────── */

.rhg-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 56px 24px;
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md, 8px);
  background: var(--surface-bg);
  min-height: 240px;
}
.rhg-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  background: var(--page-bg);
  border: 1px solid var(--border-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.rhg-state-icon svg { width: 32px; height: 32px; stroke-width: 1.4; }
.rhg-state-icon--error { color: var(--negative); border-color: rgba(255, 96, 92, 0.30); }

.rhg-state-title {
  font-family: inherit;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0;
}
.rhg-state-sub {
  font-size: 12px;
  line-height: 18px;
  color: var(--text-tertiary);
  max-width: 380px;
}
.rhg-state--error .rhg-state-title { color: var(--text-primary); }

.rhg-retry {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius, 4px);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.rhg-retry:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.rhg-retry svg { width: 14px; height: 14px; stroke-width: 1.6; }

@keyframes rhg-pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .rhg-badge-dot {
    animation: none !important;
  }
}
