/*
 * The stylesheet of the operator area (OPS-052; design pass of release 003, section 1). Every colour,
 * size, face and duration comes from tokens.css beside it, the copy of the client's token file, which
 * a test holds equal to the original byte for byte. The one value repeated here is the width of the
 * wide layout in the media query below, because a media query cannot refer to a custom property; a
 * test holds it equal to the token --wide. No script reads this sheet, and it loads nothing else.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-block-size: 100svh;
  margin: 0;
  background: var(--color-page);
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: var(--type-m-size);
  line-height: var(--type-m-line);
  overflow-wrap: break-word;
}

/* Sign-in retains a text column; authenticated pages use the operator width. */
.frame,
main {
  max-width: var(--text);
  margin-inline: auto;
  padding: var(--space-4);
}

main {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  outline: none;
}

main > * {
  margin: 0;
}

/* The public sign-in uses the same card, fields and action tokens as the client. */
.sign-in-page {
  display: flex;
  flex-direction: column;
  min-block-size: 100svh;
}

.sign-in-layout {
  inline-size: 100%;
}

.sign-in-page .frame {
  max-width: var(--operator-wide);
}

.sign-in-layout {
  margin-block: auto;
  padding-block: var(--space-6);
}

.sign-in-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-inline-size: 0;
  padding: var(--space-5);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-l);
  background: var(--color-surface);
  box-shadow: var(--shadow-dialog);
}

.sign-in-card > *,
.sign-in-intro > * {
  margin: 0;
}

.sign-in-intro {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sign-in-intro p,
.sign-in-card .resend > p {
  color: var(--color-text-muted);
}

.sign-in-card .form > .button {
  inline-size: 100%;
}

.sign-in-card .resend {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-3);
  padding-block-start: var(--space-5);
  border-block-start: 1px solid var(--color-divider);
}

.sign-in-card .resend > * {
  margin: 0;
}

.sign-in-page a.button {
  text-decoration: none;
}

.pages {
  inline-size: 100%;
}

/* The choice of the period on the pages visits and interest is a navigation as well, and its
   current period is marked as the current page is (design pass, 1.5). */
.pages ul,
.periods ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.pages a,
.periods a {
  display: inline-flex;
  align-items: center;
  min-width: var(--control-size);
  min-height: var(--control-size);
  padding: 0 var(--space-3);
  border-bottom: 3px solid transparent;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  color: var(--color-primary);
  text-decoration: none;
  transition: background-color var(--motion-control);
}

.pages a:hover,
.periods a:hover {
  background: var(--color-primary-soft);
}

/* The current page: weight, a bottom border and a surface, so that colour is not its only sign. */
.pages a[aria-current="page"],
.periods a[aria-current="true"] {
  border-bottom-color: var(--color-primary);
  background: var(--color-primary-soft);
  font-weight: 600;
}

.sign-out {
  margin: 0;
}

/* The skip link stands first in the reading order and shows when it has the focus. */
.skip {
  position: absolute;
  inset-block-start: var(--space-2);
  inset-inline-start: var(--space-2);
  z-index: 1;
  display: inline-flex;
  align-items: center;
  min-height: var(--control-size);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  background: var(--color-surface);
  color: var(--color-primary);
}

.skip:not(:focus) {
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Headings */
h1 {
  font-size: var(--type-xl-size);
  line-height: var(--type-xl-line);
  font-weight: var(--type-xl-weight);
  letter-spacing: var(--type-heading-tracking);
}

h2,
h3 {
  margin: 0 0 var(--space-3);
}

h2 {
  font-size: var(--type-l-size);
  line-height: var(--type-l-line);
  font-weight: var(--type-l-weight);
}

h3 {
  font-size: var(--type-m-size);
  line-height: var(--type-m-line);
  font-weight: 600;
}

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

/* A section is a card. */
.card {
  padding: var(--space-4);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-m);
  background: var(--color-surface);
}

.card > :first-child {
  margin-block-start: 0;
}

.card > :last-child,
.item > :last-child,
.field > :last-child {
  margin-bottom: 0;
}

.item + .item {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
}

/* Links and actions: every one at least the control size high and wide (UIC-040). */
main a {
  display: inline-flex;
  align-items: center;
  min-width: var(--control-size);
  min-height: var(--control-size);
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

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

.links {
  margin: 0;
  padding-inline-start: var(--space-5);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--control-size);
  min-height: var(--control-size);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-primary);
  border-radius: var(--button-radius);
  font: inherit;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition:
    background-color var(--motion-control),
    border-color var(--motion-control),
    color var(--motion-control);
}

.button.primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-primary);
}

.button.primary:hover {
  border-color: var(--color-primary-hover);
  background: var(--color-primary-hover);
}

