/* ==========================================================================
   Dashboard Hub — report card (redesign, from CARD-REDESIGN spec)
   Theme-adapted for the Hub: default = DARK (:root); light via body.theme-light
   / [data-theme="light"] (the Hub's toggle sets body.theme-light).
   ========================================================================== */

:root {
  /* Defaults = DARK (Hub's default theme) */
  --dh-red:            #C52127;
  --dh-red-hover:      #A51A1F;
  --dh-red-tint:       #331416;
  --dh-ink:            #E8EAED;
  --dh-ink-2:          #E8EAED;
  --dh-muted:          #9CA3AF;
  --dh-muted-2:        #9CA3AF;
  --dh-icon:           #9CA3AF;
  --dh-icon-active:    #E8EAED;
  --dh-surface:        #1A1F26;
  --dh-surface-2:      #222831;
  --dh-surface-3:      #222831;
  --dh-avatar-bg:      #2A3038;
  --dh-border:         #2A3038;
  --dh-border-strong:  #3A424C;
  --dh-rule:           #2A3038;
  --dh-shadow:         0 1px 2px rgba(0, 0, 0, 0.4);
  --dh-shadow-hover:   0 6px 18px rgba(0, 0, 0, 0.55);
  --dh-cert:           #4ADE80;
  --dh-cert-tint:      rgba(74, 222, 128, 0.15);

  --dh-radius:         10px;
  --dh-radius-sm:      4px;
  --dh-font-display:   'League Spartan', system-ui, sans-serif;
  --dh-font-label:     'Barlow Semi Condensed', system-ui, sans-serif;
  --dh-font-body:      Inter, system-ui, sans-serif;
}

/* LIGHT theme overrides (Hub sets body.theme-light; also support [data-theme="light"]) */
body.theme-light, [data-theme="light"] {
  --dh-red-tint:      #FBECEC;
  --dh-ink:           #141413;
  --dh-ink-2:         #333333;
  --dh-muted:         #5F5F5F;
  --dh-muted-2:       #6B6B6B;
  --dh-icon:          #8A8A8A;
  --dh-icon-active:   #3F3F3F;
  --dh-surface:       #FFFFFF;
  --dh-surface-2:     #F5F4F1;
  --dh-surface-3:     #F0EFEC;
  --dh-avatar-bg:     #F0EEEA;
  --dh-border:        #E6E4E0;
  --dh-border-strong: #D6D2CB;
  --dh-rule:          #EDEBE7;
  --dh-shadow:        0 1px 2px rgba(20, 20, 19, 0.05);
  --dh-shadow-hover:  0 6px 18px rgba(20, 20, 19, 0.11);
  --dh-cert:          #15803D;
  --dh-cert-tint:     rgba(34, 197, 94, 0.12);
}

/* Grid — applied to the Hub's #card-grid (which carries .dh-grid). */
.dh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  align-items: stretch;
}

.dh-card {
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background: var(--dh-surface);
  border: 1px solid var(--dh-border);
  border-radius: var(--dh-radius);
  box-shadow: var(--dh-shadow);
  overflow: hidden;
  font-family: var(--dh-font-body);
  transition: box-shadow 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.dh-card:hover,
.dh-card:focus-within {
  border-color: var(--dh-border-strong);
  box-shadow: var(--dh-shadow-hover);
  transform: translateY(-1px);
}

.dh-card__accent {
  height: 3px;
  flex-shrink: 0;
  background: var(--dh-card-accent, var(--dh-red));
}

.dh-card__body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 12px;
  box-sizing: border-box;
  padding: 14px 18px 12px;
}

