/*
 * Assessment Portal — hand-written design system, styled after scalepunk.com.
 * No framework, no CDN: CSP is 'self'.
 *
 * Brand, taken from the site: ink #222, acid lime #dff86e, white page with
 * #f5f5f5 bands, pill-shaped controls, and lowercase headings on tight
 * negative tracking.
 *
 * Light only, matching the site, which has no dark theme. The explicit
 * color-scheme below is what makes that hold on a machine set to dark: without
 * it the browser still paints native controls — date pickers, selects,
 * scrollbars, autofill — dark, against our white page.
 */

:root {
  color-scheme: light;

  --ink: #222222;
  --lime: #dff86e;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --border: #e4e4e4;
  --text: #222222;
  /* The site uses #b1b1b1 for secondary text. That is 1.9:1 on white — fine for
     a landing page, not for a tool people read all day. Kept as the hairline
     colour only; muted text is darkened to clear 4.5:1. */
  --hairline: #b1b1b1;
  --text-muted: #63666a;

  --accent: #222222;
  --accent-hover: #000000;
  --accent-soft: #f1fbcf;
  --on-accent: #ffffff;
  /* Lime reads as emphasis, never as a text colour — it fails contrast on white. */
  --highlight: #dff86e;

  --danger: #c0392b;
  --danger-soft: #fbeae8;
  --ok: #1e7d51;
  --ok-soft: #e9f5ef;
  --warn: #8a5d05;
  --warn-soft: #fbf2df;
  --info: #2b5c96;
  --info-soft: #ecf1f7;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --space: 8px;
  --shadow: 0 1px 2px rgba(34, 34, 34, 0.04), 0 6px 20px rgba(34, 34, 34, 0.05);
  /* The same stack scalepunk.com serves, so the portal renders exactly as the
     site does on any given machine. No webfont, so nothing to load off-origin. */
  --font: 'Work Sans', -apple-system, 'system-ui', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

/* Tight negative tracking at weight 600 is the site's headline signature. */
h1, h2, h3, h4, h5 {
  line-height: 1.2; margin: 0 0 calc(var(--space) * 1.5);
  font-weight: 600; letter-spacing: -0.03em;
}
h1 { font-size: 1.75rem; letter-spacing: -0.04em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: 0.95rem; letter-spacing: -0.02em; }
h5 { font-size: 0.875rem; letter-spacing: -0.02em; }
/* The site sets its headings lowercase. That is done here in the strings, not
   with text-transform, because headings also carry candidate names, reference
   codes and acronyms — CSS would flatten "CMP-4471" and "AI" along with them. */
p { margin: 0 0 calc(var(--space) * 1.5); }
a { color: var(--text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--hairline); }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.danger { color: var(--danger); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Layout ------------------------------------------------------------ */

.wrap { max-width: 1100px; margin: 0 auto; padding: calc(var(--space) * 3) calc(var(--space) * 2) calc(var(--space) * 8); }
.wrap.candidate { max-width: 860px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: calc(var(--space) * 1.5) calc(var(--space) * 2);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space);
}
.topbar-left { display: flex; align-items: center; gap: calc(var(--space) * 2); flex-wrap: wrap; }
.topbar-right { display: flex; align-items: center; gap: calc(var(--space) * 1.5); }

/* --- Brand mark -------------------------------------------------------- */

/* The wordmark is inlined rather than loaded via <img>, so its paths inherit
   currentColor and follow the text colour wherever it is placed. */
.brand { display: inline-flex; align-items: center; gap: calc(var(--space) * 1.5); color: var(--text); text-decoration: none; }
.brand-mark { display: block; height: 22px; width: auto; color: var(--text); }
.brand-sub {
  font-size: 0.78rem; letter-spacing: 0.02em; color: var(--text-muted);
  padding-left: calc(var(--space) * 1.5); border-left: 1px solid var(--border); white-space: nowrap;
}
.brand-lockup { display: flex; flex-direction: column; align-items: center; gap: calc(var(--space) * 1.5); margin-bottom: calc(var(--space) * 3); }
.brand-lockup .brand-mark { height: 30px; }

/* Header nav sits in grey pill chips, as on the site. */
.topnav { display: flex; gap: calc(var(--space) * 0.5); }
.topnav a {
  font-size: 0.88rem; color: var(--text-muted); text-decoration: none;
  padding: 6px 14px; border-radius: var(--radius-pill); background: var(--surface-2);
  transition: background-color 0.15s ease, color 0.15s ease;
}
.topnav a:hover { background: var(--border); color: var(--text); }
.topnav a.active { background: var(--accent); color: var(--on-accent); font-weight: 500; }
.who { font-size: 0.88rem; }
.inline { display: inline; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: calc(var(--space) * 3);
  margin-bottom: calc(var(--space) * 3);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space); flex-wrap: wrap; }
