/*
 * SpecaMote - login.css
 *
 * The front door. Same visual vocabulary as style.css - identical token names,
 * identical values, the same card, the same button, the same focus ring - but a
 * separate file, deliberately not an @import of it. style.css is written for a
 * page whose whole job is a <video>, and two of its rules are actively wrong
 * here:
 *
 *   - `overflow: hidden` on html and body. Correct there (a scrollbar would
 *     steal pixels from a 1080p stream and let the picture be scrolled out of
 *     view), wrong here: this card must be scrollable on a small phone in
 *     landscape, and the operator may well be looking at this page on the same
 *     handset that is about to receive the Telegram prompt.
 *   - `background: var(--stage)`, a near-black surround. That is the right
 *     colour to watch video against and the wrong colour for a page that is all
 *     text. Light mode here gets a light ground; dark mode keeps the near-black.
 *     Same family, different room.
 *
 * There is not one inline style in this project - the CSP forbids it - so
 * everything login.js toggles is a class, a data attribute, or the `hidden`
 * attribute. That is also why the countdown on stage two is text rather than a
 * progress bar with a JS-driven width: text needs no style mutation at all.
 */

/* ------------------------------------------------------------------ *
 * Tokens - light is the base, dark overrides. Values match style.css.
 * ------------------------------------------------------------------ */

:root {
  color-scheme: light dark;

  --page: #eef0f4;
  --page-ink: #14171c;

  --panel: #ffffff;
  --panel-edge: rgba(0, 0, 0, 0.14);
  --ink: #14171c;
  --ink-dim: #5b6270;
  --ink-faint: #868d9b;

  --accent: #1b64d8;
  --accent-ink: #ffffff;
  --accent-hover: #1553b8;

  --ok: #1a8a4a;
  --warn: #b06800;
  --bad: #c0392b;

  /* Tinted grounds for the notice strip. Kept very pale so the text does the
     talking; the border is what actually carries the tone. */
  --bad-wash: rgba(192, 57, 43, 0.09);
  --warn-wash: rgba(176, 104, 0, 0.1);
  --ok-wash: rgba(26, 138, 74, 0.1);

  --field: #ffffff;
  --field-edge: rgba(0, 0, 0, 0.24);

  --radius: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.14);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #06070a;
    --page-ink: #eceef2;

    --panel: #16181d;
    --panel-edge: rgba(255, 255, 255, 0.14);
    --ink: #eceef2;
    --ink-dim: #a2a9b6;
    --ink-faint: #767d8b;

    --accent: #4c8dff;
    --accent-ink: #06070a;
    --accent-hover: #6ba0ff;

    --ok: #45c97e;
    --warn: #e3a33a;
    --bad: #ff6f5e;

    --bad-wash: rgba(255, 111, 94, 0.12);
    --warn-wash: rgba(227, 163, 58, 0.12);
    --ok-wash: rgba(69, 201, 126, 0.12);

    --field: #0f1115;
    --field-edge: rgba(255, 255, 255, 0.22);

    --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  }
}

@media (prefers-contrast: more) {
  :root {
    --panel-edge: currentColor;
    --field-edge: currentColor;
    --ink-dim: var(--ink);
    --ink-faint: var(--ink);
  }
}

/* ------------------------------------------------------------------ *
 * Reset
 * ------------------------------------------------------------------ */

* {
  box-sizing: border-box;
}

/* login.js switches stages with el.hidden, and several of these are flex or
   grid containers, so hidden has to win over display. */
[hidden] {
  display: none !important;
}

html {
  /* Keeps the card centred without the address bar's show/hide making it jump
     on a phone. 100vh is the fallback for browsers without dynamic units. */
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--page);
  color: var(--page-ink);
  font: 15px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------------ *
 * Layout
 * ------------------------------------------------------------------ */

.page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  /* env() keeps the card clear of a notch or a home indicator in landscape.
     The 0px fallbacks matter - a bare env() with no fallback computes to
     nothing at all on a desktop browser and the padding is lost. */
  padding: calc(24px + env(safe-area-inset-top, 0px))
           calc(20px + env(safe-area-inset-right, 0px))
           calc(24px + env(safe-area-inset-bottom, 0px))
           calc(20px + env(safe-area-inset-left, 0px));
}

