/* Library page — page-specific styles. Tokens, base form controls, button
   variants, and the .rb-topnav primitive come from /shared/brand.css. */

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#page-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 12px 0;
}
/* Run-viewer title matches the shared #page-head h1 from brand.css. */
#run-head h1 {
  margin: 0;
  font-family: var(--font-headline);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
}

/* One status contract for the list line (#status) and the run-view line
   (#run-status). */
.status-line {
  min-height: 1.2em;
  color: var(--fg-muted);
  font-size: 13px;
}
.status-line.warn { color: var(--state-warning); }
.status-line.error { color: var(--state-error); }

#list-view,
#run-view {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---- runs list ---------------------------------------------------------- */

.runs-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

/* The empty-state block occupies the whole grid row. */
.runs-grid > .rb-empty { grid-column: 1 / -1; }

.run-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.run-card:hover {
  border-color: var(--fg);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

/* The whole card is one link into the run viewer. */
.run-open {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}

.run-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 160px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.run-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.run-thumb-empty {
  font-size: 12px;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.run-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px 16px;
}

.run-title {
  font-family: var(--font-headline);
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- run viewer ---------------------------------------------------------- */

#run-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0 4px 0;
}

.back-link {
  align-self: flex-start;
  font-size: 13px;
  color: var(--fg-muted);
  text-decoration: none;
}
.back-link:hover { color: var(--fg); text-decoration: underline; }

.run-meta-line {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
}

.run-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.run-filters {
  display: flex;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
}
.run-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--fg-muted);
}
.run-filters select,
.run-filters input {
  min-width: 160px;
}

.hint {
  font-size: 12px;
  color: var(--fg-muted);
}

.files-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.file-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.file-card:hover {
  border-color: var(--fg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.file-open {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  text-align: left;
  /* The whole card is the hit area; the card, not a raised button, reacts. */
  border-radius: 0;
  box-shadow: none;
  translate: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.file-open img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--surface-alt);
  display: block;
}

.file-cap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 10px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}
.chip-warn {
  color: var(--state-warning);
  border-color: var(--state-warning);
}
.chip-dark {
  color: var(--rb-white);
  background: var(--rb-black);
  border-color: var(--rb-black);
}

/* ---- lightbox ------------------------------------------------------------ */

body.lightbox-noscroll { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox-inner {
  position: relative;
  display: flex;
  gap: 0;
  width: min(1240px, 100%);
  height: min(860px, 100%);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.lb-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: var(--btn-radius-sm);
  background: var(--btn-glass-fill);
  cursor: pointer;
}

.lightbox-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-alt);
}
.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 48px;
  padding: 0;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--btn-radius);
  /* Frosted over the creative it sits on. */
  background: var(--btn-glass-fill);
  cursor: pointer;
  opacity: 0.85;
}
.lb-nav:hover { opacity: 1; }
#lb-prev { left: 12px; }
#lb-next { right: 12px; }

.lightbox-side {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.lightbox-side h3 {
  margin: 8px 0 0 0;
  font-family: var(--font-headline);
  font-size: 14px;
}
.lightbox-side .hint { margin: 0; }

.lb-position {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-muted);
}
.lb-file {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg);
  word-break: break-all;
}
.lb-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#lb-comment { resize: vertical; }

@media (max-width: 760px) {
  .lightbox-inner { flex-direction: column; height: 100%; }
  .lightbox-side {
    width: auto;
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}
