/*
  The Multiamory account portal.

  # The palette is the app's, not a second one

  Every colour below is lifted from `ui/input.css`, which is RADAR's design system and the place
  those values are decided. The portal previously carried its own invented purple, which meant the
  sign-in page and the app it signs you in to did not look like the same company — the exact
  problem this rebuild exists to fix.

  Three role rules come with the palette and are easy to break by accident:

  - **Violet is primary. Buttons are never red.** Brick Red also signals errors, so a red button
    reads as "something has gone wrong" no matter what its label says.
  - **`--danger` is for warnings and destructive things only**, never for emphasis.
  - **Dark is not a tint of light, it is the opposite.** On dark the accent becomes Flax — a bright
    warm CTA on a near-black Violet field — and the ink flips. Redefining only the tokens is what
    keeps that from turning into two stylesheets.

  # No inline styles anywhere

  The content-security policy in `functions/[[path]].ts` is `style-src 'self'` with no
  `unsafe-inline`, because this origin can enrol passkeys for the whole of `multiamory.com`. A
  `style="..."` attribute added later will silently stop rendering rather than fail loudly, so if a
  page ever looks unstyled, that is the first thing to check.
*/

:root {
  color-scheme: light dark;

  --surface: #edeeea;
  --surface-raised: #fdfffc;
  --surface-sunken: #e3e4df;

  --ink: #39003d;
  --ink-muted: #6b5a6d;
  --ink-on-accent: #fdfffc;

  --accent: #39003d;
  --accent-pressed: #2a002d;
  --accent-wash: #efe7ef;

  --danger: #b9272c;
  --danger-wash: #fbeaea;

  --info: #1d4972;

  --line: #e7e8e3;
  --line-strong: #d2d3ce;

  --radius: 0.75rem;
  --radius-sm: 0.55rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #16011c;
    --surface-raised: #2a022e;
    --surface-sunken: #0d000f;

    --ink: #f6f1f6;
    --ink-muted: #bda9c0;
    --ink-on-accent: #2a002d;

    --accent: #fceb9c;
    --accent-pressed: #ecd977;
    --accent-wash: #fceb9c26;

    --danger: #f0777b;
    --danger-wash: #f0777b26;

    --info: #8fb3dc;

    --line: #33203a;
    --line-strong: #4a3350;
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  padding: 2.5rem 1rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  background: var(--surface);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

main {
  width: min(28rem, 100%);
}

main.wide {
  width: min(40rem, 100%);
}

/* ------------------------------------------------------------------ type */

.brand {
  display: block;
  margin: 0 0 1.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-decoration: none;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h2 {
  margin: 0 0 0.25rem;
  font-size: 1.0625rem;
  line-height: 1.3;
}

p {
  margin: 0 0 1rem;
}

p:last-child {
  margin-bottom: 0;
}

.lede {
  margin-bottom: 1.75rem;
  color: var(--ink-muted);
}

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

.tiny {
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

a {
  color: var(--ink);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent-pressed);
}

@media (prefers-color-scheme: dark) {
  a:hover {
    color: var(--accent);
  }
}

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.card + .card {
  margin-top: 0;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-head h2 {
  margin: 0;
}

/* ------------------------------------------------------------------ forms */

label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"] {
  display: block;
  width: 100%;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[disabled] {
  opacity: 0.55;
}

.field {
  margin-bottom: 1rem;
}

.field .tiny {
  margin: 0.375rem 0 0;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.25rem;
  letter-spacing: 0.3em;
  text-align: center;
}

/* ------------------------------------------------------------------ buttons */

button,
.button {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

button + button,
button + .button,
.button + button,
.button + .button {
  margin-top: 0.625rem;
}

button.primary,
.button.primary {
  color: var(--ink-on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

button.primary:hover:not(:disabled),
.button.primary:hover {
  background: var(--accent-pressed);
  border-color: var(--accent-pressed);
}

/* Quiet, because destructive actions should not compete for the eye. `--danger` colours the text
   only — a filled red button is the one thing the palette rules forbid outright. */
button.quiet-danger {
  color: var(--danger);
  border-color: var(--line-strong);
  background: transparent;
}

button.quiet-danger:hover:not(:disabled) {
  background: var(--danger-wash);
}

button.link {
  width: auto;
  padding: 0;
  margin: 0;
  font-weight: 500;
  color: var(--ink-muted);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

button.link:hover:not(:disabled) {
  color: var(--ink);
}

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

.actions {
  margin-top: 1.25rem;
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.row-actions button {
  width: auto;
  margin: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
}

/* ------------------------------------------------------------------ messages */

.note {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  font-size: 0.9375rem;
}

.note.bad {
  color: var(--danger);
  background: var(--danger-wash);
  border-color: var(--danger);
}

.note.good {
  background: var(--accent-wash);
  border-color: var(--line-strong);
}

.note button.link {
  margin-top: 0.5rem;
  display: block;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ lists */

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

.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 0;
  border-top: 1px solid var(--line);
}

.list li:first-child {
  border-top: none;
}

.list .what {
  min-width: 0;
}

.list .what strong {
  display: block;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.footer-links {
  width: min(28rem, 100%);
  margin-top: 1.5rem;
  text-align: center;
}

.spinner-text {
  color: var(--ink-muted);
  font-size: 0.9375rem;
}
