/* /login: the sign-in on the dark "prism" stage (prism.js). Always dark, whatever theme the account keeps inside the
   platform: the logo at the top left, the sign-in in the left column, the glass and its light on the right (under the
   sign-in on a phone). Every rule is scoped to .pg-login; the platform's token names are pointed at the stage's
   colours, so the shared pieces (fields, buttons, the cookie banner and its dialog) come out dark too. */

.pg-login {
  --bg: #151517; --bg-2: #1b1b1e; --ink: #ededed; --muted: #a1a1a1; --dim: #6e6e73;
  --line: rgba(255, 255, 255, 0.12); --chip: rgba(255, 255, 255, 0.04);
  --gutter: clamp(16px, 2.6vw, 28px);
  --pl-nav: 64px;
  /* the sign-in column: never wider than the room left of the glass (its left corner at 0.66W - S/2, S = min(0.36W, 0.62H)) */
  --pl-col: min(23.5rem, calc(66vw - min(18vw, 31svh) - var(--gutter) - 2.5rem));
  /* the platform's names on the stage */
  --fg: var(--ink); --text-2: #bdbdc1; --text-3: var(--muted); --faint: #8b8b90;
  --panel: var(--bg-2); --raised: #1f1f23; --panel-2: rgba(255, 255, 255, 0.06); --paper: var(--bg-2); --seg-on: #2e2e33;
  --field-bg: var(--chip); --line-strong: rgba(255, 255, 255, 0.2); --ring: rgba(255, 255, 255, 0.1);
  --primary: var(--ink); --primary-fg: var(--bg); --primary-hover: #ffffff;
  --bad-fg: #ffaaa3; --bad-bg: rgba(255, 99, 88, 0.12);
  --ok-fg: #4ade80; --ok-bg: #0f2a1a; --warn-fg: #fbbf24; --warn-bg: #2a2108; --info-fg: #60a5fa; --info-bg: #0f1c33;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px #ffffff;
  --focus-ring-inset: inset 0 0 0 2px #ffffff;
  --input-ring: none;
  --shadow-1: none;
  --shadow-pop: 0 8px 24px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--line);
  --shadow-modal: 0 24px 56px -16px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--line);
  --backdrop: rgba(0, 0, 0, 0.62);
  color-scheme: dark;
  margin: 0; min-height: 100vh; min-height: 100svh;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* the page behind the page (overscroll, the browser's own controls) is the stage's grey too, even with "light" kept */
:root:has(> body.pg-login) { color-scheme: dark; background: #151517; }

.pg-login a { color: inherit; }
.pg-login :focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; box-shadow: none; }
.pg-login :is(a, .linklike, .btn-link):focus-visible { border-radius: 6px; }

/* =====================================================================================================================
   The stage: full screen, the glass and the light behind everything; the logo where the bar is; the sign-in in the
   left column, centred in the height; the legal links quiet at the bottom.
   ===================================================================================================================== */
.pg-login .pl-hero {
  position: relative; isolation: isolate;
  overflow: hidden; overflow: clip;   /* clip: no scroll range either (find-in-page, a #fragment cannot shift it) */
  display: flex; flex-direction: column;
  min-height: 100vh; min-height: 100svh;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg);
}
.pg-login .pl-stage { position: absolute; inset: 0; z-index: -1; pointer-events: none; touch-action: pan-y; opacity: 0; }
.pg-login .pl-stage.is-ready { opacity: 1; animation: pl-fade 1.6s 0.2s ease both; }
.pg-login .pl-stage canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; }
.pg-login .pl-stage #fx { mix-blend-mode: screen; }
.pg-login .pl-stage.is-gl #fx, .pg-login .pl-stage.is-2d #gl { display: none; }
@keyframes pl-fade { from { opacity: 0; } }

.pg-login .pl-nav {
  position: relative; z-index: 2; flex: none;
  display: flex; align-items: center;
  height: var(--pl-nav);
  padding: 14px var(--gutter);
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
}
.pg-login .pl-logo { display: block; height: 23px; width: auto; max-width: none; }

