/*
 * VRP help walkthroughs: the shared stylesheet (US-V710, issues #250-#254).
 *
 * Every page under /help/<locale>/<slug>.html links this file and nothing
 * else: the walkthroughs carry no script and no inline style, so the
 * portal's per-request nonce CSP (infra/nginx/portal.conf) is untouched.
 * Their only images are same-origin PNGs (img-src 'self') under
 * /help/img/<locale>/, each in a figure.help-figure (issue #274).
 * The classes styled here are the only ones a walkthrough may use (help
 * contract): help-skip, help-header, help-institution, help-portal, help-emblem,
 * help-languages, help-main, help-back, help-lede, help-toc, help-steps,
 * help-result, help-ui, help-note, help-note--blocker, help-note--warning,
 * help-note--deadline, help-table, help-figure, help-footer; plus the plain
 * elements h1-h3, p, ul, ol, dl, code, kbd and table.
 * scripts/check_help_pages.py checks a walkthrough against the contract.
 *
 * UI_STANDARDS: ECOWAS tokens only, Inter at 400/500/600, 4px radius, no
 * shadow, no gradient, no emoji.
 */

/* Inter via Google Fonts (UI_STANDARDS, Typography). The portal CSP allows
   style-src https://fonts.googleapis.com and font-src https://fonts.gstatic.com.
   When the font cannot be fetched the stack below falls back to system fonts. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/*
 * Design tokens: a COPY of the colour, type, spacing and structure tokens
 * these pages use from apps/vendor-portal/src/styles/tokens.css (the import,
 * AI and layout-chrome tokens are not needed here and are left out).
 *
 * These pages are served by nginx as plain files, outside the Next.js
 * bundle, so they cannot import the portal's stylesheet. Every value below
 * must stay identical to that file; src/test/help.test.ts fails when one
 * differs. Change the source first, then this copy. Only the --help-*
 * properties at the end are local to the help pages.
 */
:root {
  /* -- ECOWAS brand ----------------------------------------------------- */
  --color-primary: #006b3f;
  --color-primary-dark: #004d2c;
  --color-primary-light: #00895a;

  /* -- ECOWAS accent (never body text) ---------------------------------- */
  --color-accent: #d4a843;
  --color-accent-dark: #b8902e;
  --color-accent-light: #f5e6c0;

  /* -- ECOWAS earth ------------------------------------------------------ */
  --color-secondary: #6b3a2a;
  --color-secondary-light: #8b5a4a;

  /* -- Neutrals ---------------------------------------------------------- */
  --color-text-primary: #1a1a2e;
  --color-text-secondary: #595959;
  --color-text-muted: #8c8c8c;
  --color-border: #d9d9d9;
  --color-border-strong: #bfbfbf;
  --color-surface: #ffffff;
  --color-surface-raised: #f7f8fa;
  --color-surface-sunken: #f0f2f5;

  /* -- Status (legal weight; AA on a light background) ------------------- */
  --color-success: #006b3f;
  --color-success-light: #e2efda;
  --color-warning: #7f6000;
  --color-warning-light: #fff2cc;
  --color-danger: #c00000;
  --color-danger-light: #fce4d6;
  --color-info: #2e75b6;
  --color-info-light: #deeaf1;
  --color-info-text: #1f4e79;

  /* -- Typography -------------------------------------------------------- */
  --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-md: 18px;
  --font-size-lg: 20px;
  --font-size-xl: 24px;
  --font-size-2xl: 30px;
  --line-height-body: 1.5;
  --line-height-heading: 1.25;

  /* -- Spacing scale (no other values) ----------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* -- Structure --------------------------------------------------------- */
  --radius: 4px;
  --gutter: 24px;

  /* -- Help pages only (not a portal token) ------------------------------ */
  /* A readable measure: about 75 characters of body text at 16px. */
  --help-measure: 760px;
  /* Side padding that centres a column of --help-measure in any width. */
  --help-inline: max(var(--gutter), calc((100% - var(--help-measure)) / 2));
}

/* -- Document ------------------------------------------------------------ */

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

html {
  font-size: 100%;
}

body {
  margin: 0;
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  font-weight: 400;
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-4);
  font-weight: 600;
  line-height: var(--line-height-heading);
}

h1 {
  font-size: var(--font-size-xl);
}

h2 {
  font-size: var(--font-size-lg);
}

h3 {
  margin-top: var(--space-6);
  font-size: var(--font-size-md);
}

p {
  margin: 0 0 var(--space-4);
}

ul,
ol {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-6);
}

li + li {
  margin-top: var(--space-2);
}

dl {
  margin: 0 0 var(--space-4);
}

dt {
  font-weight: 600;
}

dd {
  margin: 0 0 var(--space-3) var(--space-6);
}

a {
  color: var(--color-primary);
  text-decoration: underline;
}

a:hover {
  color: var(--color-primary-dark);
}

/* A visible focus ring (WCAG 2.4.7), the portal's own. */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

code,
kbd {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

code {
  padding: 0 var(--space-1);
  border-radius: var(--radius);
  background: var(--color-surface-sunken);
}

kbd {
  padding: 0 var(--space-1);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface-raised);
}

strong {
  font-weight: 600;
}

/* -- Skip link: the first focusable element ------------------------------ */

.help-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: var(--color-surface);
  text-decoration: none;
}

.help-skip:focus {
  left: var(--space-4);
  top: var(--space-2);
  color: var(--color-surface);
}

/* -- Header: institution, portal, languages ------------------------------ */

.help-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-6);
  padding: var(--space-3) var(--help-inline);
  border-bottom: 3px solid var(--color-primary);
  background: var(--color-surface);
}

.help-header p {
  margin: 0;
}

