/* ipasc_iqa GUI styles — hand-tune freely.
   Palette anchored on the IPASC navy #001F4C. */

:root {
  --navy:        #001F4C;
  --navy-700:    #0a2f66;
  --accent:      #2563eb;
  --bg:          #f5f7fb;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --text:        #1e293b;
  --muted:       #64748b;
  --ok:          #15803d;
  --warn:        #b45309;
  --radius:      12px;
  --shadow:      0 1px 3px rgba(0, 31, 76, 0.08), 0 6px 20px rgba(0, 31, 76, 0.06);
  --maxw:        1080px;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;  /* the page never scrolls sideways; wide blocks scroll inside */
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Media never forces the page wider than the screen. */
img, svg, video, table { max-width: 100%; }

/* Wrap a wide table in this to let it scroll horizontally on its own. */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 0.6rem; text-decoration: none; }
.brand img { transform: translateY(4px); }
.brand__sub { color: var(--muted); font-size: 1rem; letter-spacing: 0.01em; }
.nav { display: flex; gap: 0.25rem; }
.nav__link {
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--navy);
  font-weight: 500;
  font-size: 0.95rem;
}
.nav__link:hover { background: var(--bg); }
.nav__link.is-active { background: var(--navy); color: #fff; }

/* Hamburger toggle — hidden on wide screens, shown when the bar collapses. */
.nav-toggle {
  display: none;
  flex-direction: column; justify-content: center; gap: 4px;
  width: 2.5rem; height: 2.5rem; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer;
}
.nav-toggle__bar { display: block; width: 1.15rem; height: 2px; margin: 0 auto;
                   background: var(--navy); border-radius: 2px; }

/* ---------- Mobile: collapse the nav into a dropdown ---------- */
@media (max-width: 820px) {
  .topbar { padding: 0.6rem 1rem; gap: 0.75rem; }
  .brand__sub { font-size: 0.85rem; }
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0.15rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow); padding: 0.5rem 1rem 0.75rem;
  }
  .nav--open { display: flex; }
  .nav__link { padding: 0.7rem 0.6rem; font-size: 1rem; }
  .nav__logout { width: 100%; }
  .nav__link--button { width: 100%; text-align: left; }
  .content { padding: 1rem 1rem 3rem; }
  .page-title { font-size: 1.3rem; }
}

/* ---------- Layout ---------- */
.content { max-width: var(--maxw); margin: 0 auto; padding: 2rem 1.5rem 4rem; }
.page-title { color: var(--navy); margin: 0 0 1.25rem; font-size: 1.6rem; }
.footer { text-align: center; color: var(--muted); font-size: 0.8rem; padding: 1.5rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 2rem; text-align: center;
         background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- Welcome ---------- */
.hero { text-align: center; padding: 2.5rem 1rem 1rem; }
.hero__logo { height: 52px; }
.hero__title { color: var(--navy); font-size: 2.2rem; margin: 1rem 0 0.5rem; }
.hero__lead { color: var(--muted); max-width: 40rem; margin: 0 auto; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
         gap: 1.25rem; margin-top: 2.5rem; }
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,31,76,0.12); }
.card--accent { border-color: var(--navy); border-width: 2px; }
.card__icon { font-size: 1.5rem; color: var(--navy); }
.card__title { color: var(--navy); margin: 0.5rem 0 0.35rem; font-size: 1.15rem; }
.card__text { color: var(--muted); margin: 0; font-size: 0.92rem; }

