/* Model Verdict — stylesheet built against the Figma design (Phase 1).
   Tokens below come from the landing-frame get_design_context pull (exact values)
   and the loading/comparison/winner/expanded frame exports (greens/accents are
   close approximations read off the PNGs). */

@font-face {
  font-family: "Inter";
  src: url("/vendor/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* surfaces + lines */
  --bg: #fafafc;
  --surface: #ffffff;
  --border: #e7e5ef;
  --border-soft: #e4e1e1;
  /* brand */
  --accent: #7a50c9;
  --glow: 0 5px 50px rgba(141, 32, 208, 0.25);
  --glow-soft: 0 5px 50px rgba(144, 91, 197, 0.25);
  /* text */
  --ink: #131212;
  --gray-1: #595757;
  --gray-2: #6b6868;
  --gray-3: #827f7f;
  --badge-blue: #3182d8;
  /* verdict / success greens (approximated from the frame PNGs) */
  --green: #28a745;
  --green-ink: #1e8e3e;
  --green-bg: #eefaf1;
  --green-border: #cdeed8;
  /* radii */
  --r-btn: 15px;
  --r-card: 20px;
  --r-pill: 30px;
}

* { box-sizing: border-box; }

/* The views/layouts are toggled via the hidden attribute; keep it winning over
   any display value set by a more specific rule (e.g. #columns { display: grid }). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  color-scheme: light;
}

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ---------- header ---------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 24px 8px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 24px;
  display: grid;
  place-items: center;
}

.logo-name {
  font-size: 26px;
  font-weight: 700;
}

/* ---------- landing ---------- */

.hero { text-align: center; margin-top: 56px; }

.hero-badge {
  display: inline-block;
  background: #f6f6f6;
  border: 2px solid var(--border-soft);
  border-radius: var(--r-pill);
  color: var(--badge-blue);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 10px 22px;
}

.hero-title {
  margin: 26px 0 0;
  font-size: clamp(2.1rem, 4.5vw, 3.375rem);
  font-weight: 700;
  line-height: 1.15;
}

.hero-title .hero-accent {
  display: block;
  color: var(--accent);
  font-size: 0.89em;
}

.hero-subtitle {
  margin: 22px auto 0;
  max-width: 560px;
  color: var(--gray-3);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
}

.prompt-card {
  position: relative;
  margin-top: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--glow);
}

.prompt-card textarea {
  display: block;
  width: 100%;
  min-height: 150px;
  padding: 26px 96px 26px 28px;
  border: 0;
  border-radius: var(--r-card);
  resize: none;
  background: transparent;
  font: 600 19px/1.45 "Inter", system-ui, sans-serif;
  color: var(--ink);
}

.prompt-card textarea::placeholder { color: var(--gray-3); }
.prompt-card textarea:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.send-button {
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: var(--r-btn);
  background: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.send-button svg { width: 26px; height: 23px; transform: rotate(90deg); }
.send-button:hover { filter: brightness(1.08); }
.send-button:disabled { opacity: 0.55; cursor: default; }

/* ---------- contestant picker ---------- */

.contestants { margin-top: 40px; text-align: center; }

.contestants-head {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 12px;
}

.contestants-label { color: var(--gray-2); font-size: 18px; font-weight: 700; }

.contestants-hint { color: var(--gray-3); font-size: 14px; font-weight: 600; }
.contestants-hint.error { color: #b3261e; }

.model-menu { margin-top: 6px; }

.model-group-label {
  margin-top: 18px;
  color: var(--gray-3);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.model-group-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
}

.model-chip {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-card);
  color: var(--gray-1);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  padding: 12px 20px;
  cursor: pointer;
}

.model-chip:hover { border-color: var(--gray-3); }

.model-chip.selected {
  border-color: var(--accent);
  color: var(--accent);
  background: #f6f1fd;
  box-shadow: 0 0 0 2px rgba(122, 80, 201, 0.15);
}

.model-chip.selected::before { content: "✓ "; }

.examples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 44px;
}

.examples-label { color: var(--gray-2); font-size: 18px; font-weight: 700; }

.chip {
  border: 2px solid #fffcfc;
  border-radius: var(--r-card);
  background: #ddd9d9;
  box-shadow: var(--glow-soft);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  padding: 14px 24px;
  cursor: pointer;
}

.chip:hover { background: #d0cccc; }

/* ---------- shared view chrome ---------- */

.view-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
}

.ghost-button {
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  padding: 12px 20px;
  cursor: pointer;
}

.ghost-button:hover { border-color: var(--gray-3); }

.question-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
}

.question-title {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.question-row .ghost-button { flex: none; white-space: nowrap; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(19, 18, 18, 0.25);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 10;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- pipeline indicator ---------- */

.pipeline {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 24px;
}

.stages {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0;
  margin: 0;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-3);
}

.stages li { display: flex; align-items: center; }

.stages li + li::before {
  content: "→";
  margin: 0 10px;
  color: var(--gray-3);
}

.stages li.active { color: var(--accent); }
.stages li.done { color: var(--green-ink); }

.stages li.active .stage-name::after {
  content: "…";
  animation: ellipsis 1.2s steps(4) infinite;
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}

@keyframes ellipsis { 0% { width: 0; } 100% { width: 1.1em; } }

.progress-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}

