/* NCSA Labs: colours and type follow UI_Development/STYLEGUIDE.md (14px base, rem sizes). */
:root {
  --primary: #0b3d93;
  --primary-dark: #00338d;
  --accent: #c9a227;
  --text: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9f9f9;
  --card: #ffffff;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --console: #111827;
  --fs-2xs: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-2xl: 1.5rem;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 var(--fs-base)/1.4286 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--fs-sm); }
pre { background: var(--console); color: #e5e7eb; padding: 0.625rem 0.75rem; border-radius: 6px; overflow-x: auto; }
:not(pre) > code { background: #eef2f7; padding: 0.05rem 0.3rem; border-radius: 4px; }

.btn {
  font: 500 var(--fs-base)/1.25 inherit; border: 1px solid var(--primary); background: var(--card);
  color: var(--primary); border-radius: 6px; padding: 0.45rem 0.9rem; cursor: pointer; text-decoration: none;
  display: inline-block;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn.ghost { border-color: rgba(255, 255, 255, 0.5); background: transparent; color: #fff; }
.btn.small { padding: 0.3rem 0.7rem; font-size: var(--fs-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.brand { font-weight: 700; letter-spacing: 0.5px; }
.brand span { color: var(--accent); }

/* message page */
body.centered { display: grid; place-items: center; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.message { max-width: 32rem; padding: 2rem; }
.message .brand { color: var(--primary); margin-bottom: 1rem; }
.message h1 { font-size: var(--fs-2xl); margin: 0 0 0.5rem; }

/* lab app */
body.lab-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 0.5rem 1rem; background: var(--primary); color: #fff;
  flex-wrap: wrap;
}
.topbar .lab-title { font-size: var(--fs-md); font-weight: 600; flex: 1; min-width: 10rem; }
.topbar .meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.pill {
  background: rgba(255, 255, 255, 0.15); border-radius: 999px; padding: 0.25rem 0.7rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.timer.warn { background: var(--warn); }

.staff-bar {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.5rem 1rem;
  background: var(--warn-bg); border-bottom: 1px solid #fde68a; font-size: var(--fs-sm);
}
.staff-bar select { font: inherit; padding: 0.2rem; margin-left: 0.25rem; max-width: 22rem; }

.workspace { flex: 1; display: grid; grid-template-columns: minmax(18rem, 26rem) 1fr; min-height: 0; }
.workspace.console-only { grid-template-columns: 1fr; }
.notice-bar { padding: 0.5rem 1rem; background: #eef4ff; border-bottom: 1px solid #c7d7f5; font-size: var(--fs-sm); }
.notice-bar a { color: var(--primary); font-weight: 600; }
/* Embedded in the Moodle worksheet: slim bar, all space to the machine. */
body.embedded .topbar { padding: 0.3rem 0.6rem; gap: 0.5rem; }
body.embedded .topbar .lab-title { font-size: var(--fs-sm); }
body.embedded .btn { padding: 0.25rem 0.6rem; font-size: var(--fs-sm); }
body.embedded .staff-bar { padding: 0.35rem 0.6rem; }
.panel { overflow-y: auto; border-right: 1px solid var(--border); background: var(--card); padding: 0.75rem 1rem 2rem; }
.panel h2 { font-size: var(--fs-lg); margin: 1rem 0 0.5rem; }
.instructions summary, .hint summary { cursor: pointer; font-weight: 600; }
.instructions { border: 1px solid var(--border); border-radius: 8px; padding: 0.5rem 0.75rem; }
.md p { margin: 0.4rem 0; }
.md ul, .md ol { padding-left: 1.2rem; }

.tasks { list-style: none; margin: 0; padding: 0; counter-reset: task; display: grid; gap: 0.625rem; }
.task {
  counter-increment: task; border: 1px solid var(--border); border-radius: 8px; padding: 0.625rem 0.75rem;
  border-left: 4px solid var(--border);
}
.task.passed { border-left-color: var(--ok); background: var(--ok-bg); }
.task.failed { border-left-color: var(--bad); }
.task.pending { border-left-color: var(--warn); background: var(--warn-bg); }
.task-head { display: flex; gap: 0.5rem; align-items: flex-start; }
.task-head .status::before {
  content: counter(task); display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem;
  border-radius: 50%; background: #eef2f7; font-size: var(--fs-xs); font-weight: 700;
}
.task.passed .status::before { content: "✓"; background: var(--ok); color: #fff; }
.task.pending .status::before { content: "…"; background: var(--warn); color: #fff; }
.task-head .prompt { flex: 1; }
.task-head .prompt p { margin: 0; }
.points { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }
.hint { margin: 0.4rem 0 0 1.9rem; font-size: var(--fs-sm); }
.task-body { display: flex; gap: 0.5rem; margin: 0.5rem 0 0 1.9rem; align-items: flex-start; }
.task-body .answer {
  flex: 1; font: inherit; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: var(--fs-sm);
  border: 1px solid var(--border); border-radius: 6px; padding: 0.35rem 0.5rem; min-width: 0;
}
.task-body .answer:focus { outline: 2px solid var(--primary); outline-offset: 0; }
.feedback { margin: 0.35rem 0 0 1.9rem; font-size: var(--fs-sm); color: var(--muted); }
.task.passed .feedback { color: var(--ok); }
.task.failed .feedback { color: var(--bad); }

.console { display: flex; flex-direction: column; min-height: 0; background: var(--console); }
.tabs { display: flex; gap: 0.25rem; padding: 0.4rem 0.5rem 0; background: #0b1220; }
.tab {
  font: 500 var(--fs-sm)/1 inherit; color: #cbd5e1; background: transparent; border: 0; cursor: pointer;
  padding: 0.55rem 0.9rem; border-radius: 6px 6px 0 0;
}
.tab.active { background: var(--console); color: #fff; }
.tab.reconnect { margin-left: 0.25rem; }
#btn-newterm { margin-left: 0.25rem; }
.termtabs { display: flex; gap: 0.2rem; margin-left: 0.75rem; align-self: flex-end; overflow-x: auto; }
.termtab {
  font: 500 var(--fs-xs)/1 inherit; color: #cbd5e1; background: #1f2937; border: 0; cursor: pointer;
  padding: 0.45rem 0.7rem; border-radius: 6px 6px 0 0; white-space: nowrap;
}
.termtab.active { background: var(--accent); color: #111827; }
.conn-state { margin-left: auto; align-self: center; font-size: var(--fs-xs); color: #cbd5e1; }
.conn-state.warn { color: #fbbf24; }
.frame.guac { overflow: hidden; outline: none; cursor: text; }
.frame.guac:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.frame.guac .guac-display { margin: 0 auto; }
.frames { position: relative; flex: 1; min-height: 0; }
.frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: none; background: var(--console); }
.frame.active { display: block; }
.overlay {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 0.75rem;
  background: var(--console); color: #e5e7eb; text-align: center; padding: 1rem;
}
.overlay[hidden] { display: none; }
.overlay p { max-width: 28rem; margin: 0; }
.spinner {
  width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
.spinner[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  body.lab-app { height: auto; overflow: auto; }
  .workspace { grid-template-columns: 1fr; }
  .panel { border-right: 0; border-bottom: 1px solid var(--border); }
  .console { height: 70vh; }
}
