/* Colours are taken from the NLA-SA logo. Blue and cyan are too light for
   text on white (contrast), so they are only used for accents. */
:root {
  --color-brand: #003a75;
  --color-brand-dark: #002a55;
  --color-accent: #0089c4;
  --color-accent-light: #3bbfd4;
  --color-text: #1f2933;
  --color-muted: #5f6b7a;
  --color-surface: #ffffff;
  --color-page: #f3f5f8;
  --color-border: #d9dee5;
  --color-error: #b42318;
  --color-error-bg: #fef3f2;
  --color-success: #067647;
  --color-success-bg: #ecfdf3;
  --color-info-bg: #eff8ff;
  --radius: 8px;
  --space: 1rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--color-text);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-page);
}

.container {
  width: 100%;
  max-width: 80rem;
  margin: 0 auto;
  padding: 0 var(--space);
}

a {
  color: var(--color-brand);
}

:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.site-header {
  background: var(--color-surface);
  border-bottom: 4px solid var(--color-accent);
  padding: calc(var(--space) * 0.5) 0;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
}

/* Shown on every page while an admin views the site as a member: hard to miss, unlike flash alerts. */
.impersonation-banner {
  background: #b54708;
  color: #ffffff;
  padding: calc(var(--space) * 0.5) 0;
}

.impersonation-banner .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--space) * 0.5);
}

.impersonation-banner p {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.impersonation-banner .button {
  color: #b54708;
  background: #ffffff;
}

.impersonation-banner .button:hover {
  background: #fff4e5;
}

.brand {
  display: flex;
  align-items: center;
  gap: calc(var(--space) * 0.75);
  color: var(--color-brand);
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
}

.brand img {
  height: 48px;
  width: auto;
}

/* Two lines on the right: the menu, then the signed-in name under Sign Out. */
.header-account {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: calc(var(--space) * 0.25);
}

/* Wraps: an admin's nav (Content, Registrations) is too long for one line on a phone. */
.user-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: calc(var(--space) * 0.25);
  font-size: 0.9375rem;
}

.user-nav form {
  margin: 0;
}

.user-nav a,
.user-nav .button-link {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--color-brand);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.user-nav a:hover,
.user-nav .button-link:hover {
  background: var(--color-info-bg);
  border-color: var(--color-accent-light);
}

/* Outlined, so leaving the site doesn't look like another page link. */
.user-nav .nav-sign-out {
  border-color: var(--color-brand);
}

.user-nav .nav-sign-out:hover {
  background: var(--color-brand);
  border-color: var(--color-brand);
  color: #fff;
}

.user-name {
  margin: 0;
  padding-right: 0.875rem;
  font-size: 0.875rem;
  color: var(--color-muted);
}

/* On small phones keep just the logo and the action, not the name. */
@media (max-width: 30rem) {
  .brand-name,
  .user-name {
    display: none;
  }
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.site-main {
  flex: 1;
  padding-top: calc(var(--space) * 2);
  padding-bottom: calc(var(--space) * 2);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space) 0;
  font-size: 0.875rem;
  color: var(--color-muted);
  text-align: center;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: calc(var(--space) * 1.5);
}

.panel h1 {
  margin-top: 0;
  font-size: 1.5rem;
  color: var(--color-brand);
}

.panel-narrow {
  max-width: 26rem;
  margin: 0 auto;
}

.panel-logo {
  display: block;
  width: 120px;
  height: auto;
  margin: 0 auto var(--space);
}

.muted {
  color: var(--color-muted);
}

/* ── Signed-out landing page ────────────────────────────────────────────── */

.cpd-types dt {
  margin-top: var(--space);
  font-weight: 600;
  color: var(--color-brand);
}

.cpd-types dd {
  margin: 0.25rem 0 0;
}

/* Tinted, bordered box so visitors see at once where signing in starts. */
.start-box {
  max-width: 30rem;
  margin: calc(var(--space) * 2) auto 0;
  padding: calc(var(--space) * 1.5);
  text-align: center;
  background: var(--color-info-bg);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius);
}