/* ---------- Panels / forms ---------- */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 720px) { .panel-grid { grid-template-columns: 1fr; } }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
}
.panel__title { color: var(--navy); margin: 0 0 0.25rem; font-size: 1.1rem; }
.panel__hint { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.85rem; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
/* Cap long lists at ~half the viewport and scroll internally, so the panels
   stay compact and the Run button below the grid is always visible. */
.checklist--scroll { max-height: 50vh; overflow-y: auto; padding-right: 0.35rem; }
.check { display: flex; align-items: flex-start; gap: 0.6rem; padding: 0.5rem 0.6rem;
         border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.check:hover { border-color: var(--accent); }
.check input { margin-top: 0.25rem; }
.check__label { font-weight: 500; }
.check__label small { display: block; color: var(--muted); font-weight: 400; font-size: 0.78rem; }

/* Each row holds the selectable label plus an optional citation icon, pinned
   to the top-right so it never interferes with the checkbox/label hit area. */
.check-row { position: relative; }
.check-row .check { padding-right: 2.4rem; }
.cite-btn {
  position: absolute; top: 0.5rem; right: 0.5rem;
  width: 1.7rem; height: 1.7rem; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  font-size: 0.8rem; transition: color 0.12s ease, border-color 0.12s ease;
}
.cite-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Inline variant: sits next to text (e.g. in a table cell), not absolutely placed. */
.cite-btn--inline {
  position: static; width: 1.4rem; height: 1.4rem; margin-left: 0.4rem;
  font-size: 0.7rem; vertical-align: middle;
}

/* Measure cell: fixed-width icon slot so names line up whether or not a row
   has a citation icon. */
.measure-cell { display: inline-flex; align-items: center; gap: 0.4rem; }
.measure-cell__icon { flex: 0 0 1.4rem; display: inline-flex; justify-content: center; }
.measure-cell__icon .cite-btn--inline { margin-left: 0; }

/* Citation popup */
.cite-dialog { border: none; border-radius: var(--radius); padding: 0;
               box-shadow: var(--shadow); max-width: min(560px, 92vw); }
.cite-dialog::backdrop { background: rgba(0, 31, 76, 0.35); }
.cite-dialog__card { padding: 1.25rem; }
.cite-dialog__head { display: flex; align-items: center; justify-content: space-between;
                     gap: 1rem; margin-bottom: 0.75rem; }
.cite-dialog__title { color: var(--navy); font-weight: 600; }
.cite-dialog__copy { padding: 0.35rem 0.9rem; font-size: 0.85rem;
                     background: var(--bg); color: var(--navy); }
.cite-dialog__copy:hover { background: var(--border); }
.cite-dialog__text {
  margin: 0; padding: 0.9rem; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.8rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  user-select: text; max-height: 50vh; overflow: auto;
}
.cite-dialog__foot { margin-top: 0.9rem; text-align: right; }

.actions { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0 0.5rem; }
/* Pin the Run bar to the bottom of the viewport so it stays reachable even
   when the (capped, internally-scrolling) measure list makes the page tall. */
.actions--sticky { position: sticky; bottom: 0; padding: 0.75rem 0;
                   background: linear-gradient(to top, var(--bg) 70%, transparent); }
.btn { border: none; border-radius: 8px; padding: 0.6rem 1.4rem; font-size: 1rem;
       font-weight: 600; cursor: pointer; }
.btn--primary { background: var(--navy); color: #fff; }
.btn--primary:hover { background: var(--navy-700); }
.btn--danger { background: #dc2626; color: #fff; }
.btn--danger:hover { background: #b91c1c; }
.btn--sm { padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* Inline role selector in the admin users table. */
.role-form { display: flex; align-items: center; gap: 0.4rem; }
.select--sm { padding: 0.3rem 0.45rem; font-size: 0.85rem; }

/* Logout sits in the nav as a button styled like a link. */
.nav__logout { margin: 0; display: inline; }
.nav__link--button { background: none; border: none; cursor: pointer; font-family: inherit; }

/* Auth pages (login / register / reset / profile): a centred narrow column. */
.auth-wrap { max-width: 26rem; margin: 1.5rem auto; display: flex; flex-direction: column; gap: 1.25rem; }
.auth-wrap--wide { max-width: 32rem; }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; }
.auth-form .field { margin: 0; }

.status { margin-top: 1rem; }
.notice { padding: 0.75rem 1rem; border-radius: 8px; margin: 0; }
.notice--ok { background: #ecfdf5; color: var(--ok); border: 1px solid #a7f3d0; }
.notice--warn { background: #fffbeb; color: var(--warn); border: 1px solid #fde68a; }

.spinner { color: var(--muted); }
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* ---------- Analysis / controls ---------- */
.analysis-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; }
@media (max-width: 820px) { .analysis-layout { grid-template-columns: 1fr; } }
/* Grid items default to min-width:auto and won't shrink below their content,
   which overflows narrow screens — let them shrink so chips/tables fit. */
.analysis-layout > * { min-width: 0; }
.controls {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 1rem; align-self: start; min-width: 0;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; border: none; margin: 0; padding: 0;
         min-width: 0; min-inline-size: 0; }  /* fieldset defaults to min-content width */
.field__label { font-weight: 600; color: var(--navy); font-size: 0.85rem; }
.select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px;
          background: #fff; font-size: 0.95rem; }
.field--preset { margin: 0.2rem 0 0.6rem; }
.measure-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.3rem 0.6rem;
        border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; cursor: pointer; }
.chip input { accent-color: var(--navy); }
.chip--disabled { opacity: 0.45; cursor: not-allowed; background: var(--bg);
                  text-decoration: line-through; }
.chip--disabled input { cursor: not-allowed; }

.result-area { min-height: 4rem; }
.task-block { margin-bottom: 1.5rem; }
.task-block__title { color: var(--navy); font-size: 1rem; margin: 0 0 0.5rem;
                     text-transform: capitalize; }
.check__desc { color: var(--muted); font-weight: 400; font-size: 0.74rem; margin-top: 0.15rem; }
.result-head { margin-bottom: 0.75rem; }
.result-head__top { display: flex; align-items: center; gap: 0.6rem; }
.result-head__title { color: var(--navy); margin: 0; font-size: 1.2rem; }
.result-head__desc { color: var(--muted); margin: 0.4rem 0 0; font-size: 0.9rem;
                     max-width: 60ch; line-height: 1.4; }

/* Methodological metadata for the active task (image/annotation counts). */
.result-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin: 0.7rem 0 0; }
.result-meta__item dt { color: var(--muted); font-size: 0.72rem; text-transform: uppercase;
                        letter-spacing: 0.03em; margin-bottom: 0.1rem; }
.result-meta__item dd { color: var(--navy); margin: 0; font-size: 1.05rem; font-weight: 600; }
.result-meta__sub { color: var(--muted); font-size: 0.78rem; font-weight: 400; }
.badge { background: var(--bg); border: 1px solid var(--border); color: var(--muted);
         border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.75rem; }
.badge--muted { color: #94a3b8; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface);
              border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 0.6rem 0.9rem; text-align: left;
                                  border-bottom: 1px solid var(--border); }
.data-table thead th { background: var(--navy); color: #fff; font-weight: 600; font-size: 0.85rem; }
.data-table tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.corr-cell { font-weight: 600;background: hsl(var(--corr-hue), 70%, 90%); }

.legend { color: var(--muted); font-size: 0.8rem; margin-top: 0.75rem; display: flex;
          align-items: center; gap: 0.4rem; }
.legend__swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 4px;
                  border: 1px solid var(--border); vertical-align: middle; }

/* ---------- Standings ---------- */
.standings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
                  gap: 1.25rem; margin-top: 1rem; }
.standings-card { background: var(--surface); border: 1px solid var(--border);
                  border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.standings-card__title { color: var(--navy); margin: 0 0 0.5rem; font-size: 1.1rem; }
.ranking { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex;
           flex-direction: column; gap: 0.4rem; }
.ranking__row { display: grid; grid-template-columns: 2rem 1fr auto auto; align-items: center;
                gap: 0.5rem; padding: 0.55rem 0.7rem; border-radius: 8px; background: var(--bg); }
.ranking__row--1 { background: #fef9c3; }
.ranking__medal { font-size: 1.2rem; text-align: center; }
.ranking__group { font-weight: 600; }
.ranking__score { font-variant-numeric: tabular-nums; color: var(--muted); }
.ranking__actions { display: inline-flex; align-items: center; gap: 0.25rem; }
/* Info button: same look as the inline citation button. */
.info-btn {
  width: 1.4rem; height: 1.4rem; padding: 0; font-size: 0.7rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--muted); cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.info-btn:hover { color: var(--accent); border-color: var(--accent); }
.ranking__actions .cite-btn--inline { margin-left: 0; }

/* Measure-info popup: reuse the citation dialog frame; the description block
   shouldn't carry its scatter-context top divider here. */
#measure-dialog .cite-dialog__card { max-width: 32rem; }
.measure-dialog__body .measure-desc { margin-top: 0; padding-top: 0; border-top: none; }

/* ---------- Run progress view ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes chip-pop {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes indeterminate-bar {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.run-progress {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
  margin-top: 1.5rem;
}
.run-progress--done { border-color: #6ee7b7; }

.run-progress__header {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 1.05rem; font-weight: 500; color: var(--navy);
}

.progress-spinner {
  display: inline-block; width: 1.1em; height: 1.1em; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
.progress-ok  { color: var(--ok); }
.progress-err { color: var(--warn); }

/* Per-dataset progress block: name + percentage, a bar, then per-measure chips. */
.run-dataset { margin-top: 1.25rem; }
.run-dataset + .run-dataset { border-top: 1px solid var(--border); padding-top: 1rem; }
.run-dataset__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
}
.run-dataset__name { font-weight: 600; color: var(--navy); }
.run-dataset__pct { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.9rem; }
.run-bar {
  margin-top: 0.4rem; height: 0.5rem; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--border); overflow: hidden;
}
.run-bar__fill {
  height: 100%; width: var(--run-progress, 0%); background: var(--accent); border-radius: 999px;
  transition: width 0.4s ease;
}
.run-bar--indeterminate .run-bar__fill {
  width: 35%;
  animation: indeterminate-bar 1.2s ease-in-out infinite;
}
.run-progress--done .run-bar__fill { background: var(--ok); }

.progress-chips {
  list-style: none; margin: 0.7rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.progress-chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.65rem; border-radius: 999px; font-size: 0.82rem; font-weight: 500;
  animation: chip-pop 0.2s ease;
}
.progress-chip--active {
  background: #eff6ff; border: 1px solid #93c5fd; color: #1d4ed8;
}
.progress-chip--done {
  background: #ecfdf5; border: 1px solid #6ee7b7; color: var(--ok);
}
.progress-chip__count {
  font-size: 0.72rem; background: #dbeafe; color: #1d4ed8;
  border-radius: 999px; padding: 0.05rem 0.45rem; min-width: 1.4em; text-align: center;
  font-variant-numeric: tabular-nums;
}
.progress-chip__check { font-size: 0.85rem; }

/* ---------- Tabs in Deatailed analysis -------------------------------- */
.analysis-tabs {
  margin-top: 1rem;
}

.analysis-tabs > input {
  display: none;
}

.analysis-tabs__nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.analysis-tabs__nav label {
  cursor: pointer;
  padding: 0.6rem 0.9rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 0.6rem 0.6rem 0 0;
  color: var(--muted);
  font-weight: 700;
}

#tab-metric-overview:checked ~ .analysis-tabs__nav label[for="tab-metric-overview"],
#tab-human-agreement:checked ~ .analysis-tabs__nav label[for="tab-human-agreement"] {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.analysis-tabs__panel {
  display: none;
}

#tab-metric-overview:checked ~ .analysis-tabs__panel--metric,
#tab-human-agreement:checked ~ .analysis-tabs__panel--human {
  display: block;
}

.analysis-example-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 0.75rem;
}