.card-head h1, .card-head h2 { margin-bottom: var(--space); }
.card-danger { border-color: var(--danger); }
.card-danger h3 { color: var(--danger); }

/* --- Forms ------------------------------------------------------------- */

label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: calc(var(--space) * 0.5); }

input[type='text'], input[type='email'], input[type='password'], input[type='number'],
input[type='date'], input[type='search'], textarea, select {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: calc(var(--space) * 2);
}
textarea { resize: vertical; min-height: 90px; }

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint { font-size: 0.82rem; color: var(--text-muted); margin-top: -12px; margin-bottom: calc(var(--space) * 2); }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 calc(var(--space) * 2); align-items: start; }
.form-actions { display: flex; align-items: flex-end; padding-bottom: calc(var(--space) * 2); }

.field { margin-bottom: calc(var(--space) * 2); }
.field-inline { max-width: 420px; }

.inline-form { display: flex; align-items: flex-end; gap: var(--space); flex-wrap: wrap; }
.inline-form label { margin-bottom: 0; }
.inline-form input { margin-bottom: 0; width: auto; }
.manage-row { display: flex; gap: calc(var(--space) * 3); flex-wrap: wrap; align-items: flex-end; }

/* --- Buttons ----------------------------------------------------------- */

/* Pill buttons, after the site's "get customers" call to action. */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px;
  font: inherit; font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--hairline); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); background: var(--danger); border-color: var(--danger); }