.start-box p {
  margin: 0;
}

.start-box .start-box-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: var(--space);
}

.start-box-buttons .button {
  min-width: 9rem;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

.field {
  margin-bottom: var(--space);
}

.field label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.field input {
  width: 100%;
  padding: 0.625rem 0.75rem;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
}

.field input:focus {
  border-color: var(--color-accent);
}

.field-hint {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.form-footer {
  margin: var(--space) 0 0;
  text-align: center;
  font-size: 0.9375rem;
}

.button {
  display: inline-block;
  padding: 0.625rem 1.25rem;
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: var(--color-brand);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  background: var(--color-brand-dark);
}

.button-block {
  width: 100%;
}

.button-secondary {
  color: var(--color-brand);
  background: var(--color-surface);
  box-shadow: inset 0 0 0 2px var(--color-brand);
}

.button-secondary:hover {
  color: #ffffff;
}

.button-small {
  padding: 0.375rem 0.875rem;
  font-size: 0.9375rem;
}

.button-danger {
  background: var(--color-error);
}

.button-danger:hover {
  background: #912018;
}

.field-has-error input {
  border-color: var(--color-error);
}

.field-error {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  color: var(--color-error);
}

/* Spam-bot trap: off screen for people, still in the HTML for bots. */
.honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Read by screen readers, not shown on screen. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Looks like a link; used for the logout form button. */
.button-link {
  padding: 0;
  font: inherit;
  color: var(--color-brand);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* ── Messages ───────────────────────────────────────────────────────────── */

.alert {
  padding: 0.75rem var(--space);
  margin-bottom: var(--space);
  border-radius: 6px;
  border: 1px solid transparent;
}

.alert-error {
  color: var(--color-error);
  background: var(--color-error-bg);
  border-color: #fecdca;
}

.alert-success {
  color: var(--color-success);
  background: var(--color-success-bg);
  border-color: #abefc6;
}

.alert-info {
  color: var(--color-brand);
  background: var(--color-info-bg);
  border-color: #b2ddff;
}

.debug {
  overflow-x: auto;
  padding: var(--space);
  background: #fff4f4;
  border: 1px solid #f0c2c2;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  white-space: pre-wrap;
}

/* ── Admin tables ───────────────────────────────────────────────────────── */

/* Wide tables scroll inside the panel on phones instead of widening the page. */
.table-wrap {
  /* relative: absolutely positioned children (visually-hidden labels) stay
     inside the scroll box instead of widening the page on phones. */
  position: relative;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.data-table th,
.data-table td {
  padding: 0.625rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}

.decision {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.decision-approve {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

/* Group checkboxes sit in the same row as the member type and wrap on phones.
   min-width: 0 undoes the fieldset default that would otherwise overflow. */
.decision-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.decision-groups legend {
  float: left;
  margin-right: 0.25rem;
  padding: 0;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.decision-groups label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
}

.decision select {
  padding: 0.375rem 0.5rem;
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
}

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem var(--space);
}

.details dt {
  font-weight: 600;
}

.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ── Courses and lessons ────────────────────────────────────────────────── */

.breadcrumb {
  margin-bottom: var(--space);
  font-size: 0.9375rem;
  color: var(--color-muted);
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
  color: var(--color-muted);
  background: var(--color-page);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.course-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: var(--space);
  margin: 0;
  padding: 0;
  list-style: none;
}

.course-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: var(--space);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--color-accent);
  border-radius: var(--radius);
}

.course-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  color: var(--color-brand);
}

.course-card p {
  margin: 0 0 0.75rem;
}

/* Push the button to the bottom so cards in a row line up. */
.course-card .button {
  margin-top: auto;
}

@media (max-width: 30rem) {
  .course-cards {
    grid-template-columns: 1fr;
  }
}

.course-rules {
  margin: var(--space) 0;
  padding: 0.75rem var(--space);
  background: var(--color-info-bg);
  border-radius: 6px;
}

.course-rules summary {
  font-weight: 600;
  color: var(--color-brand);
  cursor: pointer;
}

.rich-text {
  overflow-wrap: anywhere;
}

/* Lesson and course text keeps a comfortable line length inside the wider page;
   div only, so the admin editor boxes stay full width. */
div.rich-text {
  max-width: 48rem;
}

.rich-text img {
  max-width: 100%;
  height: auto;
}

/* Lesson files: the main call to action, so they come before the text. */
.materials {
  margin: var(--space) 0 calc(var(--space) * 1.5);
  padding: var(--space);
  background: var(--color-info-bg);
  border-radius: var(--radius);
}

.materials h2 {
  margin: 0 0 0.25rem;
  font-size: 1.125rem;
}

.materials p {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
}

.materials-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Long file names wrap inside the button instead of widening the page. */
.materials-list .button {
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
}

.quiz:empty {
  display: none;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space);
  margin-top: calc(var(--space) * 1.5);
  padding-top: var(--space);
  border-top: 1px solid var(--color-border);
}

.pager-next {
  margin-left: auto;
  text-align: right;
}

/* ── Quizzes ────────────────────────────────────────────────────────────── */

.quiz {
  margin-top: calc(var(--space) * 2);
  padding-top: var(--space);
  border-top: 1px solid var(--color-border);
}

.quiz-title {
  margin-top: 0;
  font-size: 1.25rem;
  color: var(--color-brand);
}

.quiz-meta {
  font-weight: 600;
  color: var(--color-muted);
}

.unanswered-links {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

.question {
  min-width: 0;
  margin: 0 0 var(--space);
  padding: var(--space);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

/* Unanswered after a submit: red edge so it is easy to spot when scrolling. */
.question-unanswered {
  border-color: var(--color-error);
  border-left-width: 4px;
  background: var(--color-error-bg);
}

.question legend {
  padding: 0 0.25rem;
  font-weight: 600;
}

.question-hint {
  margin-left: 0.5rem;
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.question-text p {
  margin-top: 0;
}

/* Whole row is the tap target, so answers are easy to hit on a phone. */
.answer {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.5rem 0.25rem;
  border-radius: 6px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.answer:hover {
  background: var(--color-page);
}

.answer input {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0.2rem 0 0;
}

.outcome {
  margin: var(--space) 0;
  padding: var(--space);
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.outcome p {
  margin: 0;
}

.outcome-title {
  font-size: 1.375rem;
  font-weight: 700;
}

.outcome-passed {
  color: var(--color-success);
  background: var(--color-success-bg);
  border-color: #abefc6;
}

.outcome-failed {
  color: var(--color-error);
  background: var(--color-error-bg);
  border-color: #fecdca;
}

.certificate-spot {
  padding: var(--space);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  color: var(--color-muted);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.review {
  padding-left: 1.25rem;
}

.review-question {
  margin-bottom: var(--space);
  overflow-wrap: anywhere;
}

.review-verdict {
  margin: 0;
  font-weight: 600;
}

.review-correct .review-verdict {
  color: var(--color-success);
}

.review-wrong .review-verdict {
  color: var(--color-error);
}

.review-answers {
  padding-left: 1.25rem;
}

.answer-correct {
  font-weight: 600;
}

.badge-correct {
  color: var(--color-success);
  background: var(--color-success-bg);
  border-color: #abefc6;
}

/* ── My CPD ─────────────────────────────────────────────────────────────── */

.cpd-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cpd-row {
  border-top: 1px solid var(--color-border);
  padding: var(--space) 0;
}

.cpd-title {
  font-size: 1.125rem;
  margin: 0 0 calc(var(--space) * 0.25);
  overflow-wrap: anywhere;
}

.cpd-row .muted {
  margin: 0 0 calc(var(--space) * 0.5);
}

/* Date, score and status sit side by side and wrap on narrow phones. */
.cpd-facts {
  display: flex;
  flex-wrap: wrap;
  gap: calc(var(--space) * 0.5) calc(var(--space) * 1.5);
  margin: 0 0 calc(var(--space) * 0.5);
}

.cpd-facts dt {
  font-size: 0.8125rem;
  color: var(--color-muted);
}

.cpd-facts dd {
  margin: 0;
}

.cpd-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: calc(var(--space) * 0.75);
  margin: 0;
}

/* ---- Admin content pages ---- */

.admin-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: calc(var(--space) * 0.75);
}

.breadcrumb {
  margin: 0 0 calc(var(--space) * 0.75);
  font-size: 0.9375rem;
}

.admin-form textarea,
.admin-form select,
.field textarea,
.field select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--color-border, #c8c8c8);
  border-radius: 4px;
}

.field textarea {
  min-height: 10rem;
}

fieldset.field {
  border: 0;
  padding: 0;
  margin-left: 0;
  margin-right: 0;
}

fieldset.field legend {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* .field label and .field input (written for text boxes) would otherwise make
   tick-box labels bold and stretch the box to full width, pushing the text below it. */
.choice,
.field .choice {
  display: block;
  font-weight: normal;
  margin: 0.25rem 0;
}

.choice input[type="checkbox"],
.choice input[type="radio"] {
  width: auto;
  padding: 0;
  margin: 0 0.5rem 0 0;
  vertical-align: middle;
}

.move-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.move-buttons form {
  margin: 0;
}

.actions a + a {
  margin-left: 0.75rem;
}

.lesson-tree,
.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.topic-list {
  padding-left: calc(var(--space) * 1.5);
}

.tree-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border, #e2e2e2);
}

.tree-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Toolbar editor (public/assets/js/rich-text.js) */
.rich-editor {
  border: 1px solid var(--color-border, #c8c8c8);
  border-radius: 4px;
}

.rich-toolbar,
.rich-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.375rem;
  border-bottom: 1px solid var(--color-border, #e2e2e2);
  background: #f6f6f6;
}

.rich-toolbar button[aria-pressed="true"] {
  outline: 2px solid currentColor;
}

.rich-link-row input {
  flex: 1 1 12rem;
  min-width: 0;
}

.rich-area {
  min-height: 12rem;
  padding: 0.5rem 0.75rem;
  overflow-wrap: anywhere;
}

.rich-area:focus {
  outline: 2px solid #1a5fb4;
  outline-offset: -2px;
}

.rich-editor textarea {
  border: 0;
  border-radius: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
}

.file-link {
  flex: 1 1 14rem;
  min-width: 0;
  font-size: 0.8125rem;
}

.field-short input {
  max-width: 10rem;
}

.answer-rows {
  margin: 0 0 0.75rem;
  padding-left: 1.5rem;
}

.answer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.5rem;
}

.answer-row input[type="text"] {
  flex: 1 1 14rem;
  min-width: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.delete-link {
  margin-top: calc(var(--space) * 1.5);
}

.delete-link a {
  color: var(--color-danger, #b3261e);
}

.template-thumb,
.template-preview {
  border: 1px solid var(--color-border, #c8c8c8);
  height: auto;
  max-width: 100%;
}

/* CSV import preview */
.import-text {
  white-space: pre-line;
  min-width: 12rem;
}

.import-answers {
  margin: 0;
  padding-left: 1rem;
}

.import-answers .is-correct {
  font-weight: 600;
}

/* Members */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  align-items: flex-end;
}

.filter-form .field {
  flex: 1 1 10rem;
}

.filter-form .button {
  margin-bottom: 1rem;
}

.filter-form .filter-note {
  flex-basis: 100%;
  margin: -0.5rem 0 1rem;
}

/* Reports */
.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  margin-bottom: 1rem;
}

.view-switch [aria-current="page"] {
  font-weight: 600;
  text-decoration: none;
  color: inherit;
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0 0 1rem;
}

.facts dt {
  font-weight: 600;
}

.facts dd {
  margin: 0;
}