.button.primary:active {
  border-color: var(--color-primary-pressed);
  background: var(--color-primary-pressed);
}

.button.secondary {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.button.secondary:hover {
  border-color: var(--color-primary-hover);
  color: var(--color-primary-hover);
}

.button.secondary:active {
  background: var(--color-divider);
}

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

.button.danger:hover,
.button.danger:active {
  background: var(--color-danger-soft);
}

/* One focus ring for every action: a dark ring outside a light gap (UIC-044), as the client's. */
:root :focus-visible {
  outline: var(--focus-ring) solid var(--color-focus);
  outline-offset: var(--focus-gap);
  box-shadow: 0 0 0 var(--focus-gap) var(--color-focus-gap);
}

/* The main region takes the focus from the skip link; it is no action and shows no ring. */
main:focus-visible {
  outline: none;
  box-shadow: none;
}

/* Forms: the label above the control, then the control, the hint and the error (UIC-020). */
.form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
}

.field label {
  font-weight: 600;
}

.field input {
  width: 100%;
  min-height: var(--control-size);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--field-radius);
  background: var(--field-surface);
  color: var(--color-text);
  font: inherit;
}

.field input:hover,
.field input:focus {
  border-color: var(--color-primary);
}

.field input[aria-invalid="true"] {
  border-color: var(--color-danger);
}

.hint {
  color: var(--color-text-muted);
  font-size: var(--type-s-size);
  line-height: var(--type-s-line);
}

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

/* A refusal of the page stands as one notice above the form, in the state-card presentation. */
.notice,
.status {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-m);
  background: var(--color-notice-bg);
}

.notice > div,
.status > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.notice p,
.status p {
  margin: 0;
}

.notice svg,
.status svg,
.badge svg {
  flex: none;
  width: 1.25em;
  height: 1.25em;
}

.notice > svg,
.status > svg {
  margin-block-start: max(0px, (1lh - 1.25em) / 2);
}

.status {
  border-color: var(--color-divider);
  background: var(--color-primary-soft);
}

/* Badges: words, a glyph and a surface; the colour never carries the meaning alone (1.3). */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  font-weight: 600;
}

.badge.ok {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.badge.warning {
  border-color: var(--color-border);
  background: var(--color-notice-bg);
  color: var(--color-text);
}

.badge.danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.badge.neutral {
  border-color: var(--color-border);
  background: var(--color-subtle);
  color: var(--color-text);
}

/* Facts: the label above the value; from the wide layout on, two columns (1.7). */
.facts {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-3);
}

.facts div {
  display: grid;
  gap: 0;
}

.facts dt {
  color: var(--color-text-muted);
  font-size: var(--type-s-size);
  line-height: var(--type-s-line);
}

.facts dd {
  margin: 0;
}

/* The width of the wide layout, the token --wide, which a test compares with this value. */
@media (min-width: 48em) {
  .facts div {
    grid-template-columns: minmax(10rem, 1fr) 2fr;
    gap: var(--space-4);
  }
}

/* Checksums, sources, build identifiers, places of errors and commands (1.2, 1.7). */
code,
pre,
.code {
  font-family: var(--font-code);
  overflow-wrap: anywhere;
}

pre {
  margin: 0 0 var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-s);
  background: var(--color-subtle);
  font-size: var(--type-s-size);
  line-height: var(--type-s-line);
  white-space: pre-wrap;
}

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

summary {
  display: flex;
  align-items: center;
  min-height: var(--control-size);
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
}

details[open] > pre {
  margin-top: var(--space-2);
}

/* A total of a period, in the size of a figure (1.2). */
.stat {
  font-size: var(--type-stat-size);
  line-height: var(--type-xl-line);
  font-weight: var(--type-xl-weight);
  font-variant-numeric: tabular-nums;
}

/* A chart (1.4): the SVG stretched to the width at a height that grows with the text, its bars and
   the stubs of the days without a figure filled by their classes, the baseline under it, and the
   axis as text of the page. */
.chart .plot {
  display: block;
  width: 100%;
  height: 10rem;
  overflow: visible;
  border-bottom: 1px solid var(--color-border);
}

.chart .bar {
  fill: var(--color-primary);
}

.chart .zero {
  fill: var(--color-divider);
}

.axis {
  color: var(--color-text-muted);
  font-size: var(--type-s-size);
  line-height: var(--type-s-line);
  font-variant-numeric: tabular-nums;
}

.axis.days {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 var(--space-2);
  margin-top: var(--space-1);
}

details[open] > .table {
  margin-top: var(--space-2);
}

