/* Certifly ID. The look of the console's sign-in panel (web/src/pages/Login.tsx),
   for every page the identity service renders: sign-in, two-step sign-in, password
   reset, email verification, sign-out and the account page.

   Loaded after the service's built-in styles, so everything here wins. The colours
   are the console's own tokens (web/src/themes/ember.css and light.css), by value:
   this file is served by another service and cannot import them. A test
   (k8s/idp/theme_test.go) fails when the two drift apart.

   Like the console before anyone has chosen a theme, the page follows the system:
   Ember (dark) by default, Light for a light-preferring system. */

@font-face {
  font-family: 'Inter';
  src: url('/theme/fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/theme/fonts/jetbrains-mono-var.woff2') format('woff2');
  font-weight: 100 800; font-style: normal; font-display: swap;
}

:root {
  color-scheme: dark;
  --c-bg: #121014;
  --c-surface: #1a171d;
  --c-raised: #232027;
  --c-border: #2e2a33;
  --c-ink: #f5f0f2;
  --c-muted: #b3a9b5;
  --c-faint: #948a99;
  --c-accent: #ff7a45;
  --c-accent-hover: #ff9466;
  --c-accent-ink: #1d0b05;
  --c-ok: #5ad1a6;
  --c-danger: #ff5967;
  --c-ring: rgba(46, 42, 51, 0.6);
  --c-radius: 0.375rem;
  --c-radius-panel: 0.625rem;

  /* The service's own variables, so anything it adds later is on-brand too. */
  --idp-bg: var(--c-bg);
  --idp-surface: var(--c-surface);
  --idp-text: var(--c-ink);
  --idp-muted: var(--c-muted);
  --idp-border: var(--c-border);
  --idp-input-border: var(--c-border);
  --idp-accent: var(--c-accent);
  --idp-accent-text: var(--c-accent-ink);
  --idp-danger: var(--c-danger);
  --idp-radius: var(--c-radius-panel);
  --idp-font: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --idp-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
  --idp-width: 24rem;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --c-bg: #fbf9f8;
    --c-surface: #ffffff;
    --c-raised: #f4f1f0;
    --c-border: #e6e1df;
    --c-ink: #1b1719;
    --c-muted: #5e5560;
    --c-faint: #766c75;
    --c-accent: #c94410;
    --c-accent-hover: #a83808;
    --c-accent-ink: #ffffff;
    --c-ok: #137552;
    --c-danger: #c01c2c;
    --c-ring: rgba(40, 20, 20, 0.06);
  }
}

/* ---- the page and the panel ------------------------------------------------ */

body {
  font: 0.875rem/1.5 var(--idp-font);
  min-height: 100vh;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
}
main {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 2rem;
  border-radius: var(--c-radius-panel);
  box-shadow: 0 0 0 1px var(--c-ring);
}
/* The account page is a list of things, not one form: give it room. */
.step-account main { max-width: 30rem; }

/* ---- the brand, as on the console's sign-in panel -------------------------- */

.brand { text-align: center; margin-bottom: 1.5rem; }
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1rem;
  border-radius: var(--c-radius);
  color: var(--c-accent);
  background: color-mix(in srgb, var(--c-accent) 10%, transparent);
}
.brand-mark svg { width: 1.5rem; height: 1.5rem; }
.wordmark { font-size: 1.5rem; line-height: 2rem; font-weight: 600; letter-spacing: 0.025em; }
.wordmark span { color: var(--c-accent); }
.tagline { margin: 0.5rem 0 0; color: var(--c-muted); }
/* The tagline introduces the product on the way in. Past that it is noise. */
body:not(.step-login):not(.step-identify) .tagline { display: none; }

/* ---- headings and text ------------------------------------------------------ */

h1 { font-size: 1rem; font-weight: 600; text-align: center; margin: 0 0 1rem; }
/* "Sign in to Certifly" under a wordmark that says Certifly: kept for a screen
   reader and the document outline, not drawn twice. The same on the error page,
   whose heading is the name alone. */
