/* ============================================================
   Project Builder — /projects/ hub
   Component styles for the hub gallery. Depends on pb-tokens.css
   (variables scoped under `.pb-scope`). All rules are namespaced
   under `.pb-scope` so nothing leaks onto the shared app shell.
   ============================================================ */

.pb-scope {
  color: var(--pb-text);
  font-family: var(--pb-font-ui);
}

/* The hero now lives in pb-shell.css as .pb-shell-hero (indigo band). */

/* ── Section headings ─────────────────────────────────────── */
.pb-section {
  margin: 2.25rem 0;
}
.pb-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.pb-section__title {
  font-family: var(--pb-font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--pb-ink-800);
  margin: 0;
}
.pb-section__hint {
  font-size: .85rem;
  color: var(--pb-text-subtle);
  margin: 0;
}

/* ── Vertical grid + cards ────────────────────────────────── */
.pb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 1.1rem;
}
.pb-card {
  display: flex;
  flex-direction: column;
  background: var(--pb-bg-elev);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-r-lg);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--pb-shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.pb-card:hover,
.pb-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--pb-shadow-md);
  border-color: var(--pb-border-strong);
  outline: none;
}
.pb-card:focus-visible {
  outline: 2px solid var(--pb-primary);
  outline-offset: 2px;
}
.pb-card__icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--pb-r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.4rem;
  margin-bottom: .9rem;
  background: linear-gradient(135deg, var(--pb-grad-a, var(--pb-indigo-500)), var(--pb-grad-b, var(--pb-indigo-400)));
}
.pb-card__title {
  font-family: var(--pb-font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0 0 .3rem;
  color: var(--pb-ink-900);
}
.pb-card__desc {
  font-size: .9rem;
  color: var(--pb-text-muted);
  margin: 0 0 1rem;
  flex: 1;
}
.pb-card__cta {
  font-size: .85rem;
  font-weight: 600;
  color: var(--pb-primary);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.pb-card:hover .pb-card__cta { color: var(--pb-primary-hover); }

.pb-chip {
  display: inline-block;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--pb-ink-600);
  background: var(--pb-neutral-150);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-r-pill);
  padding: .12rem .55rem;
}

/* ── Stat tiles ───────────────────────────────────────────── */
/* The numbers are the hook, so they're the biggest thing on the page. Shown at
   zero rather than hidden — a new user should still see what gets counted. */
.pb-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1.1rem;
}
.pb-stat {
  background: var(--pb-bg-elev);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-r-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--pb-shadow-sm);
}
.pb-stat__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--pb-r-sm);
  background: var(--pb-stat-bg);
  color: var(--pb-stat);
  font-size: .95rem;
  margin-bottom: .6rem;
}
.pb-stat__num {
  font-family: var(--pb-font-display);
  font-size: clamp(2.5rem, 6vw, 4.25rem);
  line-height: 1;
  font-weight: 600;
  color: var(--pb-stat);
  /* Digits share a width, so a column of numbers doesn't jitter. */
  font-variant-numeric: tabular-nums;
  margin: 0 0 .35rem;
}
.pb-stat__label {
  font-size: .85rem;
  color: var(--pb-text-muted);
  margin: 0;
}

/* ── Role cards ───────────────────────────────────────────── */
.pb-card--role .pb-card__icon { width: 3.4rem; height: 3.4rem; font-size: 1.6rem; }
.pb-card--role .pb-chip { align-self: flex-start; margin-bottom: .75rem; }
/* The chooser renders each card as its own <form>; without this its button
   would stretch the full card width. */
.pb-card--role .pb-btn { align-self: flex-start; }
.pb-card--role.is-preselected {
  border-color: var(--pb-primary);
  box-shadow: var(--pb-shadow-indigo);
}

/* ── Data table (recent projects) ─────────────────────────── */
/* Wide content scrolls inside its own box — the page body must never scroll
   sideways on a phone. */
.pb-tablewrap {
  overflow-x: auto;
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-r-lg);
  background: var(--pb-bg-elev);
  box-shadow: var(--pb-shadow-sm);
}
.pb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  min-width: 40rem;
}
.pb-table thead th {
  text-align: left;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--pb-text-subtle);
  font-weight: 700;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--pb-border);
  background: var(--pb-neutral-50);
  white-space: nowrap;
}
.pb-table tbody th,
.pb-table tbody td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--pb-neutral-100);
  vertical-align: middle;
  text-align: left;
  font-weight: 400;
  color: var(--pb-ink-800);
}
.pb-table tbody th { font-weight: 600; color: var(--pb-ink-900); }
.pb-table tbody tr:last-child th,
.pb-table tbody tr:last-child td { border-bottom: 0; }
.pb-table tbody tr:hover { background: var(--pb-neutral-50); }

/* ── Empty state (recent projects) ────────────────────────── */
.pb-empty {
  border: 1px dashed var(--pb-border-strong);
  border-radius: var(--pb-r-lg);
  background: var(--pb-bg-sunken);
  padding: 2rem;
  text-align: center;
  color: var(--pb-text-subtle);
}
.pb-empty__icon { font-size: 1.8rem; color: var(--pb-ink-400); margin-bottom: .5rem; }

@media (max-width: 700px) {
  /* Four tiles across is unreadable on a phone; two keeps the numbers big. */
  .pb-stats { grid-template-columns: repeat(2, 1fr); }
  .pb-stat { padding: 1rem; }
}

/* ── Institution template library (S9) ────────────────────────────────────── */
.pb-inst-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem; margin-top: 1.5rem;
}
.pb-inst-card {
  border: 1px solid var(--pb-border); border-radius: var(--pb-r-md);
  padding: 1rem 1.1rem; background: var(--pb-bg); display: flex; flex-direction: column; gap: .5rem;
}
.pb-inst-card__head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.pb-inst-card__title { font-size: 1rem; font-weight: 700; color: var(--pb-ink-800); margin: 0; }
.pb-inst-card__foot { display: flex; align-items: center; gap: .6rem; margin-top: auto; flex-wrap: wrap; }

.pb-badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: .15rem .5rem; border-radius: 999px;
  background: var(--pb-neutral-100); color: var(--pb-ink-500);
}
.pb-badge--custom { background: var(--pb-indigo-100); color: var(--pb-indigo-700); }

.pb-inst-weights, .pb-inst-formats { border: 0; padding: 0; margin: 1rem 0; }
.pb-inst-weights {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .5rem .9rem;
}
.pb-inst-weight { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-size: .84rem; }
.pb-inst-weight__num { width: 4.5rem; padding: .3rem .4rem; border: 1px solid var(--pb-border); border-radius: var(--pb-r-sm); }
.pb-inst-formats { display: flex; gap: 1rem; }
