/* ============================================================
   ARETE: ECET AI Evaluation Framework
   Design system: institutional ledger. Deep ink-navy on cool
   paper, serif for record-keeping, plex sans for instrument UI,
   plex mono for the case-record stamp.
   ============================================================ */

:root {
  --ink: #1a2332;
  --ink-muted: #5b6472;
  --ink-faint: #8a92a0;
  --navy: #1f3864;
  --navy-soft: #2e5395;
  --navy-wash: #eef1f7;
  --paper: #f5f5f2;
  --paper-raised: #ffffff;
  --line: #dcdad2;
  --line-strong: #b9b6ac;

  --proceed: #2f6b4f;
  --proceed-wash: #e7f1ec;
  --safeguards: #96690f;
  --safeguards-wash: #faf1e1;
  --donotproceed: #8c2f2f;
  --donotproceed-wash: #f7e9e9;
  --insufficient: #4d5261;
  --insufficient-wash: #e9eaee;
  --gate: #7a3b12;
  --gate-wash: #f3e6dc;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --radius: 3px;
  --shadow-card: 0 1px 2px rgba(26,35,50,0.06), 0 1px 1px rgba(26,35,50,0.04);
  --shadow-raised: 0 6px 20px rgba(26,35,50,0.12), 0 2px 6px rgba(26,35,50,0.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--paper);
  background-image:
    linear-gradient(rgba(31,56,100,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31,56,100,0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--ink);
  line-height: 1.5;
  font-size: 15px;
}

@media (prefers-reduced-motion: no-preference) {
  .fade-in { animation: fadeIn 0.35s ease both; }
  .rise-in { animation: riseIn 0.4s cubic-bezier(.2,.7,.3,1) both; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink); margin: 0 0 0.4em; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
a { color: var(--navy-soft); }
button { font-family: inherit; }

/* ---------------- App shell ---------------- */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  color: var(--navy);
  letter-spacing: 0.01em;
}
.brand-sub {
  font-size: 12px;
  color: var(--ink-muted);
  font-family: var(--mono);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.topbar-record {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-muted);
  text-align: right;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-rail {
  display: flex;
  gap: 0;
  padding: 0 28px;
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.stage-pip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px 10px 0;
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  font-family: var(--mono);
}
.stage-pip .n {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: var(--ink-faint);
  flex-shrink: 0;
}
.stage-pip.active { color: var(--navy); font-weight: 600; }
.stage-pip.active .n { background: var(--navy); border-color: var(--navy); color: #fff; }
.stage-pip.done .n { background: var(--proceed); border-color: var(--proceed); color: #fff; }
.stage-pip.done { color: var(--ink-muted); }
.stage-sep { color: var(--line-strong); padding: 10px 4px 10px 0; }

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 40px 24px 80px;
}
.view {
  width: 100%;
  max-width: 760px;
}
.view.wide { max-width: 920px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy-soft);
  margin-bottom: 10px;
  display: block;
}

.lede { font-size: 16px; color: var(--ink-muted); max-width: 62ch; }

/* ---------------- Cards / choices ---------------- */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.choice-grid { display: grid; gap: 14px; margin-top: 24px; }
.choice-card {
  display: block;
  text-align: left;
  width: 100%;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}
.choice-card:hover { border-color: var(--navy-soft); box-shadow: var(--shadow-raised); transform: translateY(-1px); }
.choice-card:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.choice-card.selected { border-color: var(--navy); background: var(--navy-wash); }
.choice-card .ct { font-family: var(--serif); font-weight: 600; font-size: 17px; margin-bottom: 4px; color: var(--ink); }
.choice-card .cd { font-size: 13.5px; color: var(--ink-muted); }
.choice-card .cx { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); margin-top: 8px; }
.choice-card.checkbox-style { display: flex; align-items: flex-start; gap: 12px; }
.choice-card.checkbox-style .box {
  width: 18px; height: 18px; border: 1.5px solid var(--line-strong); border-radius: 3px;
  flex-shrink: 0; margin-top: 3px; position: relative;
}
.choice-card.checkbox-style.selected .box { background: var(--navy); border-color: var(--navy); }
.choice-card.checkbox-style.selected .box::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 4px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

/* ---------------- Forms ---------------- */
label.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
  margin-top: 18px;
}
label.field-label .req { color: var(--donotproceed); }
label.field-label:first-child { margin-top: 0; }
.field-hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

