/*
 * Melee custom login page.
 *
 * Tokens and metrics come from the Figma source of truth:
 * file LcFIK7rZRoTyqMPInGkSeT, section 377-26992 ("Sign in and create account"),
 * frames 133:961 (provider picker) and 377:26735 (email + password).
 * The design is a Material 3 dark theme at 440x956; on wider viewports the same
 * 400px column simply centres.
 */

/* Roboto latin, variable weight (400 and 500 are both used). Self-hosted
   because the page's CSP is default-src 'none' with font-src 'self'. */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/roboto-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* material-theme/sys/dark */
  --surface: #15171a;
  --surface-container-low: #181c20;
  --on-surface: #e0e2e8;
  --on-surface-variant: #c2c7ce;
  --outline: #8c9198;
  --primary: #99ccfa;
  --on-primary: #003352;
  --sub-text: #ededed;
  --error: #ffb4ab;

  --elevation-2: 0 1px 2px 0 rgba(0, 0, 0, 0.3),
    0 2px 6px 2px rgba(0, 0, 0, 0.15);

  --column-width: 400px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background-color: var(--surface);
  /* Figma applies a subtle blue lift toward the bottom of the frame. */
  background-image: linear-gradient(
    180deg,
    rgba(21, 23, 26, 0.2) 74.72%,
    rgba(0, 59, 112, 0.2) 100%
  );
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--on-surface);
  font-family: "Roboto", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* The card centres in the space above the wordmark, which sits at the bottom of
   the viewport as it does in the design. */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 32px 20px;
}

.column {
  flex: 1;
  width: 100%;
  max-width: var(--column-width);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 24px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.view[hidden] {
  display: none;
}

/* ---------- Typography ---------- */

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

/* material-theme/headline/medium. The width matches the 207px text box in Figma,
   which is what makes the heading wrap onto two lines; without it the single
   long line overflows the column and breaks the page centring. */
.headline {
  margin: 0;
  max-width: 207px;
  font-size: 28px;
  font-weight: 400;
  line-height: 36px;
  letter-spacing: 0;
  color: var(--on-surface);
  overflow-wrap: break-word;
}

/* material-theme/body/medium */
.sub {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--sub-text);
}

/* material-theme/label/large, used for every text button */
.text-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
  color: var(--primary);
  text-decoration: none;
  border-radius: 100px;
  padding: 2px 4px;
}

.text-link:hover,
.text-link:focus-visible {
  text-decoration: underline;
}

.error {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  letter-spacing: 0.25px;
  color: var(--error);
}

.error[hidden] {
  display: none;
}

/* ---------- Buttons ---------- */

.button-group {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* material-theme/title/medium on an M3 round button */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 56px;
  padding: 16px 24px;
  border: 0;
  border-radius: 100px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: 0.15px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: filter 120ms ease, opacity 120ms ease;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.12);
}

.btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.btn-filled {
  background-color: var(--primary);
  color: var(--on-primary);
}

.btn-elevated {
  background-color: var(--surface-container-low);
  color: var(--on-surface);
  box-shadow: var(--elevation-2);
}

/* The picker's elevated buttons use the primary colour for their label. */
.btn-accent {
  color: var(--primary);
}

.btn-icon {
  display: block;
  flex: none;
  width: 24px;
  height: 24px;
}

.btn[hidden] {
  display: none;
}

/* ---------- Text fields (M3 outlined) ---------- */

/* The form is a nested flex column so it reproduces the 24px rhythm the parent
   .view uses between the field block, any error, and the buttons. */
#signin-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 21px;
}

.field {
  position: relative;
}

.field-input {
  width: 100%;
  height: 56px;
  padding: 4px 16px;
  background-color: transparent;
  border: 1px solid var(--outline);
  border-radius: 4px;
  color: var(--on-surface);
  font-family: inherit;
  /* material-theme/body/large */
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: 0.5px;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
  border-width: 2px;
  /* Keep the text from shifting when the border thickens. */
  padding: 3px 15px;
}

.field-input:autofill {
  -webkit-text-fill-color: var(--on-surface);
}

/* The label always sits in its floated position, notching the field outline,
   which is how the design shows it in every state. */
.field-label {
  position: absolute;
  top: -8px;
  left: 12px;
  padding: 0 4px;
  background-color: var(--surface);
  /* material-theme/body/small */
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  letter-spacing: 0.4px;
  color: var(--on-surface-variant);
  pointer-events: none;
}

.field:focus-within .field-label {
  color: var(--primary);
}

/* ---------- Remember me / forgot password row ---------- */

.options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.switch-label {
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.1px;
  color: #ffffff;
  cursor: pointer;
  user-select: none;
}

.switch {
  flex: none;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  line-height: 0;
}

.switch-track {
  display: flex;
  align-items: center;
  width: 52px;
  height: 32px;
  padding: 2px 4px;
  border-radius: 100px;
  background-color: var(--primary);
  transition: background-color 120ms ease, border-color 120ms ease;
}

.switch-handle {
  display: block;
  width: 24px;
  height: 24px;
  margin-left: auto;
  border-radius: 100px;
  background-color: var(--on-primary);
  transition: width 120ms ease, height 120ms ease, background-color 120ms ease,
    margin 120ms ease;
}

.switch[aria-checked="false"] .switch-track {
  background-color: var(--surface-container-low);
  box-shadow: inset 0 0 0 2px var(--outline);
}

.switch[aria-checked="false"] .switch-handle {
  width: 16px;
  height: 16px;
  margin-left: 4px;
  margin-right: auto;
  background-color: var(--outline);
}

/* Inputs signal focus with the thicker primary border above, so they are
   deliberately absent here to avoid stacking two focus indicators. */
.switch:focus-visible .switch-track,
.btn:focus-visible,
.text-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.noscript {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  color: var(--on-surface);
}

/* ---------- Wordmark ---------- */

.wordmark {
  display: block;
  flex: none;
  width: 160px;
  height: auto;
}

@media (max-width: 420px) {
  .headline {
    font-size: 26px;
    line-height: 34px;
  }
}