.progress-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: #e9e7ee;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: var(--green);
  transition: width 0.5s ease;
}

.progress-pct { font-size: 17px; font-weight: 700; min-width: 3.2em; text-align: right; }

.pipeline-status { margin: 12px 0 0; color: var(--gray-2); font-size: 15px; font-weight: 600; }
.pipeline-status.error { color: #b3261e; }

/* ---------- comparison: layout toggle ---------- */

.layout-toggle {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.layout-toggle .toggle-group {
  display: inline-flex;
  background: #e9e7ee;
  border-radius: 10px;
  padding: 3px;
}

.layout-toggle button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--gray-1);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  padding: 8px 14px;
  cursor: pointer;
}

.layout-toggle button.active { background: var(--surface); color: var(--accent); }

/* ---------- comparison: cards ---------- */

#columns {
  display: grid;
  /* The run's own column count, set by app.js. auto-fit used to decide this from the
     available width, which silently dropped a 4-model run to 3 + 1 on any viewport
     between 901px and 1159px and orphaned the fourth card on its own short row. */
  grid-template-columns: repeat(var(--column-count, 3), minmax(0, 1fr));
  gap: 24px;
  margin-top: 18px;
  align-items: stretch;
}

.column-cell { display: flex; flex-direction: column; min-width: 0; }

/* A column that produced nothing: muted, and visibly not a candidate. */
.column.unavailable { opacity: 0.62; }
.column.unavailable .response-body { color: var(--gray-2); font-style: italic; }
.column.unavailable:hover { cursor: default; border-color: var(--border); }
tr.unavailable { opacity: 0.62; }
tr.unavailable:hover { cursor: default; }

