/* theme5 gallery. Everything reads --t5-* tokens: the toolbar from the page's theme, each card
   from its own data-theme. Class prefix t5g- so it cannot collide with app styles. */

.t5g { --t5g-card-min: 260px; font-family: var(--t5-font-ui, system-ui, sans-serif); color: var(--t5-text, inherit); }
.t5g *, .t5g *::before, .t5g *::after { box-sizing: border-box; }

/* ---- toolbar -------------------------------------------------------------------------- */
.t5g-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.t5g-search, .t5g-mode {
  font: inherit; font-size: 14px; color: var(--t5-text); background: var(--t5-surface2);
  border: var(--t5-border-width, 1px) solid var(--t5-border); border-radius: var(--t5-radius-sm, 4px);
  padding: 8px 10px; min-height: 38px;
}
.t5g-search { flex: 1 1 200px; min-width: 0; }
.t5g-search:focus-visible, .t5g-mode:focus-visible, .t5g button:focus-visible {
  outline: 2px solid var(--t5-focus); outline-offset: 2px;
}
.t5g-count { font-family: var(--t5-font-label); font-size: 12px; color: var(--t5-text-muted); white-space: nowrap; }
.t5g-chips { display: flex; gap: 6px; flex: 1 0 100%; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.t5g-fchip {
  font: inherit; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  color: var(--t5-text-muted); background: transparent; cursor: pointer; min-height: 34px;
  border: var(--t5-border-width, 1px) solid var(--t5-border); border-radius: 999px; padding: 6px 12px;
}
.t5g-fchip small { font-size: 11px; opacity: .8; }
.t5g-fchip[aria-pressed="true"] { color: var(--t5-accent-text); background: var(--t5-accent); border-color: var(--t5-accent); }

/* ---- list layouts ---------------------------------------------------------------------- */
.t5g-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--t5g-card-min)), 1fr)); }
.t5g-rail {
  display: grid; grid-auto-flow: column; grid-auto-columns: min(82%, var(--t5g-card-min)); gap: 14px;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; overscroll-behavior-x: contain;
}
.t5g-rail > .t5g-card { scroll-snap-align: start; }
.t5g-empty { color: var(--t5-text-muted); padding: 24px 0; }

/* ---- a card: entirely in its own theme --------------------------------------------------- */
.t5g-card {
  display: flex; flex-direction: column; overflow: hidden; color: var(--t5-text);
  background: var(--t5-surface); border: var(--t5-border-width) var(--t5-border-style, solid) var(--t5-border);
  border-radius: var(--t5-radius-lg); box-shadow: var(--t5-shadow);
  transition: transform var(--t5-duration) var(--t5-easing), box-shadow var(--t5-duration) var(--t5-easing);
}
.t5g-card:hover { transform: translateY(-2px); }
.t5g-card.t5g-current { outline: 2px solid var(--t5-accent); outline-offset: 2px; box-shadow: var(--t5-glow), var(--t5-shadow); }
.t5g-hit { all: unset; display: block; cursor: zoom-in; }
.t5g-hit:focus-visible { outline: 2px solid var(--t5-focus); outline-offset: -2px; }