/* The <noscript> fallback covers the real card rather than stacking under it. */
.noscript-cover {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--page);
}

.card {
  width: min(420px, 100%);
  padding: 26px 28px 24px;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 420px) {
  .card {
    padding: 22px 18px 20px;
  }
}

/* ------------------------------------------------------------------ *
 * Brand
 * ------------------------------------------------------------------ */

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--panel-edge);
}

.brand-mark {
  display: block;
  flex: none;
}

.brand-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--ink-dim);
}

/* ------------------------------------------------------------------ *
 * Stage furniture
 * ------------------------------------------------------------------ */

.stage-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* The headings are focus targets: login.js moves focus to them on a stage
   change so a screen reader is told where it now is. tabindex="-1" would
   otherwise draw a ring on a plain mouse click, hence :focus-visible. */
.stage-title:focus {
  outline: none;
}

.stage-title:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.stage-lead {
  margin: 0 0 18px;
  color: var(--ink-dim);
  font-size: 14px;
}

/*
 * The outcome stage carries a tone on the section itself, set by login.js as a
 * data attribute rather than a style. The heading is the only thing coloured by
 * it: a declined login should look like the serious thing it is - somebody who
 * had the password was refused at the phone - without turning the whole card
 * into an alarm.
 */
.stage[data-tone="bad"] .stage-title {
  color: var(--bad);
}

.stage[data-tone="warn"] .stage-title {
  color: var(--warn);
}

.stage[data-tone="ok"] .stage-title {
  color: var(--ok);
}

.foot {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--panel-edge);
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.6;
}

.emphasis {
  margin: 0 0 16px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 550;
  line-height: 1.55;
}

/* ------------------------------------------------------------------ *
 * Fields
 * ------------------------------------------------------------------ */

.field {
  margin: 0 0 14px;
}

.field label {
  display: block;
  margin: 0 0 5px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink);
}

.field input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--field-edge);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  /* 16px is not a design choice. Anything smaller makes iOS Safari zoom the
     viewport the moment the field takes focus, and the operator may well be on
     a phone. */
  font: 400 16px/1.4 var(--font);
}

.field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

/* Both fields are frozen while a request is in flight. */
.field input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

button.primary {
  display: block;
  width: 100%;
  margin: 18px 0 0;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 14px/1 var(--font);
  cursor: pointer;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

button.primary:active:not(:disabled) {
  translate: 0 1px;
}

/*
 * The disabled state is not decoration. The button is disabled for the whole
 * time a request is in flight, so that a double-click cannot start two logins
 * and put two approval prompts on the phone - and the server only allows one
 * approval to be pending at a time, so the second would be refused anyway and
 * the operator would be left reading an error about a race they caused.
 */
button.primary:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ------------------------------------------------------------------ *
 * Notices
 * ------------------------------------------------------------------ */

.notice {
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--panel-edge);
  border-left-width: 3px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}

.notice[data-tone="bad"] {
  border-color: var(--bad);
  background: var(--bad-wash);
}

.notice[data-tone="warn"] {
  border-color: var(--warn);
  background: var(--warn-wash);
}

.notice[data-tone="ok"] {
  border-color: var(--ok);
  background: var(--ok-wash);
}

/* ------------------------------------------------------------------ *
 * Stage 2 - the two taps
 * ------------------------------------------------------------------ */

.taps {
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

/* Two columns rather than a hanging indent, for the same reason style.css uses
   them on the shortcut hints: the marker is a fixed-width block and wrapped
   text needs its own column to line up against. */
.taps li {
  display: flex;
  gap: 11px;
  margin: 0 0 11px;
  font-size: 13.5px;
  color: var(--ink-dim);
}

.taps li:last-child {
  margin-bottom: 0;
}

.taps li b {
  color: var(--ink);
  font-weight: 650;
}

.tap-n {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font: 650 12px/22px var(--font);
  text-align: center;
}

.waiting {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink);
}

/* Same pulsing dot as the connection pill on the session page, so "the machine
   is still working on it" reads the same in both places. */
.waiting-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.clock {
  margin-left: auto;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .waiting-dot {
    animation: none;
  }
  button.primary:active:not(:disabled) {
    translate: none;
  }
}