input[type=text], input[type=date], textarea, select {
  width: 100%;
  font-family: var(--sans);
  font-size: 14.5px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; font-family: var(--sans); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--navy-soft); outline-offset: 1px; border-color: var(--navy-soft); }

select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13.5px; color: var(--ink-muted); }
.checkbox-row input { width: 16px; height: 16px; }

/* ---------------- Buttons ---------------- */
.btn {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #16294c; }
.btn-primary:disabled { background: var(--line-strong); cursor: not-allowed; }
.btn-secondary { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { border-color: var(--navy); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--ink-muted); border-color: transparent; padding: 11px 8px; }
.btn-ghost:hover { color: var(--navy); }
.btn-row { display: flex; justify-content: space-between; align-items: center; margin-top: 32px; gap: 12px; }
.btn-row .right { display: flex; gap: 10px; }

/* ---------------- Item assessment ---------------- */
.lane-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.lane-progress { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

.item-card {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  box-shadow: var(--shadow-card);
}
.item-id-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.item-id {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--navy);
  background: var(--navy-wash);
  padding: 3px 8px;
  border-radius: 3px;
  font-weight: 600;
}
.item-column { font-size: 12.5px; color: var(--ink-muted); font-weight: 600; }
.tag-gate {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gate);
  background: var(--gate-wash);
  padding: 3px 7px;
  border-radius: 3px;
  border: 1px solid #e5cdb8;
}
.tag-crit {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  border: 1px solid var(--line-strong);
  padding: 3px 7px;
  border-radius: 3px;
}
.item-statement { font-size: 14px; color: var(--ink-muted); margin-bottom: 10px; font-style: italic; }
.item-question { font-family: var(--serif); font-size: 19px; line-height: 1.4; color: var(--ink); margin-bottom: 22px; }
.item-anchor { font-size: 12.5px; color: var(--navy-soft); margin-top: -10px; margin-bottom: 20px; }
.item-anchor b { font-weight: 600; }

