/*
 * The pages the API renders itself (spec §05A, §07G): the sign-in page, the
 * code page, the expired, cancelled, failed and refusal pages, and the agent
 * consent page. `htmlPage` in src/api/http.ts links this file after
 * tokens.css and paper.css, so these pages wear the paper look the landing
 * page wears (spec §07A). They are files on this server, because the pages'
 * policy admits stylesheets, images and fonts from this origin and nothing
 * else.
 *
 * The public pages pick the dark mode with an inline script that stamps
 * `[data-mode]`. These pages run no script, so the dark block below repeats
 * the Paper group's dark values from tokens.css under the system setting.
 * src/api/signin-page-style.test.ts holds each repeated value equal to the
 * one in tokens.css.
 */

@media (prefers-color-scheme: dark) {
  :root:not([data-mode='light']) {
    color-scheme: dark;
    --paper: #18181a;
    --paper-sheet: #202023;
    --paper-rule: #34343a;
    --ink: #ecebe6;
    --ink-2: #c2c0b9;
    --ink-3: #8e8c85;
    --ink-blue: #6f93f0;
    --support-error: #fa4d56;
  }

  :root:not([data-mode='light']) body {
    background-image: url('./paper/paper-dark.jpg');
  }
}

/* paper.css draws the paper flat for more contrast; the dark ground above
   comes after it, so it states the same rule again, at the same weight. */
@media (prefers-contrast: more) {
  :root:not([data-mode='light']) body {
    background-image: none;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-size: 16px;
  line-height: 1.55;
}

main {
  display: block;
  max-width: 28rem;
  margin: 0 auto;
  padding: var(--space-9) var(--space-6);
}

h1 {
  margin: 0 0 var(--space-5);
  font: 700 2rem/1.1 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  margin: 0 0 var(--space-5);
}

a {
  color: var(--ink-blue);
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  word-break: break-all;
}

/* The buttons follow the landing page's: square, ink on paper. The primary
   act is filled, every other act is outlined. */
button,
a.provider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height-lg);
  padding: 0 18px;
  font: 600 15px/1 var(--font-prose);
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  text-decoration: none;
  cursor: pointer;
}

button.allow {
  color: var(--paper);
  background: var(--ink);
}

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

button.deny:hover,
a.provider:hover,
button.provider:hover {
  background: var(--paper-sheet);
}

/* `hidden` must win over the display above: the passkey button stays hidden
   until its script finds a browser that can run the ceremony. */
[hidden] {
  display: none !important;
}

a.provider,
button.provider {
  width: 100%;
}

.actions {
  display: flex;
  gap: var(--space-4);
  margin: var(--space-6) 0;
}

form.signin {
  margin: var(--space-6) 0;
}

form.signin label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
}

form.signin input {
  display: block;
  width: 100%;
  min-height: var(--control-height-lg);
  padding: 0 var(--space-4);
  font: inherit;
  color: var(--ink);
  background: var(--paper-sheet);
  border: 1.5px solid var(--ink-3);
  border-radius: 0;
}

form.signin button {
  width: 100%;
  margin-top: var(--space-4);
}

p.fine {
  font-size: 0.875rem;
  color: var(--ink-2);
}

p.error {
  color: var(--support-error);
}