/* the light is dimmed behind the words by prism.js itself (a soft hole cut out of it where the sign-in, the logo and the
   legal links stand), so nothing here lies over the stage */
.pg-login .pl-copy {
  position: relative;
  flex: 1 0 auto;
  display: flex; flex-direction: column; justify-content: center;
  width: 100%; max-width: calc(var(--pl-col) + var(--gutter) * 2);
  min-height: calc(100svh - var(--pl-nav) - env(safe-area-inset-top, 0px));
  padding: 24px var(--gutter) 64px;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  animation: none;
}
.pg-login .pl-sign { position: relative; }
.pg-login .pl-room { display: none; }
.pg-login .pl-foot {
  position: absolute; left: 0; bottom: 0;
  padding: 0 var(--gutter) max(14px, env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
}

/* ---------- the words (rem: they follow the platform's text size and the browser's) ---------- */
.pg-login .pl-title {
  margin: 0;
  font-size: clamp(1.75rem, 1rem + 1.6vw, 2.5rem); line-height: 1.15; font-weight: 460; letter-spacing: -0.025em;
  color: var(--ink); text-align: left; text-wrap: balance;
}
.pg-login .auth-sub { margin: 0.625rem 0 0; font-size: 0.9375rem; line-height: 1.5; color: var(--muted); text-align: left; }
.pg-login .pl-body > form { display: grid; gap: 1rem; margin-top: clamp(24px, 2.6vw, 32px); }
.pg-login .pl-body > form[hidden] { display: none; }
.pg-login .auth-note { margin: 0; font-size: 0.875rem; line-height: 1.5; color: var(--text-2); }
.pg-login .hint { color: var(--muted); }
.pg-login .auth-foot {
  position: relative;
  margin: 28px 0 0; padding: 14px 0 0; border: 0;
  font-size: var(--fs-meta); line-height: 1.5; color: var(--muted); text-align: left;
}
/* the prompt's hairline: bright at the start, gone at the end */
.pg-login .auth-foot::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08) 70%, transparent);
}
.pg-login .auth-legal { justify-content: flex-start; gap: 0.25rem 0.5rem; margin: 0; font-size: var(--fs-meta); color: var(--muted); }
.pg-login .auth-legal :is(a, .linklike) { color: var(--muted); text-decoration: none; transition: color 0.2s; }
@media (hover: hover) and (pointer: fine) {
  .pg-login .auth-legal :is(a, .linklike):hover { color: var(--ink); text-decoration: none; }
}

/* ---------- fields: a faint chip on the dark, a hairline edge, the white ring on focus ---------- */
.pg-login .field { gap: 0.5rem; }
.pg-login .field label { font-size: var(--fs-label); font-weight: 500; line-height: 1.35; color: var(--text-2); }
/* the value's size from app.css (16px on touch so iOS does not zoom, the UI's size with a mouse): label and value grow together */
.pg-login .field input:where(:not([type="checkbox"], [type="radio"])) {
  min-height: 2.5rem; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background-color: var(--chip); color: var(--ink); caret-color: var(--ink);
  box-shadow: none;
}
.pg-login .pw input { padding-right: 3rem; }
.pg-login .field input::placeholder { color: var(--faint); }
@media (hover: hover) and (pointer: fine) {
  .pg-login .field input:where(:not([type="checkbox"], [type="radio"])):hover:not(:focus):not(:disabled) { border-color: rgba(255, 255, 255, 0.22); }
}
.pg-login .field input:where(:not([type="checkbox"], [type="radio"])):focus-visible {
  border-color: rgba(255, 255, 255, 0.3); outline: 2px solid #ffffff; outline-offset: 3px; box-shadow: none;
}
.pg-login .field input[aria-invalid="true"] { border-color: var(--bad-fg); }
/* a browser or a password manager filling the fields: the same dark field, never a yellow or blue box */
.pg-login .field input:is(:-webkit-autofill, :autofill),
.pg-login .field input:is(:-webkit-autofill, :autofill):hover,
.pg-login .field input:is(:-webkit-autofill, :autofill):focus {
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px #1e1e21 inset;
  box-shadow: 0 0 0 1000px #1e1e21 inset;
  border-color: var(--line);
  transition: background-color 600000s 0s, color 600000s 0s;
}
.pg-login .field input.login-code { min-height: 3.25rem; color: var(--ink); }
.pg-login .pw-toggle { right: 0.25rem; width: 2.25rem; height: 2.25rem; border-radius: 6px; color: var(--muted); background: transparent; }
.pg-login .pw-toggle[aria-pressed="true"] { color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .pg-login .pw-toggle:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
}
.pg-login .pw-toggle:focus-visible { outline-offset: 0; }

