/* ============================================================
   Managerial Decision-Making Experiment — survey styles
   Identity: scholarly briefing dossier.
   Type: Spectral (display) · IBM Plex Sans (body) · IBM Plex Mono (data)
   ============================================================ */

:root {
  --bg: #EDF0F2;
  --card: #FFFFFF;
  --ink: #101D2C;
  --muted: #5A6B7C;
  --line: #D4DBE1;
  --accent: #0D5C63;
  --accent-ink: #094046;
  --accent-soft: #E2EEED;
  --gold: #B9862F;
  --danger: #A63434;
  --danger-soft: #F7E9E9;
  --ok: #2E7D4F;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 29, 44, .05), 0 10px 30px -12px rgba(16, 29, 44, .18);
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Spectral", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.page { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------------- masthead ---------------- */

.masthead {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.masthead-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background:
    linear-gradient(0deg, transparent 0, transparent 0) ,
    var(--accent);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 8px 7px 7px;
  background:
    linear-gradient(to right,
      #F4F7F6 0 3px, transparent 3px 8px,
      #F4F7F6 8px 11px, transparent 11px 16px,
      #F4F7F6 16px 19px, transparent 19px);
  clip-path: polygon(0 55%, 33% 55%, 33% 15%, 66% 15%, 66% 70%, 100% 70%, 100% 100%, 0 100%);
}
.kicker {
  display: block;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress { text-align: right; flex: none; }
.progress-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .04em;
}
.progress-track {
  width: 180px; height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), #12867F);
  border-radius: 2px;
  transition: width .6s cubic-bezier(.22,.8,.3,1);
}

/* ---------------- layout ---------------- */

main { flex: 1; width: 100%; }
.screen-host {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 28px 90px;
}
.screen-host.wide { max-width: 1240px; }

.screen {
  animation: rise .45s cubic-bezier(.22,.8,.3,1);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.screen.leaving {
  animation: sink .22s ease forwards;
}
@keyframes sink {
  to { opacity: 0; transform: translateY(-10px); }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 22px; }

.card-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 18px 30px 0;
}
.sec-no {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .08em;
  border: 1px solid var(--accent-soft);
  background: var(--accent-soft);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}
.card-head h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.3;
}
.card-body { padding: 20px 30px 30px; }
.card-body > p { margin-bottom: 14px; }
.card-body h3 {
  font-family: var(--font-display);
  font-size: 18.5px;
  font-weight: 600;
  margin: 22px 0 8px;
}
.card-body ul, .card-body ol { margin: 0 0 14px 22px; }
.card-body li { margin-bottom: 6px; }

.qtext {
  font-weight: 600;
  margin: 26px 0 10px;
  font-size: 16.5px;
}
.qtext:first-child { margin-top: 4px; }
.qnote { font-weight: 400; color: var(--muted); font-size: 14px; }

/* highlight a question that was left unanswered */
.q-missing { position: relative; }
.q-missing::before {
  content: "";
  position: absolute; left: -30px; top: 0; bottom: 0;
  width: 3px; background: var(--danger); border-radius: 2px;
}

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

input[type=number], input[type=text], select, textarea {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--ink);
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  max-width: 340px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input[type=number] { font-family: var(--font-mono); }
textarea { max-width: 100%; min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, label:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Likert 1-7 */
.likert { margin: 4px 0 8px; max-width: 560px; }
.lrow { display: flex; justify-content: space-between; gap: 6px; }
.lpt {
  flex: 1;
  text-align: center;
  cursor: pointer;
  padding: 6px 0 4px;
  border-radius: 8px;
  transition: background .15s;
}
.lpt:hover { background: var(--accent-soft); }
.lpt input { position: absolute; opacity: 0; pointer-events: none; }
.ldot {
  display: block;
  width: 20px; height: 20px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  margin: 0 auto 6px;
  background: var(--card);
  transition: background .12s, transform .12s, border-color .12s;
}
.lpt input:checked + .ldot {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
}
.lpt input:checked ~ .ln { color: var(--accent-ink); }
.ln { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; }
.lanchors {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted);
  margin-top: 2px;
}

