/*
 * Styles for the prototype's password page and its login log. Plain CSS on purpose: these pages are served by
 * CloudFront before the app (and the UI library) is reachable. Values are the @yapla-dev/neodot-ui tokens; keep
 * them in step with libs/uzgl-neodot_register_ui_library-fe when the tokens change.
 */
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 500;
  font-display: swap;
  src: url('fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-weight: 600;
  font-display: swap;
  src: url('fonts/ibm-plex-sans-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-weight: 400;
  font-display: swap;
  src: url('fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --bg: #f9fafb;
  --surface: #ffffff;
  --surface-sunken: #f2f4f5;
  --surface-hover: #f2f4f5;
  --surface-selected: #eff6f9;
  --text: #1b2022;
  --text-secondary: #444f55;
  --text-tertiary: #59666d;
  --text-disabled: #9facb2;
  --border: #e5e9eb;
  --border-control: #74838b;
  --primary: #0a5f7a;
  --primary-hover: #084c63;
  --primary-border: #6fafc6;
  --on-primary: #ffffff;
  --focus-ring: #2e5fa8;
  --danger: #c4314b;
  --danger-subtle: #fceef2;
  --danger-text: #992232;
  --success-subtle: #effaf5;
  --success-text: #1e5b33;
  --info-subtle: #eef5fb;
  --info-text: #214586;
  --elevation-1:
    0 1px 2px rgba(17, 40, 37, 0.06), 0 1px 3px rgba(17, 40, 37, 0.1);
  --sans:
    'IBM Plex Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI',
    sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1315;
    --surface: #161b1e;
    --surface-sunken: #0b0e10;
    --surface-hover: #212c31;
    --surface-selected: #122c35;
    --text: #e6ebed;
    --text-secondary: #b2bdc3;
    --text-tertiary: #929fa5;
    --text-disabled: #5b686f;
    --border: #2a3439;
    --border-control: #6d7e86;
    --primary: #5fa8c2;
    --primary-hover: #7fbdd3;
    --primary-border: #3a6f82;
    --on-primary: #0b161a;
    --focus-ring: #8db6f0;
    --danger: #f0798f;
    --danger-subtle: #3a1a20;
    --danger-text: #f7a8b6;
    --success-subtle: #14301f;
    --success-text: #93ddb2;
    --info-subtle: #152741;
    --info-text: #a9c6f0;
    --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 24px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm {
  width: 16px;
  height: 16px;
}

/* Logo: the light or the dark version, following the colour scheme. */
.logo {
  display: block;
  width: auto;
}
.logo--dark {
  display: none;
}
@media (prefers-color-scheme: dark) {
  .logo--light {
    display: none;
  }
  .logo--dark {
    display: block;
  }
}

/*
 * The inline logo on the password page, with the hello animation of the Logo component (logo.scss in
 * @yapla-dev/neodot-ui): about 1 s, once, not with reduced motion. Colours are the brand-* tokens.
 */
svg.logo {
  overflow: visible;
  --brand-primary: #0b7191;
  --brand-accent: #f07f5e;
  --brand-ink: #14294a;
}
@media (prefers-color-scheme: dark) {
  svg.logo {
    --brand-primary: #5ca8c4;
    --brand-ink: #ffffff;
  }
}
.logo__ring path {
  stroke: var(--brand-primary);
}
.logo__dot,
.logo__dotword {
  fill: var(--brand-accent);
}
.logo__core {
  fill: var(--brand-primary);
}
.logo__neo {
  fill: var(--brand-ink);
}

.logo--animate .logo__ring {
  transform-origin: 50px 50px;
  animation: logo-ring 1s 0.15s both;
}
.logo--animate .logo__dot {
  transform-box: fill-box;
  transform-origin: center;
  animation: logo-dot 1s 0.15s both;
}
.logo--animate .logo__core {
  transform-box: fill-box;
  transform-origin: center;
  animation: logo-core 1s 0.15s both;
}

/* The ring wobbles back against the jump. */
@keyframes logo-ring {
  0% {
    transform: rotate(0);
    animation-timing-function: cubic-bezier(0.3, 0, 0.3, 1);
  }
  30% {
    transform: rotate(-12deg);
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  }
  64% {
    transform: rotate(5deg);
    animation-timing-function: ease-in-out;
  }
  84% {
    transform: rotate(-1.5deg);
    animation-timing-function: ease-out;
  }
  100% {
    transform: rotate(0);
  }
}

/* The dot takes a run-up, jumps out of the opening (along the 45° diagonal) and lands with a squash. */
@keyframes logo-dot {
  0% {
    transform: translate(0, 0) rotate(-45deg) scale(1, 1) rotate(45deg);
    animation-timing-function: ease-out;
  }
  16% {
    transform: translate(-1.4px, 1.4px) rotate(-45deg) scale(0.8, 1.16)
      rotate(45deg);
    animation-timing-function: cubic-bezier(0.2, 0.7, 0.3, 1);
  }
  44% {
    transform: translate(8.6px, -8.6px) rotate(-45deg) scale(1.16, 0.9)
      rotate(45deg);
    animation-timing-function: ease-out;
  }
  56% {
    transform: translate(9.6px, -9.6px) rotate(-45deg) scale(1, 1) rotate(45deg);
    animation-timing-function: cubic-bezier(0.6, 0, 0.9, 0.6);
  }
  74% {
    transform: translate(0, 0) rotate(-45deg) scale(0.76, 1.2) rotate(45deg);
    animation-timing-function: ease-out;
  }
  88% {
    transform: translate(0, 0) rotate(-45deg) scale(1.06, 0.96) rotate(45deg);
    animation-timing-function: ease-in-out;
  }
  100% {
    transform: translate(0, 0) rotate(-45deg) scale(1, 1) rotate(45deg);
  }
}

/* The core bounces when the dot lands. */
@keyframes logo-core {
  0%,
  72% {
    transform: scale(1);
    animation-timing-function: ease-out;
  }
  80% {
    transform: scale(1.32);
    animation-timing-function: ease-in-out;
  }
  90% {
    transform: scale(0.94);
    animation-timing-function: ease-out;
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo--animate .logo__ring,
  .logo--animate .logo__dot,
  .logo--animate .logo__core {
    animation: none;
  }
}

/* ---- Password page ------------------------------------------------------------------------------------------ */

.gate {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 48px 16px;
}

.gate__card {
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.gate__band {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-sunken);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
}

.gate__band strong {
  font-weight: 600;
}

.gate__body {
  display: flex;
  flex-direction: column;
  gap: 40px;
  padding: 48px;
}

.gate__logo {
  display: flex;
  justify-content: center;
}

.gate__logo .logo {
  height: 64px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.label {
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

.input {
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--border-control);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.input:hover {
  border-color: var(--text-secondary);
}

.input:focus-visible {
  outline-offset: 1px;
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}

.password {
  position: relative;
  display: flex;
}

.password .input {
  padding-right: 48px;
}

.password__toggle {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
}

.password__toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.error {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  margin: 0;
  color: var(--danger-text);
  font-size: 14px;
  line-height: 20px;
}

.error .icon {
  margin-top: 2px;
}

.error[hidden] {
  display: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  box-shadow: var(--elevation-1);
  color: var(--on-primary);
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

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

.button[aria-disabled='true'] {
  cursor: progress;
  opacity: 0.8;
}

.button--secondary {
  height: 40px;
  border: 1px solid var(--primary-border);
  background: var(--surface);
  color: var(--primary);
  font-size: 14px;
}

.button--secondary:hover {
  background: var(--surface-selected);
}

@media (max-width: 480px) {
  .gate__body {
    padding: 40px 24px 32px;
  }
}

/* ---- Login log ----------------------------------------------------------------------------------------------- */

.log-header {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.log-header .logo {
  height: 32px;
}

.chip-static {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-sunken);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
}

.log {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1440px;
  padding: 32px;
}

.log h1 {
  margin: 0;
  font-size: 28px;
  line-height: 36px;
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
}

.toolbar__spacer {
  flex: 1;
}

.select {
  height: 40px;
  min-width: 200px;
  margin: 0;
  padding: 0 40px 0 12px;
  border: 1px solid var(--border-control);
  border-radius: 6px;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2359666D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 10px center;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  appearance: none;
  cursor: pointer;
}

.select:hover {
  border-color: var(--text-secondary);
}

.select--sm {
  width: 80px;
  min-width: 0;
  height: 32px;
  padding-right: 32px;
  background-position: right 6px center;
  font-variant-numeric: tabular-nums;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-control);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.chip:hover {
  background: var(--surface-hover);
}

.chip[aria-pressed='true'] {
  border-color: var(--primary-border);
  background: var(--surface-selected);
  color: var(--primary);
}

.chip__count {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.search {
  position: relative;
  display: flex;
  width: 320px;
  max-width: 100%;
}

.search .icon {
  position: absolute;
  top: 12px;
  left: 12px;
  color: var(--text-tertiary);
}

.search .input {
  height: 40px;
  padding-left: 36px;
  font-size: 14px;
}

.table-box {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 20px;
}

th {
  padding: 10px 16px;
  background: var(--surface-sunken);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 20px;
  font-weight: 500;
}

.badge--ok {
  background: var(--success-subtle);
  color: var(--success-text);
}

.badge--fail {
  background: var(--danger-subtle);
  color: var(--danger-text);
}

.badge--audit {
  background: var(--info-subtle);
  color: var(--info-text);
}

.empty {
  padding: 48px 16px;
  color: var(--text-secondary);
  text-align: center;
}

/* Pagination, as the Pagination component of @yapla-dev/neodot-ui. */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 20px;
}

.pagination__left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
}

.pagination__size {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.pages {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.page {
  display: inline-grid;
  min-width: 32px;
  height: 32px;
  place-items: center;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

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

.page[aria-current='page'] {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.page:disabled {
  background: transparent;
  color: var(--text-disabled);
  cursor: not-allowed;
}

.page--gap {
  cursor: default;
}

.page--gap:hover {
  background: transparent;
}

.notice {
  margin: 0;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--danger-subtle);
  color: var(--danger-text);
  font-size: 14px;
}

.notice[hidden] {
  display: none;
}

@media (max-width: 640px) {
  .log-header {
    padding: 0 16px;
  }
  .log {
    padding: 24px 16px;
  }
  .toolbar__spacer {
    display: none;
  }
}
