/* Pratique's server-rendered auth pages (login, code entry, consent, org
   select, problem pages). Hand-written rather than a CSS framework: these pages
   use a handful of elements, and the operator's accent color has to reach every
   one of them, which is cleaner to express directly than as overrides.

   The operator's three accent-derived values (--brand, --brand-on, --brand-link)
   are injected per-deployment in the page shell; everything here is static and
   cached. Colors follow the OS light/dark preference via light-dark(). */

:root {
  color-scheme: light dark;

  --ink: light-dark(#202733, #ecedf2);
  --muted: light-dark(#667080, #a1a9b8);
  --paper: light-dark(#fff, #1c2028);
  --bg: light-dark(#f5f6f8, #12151b);
  --line: light-dark(#e1e4e9, #363c47);
  --danger: light-dark(#c0341d, #ff8a70);
  --success: light-dark(#0a7d48, #4ac98a);

  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 6px;
  --field-h: 44px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* --- masthead: the operator's mark + name --- */

.mast {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.7px;
  color: var(--ink);
  text-decoration: none;
}

/* The monogram tile, shown when the operator configured no logo image. */
.brand .mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--brand);
  color: var(--brand-on);
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 22px;
  line-height: 1;
}

/* An operator logo is constrained, never cropped: unknown aspect ratios have to
   sit on the same baseline as the monogram tile they replace. */
.brand img.mark {
  width: auto;
  max-width: 140px;
  height: 32px;
  object-fit: contain;
  background: none;
  border-radius: 0;
}

/* Operator links in the masthead. They are chrome, not actions, so they stay
   muted and never take the accent-filled button treatment. */
.mast-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.mast-links a,
footer.auth-footer a {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.mast-links a:hover,
footer.auth-footer a:hover { color: var(--ink); }

/* --- the centered card --- */

main.auth {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 24px 48px;
  min-width: 0;
}

main.auth > article {
  width: 388px;
  max-width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 34px;
  box-shadow: 0 8px 24px light-dark(#0000000d, #00000038);
}

/* --- type --- */

h1 {
  font-size: 27px;
  line-height: 1.2;
  letter-spacing: -1px;
  font-weight: 500;
  margin: 0 0 10px;
}

hgroup { margin: 0 0 28px; }
hgroup h1 { margin-bottom: 8px; }
hgroup p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

p { margin: 0 0 16px; }
small { font-size: 12px; }

a {
  color: var(--brand-link);
  font-weight: 500;
  text-decoration: none;
}
a:hover, a:focus-visible { text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 13px;
  background: light-dark(#00000008, #ffffff12);
  padding: 2px 6px;
  border-radius: 4px;
}

/* --- forms --- */

form { margin: 0; }

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
}

input:not([type="checkbox"]):not([type="radio"]) {
  display: block;
  width: 100%;
  height: var(--field-h);
  padding: 0 12px;
  margin: 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

input::placeholder { color: var(--muted); }

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

/* Buttons. The default is the accent-filled primary action; .outline and
   .secondary are the quieter variants the org-select and passkey pages use. */
button,
a[role="button"] {
  display: flex;
  width: 100%;
  min-height: var(--field-h);
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--brand-on);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

button:hover, a[role="button"]:hover { filter: brightness(0.94); }

button.outline,
button.secondary,
a[role="button"].outline {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

button.outline:hover,
button.secondary:hover { background: light-dark(#00000006, #ffffff0f); }

/* A button that has to read as inline text (the "Resend code" submit inside a
   sentence): it is a real <button> for the POST, styled as a link. */
button.link {
  display: inline;
  width: auto;
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: inherit;
  font-weight: inherit;
  text-decoration: underline;
}
button.link:hover {
  background: none;
  color: var(--ink);
  filter: none;
}

/* A row of quiet inline actions under the card's main control. */
.inline-actions {
  display: flex;
  justify-content: center;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}
.inline-actions a { color: var(--muted); font-weight: 400; }
.inline-actions a:hover { color: var(--ink); }
.inline-actions form { display: inline; }

/* The "or" rule between the primary action and the passkey alternative,
   drawn as the mockup does: centered label with a line out to each side. */
.or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 19px 0;
  color: var(--muted);
  font-size: 11px;
}
.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Status messages a handler puts above the form. */
.notice { color: var(--success); }
.error  { color: var(--danger); }

/* Pages whose whole body is centered prose (consent, problem, no-access). */
.centered { text-align: center; }

/* The reference id on the problem page. */
.ref {
  color: var(--muted);
  font-size: 0.85rem;
}

/* The org picker: one submit button per membership, reading as a list row. */
.org-list form { margin-bottom: 0.5rem; }
.org-list button {
  justify-content: flex-start;
  text-align: left;
  gap: 10px;
}
.org-list small { color: var(--muted); font-weight: 400; }

/* --- the shared bits the templates rely on --- */

footer.auth-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 22px 36px;
  color: var(--muted);
  font-size: 11px;
}

.foot-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

footer.auth-footer a { font-size: 11px; }

.secure {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Segmented code entry: ONE real input (transparent text, the source of truth
   for paste / OTP autofill / the form) overlaid on eight display cells that JS
   mirrors the value into. Copy/paste and autofill keep working because nothing
   is split across multiple inputs. */
.otp-wrap {
  position: relative;
  width: max-content;
  max-width: 100%;
  margin: 0.4rem auto 1.1rem;
}
.otp-cells { display: flex; gap: 0.35rem; pointer-events: none; }
.otp-cell {
  width: 2.15rem;
  height: 2.9rem;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}
.otp-cell.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}
.otp-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  border: none;
  background: transparent;
  font-size: 1rem;
  letter-spacing: 0;
  caret-color: transparent;
  cursor: pointer;
}

@media (max-width: 680px) {
  .mast { padding: 22px; }
  main.auth { padding: 4px 16px 32px; }
  main.auth > article { padding: 28px 22px; }
  footer.auth-footer { padding: 20px; }
  .foot-links { gap: 14px; }
  .mast-links { gap: 12px; }
  .secure { display: none; }
  /* 16px keeps iOS Safari from zooming the viewport on focus. */
  input:not([type="checkbox"]):not([type="radio"]) { font-size: 16px; }
}