.corr-cell {
  background: hsl(var(--corr-hue, 0), 70%, 90%);
}

.legend__swatch--weak {
  background: hsl(0, 70%, 90%);
}

.legend__swatch--strong {
  background: hsl(120, 70%, 90%);
}

@media (max-width: 900px) {
  .analysis-example-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Detailed analysis: clickable rows + scatter plot ---------- */
.measure-row { cursor: pointer; transition: background 0.1s ease; }
.measure-row:hover td { background: #eef2ff; }
.measure-row:hover td.corr-cell { filter: brightness(0.97); }

.scatter-result { margin-top: 1.5rem; }
.scatter {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
}
.scatter__head { display: flex; align-items: baseline; justify-content: space-between;
                 gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.scatter__title { color: var(--navy); margin: 0; font-size: 1.05rem; }
.scatter__sub { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.scatter__svg { width: 100%; height: auto; display: block; }
.scatter__tick { fill: var(--muted); font-size: 11px; }
.scatter__axis { fill: var(--text); font-size: 12px; font-weight: 500; }
.scatter__label-name { fill: var(--navy); font-size: 13px; font-weight: 700; }
.scatter__label-stat { fill: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.scatter__legend { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.6rem;
                   font-size: 0.8rem; color: var(--text); }
.scatter__legend-item { display: inline-flex; align-items: center; gap: 0.3rem; }
.scatter__swatch { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 50%; }

/* Measure description shown beneath the scatter plot. */
.measure-desc { margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--border);
                color: var(--text); font-size: 0.9rem; }
.measure-desc p { margin: 0 0 0.4rem; }
.measure-desc__title { font-weight: 600; color: var(--navy); }

/* ---------- Contribute annotations ---------- */
.annotate-login { max-width: 34rem; }
.annotate-login .field, .annotate-picker .field { margin-bottom: 0.9rem; }

/* Picker beside a scrollable annotators leaderboard. The columns share a height
   (grid stretch); the picker drives that height and the table scrolls within it. */
.contribute-layout {
  display: grid; grid-template-columns: minmax(0, 34rem) 1fr;
  gap: 1.25rem; align-items: stretch;
}
@media (max-width: 820px) {
  .contribute-layout { grid-template-columns: 1fr; }
}

.annotators-panel { display: flex; flex-direction: column; min-height: 0; }
.annotators-panel .panel__title { margin-bottom: 0.75rem; }
.annotators-scroll { flex: 1 1 0; min-height: 0; max-height: 60vh; overflow-y: auto; }
.annotators-table thead th { position: sticky; top: 0; }  /* keep header visible while scrolling */
/* Stacked (mobile): the panel height is content-driven, so flex-basis:0 collapses
   the scroll area to nothing — size it to its content (capped) instead. Placed
   after the base rule so it wins the cascade under the media query. */
@media (max-width: 820px) {
  .annotators-scroll { flex: 0 1 auto; max-height: 50vh; }
}

/* While a comparison is on screen, dark-theme the WHOLE page (BT.500 controlled
   surround), not just the stage. `:has()` flips it on automatically when the
   compare fragment is present and reverts for the picker/login. */
body:has(.annotate-stage) {
  background: #1a1a1a;
  color: #ececec;
}
body:has(.annotate-stage) .topbar {
  background: #262626; border-bottom-color: #3a3a3a;
}
body:has(.annotate-stage) .brand__sub { color: #cbd5e1; }
body:has(.annotate-stage) .nav__link { color: #d8dee9; }
body:has(.annotate-stage) .nav__link:hover { background: #333333; }
body:has(.annotate-stage) .nav__link.is-active { background: var(--navy-700); color: #fff; }
body:has(.annotate-stage) .nav-toggle { background: #262626; border-color: #3a3a3a; }
body:has(.annotate-stage) .nav-toggle__bar { background: #d8dee9; }
@media (max-width: 820px) {
  body:has(.annotate-stage) .nav { background: #262626; border-bottom-color: #3a3a3a; }
}
body:has(.annotate-stage) .page-title { color: #ffffff; }
body:has(.annotate-stage) .footer { color: #8a8a8a; }

/* Dark, neutral-grey annotation stage (ITU-R BT.500-style controlled surround). */
.annotate-stage {
  background: #2b2b2b; color: #ececec;
  border-radius: var(--radius); padding: 1.5rem 1.5rem 1.25rem;
  margin-top: 0.5rem; box-shadow: var(--shadow);
}
.annotate-toast {
  background: #14532d; color: #d1fae5; border: 1px solid #16a34a;
  border-radius: 8px; padding: 0.5rem 0.85rem; margin: 0 0 1rem; font-size: 0.9rem;
}
.annotate-prompt {
  text-align: center; font-size: 1.25rem; font-weight: 600;
  color: #fff; margin: 0 0 1.25rem;
}
.annotate-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
  justify-items: center; align-items: center;
}
@media (max-width: 640px) { .annotate-pair { grid-template-columns: 1fr; } }
.annotate-choice { margin: 0; width: 100%; display: flex; justify-content: center; }
.annotate-img-btn {
  padding: 0; border: 3px solid transparent; border-radius: 8px;
  background: #1a1a1a; cursor: pointer; line-height: 0;
  transition: border-color 0.12s ease, transform 0.12s ease;
  max-width: 100%; overflow: hidden;   /* clip the scroll-zoomed image */
}
/* Scroll-to-zoom: clip each image to its box; the transform is driven by JS. */
.annotate-pair img { will-change: transform; }
.annotate-zoom {
  display: inline-block; overflow: hidden; line-height: 0;
  max-width: 100%; border-radius: 5px; background: #1a1a1a;
}
.annotate-img-btn:hover { border-color: #38bdf8; transform: scale(1.01); }
.annotate-img-btn:focus-visible { outline: none; border-color: #7dd3fc; }
.annotate-img-btn img {
  display: block; max-width: 100%; height: auto; border-radius: 5px;
  image-rendering: pixelated;
  max-height: 60vh;   /* fallback for browsers without dvh */
  max-height: 60dvh;
}
.annotate-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-top: 1.25rem; flex-wrap: wrap;
}
.annotate-progress { color: #b8b8b8; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.annotate-finish {
  background: #3f3f3f; color: #ececec; border: 1px solid #5a5a5a;
}
.annotate-finish:hover { background: #4a4a4a; }

/* Single-stimulus MOS rating stage */
.annotate-rate__panel { margin: 0; text-align: center; }
.annotate-rate__panel img {
  display: block; max-width: 100%; height: auto;
  max-height: 55vh;   /* fallback for browsers without dvh */
  max-height: 55dvh;
  border-radius: 5px; background: #1a1a1a; image-rendering: pixelated;
}
.annotate-rate__panel figcaption { color: #b8b8b8; font-size: 0.8rem; margin-top: 0.4rem; }
.annotate-rate__form { margin-top: 1.25rem; }
.annotate-rate__scale {
  display: flex; align-items: center; gap: 0.85rem;
  max-width: 30rem; margin: 0 auto; color: #cfcfcf; font-size: 0.85rem;
}
.annotate-rate__slider { flex: 1 1 auto; accent-color: #38bdf8; cursor: pointer; }
.annotate-rate__value {
  min-width: 1.6em; text-align: center; font-size: 1.2rem; font-weight: 700; color: #fff;
}
.annotate-rate__confirm small { font-weight: 400; opacity: 0.85; }
.annotate-rate__finish { margin-top: 0.75rem; text-align: center; }

/* ---------- Annotation stage: fit one screen on mobile (controls stay visible) ----------
   The rate stage carries a slider + Confirm + Finish below the images, so it
   needs more room for controls (smaller images) than the comparison stage, which
   only has a Finish button. Caps are tuned per stage and per orientation. */
@media (max-width: 820px) {
  .annotate-stage { padding: 0.9rem 0.9rem 1rem; margin-top: 0.25rem; }
  .annotate-prompt { font-size: 1.05rem; margin-bottom: 0.6rem; }
  .annotate-pair { gap: 0.75rem; }
  .annotate-foot { margin-top: 0.7rem; }
  .annotate-rate__form { margin-top: 0.7rem; }
  .annotate-rate__finish { margin-top: 0.4rem; }
  .annotate-rate__panel figcaption { margin-top: 0.25rem; }
}
/* Portrait phones: the pair stacks (two rows), so each image must be small. */
@media (max-width: 640px) {
  .annotate-img-btn img { max-height: 40vh; max-height: 40dvh; }       /* compare + Finish */
  .annotate-rate__panel img { max-height: 26vh; max-height: 26dvh; }   /* rate + slider + 2 buttons */
}
/* Landscape / short phones: the pair is side-by-side (one row) but height is
   scarce, so cap by height; rate still leaves room for its extra controls. */
@media (max-height: 600px) and (min-width: 641px) {
  .annotate-stage { padding: 0.6rem 0.8rem; }
  .annotate-prompt { font-size: 1rem; margin-bottom: 0.4rem; }
  .annotate-img-btn img { max-height: 60vh; max-height: 60dvh; }
  .annotate-rate__panel img { max-height: 44vh; max-height: 44dvh; }
}

/* ---------- Standings ---------- */
.standings-head { display: flex; align-items: flex-end; justify-content: space-between;
                  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.standings-endpoint { display: flex; flex-direction: column; gap: 0.25rem; }

/* ---------- Download ---------- */
.download-contents { color: var(--text); font-size: 0.9rem; margin: 0.5rem 0 1rem; padding-left: 1.2rem; }
.download-contents li { margin: 0.25rem 0; }
.download-contents code { font-size: 0.85em; }

.dataset-status {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.dataset-status--download {
  border: 1px solid #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.dataset-status--ready {
  border: 1px solid #22c55e;
  background: #f0fdf4;
  color: #166534;
}


