/* app/assets/stylesheets/devise.css */

:root {
  --bg: #0b0c12;
  --panel: #12141c;
  --panel-2: #171a24;
  --panel-3: #1f2132;

  --line: #262a38;
  --line-2: #343949;

  --ink: #f4f5f7;
  --ink-2: #a2a7b5;
  --ink-3: #6b7186;

  --accent: #defd00;
  --accent-2: #c2dd00;
  --accent-dim: #4d5806;

  --bad: #ff5a52;
  --warn: #ffb020;

  --mono:
    "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  --sans:
    "Helvetica Neue", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Arial, sans-serif;

  color-scheme: dark;
}

/* ───────────────── Base reset ───────────────── */

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

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

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

/* Flat ground. A lit corner behind the card would make the card read as a
   different colour depending on where it sat. */
body,
.devise-body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ───────────────── Typography ───────────────── */

h1,
h2,
h3,
h4,
h5 {
  font-family: var(--sans);
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-top: 0;
  color: var(--ink);
}

.text {
  font-size: 14px;
  color: var(--ink-2);
}

a,
.text a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover,
.text a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

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

/* ───────────────── Layout helpers ───────────────── */

.container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;

  /* Reserve room for the wordmark that floats above the card, so it is never
     clipped on a short viewport. */
  padding-top: 100px;
}

.container > .card {
  margin: auto;
}

.mb24 {
  margin-bottom: 24px;
}
.mb32 {
  margin-bottom: 32px;
}
.mt8 {
  margin-top: 8px;
}
.mt16 {
  margin-top: 16px;
}
.mt24 {
  margin-top: 24px;
}
.mt32 {
  margin-top: 32px;
}
.mt38 {
  margin-top: 38px;
}
.center {
  text-align: center;
}

.flex-container {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.flex-1 {
  flex: 1;
}

/* ───────────────── Panel ───────────────── */

.card {
  position: relative;
  overflow: visible;
  margin-top: 64px;
  width: min(520px, 100%);
  max-width: 100%;
  padding: 32px;

  background: var(--panel);
  border: 1px solid var(--line);
}

.card h2 {
  margin-bottom: 24px;
}

.card::after {
  content: "";
  position: absolute;
  top: -78px;
  left: 0;
  right: 0;
  margin: auto;

  width: 200px;
  height: 50px;

  background-image: url("/assets/sonic_logo-1377ad58.avif");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;

  pointer-events: none;
  transform: translateX(-8px);
}

/* ───────────────── Inputs ───────────────── */

.outlined-input {
  position: relative;
  width: 100%;
  display: flex;
  margin-bottom: 25px;
}

.outlined-input input {
  flex: 1;
  height: 48px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);

  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  padding: 0 16px;

  outline: none;
  transition: border-color 0.15s;
}

/* Make room for the toggle button text/icon */
.outlined-input input[type="password"],
.outlined-input input[type="text"].password-input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--ink-3);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: color 0.15s;
}

.password-toggle:hover {
  color: var(--accent);
}

.outlined-input input::placeholder {
  color: transparent;
}

.outlined-input input[readonly] {
  color: var(--ink-3);
  border-color: var(--line);
}

/* The label rides on the field border, so it takes the mono label treatment
   once it has floated up and become a name rather than a prompt. */
.outlined-input label {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translateY(-50%);

  color: var(--ink-3);
  transition: 0.15s ease;

  font-size: 0.95rem;
  pointer-events: none;

  padding: 0 6px;
  background: transparent;
}

.outlined-input input:not(:placeholder-shown) ~ label,
.outlined-input input:focus ~ label {
  top: -9px;
  left: 8px;
  transform: none;

  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--panel);
}

.outlined-input:has(.field_with_errors input:not(:placeholder-shown)) label,
.outlined-input:has(.field_with_errors input:focus) label {
  top: -9px;
  left: 8px;
  transform: none;

  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--bad);
  background: var(--panel);
}

.outlined-input input:hover,
.outlined-input input:focus {
  border-color: var(--accent);
}

.outlined-input input:-webkit-autofill,
.outlined-input input:-webkit-autofill:hover,
.outlined-input input:-webkit-autofill:focus,
.outlined-input input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--ink) !important;

  /* Override the browser's injected background by painting the inside */
  -webkit-box-shadow: 0 0 0 1000px var(--panel-2) inset !important;
  box-shadow: 0 0 0 1000px var(--panel-2) inset !important;

  caret-color: var(--ink);
  border: 1px solid var(--line-2);
  transition: background-color 9999s ease-out 0s; /* prevents flash */
}

/* Firefox autofill */
.outlined-input input:autofill {
  box-shadow: 0 0 0 1000px var(--panel-2) inset !important;
  -webkit-text-fill-color: var(--ink) !important;
  caret-color: var(--ink);
}

/* ───────────────── Buttons ───────────────── */

/* The primary action. Filled lime with near-black ink — the one saturated
   surface in the system, and the only thing on the page that gets to be loud. */
.button {
  height: 44px;
  padding: 0 24px;
  width: 100%;
  display: block;

  background: var(--accent);
  background-image: none;
  border: 1px solid var(--accent);

  color: #0a0a0a;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;

  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s;
  position: relative;
  user-select: none;
}

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

.button:active {
  transform: translateY(1px);
}

/* ───────────────── Google / secondary ───────────────── */

/* The quiet tier: an outline that takes the lime on hover, never a second fill
   competing with the primary action above it. */
.button.google {
  background: transparent;
  border: 1px solid var(--line-2);
  color: var(--ink-2);

  background-image: url("/identity/google_icon.svg");
  background-repeat: no-repeat;
  background-position: 16px center;
  background-size: 20px 20px;
  padding-left: 48px;
}

.button.google:hover {
  background-color: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

/* ───────────────── Errors & notices ───────────────── */

/* Marked with a rule on the leading edge rather than a tinted fill, so the
   message keeps the contrast instead of spending it on its own background. */
.errors,
#error_explanation {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--bad);
  color: var(--bad);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  padding: 13px 16px;
  margin-bottom: 26px;
}

#error_explanation h3 {
  color: var(--bad);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 12px;
  padding: 13px 16px;
}

.helper-text {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.field_with_errors {
  display: contents;
}

.field_with_errors input {
  border: 1px solid var(--bad);
}

/* ───────────────── Responsive ───────────────── */

@media (max-width: 600px) {
  html,
  body {
    height: auto;
  }

  .container {
    min-height: 100dvh;
    padding: 16px;
    padding-top: 110px;
    overflow-y: auto;
  }

  /* Don't vertically centre the card on mobile — it clips at the top. */
  .container > .card {
    margin: 0;
  }

  .card {
    padding: 24px 20px;
  }

  .card::after {
    top: -68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
