/* Styling for Prosody's mod_register_web page.
 *
 * That page is generated server-side by Prosody, not by this app — it ships as
 * a bare table-based form with no stylesheet of its own. nginx injects a link
 * to this file into the proxied response (see the /register_web location), so
 * the markup below is Prosody's and cannot be changed from here; only styled.
 *
 * Palette is kept in sync with src/style.css by hand. If the app's accent
 * changes, change it here too. */

:root {
  --bg: #0b1120;
  --surface: #0f172a;
  --raised: #151f36;
  --border: #1e293b;
  --border-strong: #2a3a54;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #0e0faa;
  --accent-hover: #1616c8;
  --edge: #6b6ef5;
  --danger: #f87171;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html {
  /* Android inflates text in some layouts ("font boosting"), which widens the
     nowrap "@domain" text and blows out the row. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Three-line masthead. nginx swaps Prosody's bare <h1> for this block —
   see the sub_filter in the /register_web location. */
.te-head {
  text-align: center;
  max-width: 23rem;
}
.te-head h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: var(--text);
}
.te-head .te-sub {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.te-head .te-tag {
  margin: 0.625rem 0 0;
  font-size: 1rem;
  font-style: italic;
  line-height: 1.35;
  color: var(--muted);
  /* Wrapping onto a second line is expected and fine. */
  text-wrap: balance;
}

/* Fallback if the sub_filter ever fails and Prosody's plain <h1> comes through
   unwrapped — it should still look deliberate rather than unstyled. */
h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  text-align: center;
}

form {
  width: 100%;
  max-width: 23rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

/* Prosody emits an empty <p> as a message slot and fills it on error. */
form > p:empty {
  display: none;
}
form > p {
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.32);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 0.8125rem;
  line-height: 1.4;
}

/* The form is a <table>; flatten it into stacked fields.
   `display: block` matters: as a real table it sizes to min-content, so the
   nowrap "@domain" cell sets a floor width for EVERY row — which is what
   pushed the password inputs past the card edge on a phone, not just the
   username row. As blocks there is no such propagation. */
table,
tbody {
  display: block;
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}
tr {
  display: block;
  margin-bottom: 0.875rem;
}
tr:last-child {
  margin-bottom: 0;
}
th {
  display: block;
  padding: 0 0 0.375rem;
  text-align: left;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}
/* Flex so the bare "@traceerase.net" text node sits beside the username input. */
td {
  display: flex;
  align-items: center;
  /* Safety valve: if the field plus the "@domain" suffix genuinely cannot fit,
     the suffix drops to its own line instead of overflowing. */
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

input {
  /* flex-basis 0, not auto: with `width: 100%` and basis auto the username
     field demands the full row while the nowrap "@domain" text demands its
     own, overflowing the card on narrow screens. */
  flex: 1 1 0;
  /* Non-zero so the row wraps rather than crushing the field to nothing. */
  min-width: 6rem;
  width: auto;
  padding: 0.55rem 0.7rem;
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder {
  color: #64748b;
}
input:focus {
  outline: none;
  border-color: var(--edge);
  box-shadow: 0 0 0 3px rgba(107, 110, 245, 0.25);
}

/* The captcha answer is a short number — don't let it span the full width. */
input[type='number'] {
  flex: 0 0 6rem;
  width: 6rem;
}

input[type='submit'] {
  flex: 1 1 100%;
  min-width: 0;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.625rem 1rem;
  background: var(--accent);
  /* #0e0faa is only 1.50:1 against the page, so the fill alone cannot make the
     button discernible. This border supplies the boundary (WCAG 1.4.11). */
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
input[type='submit']:hover {
  background: var(--accent-hover);
}
input[type='submit']:active {
  transform: translateY(0.5px);
}
input[type='submit']:focus-visible {
  outline: 2px solid var(--edge);
  outline-offset: 2px;
}