.btn-small { padding: 5px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* --- Tables ------------------------------------------------------------ */

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  z-index: 1;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tfoot th { background: var(--surface-2); font-weight: 600; }
.table-compact th, .table-compact td { padding: 7px 10px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .cellref { color: var(--text-muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.strong-row td { font-weight: 600; background: var(--surface-2); }
.empty { text-align: center; color: var(--text-muted); padding: calc(var(--space) * 4) !important; }
/* Space the actions without making the <td> a flex container — that would take
   the cell out of the table layout and detach its border from the row. */
.row-actions > * { display: inline-flex; vertical-align: middle; }
.row-actions > * + * { margin-left: var(--space); }
.filter { max-width: 260px; margin-bottom: 0; }

tr.pass td:last-child { color: var(--ok); font-weight: 600; }
tr.fail td:last-child { color: var(--text-muted); }

/* --- Badges & flashes -------------------------------------------------- */

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; text-transform: capitalize;
  background: var(--surface-2); color: var(--text-muted);
}
.badge-invited { background: var(--surface-2); color: var(--text-muted); }
.badge-started { background: var(--info-soft); color: var(--info); }
.badge-submitted { background: var(--warn-soft); color: var(--warn); }
.badge-scored { background: var(--ok-soft); color: var(--ok); }
.badge-expired { background: var(--danger-soft); color: var(--danger); }

.flash {
  padding: 10px 16px; border-radius: var(--radius-sm);
  margin-bottom: calc(var(--space) * 2); border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: currentColor; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg);
  padding: 10px 20px; border-radius: var(--radius-pill);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Auth -------------------------------------------------------------- */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: calc(var(--space) * 2); }
.auth-card { width: 100%; max-width: 380px; margin: 0; }

/* --- Invite link ------------------------------------------------------- */

.link-card { border: 1px dashed var(--text); box-shadow: none; }
.copy-row { display: flex; gap: var(--space); align-items: center; flex-wrap: wrap; }
.link-input {
  flex: 1 1 320px; margin-bottom: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem;
  background: var(--surface-2);
}

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: calc(var(--space) * 2); margin: calc(var(--space) * 2) 0; }
.meta-grid dt { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.meta-grid dd { margin: 2px 0 0; font-size: 0.92rem; }

/* --- Review: answers & manual scoring ---------------------------------- */

.answer { margin-bottom: calc(var(--space) * 2); }
.answer-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.answer-body {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; white-space: normal; word-break: break-word;
}

.manual-item {
  display: grid; grid-template-columns: 1fr 340px; gap: calc(var(--space) * 3);
  padding: calc(var(--space) * 3) 0; border-top: 1px solid var(--border);
}
.manual-item:first-of-type { border-top: none; padding-top: var(--space); }
.manual-key { background: var(--surface-2); border-radius: var(--radius-sm); padding: calc(var(--space) * 2); }
.key-note { margin-bottom: calc(var(--space) * 2); }
.key-label {
  display: inline-block; margin-bottom: 6px; padding: 2px 10px; border-radius: var(--radius-pill);
  background: var(--highlight); color: #222222;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
}
.key-note p { margin: 0; font-size: 0.88rem; }
.score-label { margin-bottom: 4px; }
.score-input { display: flex; align-items: center; gap: var(--space); }
.score-input input { width: 90px; margin-bottom: 0; }

@media (max-width: 800px) {
  .manual-item { grid-template-columns: 1fr; }
}

/* --- Sticky score bar -------------------------------------------------- */

.score-bar {
  position: sticky; bottom: 0; z-index: 15;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: calc(var(--space) * 3);
}
.score-bar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: calc(var(--space) * 2); padding: calc(var(--space) * 2); flex-wrap: wrap;
}
.score-numbers { display: flex; gap: calc(var(--space) * 3); flex-wrap: wrap; align-items: center; font-size: 0.92rem; }
.score-numbers .total { font-size: 1.05rem; }
.band { padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.band-strong { background: var(--ok-soft); color: var(--ok); }
.band-solid { background: var(--info-soft); color: var(--info); }
.band-borderline { background: var(--warn-soft); color: var(--warn); }
.band-weak { background: var(--danger-soft); color: var(--danger); }
.progress { height: 4px; background: var(--surface-2); }
.progress-fill { height: 100%; background: var(--highlight); transition: width 0.2s ease; }

/* --- Candidate page ---------------------------------------------------- */

.candidate-body { background: var(--bg); }
.intro .subtitle { color: var(--text-muted); margin-top: -8px; }
.intro-block { margin-bottom: calc(var(--space) * 2); }
.intro-block h4 { margin-bottom: 4px; }
.intro-block p { margin: 0; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space); flex-wrap: wrap; }
.time { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }

/* --- Overview: the four sections --------------------------------------- */

.section-list { list-style: none; margin: 0; padding: 0; }
.section-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: calc(var(--space) * 3); flex-wrap: wrap;
  padding: calc(var(--space) * 2.5) 0; border-top: 1px solid var(--border);
}
.section-card:first-child { border-top: none; }
.section-card-main { flex: 1 1 340px; }
.section-card h3 { margin-bottom: 4px; }
.section-card p { margin-bottom: var(--space); }
.section-card-meta { display: flex; align-items: center; gap: calc(var(--space) * 1.5); flex-wrap: wrap; }

.progress-pill {
  display: inline-block; padding: 3px 12px; border-radius: var(--radius-pill);
  font-size: 0.8rem; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--text-muted);
}
.progress-partial { background: var(--highlight); color: #222222; }
.progress-complete { background: var(--ok-soft); color: var(--ok); }

.card-warn { border-color: var(--hairline); }

.section-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space); flex-wrap: wrap; margin-bottom: calc(var(--space) * 2);
}
.section-nav-right { display: flex; align-items: center; gap: calc(var(--space) * 1.5); flex-wrap: wrap; }