.column {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 2px 14px rgba(19, 18, 18, 0.05);
  padding: 22px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.column:hover { border-color: var(--gray-3); }

.column.picked {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(122, 80, 201, 0.35), var(--glow-soft);
}

.column h3 { margin: 0 0 12px; font-size: 20px; font-weight: 700; }

.column .body {
  flex: 1;
  min-height: 7rem;
  max-height: 300px;
  overflow: hidden;
  white-space: pre-wrap;
  color: var(--gray-1);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.column .body.rendered { white-space: normal; }

/* fade the clamped preview out at the bottom once the answer is in */
.column .body.rendered {
  -webkit-mask-image: linear-gradient(#000 82%, transparent);
          mask-image: linear-gradient(#000 82%, transparent);
}

.column .body pre { background: #f4f4f4; padding: 0.6rem; border-radius: 6px; overflow-x: auto; }
.column .body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.column .body :not(pre) > code { background: #f0f0f0; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.9em; }
.column .body pre code { font-size: 0.85rem; }
.column .body h1, .column .body h2, .column .body h3 { font-size: 1rem; margin: 0.6rem 0 0.3rem; }
.column .body p { margin: 0.4rem 0; }
.column .body ul, .column .body ol { margin: 0.4rem 0; padding-left: 1.2rem; }

.card-footer { margin-top: auto; padding-top: 14px; }

.card-footer .stats { color: var(--gray-2); font-size: 14px; font-weight: 600; margin-bottom: 12px; }

.read-full {
  width: 100%;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  padding: 13px 16px;
  cursor: pointer;
}

.read-full:disabled { opacity: 0.45; cursor: default; }

/* per-column accent tints (comparison frame: green / orange / blue) */
.accent-0 { background: #e9f7ee; color: #1c8c4e; }
.accent-1 { background: #fbefe3; color: #c4732a; }
.accent-2 { background: #e7eefb; color: #2467c7; }

.model-link {
  display: inline-block;
  margin: 12px auto 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.model-link:hover { text-decoration: underline; }

/* ---------- comparison: table view ---------- */

#table-wrap { margin-top: 18px; overflow-x: auto; }

#results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
}

#results-table th, #results-table td {
  padding: 14px 18px;
  text-align: left;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

#results-table tr:last-child td { border-bottom: 0; }

#results-table th { color: var(--gray-2); font-size: 13px; letter-spacing: 0.03em; text-transform: uppercase; }

#results-table tbody tr { cursor: pointer; }
#results-table tbody tr:hover td { background: #faf8fd; }
#results-table tbody tr.picked td { background: #f3edfc; }
#results-table tbody tr.picked td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

#results-table .row-model { font-weight: 700; white-space: nowrap; }

#results-table .row-preview {
  color: var(--gray-1);
  max-width: 420px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#results-table .row-meta { white-space: nowrap; color: var(--gray-2); font-weight: 600; }

#results-table .row-read button {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 700;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- pick status + verdict strip ---------- */

.handoff-hint {
  margin: 16px 0 0;
  color: var(--gray-3);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

#pick-status { margin: 18px 0 0; font-weight: 700; min-height: 1.2em; }

.verdict-strip {
  margin-top: 18px;
  background: #f4f3f6;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 22px 26px;
}

.verdict-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.verdict-trophy {
  width: 62px;
  height: 62px;
  flex: none;
  border-radius: 50%;
  background: #fbe9e7;
  font-size: 30px;
  display: grid;
  place-items: center;
}

.verdict-text { flex: 1; min-width: 220px; }

.verdict-label { color: var(--gray-2); font-size: 14px; font-weight: 700; }

.verdict-line { margin-top: 4px; font-size: 18px; font-weight: 700; }
.verdict-line .verdict-why { font-weight: 600; color: var(--gray-1); }

.verdict-confidence {
  text-align: center;
  padding: 0 18px;
  border-left: 1px solid #dcd9e3;
}

.verdict-confidence .conf-label { color: var(--gray-2); font-size: 14px; font-weight: 700; }
.verdict-confidence .conf-value { color: var(--green-ink); font-size: 34px; font-weight: 700; }

.verdict-caption { margin-top: 14px; color: var(--gray-3); font-size: 13px; font-weight: 600; }

.verdict-exchange { margin-top: 14px; border-top: 1px solid #dcd9e3; padding-top: 14px; font-size: 15px; }
.verdict-exchange .verdict { color: var(--gray-1); }
.verdict-exchange .verdict p { margin: 0.4rem 0; }
.verdict-exchange .verdict code { background: #eceaf0; padding: 0.1rem 0.3rem; border-radius: 4px; }

/* ---------- winner view ---------- */

.winner-hero { position: relative; text-align: center; margin-top: 44px; }

.winner-trophy {
  width: 108px;
  height: 108px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--green-bg);
  font-size: 54px;
  display: grid;
  place-items: center;
}

.winner-kicker { margin-top: 20px; font-size: 15px; font-weight: 700; letter-spacing: 0.12em; }

.winner-name { margin: 8px 0 0; font-size: clamp(2rem, 4vw, 3rem); font-weight: 700; }

.winner-why {
  margin: 18px auto 0;
  max-width: 620px;
  color: var(--gray-2);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
}

.winner-link { display: inline-block; margin-top: 14px; font-size: 17px; }

/* confetti: a handful of falling ticks over the hero */
.confetti { position: absolute; inset: -20px 0 auto; height: 240px; pointer-events: none; overflow: hidden; }

.confetti i {
  position: absolute;
  top: -12px;
  width: 7px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.9;
  animation: confetti-fall 2.6s ease-in infinite;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.9; }
  100% { transform: translateY(240px) rotate(300deg); opacity: 0; }
}

.strength-tiles {
  display: grid;
  /* the judge returns UP TO four strengths — fill the row with what arrived */
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 40px;
}

.strength-tile {
  background: #fdf7f7;
  border: 1px solid var(--green-border);
  border-radius: var(--r-card);
  padding: 26px 18px;
  text-align: center;
}

.strength-tile .tile-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--green-bg);
  font-size: 24px;
  display: grid;
  place-items: center;
}

.strength-tile .tile-title { margin-top: 14px; color: var(--green-ink); font-size: 19px; font-weight: 700; }
.strength-tile .tile-note { margin-top: 10px; color: var(--gray-2); font-size: 15px; font-weight: 600; line-height: 1.4; }

.winner-others { margin-top: 40px; }
.winner-others h3 { margin: 0 0 10px; font-size: 18px; }
.winner-others ul { margin: 0; padding-left: 1.25rem; color: var(--gray-1); font-size: 15px; line-height: 1.6; }

.winner-confidence { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 40px; }
.winner-confidence .conf-label { flex-basis: 100%; color: var(--gray-2); font-size: 15px; font-weight: 700; }
.winner-confidence .progress-track { max-width: 560px; }
.winner-confidence .conf-value { font-size: 26px; font-weight: 700; }

.winner-actions { display: flex; justify-content: flex-end; margin-top: 28px; }

.winner-actions .ghost-button { color: var(--green-ink); border-color: var(--green-border); }

.winner-caption { margin-top: 26px; color: var(--gray-3); font-size: 13px; font-weight: 600; text-align: center; }

/* ---------- expanded view ---------- */

.expanded-title { margin: 30px 0 0; font-size: 28px; font-weight: 700; }

.response-body {
  margin-top: 18px;
  color: var(--gray-1);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.response-body.plain { white-space: pre-wrap; }
.response-body pre { background: #f4f4f4; padding: 0.7rem; border-radius: 8px; overflow-x: auto; }
.response-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.response-body :not(pre) > code { background: #f0f0f0; padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.9em; }
.response-body h1, .response-body h2, .response-body h3 { font-size: 1.15rem; margin: 1rem 0 0.4rem; }

/* ---------- small screens ---------- */

@media (max-width: 900px) {
  #columns { grid-template-columns: 1fr; }
  .strength-tiles { grid-template-columns: repeat(2, 1fr); }
}