.rating-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 10px; }
.rating-chip {
  border: 1.5px solid var(--line-strong);
  background: var(--paper-raised);
  border-radius: var(--radius);
  padding: 12px 6px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.12s ease;
}
.rating-chip .num { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--ink-faint); display: block; }
.rating-chip .lbl { font-size: 10.5px; color: var(--ink-muted); display: block; margin-top: 2px; line-height: 1.2; }
.rating-chip:hover { border-color: var(--navy-soft); }
.rating-chip.sel-1.selected { border-color: var(--donotproceed); background: var(--donotproceed-wash); }
.rating-chip.sel-1.selected .num { color: var(--donotproceed); }
.rating-chip.sel-2.selected { border-color: #a15a1f; background: #f7ece0; }
.rating-chip.sel-2.selected .num { color: #a15a1f; }
.rating-chip.sel-3.selected { border-color: var(--insufficient); background: var(--insufficient-wash); }
.rating-chip.sel-3.selected .num { color: var(--insufficient); }
.rating-chip.sel-4.selected { border-color: var(--safeguards); background: var(--safeguards-wash); }
.rating-chip.sel-4.selected .num { color: var(--safeguards); }
.rating-chip.sel-5.selected { border-color: var(--proceed); background: var(--proceed-wash); }
.rating-chip.sel-5.selected .num { color: var(--proceed); }

.alt-row { display: flex; gap: 8px; margin-bottom: 4px; }
.alt-chip {
  flex: 1;
  border: 1.5px dashed var(--line-strong);
  background: transparent;
  border-radius: var(--radius);
  padding: 9px 10px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
}
.alt-chip:hover { border-color: var(--ink-muted); color: var(--ink); }
.alt-chip.selected { border-style: solid; border-color: var(--navy); background: var(--navy-wash); color: var(--navy); font-weight: 600; }

.scale-meaning {
  font-size: 12.5px;
  color: var(--ink-muted);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 10px 0 18px;
}

.subfields { margin-top: 18px; padding-top: 18px; border-top: 1px dashed var(--line); }
.subfields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.safeguard-box {
  margin-top: 16px;
  padding: 16px 18px;
  background: var(--safeguards-wash);
  border: 1px solid #e4cd9c;
  border-radius: var(--radius);
}
.safeguard-box .sb-title { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--safeguards); font-weight: 700; margin-bottom: 10px; }

/* ---------------- Side rail (item navigator) ---------------- */
.assess-layout { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: start; }
.navigator { position: sticky; top: 90px; }
.nav-section { margin-bottom: 18px; }
.nav-section-title { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); margin-bottom: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-muted);
  padding: 5px 6px; border-radius: 3px; cursor: pointer;
}
.nav-item:hover { background: var(--paper); }
.nav-item.current { background: var(--navy-wash); color: var(--navy); font-weight: 600; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex-shrink: 0; }
.nav-item.answered .nav-dot { background: var(--navy-soft); border-color: var(--navy-soft); }
.nav-item.gate .nav-dot { border-color: var(--gate); }
.nav-item.gate.answered .nav-dot { background: var(--gate); border-color: var(--gate); }
.nav-item.incomplete { color: var(--safeguards); }
.nav-flag { color: var(--safeguards); font-weight: 700; font-family: var(--mono); margin-left: auto; }

@media (max-width: 860px) {
  .assess-layout { grid-template-columns: 1fr; }
  .navigator { position: static; display: none; }
  .rating-row { grid-template-columns: repeat(5, 1fr); }
  .rating-chip .lbl { display: none; }
}