.step-identify h1,
.step-login h1,
.step-error h1 {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
h2 { font-size: 0.8125rem; font-weight: 600; margin: 1.75rem 0 0.5rem; }
p { margin: 0.5rem 0; }
p.sub, .sub { color: var(--c-muted); font-size: 0.75rem; }
small { color: var(--c-faint); font-size: 0.75rem; }
a { color: var(--c-muted); text-underline-offset: 2px; }
a:hover { color: var(--c-ink); }
/* A link that is the next step ("Continue", "Set up an authenticator app"). */
main > p:not(.sub):not(.legal):not(.err):not(.ok):not(.key):not(.tagline) > a { color: var(--c-accent); font-weight: 500; }
main > p:not(.sub):not(.legal) > a:hover { color: var(--c-accent-hover); }

p.err {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--c-danger);
  background: color-mix(in srgb, var(--c-danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--c-danger) 40%, transparent);
  border-radius: var(--c-radius);
}
/* The passkey button's own error line is empty until something goes wrong. */
p.err:empty { display: none; }
.ok {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--c-ink);
  background: color-mix(in srgb, var(--c-ok) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--c-ok) 40%, transparent);
  border-radius: var(--c-radius);
}

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

label { margin: 0.75rem 0 0.375rem; font-size: 0.75rem; color: var(--c-muted); }
form > label:first-of-type { margin-top: 0; }
input {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--c-ink);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
}
input:focus { outline: none; border-color: var(--c-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c-accent) 25%, transparent); }

button {
  margin-top: 1rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--c-radius);
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms;
}
button:hover { background: var(--c-accent-hover); }
button:focus-visible { outline: 2px solid color-mix(in srgb, var(--c-accent) 50%, transparent); outline-offset: 2px; }
button.alt { margin-top: 0.5rem; color: var(--c-ink); background: transparent; border: 1px solid var(--c-border); }
button.alt:hover { background: var(--c-raised); }

/* "or", between the password form and the other ways in, as on the console. Drawn
   after the "Forgot your password?" line only when another way follows it. */
.step-login p.sub:has(+ form[action="/connect"]),
.step-login p.sub:has(+ #passkey-error) { text-align: left; }
/* On the first page (the address alone) the same "or" follows the form itself. */
.step-identify form[action="/login/identify"]:has(+ form[action="/connect"])::after,
.step-identify form[action="/login/identify"]:has(+ #passkey-error)::after,
.step-login p.sub:has(+ form[action="/connect"])::after,
.step-login p.sub:has(+ #passkey-error)::after {
  content: 'or';
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 0.75rem;
  color: var(--c-faint);
  font-size: 0.75rem;
  /* A hairline either side of the word. */
  background:
    linear-gradient(var(--c-border), var(--c-border)) left center / calc(50% - 1.25rem) 1px no-repeat,
    linear-gradient(var(--c-border), var(--c-border)) right center / calc(50% - 1.25rem) 1px no-repeat;
  justify-content: center;
}

/* ---- two-step sign-in -------------------------------------------------------- */

/* A QR code is dark on light whatever the theme: a phone camera needs the contrast. */
img.qr { padding: 0.5rem; background: #ffffff; border-radius: var(--c-radius); }
.key, ul.codes {
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
}
ul.codes li { padding: 0.125rem 0; }

/* ---- the account page -------------------------------------------------------- */

ul.sessions li, ul.passkeys li { border-top-color: var(--c-border); }
li form button, li form button.alt { margin: 0; padding: 0.3rem 0.65rem; font-size: 0.75rem; }

/* ---- the footer links, as on the console's panel ----------------------------- */

.legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  margin: 1.5rem 0 0;
  font-size: 0.75rem;
}
.legal a { color: var(--c-muted); text-decoration: none; }
.legal a:hover { color: var(--c-ink); }