/* ---------- buttons: "Hyr" light on the dark; the rest the prompt's chips ---------- */
.pg-login .btn { border-radius: 8px; font-size: var(--fs-btn); font-weight: 500; }
.pg-login .btn-primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
@media (hover: hover) and (pointer: fine) {
  .pg-login .btn-primary:hover:not(:disabled) { background: #ffffff; border-color: #ffffff; }
}
.pg-login .btn-primary:disabled { opacity: 0.6; }
.pg-login .login-go { width: 100%; min-height: 2.5rem; margin-top: 0.25rem; }
.pg-login .login-chip {
  min-height: 2.25rem; padding: 0 12px;
  border: 1px solid var(--line); background: var(--chip); color: var(--ink);
}
@media (hover: hover) and (pointer: fine) {
  .pg-login .login-chip:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.22); color: var(--ink); }
}
.pg-login .login-chip:disabled { opacity: 1; color: var(--faint); }
.pg-login .login-back { justify-self: start; color: var(--ink); }
.pg-login .login-sso { display: grid; gap: 1rem; margin: clamp(24px, 2.6vw, 32px) 0 0; }
.pg-login .login-sso[hidden] { display: none; }
.pg-login .login-sso .login-go { min-height: 2.5rem; margin: 0; }
.pg-login .login-sso:not([hidden]) ~ form { margin-top: 1rem; }
.pg-login .login-or { color: var(--muted); font-size: var(--fs-meta); }
.pg-login .login-or::before, .pg-login .login-or::after { background: var(--line); opacity: 1; }
.pg-login .login-row, .pg-login .login-row.is-pair { justify-content: flex-start; gap: 0.5rem; margin: 0; }
.pg-login .login-row .btn { color: var(--ink); }
.pg-login .login-row .btn:disabled { color: var(--faint); }
.pg-login .btn-link { color: var(--ink); text-decoration-color: rgba(255, 255, 255, 0.4); }
@media (hover: hover) and (pointer: fine) { .pg-login .btn-link:hover { color: #ffffff; text-decoration-color: currentColor; } }
.pg-login .btn-link:disabled { color: var(--muted); }

/* ---------- the open-shift notice and the errors ---------- */
.pg-login .login-notice {
  margin: clamp(20px, 2.2vw, 28px) 0 0; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, 0.05);
}
.pg-login .login-notice-ico { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.pg-login .login-notice p { color: var(--text-2); }
.pg-login .login-notice b { color: var(--ink); }
.pg-login .login-notice:not([hidden]) ~ form, .pg-login .login-notice:not([hidden]) + .login-sso { margin-top: 1.25rem; }
.pg-login .login-notice:not([hidden]) ~ .login-sso:not([hidden]) ~ form { margin-top: 1rem; }
.pg-login .auth-error {
  padding: 10px 12px; border-radius: 8px;
  background: rgba(255, 99, 88, 0.12); border: 1px solid rgba(255, 128, 118, 0.34);
  color: var(--bad-fg); font-size: 0.875rem; font-weight: 500; line-height: 1.45;
}
.pg-login #ssoError:not([hidden]) { margin-top: 1rem; }

/* ---------- the cookie banner and its dialog on the dark page ---------- */
.pg-login .cookie-banner { background: #1f1f23; color: var(--ink); box-shadow: 0 24px 56px -16px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--line); }
.pg-login .cookie-text { color: var(--text-2); }
.pg-login .cookie-text b { color: var(--ink); }
.pg-login .cookie-text a { color: var(--ink); }
.pg-login .cookie-actions .btn:not(.btn-primary) { border-color: var(--line); background: rgba(255, 255, 255, 0.05); color: var(--ink); }
@media (hover: hover) and (pointer: fine) {
  .pg-login .cookie-actions .btn:not(.btn-primary):hover { background: rgba(255, 255, 255, 0.09); border-color: rgba(255, 255, 255, 0.22); }
}
.pg-login dialog.sheet { background: #1f1f23; color: var(--ink); }


/* ---------- touch: 44px for everything that is pressed ---------- */
@media (pointer: coarse) {
  .pg-login .field input:where(:not([type="checkbox"], [type="radio"])) { min-height: 2.75rem; }
  .pg-login .login-go, .pg-login .login-sso .login-go, .pg-login .login-chip { min-height: 2.75rem; }
  .pg-login .pw-toggle { width: 2.75rem; height: 2.75rem; right: 0; }
}

/* ---------- the load: the words rise in one after the other, the stage fades in once its first frame is drawn ----------
   The hidden state lives only in the keyframe (filled backwards through the delay): wherever animations do not run,
   the words are simply there. */
.pg-login .rise { animation: pl-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.pg-login .pl-sign > .rise:nth-child(2) { animation-delay: 0.08s; }
.pg-login .pl-sign > .rise:nth-child(3) { animation-delay: 0.16s; }
.pg-login .pl-foot .rise { animation-delay: 0.24s; }
@keyframes pl-rise { from { opacity: 0; transform: translateY(12px); } }

/* =====================================================================================================================
   Stacked (a phone, and a tablet held upright; prism.js asks the same query): the sign-in at the top, the glass in the
   room under it (prism.js places it between the sign-in's bottom and the legal links), the legal links at the foot.
   ===================================================================================================================== */
@media (max-width: 820px), (max-width: 1099px) and (max-aspect-ratio: 5/6) {
  .pg-login { --pl-col: 23.5rem; }
  .pg-login .pl-hero { min-height: max(100svh, 720px); }
  .pg-login .pl-copy {
    flex: none; justify-content: flex-start; min-height: 0; max-width: 100%;
    padding-top: clamp(20px, 5svh, 48px); padding-bottom: 0;
  }
  .pg-login .pl-sign { max-width: var(--pl-col); }
  .pg-login .auth-foot { margin-top: 20px; }
  /* the glass's room: its height (0.87 of its side) and 30px above, 12px below, a little to spare */
  .pg-login .pl-room { display: block; flex: 1 0 auto; height: calc(min(72vw, 400px) * 0.92 + 64px); }
  .pg-login .pl-foot { position: relative; align-self: flex-start; padding-top: 4px; }
  /* a short phone: the glass a third of the screen tall (prism.js asks the same), so most of it shows under the sign-in */
  @media (max-height: 759px) { .pg-login .pl-room { height: calc(min(72vw, 400px, 34svh) * 0.92 + 64px); } }
  /* the first visit's cookie banner sits over the legal links at the very bottom: room to scroll them clear */
  .pg-login:has(> .cookie-banner)::after { content: ""; display: block; height: 20rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-login .rise { animation: none; }
  .pg-login .pl-stage.is-ready { animation: none; }
}
/* Windows high contrast: the system's colours and nothing behind them (prism.js does not start either) */
@media (forced-colors: active) {
  .pg-login .pl-stage { display: none; }
}
/* … and on a light high-contrast theme the logo for light backgrounds (images keep their colours there) */
@media (forced-colors: active) and (prefers-color-scheme: light) {
  .pg-login .pl-logo { content: url("/brand/logo-h-light.png"); }
}
@media print {
  .pg-login .pl-stage { display: none; }
}
