/* Media Ingest Portal
 *
 * Shared by the administrative area (ERB) and the producer application (Vue).
 * Both layouts link this one file.
 *
 * The markup is plain semantic HTML, so nearly all of this hangs off element
 * selectors rather than classes. Keep it that way: a new admin screen should
 * inherit the look by using the right elements, not by remembering a class.
 *
 * DCMP exists to serve people with sensory disabilities. The contrast ratios
 * below are noted because they were chosen, not inherited, and they target AAA
 * wherever the text size allows it. Underlines stay on links, focus rings are
 * deliberately generous, type is sized in rem so browser zoom works, and no
 * state is signalled by colour alone.
 */

:root {
  /* Cool neutral, one deep accent. Ratios are against --paper. */
  --ink: #1a2024;        /* 15.0:1  body text */
  --ink-muted: #4a555c;  /*  7.6:1  secondary text, still AAA at body size */
  --paper: #ffffff;
  --paper-sunk: #f4f6f7;
  --rule: #d5dcdf;
  --accent: #0b5c6b;     /*  7.6:1  links and primary actions */
  --accent-wash: #e8f2f4;
  --flag: #8a4b10;       /*  7.0:1  errors and warnings */
  --flag-wash: #fbf2e9;

  /* No web fonts: nothing to download, nothing for the CSP to block, and the
   * interface renders in the reader's own system face.
   *
   * --data is monospace and it is load-bearing rather than stylistic. This
   * application is largely about pasting columns of integers; a fixed pitch
   * makes a misaligned or mistyped code visible at a glance. */
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --data: ui-monospace, "Cascadia Mono", "Segoe UI Mono", "SF Mono", Menlo, Consolas, monospace;

  --s1: 0.25rem;
  --s2: 0.5rem;
  --s3: 0.75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;

  --measure: 34rem; /* forms and prose */
  --wide: 68rem;    /* the page column */
}

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

body {
  margin: 0 auto;
  max-width: var(--wide);
  padding: 0 var(--s5) var(--s7);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 1rem;
  line-height: 1.55;
}

/* Header ------------------------------------------------------------------ */

header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2) var(--s4);
  padding: var(--s5) 0 var(--s4);
  margin-bottom: var(--s6);
  border-bottom: 1px solid var(--rule);
}

header > strong {
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}

header nav {
  display: flex;
  gap: var(--s4);
  margin-right: auto;
}

/* The producer application has no nav, so its sign-out control needs to claim
 * the right edge on its own. The admin area renders sign out as a form. */
header > button,
header form {
  margin-left: auto;
}

header .organization,
header .user {
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

header .organization {
  font-weight: 600;
  color: var(--ink);
}

/* Type -------------------------------------------------------------------- */

h1 {
  margin: 0 0 var(--s5);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  margin: var(--s6) 0 var(--s3);
  font-size: 1.125rem;
  font-weight: 600;
}

p {
  margin: 0 0 var(--s4);
  max-width: var(--measure);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

code {
  font-family: var(--data);
}

/* Producer codes and series IDs, shown back to the administrator. */
pre {
  margin: 0 0 var(--s5);
  padding: var(--s4);
  max-width: var(--measure);
  background: var(--paper-sunk);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: var(--data);
  font-size: 0.9375rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* Forms ------------------------------------------------------------------- */

form > div {
  margin-bottom: var(--s5);
}

label {
  display: block;
  margin-bottom: var(--s2);
  font-weight: 600;
}

/* Field hints sit between the label and the control. */
form p {
  margin: calc(var(--s1) * -1) 0 var(--s2);
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  display: block;
  width: 100%;
  max-width: var(--measure);
  padding: var(--s3);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink);
  font: inherit;
}

textarea {
  min-height: 9rem;
  font-family: var(--data);
  font-size: 0.9375rem;
  line-height: 1.7;
  resize: vertical;
}

select {
  max-width: var(--measure);
}

button,
input[type="submit"] {
  min-height: 2.75rem; /* a comfortable target, not a 30px sliver */
  padding: var(--s3) var(--s5);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--paper);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Sign out is not the primary action on any page it appears on. */
header button {
  min-height: auto;
  padding: var(--s2) var(--s3);
  background: transparent;
  border-color: var(--rule);
  color: var(--accent);
  font-weight: 400;
}

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

table {
  width: 100%;
  margin-bottom: var(--s5);
  border-collapse: collapse;
}

th,
td {
  padding: var(--s3) var(--s4);
  text-align: left;
  border-bottom: 1px solid var(--rule);
}

thead th {
  background: var(--paper-sunk);
  font-size: 0.9375rem;
}

/* Messages ---------------------------------------------------------------- */

.notice,
.alert,
.error,
.errors {
  margin: 0 0 var(--s5);
  padding: var(--s4);
  max-width: var(--measure);
  border-left: 4px solid;
  border-radius: 0 3px 3px 0;
}

/* Deliberately quieter than the one-time password panel below it. When both
 * appear on the same page, only one of them should be shouting. */
.notice {
  border-color: var(--accent);
}

.alert,
.error,
.errors {
  background: var(--flag-wash);
  border-color: var(--flag);
  color: var(--flag);
}

.errors ul {
  margin: 0;
  padding-left: var(--s5);
}

/* The one-time password.
 *
 * This is the highest-stakes moment in the administrative flow: there is no
 * mail delivery, so this string is shown exactly once and only its digest is
 * kept. If the administrator misses it, the account exists and nobody knows
 * its password. It gets the weight it deserves, and clicking it selects the
 * whole value so it can be copied in one action. */
.initial-password {
  margin: 0 0 var(--s5);
  padding: var(--s4);
  max-width: var(--measure);
  background: var(--accent-wash);
  border: 1px solid var(--accent);
  border-left-width: 4px;
  border-radius: 0 3px 3px 0;
  font-weight: 600;
}

.initial-password code {
  display: block;
  margin-top: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  user-select: all;
}

/* Focus ------------------------------------------------------------------- */

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

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

@media (max-width: 40rem) {
  body {
    padding: 0 var(--s4) var(--s6);
  }

  header {
    padding-top: var(--s4);
  }
}

/* Secondary explanatory copy, e.g. what will fill an empty screen. */
.hint {
  color: var(--ink-muted);
}

/* Two separate sign-in surfaces exist, and an account from one is not
 * recognised by the other. Someone who lands on the wrong one otherwise gets
 * told their password is incorrect, which sends them looking for the wrong
 * problem entirely. This is a static hint on both pages rather than a message
 * triggered by a failed attempt, so it discloses nothing about whether any
 * particular account exists. */
.other-portal {
  margin-top: var(--s6);
  padding-top: var(--s4);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: 0.9375rem;
}