/* radio / checkbox option rows */
.opt {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--accent); }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }

/* matrix (intuition scale) */
.tbl-wrap { overflow-x: auto; }
table.matrix { width: 100%; border-collapse: collapse; margin: 10px 0 8px; font-size: 15px; }
table.matrix th {
  background: #F3F6F8;
  border: 1px solid var(--line);
  padding: 8px;
  font-weight: 600;
  text-align: center;
  font-size: 13.5px;
}
table.matrix th:first-child { text-align: left; }
table.matrix th .anchor { font-weight: 400; font-size: 11.5px; color: var(--muted); display: block; }
table.matrix td { border: 1px solid var(--line); padding: 8px; text-align: center; }
table.matrix td:first-child { text-align: left; }
table.matrix td label { display: block; padding: 4px; cursor: pointer; }
table.matrix input { width: 17px; height: 17px; accent-color: var(--accent); }
table.matrix tr.q-missing td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
table.matrix tr:hover td { background: #F7FAFA; }

/* data tables (Company X document) */
.doc h2 { font-family: var(--font-display); font-size: 23px; font-weight: 600; margin-bottom: 4px; }
.doc-meta { color: var(--muted); font-style: italic; margin-bottom: 14px; }
.doc h3 {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 600;
  margin: 24px 0 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.doc p { margin-bottom: 12px; }
.doc ul { margin: 0 0 14px 22px; }
table.data {
  width: 100%; border-collapse: collapse;
  margin: 10px 0 4px; font-size: 13.8px;
}
table.data th {
  background: #10202E;
  color: #ECF1F4;
  text-align: left;
  font-weight: 500;
  padding: 7px 10px;
  border: 1px solid #10202E;
  font-size: 13px;
}
table.data td { padding: 6px 10px; border: 1px solid var(--line); vertical-align: top; }
table.data td:not(:first-child) { font-family: var(--font-mono); font-size: 12.8px; }
table.data tr:nth-child(even) td { background: #F7F9FA; }
.src { font-size: 12.5px; color: var(--muted); font-style: italic; margin: 4px 0 14px; }

.notice {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 12px 18px;
  margin: 16px 0;
  font-size: 15px;
}

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 12px 34px;
  cursor: pointer;
  margin-top: 22px;
  transition: background .15s, transform .1s, box-shadow .15s;
  box-shadow: 0 2px 8px -2px rgba(13, 92, 99, .5);
}
.btn:hover:not(:disabled) { background: var(--accent-ink); transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { background: #9FB2B4; cursor: not-allowed; box-shadow: none; }
.btn .spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 45s countdown ring on the scenario Next button */
.wait-ring {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  background: conic-gradient(#fff var(--deg, 0deg), rgba(255,255,255,.25) 0deg);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  color: var(--accent-ink);
}
.wait-ring span {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  display: grid; place-items: center;
}
.btn:disabled .wait-ring span { background: #9FB2B4; }

.form-error {
  display: none;
  margin-top: 16px;
  background: var(--danger-soft);
  border-left: 4px solid var(--danger);
  border-radius: 0 8px 8px 0;
  color: var(--danger);
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 500;
}
.form-error.show { display: block; animation: rise .3s ease; }

/* ---------------- allocation ---------------- */

.alloc-rules { color: var(--muted); font-size: 14.5px; margin-bottom: 16px; }
.alloc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.alloc-row label { flex: 1 1 300px; }
.alloc-row label b { display: block; }
.alloc-row label small { color: var(--muted); font-size: 13px; }
.alloc-input {
  position: relative;
  flex: 0 1 200px;
}
.alloc-input::before {
  content: "EUR";
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.alloc-input input {
  padding-left: 46px;
  font-family: var(--font-mono);
  text-align: right;
  max-width: none;
}

.balance {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 8px;
  background: #F3F6F8;
  border: 1px solid var(--line);
  transition: background .3s, border-color .3s;
}
.balance.ok { background: #EAF4EE; border-color: #BCDCC8; }
.balance.over { background: var(--danger-soft); border-color: #E4C2C2; }
.balance-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.balance-top .lbl { font-weight: 600; font-size: 14.5px; }
.balance-total {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.balance.ok .balance-total { color: var(--ok); }
.balance.over .balance-total { color: var(--danger); }
.balance-hint { font-size: 13px; color: var(--muted); margin-top: 2px; }
.beam {
  margin-top: 12px;
  height: 10px;
  border-radius: 5px;
  background: var(--line);
  overflow: hidden;
  display: flex;
}
.beam .seg { height: 100%; width: 0; transition: width .35s cubic-bezier(.22,.8,.3,1); }
.beam .seg.a { background: #33707A; }
.beam .seg.b { background: #B9862F; }
.beam .seg.c { background: #7C4E7E; }
.beam-legend {
  display: flex; gap: 18px; margin-top: 8px;
  font-size: 12px; color: var(--muted);
  font-family: var(--font-mono);
}
.beam-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ---------------- block 7 layout + chat ---------------- */

.task-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.task-grid.with-chat { grid-template-columns: minmax(0, 7fr) minmax(320px, 5fr); align-items: start; }
.task-main { min-width: 0; }
.doc-scroll {
  max-height: 66vh;
  overflow-y: auto;
  padding: 24px 30px;
}
.chat-panel {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  height: min(78vh, 720px);
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #10202E;
  color: #ECF1F4;
  border-radius: var(--radius) var(--radius) 0 0;
}
.chat-head .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #4CC38A;
  box-shadow: 0 0 0 3px rgba(76,195,138,.25);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(76,195,138,.25); }
  50% { box-shadow: 0 0 0 6px rgba(76,195,138,.08); }
}
.chat-head b { font-size: 14.5px; font-weight: 600; }
.chat-head small { color: #9DB0BF; font-size: 12px; display: block; }
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F7F9FA;
}
.msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  animation: rise .25s ease;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}
.msg.assistant.streaming::after {
  content: "▍";
  animation: blink 1s steps(1) infinite;
  color: var(--accent);
}
@keyframes blink { 50% { opacity: 0; } }
.msg.error { align-self: center; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  max-width: 260px;
}
.chat-input {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
}
.chat-input textarea {
  flex: 1;
  min-height: 44px;
  max-height: 130px;
  resize: none;
  font-size: 14.5px;
}
.chat-send {
  align-self: flex-end;
  flex: none;
  width: 44px; height: 44px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background .15s;
}
.chat-send:hover:not(:disabled) { background: var(--accent-ink); }
.chat-send:disabled { background: #9FB2B4; cursor: not-allowed; }
.chat-send svg { width: 18px; height: 18px; }

/* thank-you */
.fin-mark {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid; place-items: center;
  margin-bottom: 18px;
  animation: pop .5s cubic-bezier(.22,.8,.3,1);
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.fin-mark svg { width: 30px; height: 30px; stroke: var(--accent); }

/* ---------------- footer ---------------- */

.site-foot {
  max-width: 1160px;
  margin: 0 auto;
  width: 100%;
  padding: 18px 28px 26px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 12.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.foot-note { max-width: 640px; text-align: right; }

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  .task-grid.with-chat { grid-template-columns: 1fr; }
  .chat-panel { position: static; height: 480px; }
  .doc-scroll { max-height: none; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .masthead-inner { padding: 10px 16px; }
  .brand h1 { font-size: 16px; }
  .kicker { font-size: 9.5px; }
  .progress-track { width: 110px; }
  .screen-host { padding: 22px 14px 60px; }
  .card-head { padding: 16px 20px 0; }
  .card-body { padding: 16px 20px 24px; }
  .q-missing::before { left: -20px; }
  .doc-scroll { padding: 18px 20px; }
  .site-foot, .foot-note { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