.help-institution {
  flex: 1 0 100%;
  color: var(--color-primary);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.help-portal {
  flex: 1 1 auto;
  font-size: var(--font-size-md);
  font-weight: 600;
}

.help-portal a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-primary);
  text-decoration: none;
}

/* The ECOWAS emblem, decorative (alt=""); kept in print. */
.help-emblem {
  flex-shrink: 0;
  width: 46px;
  height: 48px;
}

.help-portal a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.help-languages {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--font-size-sm);
}

.help-languages a[aria-current='page'] {
  color: var(--color-text-primary);
  font-weight: 600;
  text-decoration: none;
}

/* -- Main column --------------------------------------------------------- */

.help-main {
  padding: var(--space-8) var(--help-inline) var(--space-12);
}

.help-main section {
  margin-top: var(--space-10);
  /* A section reached from "On this page" lands with room above its heading. */
  scroll-margin-top: var(--space-6);
}

/* ...and its heading carries the 4px left bar the help notes use, hung in
   the gutter so the text does not move. */
.help-main section:target > h2 {
  margin-left: calc(-1 * (var(--space-3) + 4px));
  padding-left: var(--space-3);
  border-left: 4px solid var(--color-primary);
}

.help-back {
  font-size: var(--font-size-sm);
}

.help-lede {
  color: var(--color-text-secondary);
  font-size: var(--font-size-md);
}

/* -- On this page -------------------------------------------------------- */

.help-toc {
  margin: var(--space-6) 0 0;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-raised);
}

.help-toc h2 {
  margin: 0 0 var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.help-toc ol,
.help-toc ul {
  margin: 0;
}

.help-toc li + li {
  margin-top: var(--space-1);
}

/* -- Steps: numbered, the number in an ECOWAS-green circle --------------- */

.help-steps {
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
  counter-reset: help-step;
}

.help-steps > li {
  position: relative;
  min-height: var(--space-6);
  padding-left: var(--space-10);
  counter-increment: help-step;
}

.help-steps > li + li {
  margin-top: var(--space-3);
}

.help-steps > li::before {
  content: counter(help-step);
  position: absolute;
  left: 0;
  top: 0;
  width: var(--space-6);
  height: var(--space-6);
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-surface);
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: var(--space-6);
  text-align: center;
}

/* What the user sees when the steps worked. */
.help-result {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-success);
  border-radius: var(--radius);
  background: var(--color-success-light);
}

/* An on-screen label, button or field name, quoted exactly. */
.help-ui {
  padding: 0 var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface-raised);
  font-weight: 600;
}

/* -- Notes: tip (neutral), BLOCKER, WARNING, DEADLINE ---------------------- */

.help-note {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface-raised);
}

.help-note > :last-child {
  margin-bottom: 0;
}

/* Red = BLOCKED (UI_STANDARDS, status colours). */
.help-note--blocker {
  border-left-color: var(--color-danger);
  background: var(--color-danger-light);
}

/* Amber = WARNING. */
.help-note--warning {
  border-left-color: var(--color-warning);
  background: var(--color-warning-light);
}

/* Blue = informational: a deadline is tracked and alerted, never blocking. */
.help-note--deadline {
  border-left-color: var(--color-info);
  background: var(--color-info-light);
  color: var(--color-info-text);
}

/* -- Tables -------------------------------------------------------------- */

table,
.help-table {
  width: 100%;
  margin: 0 0 var(--space-4);
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

caption {
  padding-bottom: var(--space-2);
  font-weight: 600;
  text-align: left;
}

th {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border-strong);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  vertical-align: bottom;
}

tbody th {
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  letter-spacing: normal;
  text-transform: none;
  vertical-align: top;
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

th,
td {
  overflow-wrap: anywhere;
}

/* -- Figures: one screen of the portal, beside the step it illustrates ---- */

/*
 * <figure class="help-figure"><img src="../img/<locale>/<screen-id>.png"
 * alt="..." width="W" height="H" loading="lazy"><figcaption>...</figcaption>
 * </figure>. The width and height attributes reserve the space before the
 * image loads; the image never grows past its own size or the column.
 */
.help-figure {
  margin: var(--space-3) 0 var(--space-4);
}

.help-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
}

.help-figure figcaption {
  margin-top: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* -- Footer -------------------------------------------------------------- */

.help-footer {
  padding: var(--space-6) var(--help-inline);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-sunken);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

.help-footer p {
  margin: 0;
}

/* -- Narrow screens ------------------------------------------------------ */

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .help-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .help-institution {
    flex-basis: auto;
  }

  .help-main {
    padding-top: var(--space-6);
  }

  th,
  td {
    padding: var(--space-2) var(--space-3);
  }
}

/* -- Print: the walkthrough, not the page furniture ---------------------- */

@media print {
  body {
    background: var(--color-surface);
    font-size: var(--font-size-sm);
  }

  .help-skip,
  .help-languages,
  .help-back {
    display: none;
  }

  .help-header,
  .help-main,
  .help-footer {
    padding-left: 0;
    padding-right: 0;
  }

  .help-footer {
    background: none;
  }

  .help-main section:target > h2 {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }

  a {
    color: var(--color-text-primary);
  }

  h1,
  h2,
  h3 {
    break-after: avoid;
  }

  .help-steps > li,
  .help-note,
  .help-result,
  .help-toc,
  tr {
    break-inside: avoid;
  }

  .help-steps > li::before {
    border: 1px solid var(--color-primary);
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* A figure stays whole on one page, with its caption; a tall screen is
     scaled down to fit the page rather than cut. A step that holds a
     figure may break, or a long step and its image would leave a blank page. */
  .help-figure {
    break-inside: avoid;
  }

  .help-steps > li:has(.help-figure) {
    break-inside: auto;
  }

  .help-figure img {
    width: auto;
    max-height: 20cm;
  }
}