/* ---------------- Decision ledger (results) ---------------- */
.ledger {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 34px 36px;
  position: relative;
  overflow: hidden;
}
.ledger::before {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 22px);
  pointer-events: none;
}
.ledger-eyebrow { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(255,255,255,0.55); }
.ledger-record { font-family: var(--mono); font-size: 12.5px; color: rgba(255,255,255,0.75); margin-top: 6px; line-height: 1.7; }
.ledger-record .k { color: rgba(255,255,255,0.45); }
.outcome-seal {
  display: inline-flex; align-items: center; gap: 12px;
  margin-top: 22px; padding: 14px 20px;
  border-radius: var(--radius);
  font-family: var(--serif); font-size: 22px; font-weight: 700;
}
.outcome-seal .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.outcome-seal.proceed { background: rgba(120,200,160,0.14); color: #a9e3c4; }
.outcome-seal.proceed .dot { background: #4fbf87; }
.outcome-seal.safeguards { background: rgba(230,180,90,0.14); color: #f0cf8f; }
.outcome-seal.safeguards .dot { background: #d9a94a; }
.outcome-seal.donotproceed { background: rgba(220,120,120,0.14); color: #f0aeae; }
.outcome-seal.donotproceed .dot { background: #d96666; }
.outcome-seal.insufficient { background: rgba(180,185,200,0.14); color: #cdd1dc; }
.outcome-seal.insufficient .dot { background: #9096a6; }
.ledger-step { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 14px; max-width: 60ch; }
.ledger-step b { color: rgba(255,255,255,0.9); }

.report-section { margin-top: 30px; }
.report-section h3 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; font-family: var(--sans); font-weight: 700; color: var(--navy); border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 14px; }
.report-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.report-row:last-child { border-bottom: none; }
.report-row .rl { color: var(--ink-muted); flex-shrink: 0; max-width: 46%; }
.report-row .rr { text-align: right; color: var(--ink); }

.pattern-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.pattern-lane { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.pattern-lane h4 { font-size: 12.5px; font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-muted); margin-bottom: 10px; }
.pattern-bars { display: flex; flex-direction: column; gap: 5px; }
.pattern-bar-row { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ink-muted); }
.pattern-bar-row .bl { width: 78px; flex-shrink: 0; }
.pattern-bar-track { flex: 1; height: 8px; background: var(--paper); border-radius: 2px; overflow: hidden; }
.pattern-bar-fill { height: 100%; border-radius: 2px; }
.pattern-bar-row .bc { width: 16px; text-align: right; font-family: var(--mono); }

.flag-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.flag-item:last-child { border-bottom: none; }
.flag-item .fi-badge { font-family: var(--mono); font-size: 10.5px; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 3px; padding: 2px 6px; height: fit-content; flex-shrink: 0; }
.flag-item .fi-body b { display: block; margin-bottom: 2px; }
.flag-item .fi-body span { color: var(--ink-muted); }

.disclaimer-box {
  background: var(--paper);
  border-left: 3px solid var(--navy);
  padding: 16px 20px;
  font-size: 13px;
  color: var(--ink-muted);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.note-box {
  background: var(--navy-wash);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 13px;
  color: var(--ink);
}

ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin-bottom: 6px; font-size: 13.5px; color: var(--ink-muted); }

.info-toggle { background: none; border: none; color: var(--navy-soft); font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.info-panel { margin-top: 18px; }
.info-panel ol { padding-left: 20px; margin: 10px 0 0; }
.info-panel li { font-size: 13.5px; color: var(--ink-muted); margin-bottom: 6px; font-family: var(--mono); }

.footer-note { text-align: center; font-size: 12px; color: var(--ink-faint); padding: 20px; }

/* ---------------- Landing hero ---------------- */
.hero-wrap {
  width: 100%;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse 900px 500px at 85% -10%, rgba(31,56,100,0.06), transparent 60%),
    var(--paper-raised);
}
.hero-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 64px 24px 56px;
}
.hero-kicker {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--navy-soft);
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  margin-bottom: 22px;
}
.hero-title {
  font-family: var(--serif);
  font-size: 56px;
  line-height: 1;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 20px;
  letter-spacing: -0.02em;
}
.hero-lede { font-size: 17px; color: var(--ink-muted); max-width: 58ch; margin-bottom: 8px; }

.outcome-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 34px 0 6px;
}
.outcome-chip {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  border-top: 3px solid var(--line-strong);
}
.outcome-chip .oc-label { font-family: var(--serif); font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.outcome-chip .oc-desc { font-size: 11.5px; color: var(--ink-muted); line-height: 1.35; }
.outcome-chip.proceed { border-top-color: var(--proceed); }
.outcome-chip.proceed .oc-label { color: var(--proceed); }
.outcome-chip.safeguards { border-top-color: var(--safeguards); }
.outcome-chip.safeguards .oc-label { color: var(--safeguards); }
.outcome-chip.donotproceed { border-top-color: var(--donotproceed); }
.outcome-chip.donotproceed .oc-label { color: var(--donotproceed); }
.outcome-chip.insufficient { border-top-color: var(--insufficient); }
.outcome-chip.insufficient .oc-label { color: var(--insufficient); }
.outcome-preview-cap { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.04em; }

@media (max-width: 700px) {
  .hero-title { font-size: 38px; }
  .outcome-preview { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .topbar, .stage-rail, .btn-row, .navigator, .no-print { display: none !important; }
  main { padding: 0; }
  .ledger { background: #fff !important; color: #000 !important; border: 2px solid #000; }
  .ledger::before { display: none; }
  .ledger-eyebrow, .ledger-record, .ledger-step { color: #333 !important; }
  .ledger-record .k { color: #666 !important; }
  body { font-size: 12px; }
}