/* Tables: in a region that scrolls on its own as a fallback, numbers right-aligned (1.7). */
.table {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-m);
  background: var(--color-surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

caption {
  padding: var(--space-3) var(--space-4) 0;
  color: var(--color-text-muted);
  font-size: var(--type-s-size);
  text-align: start;
}

th,
td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  text-align: start;
  vertical-align: top;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

th {
  color: var(--color-text-muted);
  font-size: var(--type-s-size);
  font-weight: 600;
}

/* A head of a row names its row, a day or an hour, in the size of the text. */
th[scope="row"] {
  color: var(--color-text);
  font-size: inherit;
  font-weight: inherit;
}

th.number,
td.number {
  text-align: end;
}

/* A table of more columns than four (the days of the page visits): narrower cells, and the head of
   each row stays in view while the table scrolls sideways (design pass of release 005, 0.2). */
.dense th,
.dense td {
  padding-inline: var(--space-2);
}

.dense th:first-child {
  position: sticky;
  inset-inline-start: 0;
  background: var(--color-surface);
}

/* A line that explains a table stands apart from the table it follows (the page visits). */
.table + .hint {
  margin-top: var(--space-2);
}

/* The place of an error on the page errors: the source, the place and the type one under another,
   then the call site to open (1.5). */
.place p {
  margin: 0 0 var(--space-1);
}

.place details {
  margin-top: 0;
}

/* Windows high contrast: the badges and the notice keep an outline of the system's text colour,
   and the bars of a chart and its baseline take it too (1.4). */
@media (forced-colors: active) {
  .badge,
  .notice,
  .card,
  .chart .plot {
    border-color: CanvasText;
  }

  .chart .bar {
    fill: CanvasText;
  }

  .chart .zero {
    fill: GrayText;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pages a,
  .periods a,
  .button {
    transition: none;
  }
}

.operator .frame,
.operator main {
  max-width: var(--operator-wide);
}

.operator main {
  inline-size: min(calc(100% - var(--web-header-inline) * 2), var(--website-width));
  padding-inline: 0;
}

.visits-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-inline-size: 0;
}

.visits-section > * {
  min-inline-size: 0;
  margin: 0;
}

.overview-grid,
.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, calc(var(--text) - var(--space-5) - var(--space-4))), 1fr));
  gap: var(--space-5);
}

.overview-grid > h1,
.overview-grid > #attention {
  grid-column: 1 / -1;
}

.overview-grid > *,
.maintenance-grid > * {
  min-width: 0;
}

.maintenance-grid .card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.maintenance-grid .card > * {
  margin: 0;
}

.maintenance-grid form {
  margin-top: auto;
}

.maintenance-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.storage-refresh {
  margin-block-start: var(--space-4);
}

.messages-table {
  min-width: var(--text);
}

.code-field {
  container-type: inline-size;
  text-align: center;
}

.code-field input {
  min-block-size: var(--code-size);
  text-align: center;
  letter-spacing: var(--code-tracking);
  font-size: var(--code-font-size);
  font-weight: var(--type-xl-weight);
  font-variant-numeric: tabular-nums;
}

/* The code of the second step and of the page second-factor takes a code of the application or a
   recovery code of 23 characters: centred and tabular in the large size without the tracking of the
   code entry, so that a recovery code fits at the width of a phone (design pass of release 005,
   0.2 row 2). */
.code-field.second-code input,
.code-field.factor-code input {
  letter-spacing: normal;
  font-size: var(--type-l-size);
}

.sign-in-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--space-2) var(--space-4);
}

/* The page second-factor (design pass of release 005, section 2): its state as a badge beside its
   label; the QR picture with dark modules on a light ground and its quiet zone in every colour mode
   (OPS-052); the secret and the recovery codes in the code font, a group never broken. */
/* A form of a code on the page second-factor keeps the width of the text, as the sign-in card does,
   in the wide layout too. */
.factor-form {
  max-inline-size: var(--text);
}

.factor-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.qr {
  display: block;
  inline-size: min(100%, calc(var(--text) / 2));
  block-size: auto;
  margin-block: var(--space-3);
  forced-color-adjust: none;
}

.qr-ground {
  fill: var(--color-surface);
}

.qr-modules {
  fill: var(--color-text);
}

.secret,
.recovery-codes {
  font-family: var(--font-code);
  font-size: var(--type-l-size);
  line-height: var(--type-l-line);
}

.secret span,
.recovery-codes span {
  white-space: nowrap;
}

.recovery-codes {
  margin-block: var(--space-3);
  padding-inline-start: var(--space-6);
}

.recovery-codes li + li {
  margin-top: var(--space-1);
}

/* The recovery codes printed by the browser: the heading, the warning and the codes, without the
   frame and the way back. */
@media print {
  .frame,
  .codes-done {
    display: none;
  }
}

body > .website-footer {
  margin-block-start: auto;
}
