/* Nomad design system tokens — from the DS export (colors_and_type.css).
   Load-bearing brand rule: buttons are always link blue, never green. */

@font-face {
  font-family: 'Libre Franklin';
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/LibreFranklin-Regular.woff') format('woff');
}
@font-face {
  font-family: 'Libre Franklin';
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/LibreFranklin-SemiBold.woff') format('woff');
}
@font-face {
  font-family: 'Libre Franklin';
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/LibreFranklin-Bold.woff') format('woff');
}
@font-face {
  font-family: 'Degular';
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/Degular-Semibold.otf') format('opentype');
}

:root {
  --forest-400: #3e737e;
  --forest-500: #1f5660;
  --forest-600: #023a41;
  --lake-50: #e6f2f0;
  --lake-100: #b7dfd8;
  --lake-600: #027468;
  --lake-700: #015a51;
  --link-50: #e5eff4;
  --link-600: #006494;
  --link-700: #004e75;
  --sun-100: #fce6df;
  --sun-700: #bd6b39;
  --twilight-700: #bc4e2e;

  --font-body: 'Libre Franklin', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Degular', 'Libre Franklin', sans-serif;

  --fg-default: var(--forest-600);
  --fg-muted: var(--forest-500);
  --fg-subtle: var(--forest-400);
  --bg-page: var(--lake-50);
  --bg-card: #ffffff;
  --border-subtle: rgba(2, 58, 65, 0.08);
  --border-default: rgba(2, 58, 65, 0.16);
  --border-input: rgba(2, 58, 65, 0.2);
  --cta: var(--link-600);
  --cta-hover: var(--link-700);
  --danger: var(--twilight-700);
  --warn: var(--sun-700);
  --shadow-card: 0 1px 3px rgba(2, 58, 65, 0.08), 0 4px 12px rgba(2, 58, 65, 0.06);
  --shadow-focus: 0 0 0 2px var(--lake-600);
  --radius-lg: 8px;
  --radius-xl: 12px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  background: var(--bg-page);
  color: var(--fg-default);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { height: 24px; display: block; }
.brand span { font-size: 15px; color: var(--fg-subtle); font-weight: 400; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 19px;
  background: var(--forest-600);
  color: #fff;
  padding: 5px 16px;
  border-radius: var(--radius-lg);
  transition: background 200ms var(--ease);
}
.timer.warn { background: var(--warn); }
.timer.danger { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.65; } }

.view { flex: 1; min-height: 0; }
.card-view { display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow-y: auto; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 36px 40px;
  max-width: 640px;
  box-shadow: var(--shadow-card);
}
.card h1 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.card p { line-height: 1.55; color: var(--fg-muted); }
.card .illo { display: block; margin: 0 auto 20px; max-width: 300px; width: 100%; }
.rules { line-height: 1.6; padding-left: 20px; }
.rules li { margin-bottom: 10px; color: var(--fg-muted); }
.rules li strong { color: var(--fg-default); }

input[type="email"], input[type="text"], textarea {
  font: inherit;
  color: var(--fg-default);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  padding: 10px 12px;
  width: 100%;
  background: var(--bg-card);
}
input:focus, textarea:focus { outline: none; box-shadow: var(--shadow-focus); border-color: var(--lake-600); }
::placeholder { color: var(--fg-subtle); opacity: 0.8; }

button {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 16px;
  background: var(--cta);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  cursor: pointer;
  transition: background 120ms var(--ease);
}
button:hover { background: var(--cta-hover); }
button:disabled { opacity: 0.55; cursor: default; }

#gate-form { display: flex; gap: 10px; margin-top: 18px; }
#gate-form input { flex: 1; }
#begin-btn { width: 100%; margin-top: 16px; padding: 14px 24px; font-size: 18px; }

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

/* Assessment layout */
#view-assess { display: flex; flex-direction: column; }
#tabs {
  display: flex;
  gap: 6px;
  padding: 10px 24px 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
}
.tab {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px 18px;
}
.tab:hover { background: var(--bg-page); color: var(--fg-default); }
.tab.active { background: var(--bg-page); color: var(--fg-default); border-color: var(--border-subtle); font-weight: 700; }
#submit-btn { margin-left: auto; margin-bottom: 8px; padding: 10px 18px; }

#workspace { flex: 1; display: flex; min-height: 0; padding: 16px 24px 20px; gap: 16px; }
#main-panel { flex: 1.5; min-width: 0; display: flex; flex-direction: column; }
.panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.scenario-prompt {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 16px 20px;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 14px;
  overflow-y: auto;
  max-height: 42%;
  margin-bottom: 12px;
}
.panel textarea { flex: 1; resize: none; line-height: 1.55; font-size: 15px; }
.savebar { height: 20px; text-align: right; }
.saved { font-size: 12px; color: var(--fg-subtle); }

/* Chat */
.chat-header {
  background: var(--sun-100);
  border: 1px solid rgba(189, 107, 57, 0.25);
  border-radius: var(--radius-xl);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble { max-width: 82%; padding: 9px 13px; border-radius: var(--radius-xl); line-height: 1.45; font-size: 14px; white-space: pre-wrap; }
.bubble.them { background: var(--link-50); border: 1px solid var(--border-subtle); align-self: flex-start; }
.bubble.me { background: var(--link-600); color: #fff; align-self: flex-end; }
.bubble.typing { color: var(--fg-subtle); font-style: italic; background: transparent; border: none; }
.bubble.md { white-space: normal; }
.bubble.md p { margin: 0 0 6px; }
.bubble.md p:last-child { margin-bottom: 0; }
.bubble.md ul, .bubble.md ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble.md li { margin-bottom: 3px; }
.bubble.md hr { border: none; border-top: 1px solid var(--border-default); margin: 8px 0; }
.bubble.md .md-h { font-weight: 700; margin: 8px 0 4px; }
.bubble.md code { background: rgba(2, 58, 65, 0.07); border-radius: 4px; padding: 1px 4px; font-size: 13px; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.chat-input input { flex: 1; }

/* Sidebar */
#sidebar {
  flex: 1;
  max-width: 420px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
.side-tabs { display: flex; border-bottom: 1px solid var(--border-subtle); }
.side-tab { flex: 1; background: var(--bg-page); color: var(--fg-muted); border-radius: 0; padding: 10px; }
.side-tab.active { background: var(--bg-card); color: var(--lake-700); }
.side-tab:hover { background: var(--lake-100); color: var(--fg-default); }
.side-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 12px; }
#kb-results { flex: 1; overflow-y: auto; margin-top: 10px; }
.kb-hit { padding: 10px 4px; border-bottom: 1px solid var(--border-subtle); }
.kb-hit a { color: var(--link-600); font-weight: 600; text-decoration: none; font-size: 14px; }
.kb-hit a:hover { text-decoration: underline; }
.kb-hit p { margin: 4px 0 0; font-size: 12.5px; color: var(--fg-subtle); line-height: 1.4; }
.ai-disclosure { font-size: 12px; color: var(--fg-subtle); background: var(--bg-page); border-radius: var(--radius-lg); padding: 6px 10px; margin-bottom: 8px; }
#side-ai .chat-log { border: none; padding: 4px; }

@media (max-width: 900px) {
  #workspace { flex-direction: column; overflow-y: auto; }
  #sidebar { max-width: none; min-height: 340px; }
  .scenario-prompt { max-height: none; }
  .panel textarea { min-height: 220px; }
}
