/* Claude-inspired warm-neutral palette, generous spacing, simple type. */

:root {
  --bg: #f5f4ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --border: #e6e2d6;
  --border-strong: #d6d2c4;
  --text: #1f1e1b;
  --text-muted: #6b6a64;
  --text-faint: #93908a;
  --accent: #c96442;        /* Claude warm orange */
  --accent-hover: #b3563a;
  --accent-soft: #f5e8e1;
  --accent-soft-strong: #ecd6c8;
  --error: #b3261e;
  --shadow: 0 1px 2px rgba(31, 30, 27, 0.04),
            0 4px 16px rgba(31, 30, 27, 0.04);
  --shadow-strong: 0 1px 2px rgba(31, 30, 27, 0.04),
                   0 6px 24px rgba(31, 30, 27, 0.08);
  --radius: 14px;
  --radius-sm: 8px;
  --font-serif: 'Source Serif 4', 'Source Serif Pro', 'Iowan Old Style',
                'Apple Garamond', Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI',
               Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 30px; line-height: 1.2; margin: 0 0 8px; }
h2 { font-size: 19px; margin: 32px 0 12px; }
h3 { font-size: 17px; margin: 0 0 10px; }
p  { margin: 12px 0; }

.subtitle { color: var(--text-muted); font-size: 15px; margin: 0 0 32px; }
.muted { color: var(--text-muted); }
em { font-style: italic; color: var(--text); }