/* --- Deadline ---------------------------------------------------------- */

.deadline {
  display: flex; align-items: baseline; gap: calc(var(--space) * 1.5); flex-wrap: wrap;
  padding: calc(var(--space) * 1.5) calc(var(--space) * 2.5);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface); margin-bottom: calc(var(--space) * 3);
  font-size: 0.92rem;
}
.deadline-label {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted);
}
.deadline-rel { color: var(--text-muted); }
/* Last day: the relative label is the part that matters, so make it shout. */
.deadline-today { border-color: var(--warn); background: var(--warn-soft); }
.deadline-today .deadline-label, .deadline-today .deadline-rel { color: var(--warn); font-weight: 600; }
.deadline-expired { border-color: var(--danger); background: var(--danger-soft); }
.deadline-expired .deadline-label, .deadline-expired .deadline-rel { color: var(--danger); font-weight: 600; }

.deadline-inline { font-size: 0.85rem; color: var(--text-muted); white-space: nowrap; }
.deadline-inline.deadline-today { color: var(--warn); font-weight: 600; }
.deadline-inline.deadline-expired { color: var(--danger); font-weight: 600; }
.section-actions { display: flex; gap: var(--space); flex-wrap: wrap; justify-content: flex-end; }

.save-ok { color: var(--ok); }
.save-error { color: var(--danger); font-weight: 600; }

.note {
  background: var(--warn-soft); color: var(--warn);
  border-left: 3px solid currentColor; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px; font-size: 0.9rem;
}

.policy, .source-notes {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: calc(var(--space) * 2); margin-bottom: calc(var(--space) * 3);
}
.policy ul, .source-notes ul { margin: 0; padding-left: calc(var(--space) * 3); }
.policy li { margin-bottom: var(--space); }

.campaign, .task {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: calc(var(--space) * 2); margin-bottom: calc(var(--space) * 3);
}
.campaign-head { display: flex; align-items: baseline; gap: calc(var(--space) * 1.5); flex-wrap: wrap; margin-bottom: calc(var(--space) * 1.5); }
.ref { font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.campaign-lines { margin: 0 0 calc(var(--space) * 2); }
.campaign-lines > div { display: flex; gap: var(--space); margin-bottom: 6px; flex-wrap: wrap; }
.campaign-lines dt { font-weight: 600; min-width: 72px; color: var(--text-muted); font-size: 0.88rem; }
.campaign-lines dd { margin: 0; flex: 1 1 240px; }

/* Section B's workbook download — a dashed frame, as the site uses for its
   standout call to action. */
.download-card {
  display: flex; align-items: center; justify-content: space-between;
  gap: calc(var(--space) * 3); flex-wrap: wrap;
  border: 1px dashed var(--text); border-radius: var(--radius);
  padding: calc(var(--space) * 2.5); margin-bottom: calc(var(--space) * 3);
}
.download-text { flex: 1 1 320px; }
.download-text h4 { margin-bottom: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.download-text p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }

.data-table { margin-bottom: calc(var(--space) * 3); }
.recon { display: grid; grid-template-columns: 1fr 1fr; gap: calc(var(--space) * 2); }
@media (max-width: 700px) { .recon { grid-template-columns: 1fr; } }

.options { border: none; padding: 0; margin: 0 0 calc(var(--space) * 2); }
.option {
  display: flex; gap: var(--space); align-items: flex-start;
  padding: 10px 12px; margin-bottom: 6px; font-weight: 400;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.option:hover { background: var(--surface-2); }
.option input { margin: 4px 0 0; width: auto; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

.submit-bar {
  position: sticky; bottom: 0; z-index: 15;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.submit-bar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: calc(var(--space) * 2); padding: calc(var(--space) * 2); flex-wrap: wrap;
}
.save-state { font-size: 0.88rem; }

.status-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.status-card { max-width: 520px; text-align: center; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