.t5g-specimen {
  display: grid; gap: 8px; padding: 10px; font-family: var(--t5-font-ui); font-size: 12px;
  background-color: var(--t5-bg); background-image: var(--t5-texture); color: var(--t5-text);
  border-bottom: var(--t5-border-width) var(--t5-border-style, solid) var(--t5-border);
}
.t5g-bar { display: flex; align-items: center; gap: 6px; }
.t5g-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--t5-accent-fill); box-shadow: var(--t5-glow); }
.t5g-title {
  flex: 1; font-family: var(--t5-font-display); font-weight: var(--t5-heading-weight); font-size: 15px;
  text-transform: var(--t5-heading-transform); letter-spacing: var(--t5-heading-tracking);
  text-shadow: var(--t5-heading-shadow); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.t5g-label {
  font-family: var(--t5-font-label); font-size: min(var(--t5-label-size), 10px); font-weight: var(--t5-label-weight, 400); color: var(--t5-text-muted);
  text-transform: var(--t5-label-transform); letter-spacing: var(--t5-label-tracking);
}
.t5g-grid2 { display: grid; grid-template-columns: 1fr 1.2fr; gap: var(--t5-gap); background: var(--t5-seam); }
.t5g-panel {
  display: flex; flex-direction: column; gap: 4px; padding: 8px; min-width: 0;
  background: var(--t5-surface); border: var(--t5-border-width) var(--t5-border-style, solid) var(--t5-border); border-radius: var(--t5-radius);
}
.t5g-stat { font-family: var(--t5-font-display); font-weight: var(--t5-heading-weight); font-size: 22px; line-height: 1; text-shadow: var(--t5-heading-shadow); }
.t5g-bars { display: flex; align-items: flex-end; gap: 3px; height: 30px; }
.t5g-bars span { flex: 1; border-radius: 1px; min-height: 3px; }
.t5g-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.t5g-rows li { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding-bottom: 3px; border-bottom: 1px var(--t5-border-style, solid) var(--t5-border); }
.t5g-rows li:last-child { border-bottom: 0; }
.t5g-rows li > span:first-child { color: var(--t5-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* chips cap at 9px but follow a smaller label size, so pixel fonts stay on their grid */
.t5g-chip { font-family: var(--t5-font-label); font-size: min(var(--t5-label-size), 9px); font-weight: var(--t5-label-weight, 400);
  text-transform: var(--t5-label-transform); letter-spacing: var(--t5-label-tracking);
  padding: 2px 5px; border-radius: var(--t5-radius-sm); border: 1px solid currentColor; white-space: nowrap; }
.t5g-chip.t5g-ok { color: var(--t5-ok); } .t5g-chip.t5g-warn { color: var(--t5-warn); } .t5g-chip.t5g-danger { color: var(--t5-danger); }
.t5g-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.t5g-input {
  flex: 1; min-width: 60px; padding: 4px 6px; color: var(--t5-text-faint); background: var(--t5-surface2);
  border: var(--t5-border-width) var(--t5-border-style, solid) var(--t5-border-strong); border-radius: var(--t5-radius-sm);
}
.t5g-link { color: var(--t5-link); text-decoration: underline; text-underline-offset: 2px; }

/* buttons: shared by specimen (spans) and real buttons */
.t5g-btn {
  font: inherit; font-family: var(--t5-font-ui); font-size: 12px; line-height: 1.2; cursor: pointer; white-space: nowrap;
  padding: 6px 10px; border-radius: var(--t5-radius-pill, var(--t5-radius-sm));
  border: var(--t5-border-width) var(--t5-border-style, solid) transparent;
  transition: background var(--t5-duration) var(--t5-easing), color var(--t5-duration) var(--t5-easing);
}
.t5g-primary { background: var(--t5-accent-fill); color: var(--t5-accent-text); border-color: var(--t5-accent); box-shadow: var(--t5-glow); }
button.t5g-primary:hover:not(:disabled) { background: var(--t5-btn-hover-bg); color: var(--t5-btn-hover-fg); }
.t5g-ghost { background: transparent; color: var(--t5-text); border-color: var(--t5-border-strong); }
button.t5g-ghost:hover { background: var(--t5-accent-soft); }
button.t5g-btn:disabled { cursor: default; opacity: .65; box-shadow: none; }
.t5g-specimen .t5g-btn { font-size: 10px; padding: 4px 8px; cursor: inherit; }

/* meta under the specimen (still inside the card's theme) */
.t5g-meta { display: grid; gap: 6px; padding: 10px 12px 12px; }
.t5g-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.t5g-name h3 {
  margin: 0; font-family: var(--t5-font-display); font-weight: var(--t5-heading-weight); font-size: 16px;
  text-transform: var(--t5-heading-transform); letter-spacing: var(--t5-heading-tracking);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.t5g-badge { font-family: var(--t5-font-label); font-size: 10px; padding: 2px 6px; border-radius: 999px;
  background: var(--t5-accent); color: var(--t5-accent-text); text-transform: uppercase; letter-spacing: .06em; }
.t5g-badge-dim { background: var(--t5-surface2); color: var(--t5-text-muted); }
.t5g-tagline { margin: 0; font-size: 13px; color: var(--t5-text-muted); line-height: 1.35; min-height: 2.7em; }
.t5g-strip { display: flex; height: 8px; border-radius: 999px; overflow: hidden; border: 1px var(--t5-border-style, solid) var(--t5-border); }
.t5g-strip span { flex: 1; }
.t5g-cardbtns { display: flex; gap: 8px; justify-content: flex-end; }
.t5g-cardbtns .t5g-btn { font-size: 13px; padding: 8px 14px; min-height: 36px; }

/* ---- preview bar ----------------------------------------------------------------------- */
.t5g-previewbar {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2147483000;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  width: max-content; max-width: calc(100vw - 32px); padding: 10px 12px;
  font-family: var(--t5-font-ui); font-size: 14px; color: var(--t5-text); background: var(--t5-surface3);
  border: var(--t5-border-width) solid var(--t5-border-strong); border-radius: var(--t5-radius-lg); box-shadow: var(--t5-shadow);
}
.t5g-previewbar[hidden] { display: none; }
.t5g-previewbar .t5g-btn { font-size: 13px; padding: 8px 12px; min-height: 36px; }

/* ---- details dialog -------------------------------------------------------------------- */
.t5g-dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto;
  color: var(--t5-text); background: var(--t5-surface); border: var(--t5-border-width) solid var(--t5-border-strong);
  border-radius: var(--t5-radius-lg); box-shadow: var(--t5-shadow); font-family: var(--t5-font-ui);
}
.t5g-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.t5g-dlg { display: grid; gap: 14px; padding: 16px; }
.t5g-dlg header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.t5g-dlg h2 { margin: 0; font-family: var(--t5-font-display); font-weight: var(--t5-heading-weight);
  text-transform: var(--t5-heading-transform); letter-spacing: var(--t5-heading-tracking); text-shadow: var(--t5-heading-shadow); }
.t5g-dlg p { margin: 0; line-height: 1.5; }
.t5g-x { font-size: 24px; line-height: 1; width: 40px; height: 40px; cursor: pointer; color: var(--t5-text-muted);
  background: transparent; border: var(--t5-border-width) solid var(--t5-border); border-radius: var(--t5-radius-sm); }
.t5g-big { font-size: 14px; padding: 14px; border: var(--t5-border-width) solid var(--t5-border); border-radius: var(--t5-radius); }
.t5g-big .t5g-title { font-size: 20px; } .t5g-big .t5g-stat { font-size: 34px; } .t5g-big .t5g-bars { height: 48px; }
.t5g-big .t5g-btn { font-size: 13px; padding: 6px 12px; } .t5g-big .t5g-chip { font-size: 11px; }
.t5g-insp { color: var(--t5-text-muted); font-size: 14px; }
.t5g-fonts { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.t5g-f-display { font-family: var(--t5-font-display); font-weight: var(--t5-heading-weight); font-size: 22px; }
.t5g-f-ui { font-family: var(--t5-font-ui); font-size: 16px; }
.t5g-f-mono { font-family: var(--t5-font-mono); font-size: 15px; color: var(--t5-text-muted); }
.t5g-palette { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 6px; }
.t5g-palette li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.t5g-sw { width: 22px; height: 22px; border-radius: var(--t5-radius-sm); border: 1px solid var(--t5-border-strong); }
.t5g-palette code { font-family: var(--t5-font-mono); font-size: 11px; color: var(--t5-text-muted); }
.t5g-dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.t5g-dlg-actions .t5g-btn { font-size: 14px; padding: 10px 14px; min-height: 40px; }

@media (prefers-reduced-motion: reduce) {
  .t5g-card, .t5g-btn { transition: none; }
  .t5g-card:hover { transform: none; }
}