.brand { margin-bottom: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.dim-list { padding-left: 18px; }
.dim-list li { margin: 6px 0; }

/* Initial consent page gets a slightly wider card for breathing room. */
main:has(#view-consent:not([hidden])) {
  max-width: 836px;
}

/* Eval page is much wider for the side-by-side image grid + rank panel. */
main:has(#view-eval:not([hidden])) {
  max-width: 1640px;
}

/* ----- form / inputs ----- */

.field {
  display: flex; flex-direction: column; gap: 6px;
  margin: 20px 0;
}
.field span {
  font-size: 13px; color: var(--text-muted); font-weight: 500;
}
.field input[type="text"] {
  font: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkbox {
  display: flex; gap: 12px; align-items: flex-start;
  margin: 20px 0 28px;
  font-size: 14px; line-height: 1.5; color: var(--text);
}
.checkbox input {
  margin-top: 4px; width: 16px; height: 16px; flex-shrink: 0;
  accent-color: var(--accent);
}

.btn {
  font: inherit; font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
  border: 1px solid transparent;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.link {
  background: none; border: none; padding: 8px 0;
  color: var(--text-muted); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { color: var(--text); }

.error { color: var(--error); font-size: 13px; margin: 12px 0 0; }

/* ===========================================================================
 * Eval header / progress
 * ======================================================================== */

.eval-header {
  margin-bottom: 22px;
  padding: 0 4px;
  display: flex; flex-direction: column; gap: 10px;
}
.eval-header-top {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px;
}
.batch-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.batch-status {
  font-size: 13px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.progress-bar {
  height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
#progress-fill {
  height: 100%; width: 0;
  background: var(--accent);
  transition: width .25s ease;
}
.eval-tip {
  margin: 4px 0 0;
  font-size: 13px; color: var(--text-muted);
}

/* ===========================================================================
 * Eval body: left = 2×3 image grid, right = 3 vertical rank columns
 * ======================================================================== */

.eval-body {
  display: grid;
  /* Left flexes to fill, right is a fixed-width sidebar so the rank panel
     stays compact and the image grid takes most of the room. */
  grid-template-columns: minmax(0, 1fr) 216px;
  gap: 28px;
  margin-bottom: 18px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

/* Right side container: rank columns + legend, sticky alongside the tall
   image grid so users can keep ranking in view while scrolling. */
.eval-side {
  display: flex; flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 24px;
  align-self: start;
}

.img-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .15s ease, box-shadow .15s ease,
              transform .12s ease;
}
/* When a rank slot is armed, the image cards become explicitly clickable. */
.image-grid.armed .img-card {
  cursor: pointer;
}
.image-grid.armed .img-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-strong);
  transform: translateY(-1px);
}
.img-card.unavailable {
  opacity: 0.55;
  cursor: not-allowed !important;
}

.image-wrap {
  position: relative;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  /* Source screenshots are 4:3, so match the container aspect to avoid the
     letterbox bars that 16:10 produced. */
  aspect-ratio: 4 / 3;
}
.image-wrap img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

.img-rank-badges {
  position: absolute;
  top: 8px; right: 8px;
  display: flex; gap: 4px;
}
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  background: rgba(31, 30, 27, 0.55);
  color: #f5e8e1;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  visibility: hidden;
}
.rank-badge.set { visibility: visible; }
.rank-badge[data-dim="quality"]   { color: #ffd9c8; }
.rank-badge[data-dim="realism"]   { color: #ffe6b3; }
.rank-badge[data-dim="diversity"] { color: #cfe6ff; }

.img-pos {
  display: flex; align-items: center; justify-content: center;
}
.img-pos-circle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
/* When a card is the most recently filled (across any dim), pop the circle. */
.img-card.recent .img-pos-circle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===========================================================================
 * Rank panel — vertical columns side by side (one per dimension)
 * ======================================================================== */

.rank-cols {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 14px 14px;
  /* Stretch to .eval-side full width so the legend below it lines up. */
  width: 100%;
}

.rank-col {
  display: flex; flex-direction: column;
  gap: 8px;
  padding: 8px 6px 6px;
  border-radius: var(--radius-sm);
  transition: background .15s ease;
}
.rank-col.active {
  background: var(--accent-soft);
}
.rank-col.complete .rank-col-label::after {
  content: " ✓";
  color: var(--accent);
}

.rank-col-head {
  display: flex; align-items: center; justify-content: center;
}
.rank-col-label {
  font-weight: 500;
  font-size: 13px;
  text-align: center;
  letter-spacing: 0.02em;
}

.rank-slots {
  display: flex; flex-direction: column;
  gap: 6px;
}
.rank-slot {
  position: relative;
  font: inherit;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.rank-slot:hover { background: #efece2; }
.rank-slot .slot-rank {
  font-size: 11px; color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-align: left;
}
.rank-slot .slot-fill {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  min-width: 18px;
  text-align: center;
}
.rank-slot.filled {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--text);
}
.rank-slot.filled .slot-fill {
  color: var(--accent);
}
.rank-slot.armed {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.rank-slot.armed .slot-rank,
.rank-slot.armed .slot-fill {
  color: #fff;
}

.rank-clear {
  font-size: 12px;
  padding: 6px 10px;
  white-space: nowrap;
  align-self: center;
  margin-top: 2px;
}

/* ===========================================================================
 * Inline dimension explanations (3 short lines below the eval body)
 * ======================================================================== */

.dim-explain-inline {
  /* Width must match the .rank-cols panel above it (both are children of
     .eval-side, so a flush 0 horizontal margin lines them up exactly). */
  margin: 0;
  width: 100%;
  display: flex; flex-direction: column; gap: 4px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-muted);
}
.dim-explain-inline strong {
  color: var(--text);
  font-weight: 600;
}

/* ===========================================================================
 * Eval footer & dimension explanations
 * ======================================================================== */

.eval-footer {
  position: sticky;
  bottom: 0;
  margin-top: 6px;
  padding: 14px 18px;
  background: rgba(245, 244, 238, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: flex-end;
  gap: 14px;
  z-index: 10;
}
.eval-footer .error { margin: 0; }

/* ===========================================================================
 * Done view
 * ======================================================================== */

.done-card { text-align: center; padding: 48px 32px; }
.done-card h1 { margin-bottom: 12px; }
.done-card .link { margin-top: 18px; }

/* ===========================================================================
 * Responsive
 * ======================================================================== */

/* ≤ ~1080px: collapse to vertical stacking — image grid full width on top,
   rank panel below it. Image grid drops to 2 cols. */
@media (max-width: 1080px) {
  .eval-body {
    grid-template-columns: 1fr;
  }
  .image-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
  main { padding: 24px 14px 60px; }
  .card { padding: 20px; }
  .image-grid { grid-template-columns: 1fr; gap: 12px; }
  .rank-cols { padding: 12px 10px; gap: 6px; }
  .rank-slot { min-height: 34px; padding: 3px 5px; }
  .rank-slot .slot-fill { font-size: 15px; }
  .rank-slot .slot-rank { font-size: 10px; }
  h1 { font-size: 24px; }
  .batch-title { font-size: 19px; }
}