/* Row 1 — chips + date */
.dh-card__meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dh-card__chips { display: flex; align-items: center; gap: 6px; min-width: 0; flex-wrap: wrap; }
.dh-chip {
  font-family: var(--dh-font-label);
  font-weight: 600;
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: var(--dh-radius-sm);
  white-space: nowrap;
}
.dh-chip--category  { color: var(--dh-red);   background: var(--dh-red-tint); }
.dh-chip--tier      { color: var(--dh-muted); background: var(--dh-surface-3); }
.dh-chip--certified { color: var(--dh-cert);  background: var(--dh-cert-tint); }
.dh-chip--sandbox   { color: #B45309; background: rgba(245,197,24,0.18); }
[data-theme="dark"] .dh-chip--sandbox, :root .dh-chip--sandbox { color: #F5C518; background: rgba(245,197,24,0.14); }
body.theme-light .dh-chip--sandbox, [data-theme="light"] .dh-chip--sandbox { color: #B45309; background: rgba(245,158,11,0.18); }

.dh-card__date { flex-shrink: 0; font-size: 11px; color: var(--dh-muted-2); white-space: nowrap; }

/* Row 2 — title + keywords */
.dh-card__main { display: flex; flex-direction: column; flex-grow: 1; gap: 9px; }
.dh-card__title {
  font-family: var(--dh-font-display);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  color: var(--dh-ink);
  text-decoration: none;
  transition: color 140ms ease;
}
.dh-card__title::after { content: ""; position: absolute; inset: 0; }
.dh-card:hover .dh-card__title { color: var(--dh-red); }
.dh-card__title:focus-visible { outline: 2px solid var(--dh-red); outline-offset: 2px; border-radius: 2px; }

.dh-card__keywords { display: flex; flex-wrap: wrap; gap: 6px; }
.dh-keyword {
  position: relative; z-index: 1;
  font-size: 11px; line-height: 1.5;
  color: var(--dh-muted); background: var(--dh-surface-2);
  border-radius: var(--dh-radius-sm); padding: 2px 8px; text-decoration: none;
}

/* Row 3 — owner + actions */
.dh-card__rule { height: 1px; background: var(--dh-rule); }
.dh-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dh-card__owner { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dh-avatar {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%;
  background: var(--dh-avatar-bg); color: var(--dh-ink-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
}
.dh-owner-name { font-size: 12px; font-weight: 500; color: var(--dh-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dh-card__actions {
  position: relative; z-index: 1;
  display: flex; align-items: center; flex-shrink: 0;
  color: var(--dh-icon); margin-right: -5px;
  transition: color 140ms ease;
}
.dh-card:hover .dh-card__actions { color: var(--dh-icon-active); }
.dh-action {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  padding: 0; background: none; border: none; border-radius: 6px; color: inherit;
  cursor: pointer; font: inherit; transition: background-color 120ms ease, color 120ms ease;
}
.dh-action:hover { background: var(--dh-surface-3); color: var(--dh-ink); }
.dh-action:focus-visible { outline: 2px solid var(--dh-red); outline-offset: 1px; }
.dh-action svg { width: 16px; height: 16px; display: block; }
.dh-action[aria-pressed="true"] { color: var(--dh-red); }
.dh-action[aria-pressed="true"] svg { fill: currentColor; }

@media (prefers-reduced-motion: reduce) {
  .dh-card, .dh-card__title, .dh-card__actions, .dh-action { transition: none; }
  .dh-card:hover { transform: none; }
}

/* Owner initials badge → full name on hover / keyboard focus */
.dh-avatar--tip { position: relative; cursor: default; }
.dh-avatar--tip:focus-visible { outline: 2px solid var(--color-primary, #C52127); outline-offset: 2px; }
.dh-owner-tip {
  position: absolute; left: -4px; bottom: calc(100% + 8px); z-index: 30;
  display: flex; flex-direction: column; gap: 1px; min-width: max-content; max-width: 260px;
  padding: 7px 10px; border-radius: 8px; text-align: left; white-space: nowrap;
  background: #111315; color: #F2F2F2; border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
  font-family: var(--dh-font-body); font-size: 12px; font-weight: 500; line-height: 1.35;
  opacity: 0; transform: translateY(3px); pointer-events: none; transition: opacity .12s, transform .12s;
}
.dh-owner-tip::after {   /* little arrow pointing at the badge */
  content: ""; position: absolute; left: 11px; top: 100%; border: 5px solid transparent; border-top-color: #111315;
}
.dh-avatar--tip:hover .dh-owner-tip, .dh-avatar--tip:focus-visible .dh-owner-tip { opacity: 1; transform: none; }
.dh-owner-tip__k { font-family: var(--dh-font-label); font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #9AA0A6; }
.dh-owner-tip__name { font-weight: 600; }
.dh-owner-tip__sub { color: #B8BDC2; font-size: 11.5px; }
body.theme-light .dh-owner-tip, [data-theme="light"] .dh-owner-tip { background: #FFFFFF; color: #141413; border-color: #E6E4E0; box-shadow: 0 8px 20px rgba(0,0,0,.14); }
body.theme-light .dh-owner-tip::after, [data-theme="light"] .dh-owner-tip::after { border-top-color: #FFFFFF; }
body.theme-light .dh-owner-tip__k, [data-theme="light"] .dh-owner-tip__k { color: #6B6B6B; }
body.theme-light .dh-owner-tip__sub, [data-theme="light"] .dh-owner-tip__sub { color: #5F5F5F; }
@media (hover: none) { .dh-avatar--tip:active .dh-owner-tip { opacity: 1; transform: none; } }
