/* Reshet: the look of the gatekeeper's login page (owner's decisions of
   14.11.2026, ADR 0028). The page itself is Authelia's own; nginx adds a link
   to this file and one block of HTML to it (role gate, the portal location):
     <div class="reshet-login-back"> … <video class="reshet-login-video"> …
     <p class="reshet-login-contacts"> …
   The backdrop repeats the participants' page of «Перемены»
   (apps/orbita/web/public-root/index.html): the same gradients, the same
   video, the same line of contacts. The form is laid out as the login screen
   of macOS: two narrow fields right on the backdrop, nothing else — in the
   middle of the width; by height two thirds of the screen down on a monitor,
   in the centre on a phone. Everything here is done by styles alone: the
   markup, the texts and the behaviour of the form stay Authelia's
   (v4.39.28; its own classes sit in a cascade layer, so the rules below win
   without !important). */

:root {
  --reshet-login-ink: #f6f3e9;
  --reshet-login-acid: #d8ff65;
  --reshet-login-page: min(1240px, calc(100vw - 64px));
  /* Room kept free at the bottom of the page for the line of contacts; the
     same room is kept at the top. */
  --reshet-login-contacts-zone: calc(36px + clamp(20px, 4vh, 36px));
  /* The height of the screen, and where on it the centre of the sign-in form
     stands, as a share of that height: the same place on any monitor. */
  --reshet-login-screen: 100vh;
  --reshet-login-centre: .5;
  /* The fields. */
  --reshet-login-width: 260px;
  --reshet-login-field: 36px;
  --reshet-login-gap: 10px;
  --reshet-login-fill: rgba(10, 18, 14, .42);
  --reshet-login-edge: rgba(255, 255, 255, .28);
  --reshet-login-hint: rgba(255, 255, 255, .66);
  --reshet-login-alarm: #ffa698;
}

@supports (height: 100dvh) {
  :root {
    --reshet-login-screen: 100dvh;
  }
}

/* A monitor: the form stands two thirds of the screen down. A phone (a narrow
   screen, or a low one — a phone on its side) keeps the form in the centre:
   lower, the on-screen keyboard would cover it. */
@media (min-width: 761px) and (min-height: 481px) {
  :root {
    --reshet-login-centre: .6667;
  }
}

html {
  background-color: #0c1d15;
}

body {
  position: relative;
  min-height: var(--reshet-login-screen);
  background-color: transparent;
  color: var(--reshet-login-ink);
}

/* --- the backdrop: the gradient of the participants' page, the video on wide screens --- */
.reshet-login-back {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    linear-gradient(110deg, rgba(12, 29, 21, .96) 0 43%, rgba(12, 29, 21, .68) 68%, rgba(12, 29, 21, .85)),
    radial-gradient(circle at 72% 24%, #4a9d72 0, #1b3b2b 36%, #0c1d15 72%);
}

.reshet-login-back::after {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(112deg, transparent 0 10vw, rgba(216, 255, 101, .045) 10vw 10.1vw),
    linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, .34));
  content: "";
}

.reshet-login-video {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The same condition as on the participants' page: a wide screen and no
   «reduce motion». The <source> of the video carries it too, so a phone does
   not download the file. */
@media (min-width: 761px) and (prefers-reduced-motion: no-preference) {
  .reshet-login-video {
    display: block;
  }

  .reshet-login-back::after {
    background:
      linear-gradient(110deg, rgba(6, 25, 16, .86) 0 42%, rgba(6, 25, 16, .58) 70%, rgba(6, 25, 16, .68)),
      repeating-linear-gradient(112deg, transparent 0 10vw, rgba(216, 255, 101, .045) 10vw 10.1vw),
      linear-gradient(180deg, transparent 48%, rgba(0, 0, 0, .4));
  }
}

/* --- every view of the login portal: straight on the backdrop ---
   Each view (sign in, signed in) is built the same way: <header> with one
   button (language or account), then one block that centres the content.
   The header is taken out of the flow and the block fills the screen, so
   the content stands in the centre of the screen exactly (the sign-in form
   is then moved down, below). Authelia's colours are its theme variables:
   here they are the light ones of the backdrop. */
#root header,
#root header + div {
  --foreground: var(--reshet-login-ink);
  --muted-foreground: rgba(246, 243, 233, .7);
  --muted: rgba(255, 255, 255, .16);
  --accent: rgba(255, 255, 255, .14);
  --secondary: var(--reshet-login-ink);
  --border: var(--reshet-login-edge);
  --custom-icon: rgba(246, 243, 233, .88);
  --custom-loading-bar: var(--reshet-login-ink);
}

#root header {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}

#root header + div {
  box-sizing: border-box;
  min-height: var(--reshet-login-screen);
  padding: var(--reshet-login-contacts-zone) 0;
}

/* The language switch is not shown. */
#language-button {
  display: none;
}

/* «Powered by Authelia» is not shown. */
#root header + div a[href*="www.authelia.com"],
#root header + div div:has(> a[href*="www.authelia.com"]) {
  display: none;
}

/* The tick of the signed-in view: readable on the dark backdrop. */
#authenticated-stage svg {
  color: #9be8ae;
}

/* --- the sign-in view: two fields, nothing else ---
   The block centres the form between its paddings. The top one is larger by
   (2 × centre − 1) of the screen, which puts the centre of the form at that
   share of the height: nothing for .5, a third of the screen for two thirds. */
#root header + #first-factor-stage {
  padding-top: calc(var(--reshet-login-contacts-zone) + var(--reshet-login-screen) * (2 * var(--reshet-login-centre) - 1));
}

#first-factor-stage > div {
  width: var(--reshet-login-width);
  max-width: calc(100vw - 36px);
  padding: 0;
}

/* The user icon and the title «Авторизация» are not shown. */
#first-factor-stage #UserSvg,
#first-factor-stage div:has(> #UserSvg),
#first-factor-stage h5,
#first-factor-stage div:has(> h5) {
  display: none;
}

#first-factor-stage div:has(> #form-login) {
  margin: 0;
  padding: 0;
}

#form-login > div {
  position: relative;
  gap: var(--reshet-login-gap);
}

/* The fields are «pills»: a dark translucent fill, the backdrop blurred
   under it, light text. That keeps the text readable on the lightest and on
   the darkest frames of the video alike. */
#form-login input {
  height: var(--reshet-login-field);
  padding: 0 16px;
  border: 1px solid var(--reshet-login-edge);
  border-radius: 999px;
  background-color: var(--reshet-login-fill);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .24);
  color: #fff;
  caret-color: #fff;
  /* The browser's own parts of a field (autofill, the caret, the keys of a
     password manager) are drawn for a dark field. */
  color-scheme: dark;
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
}

/* The hint inside the field is Authelia's own placeholder (it is there, only
   transparent); the label above the field is left to screen readers. */
#form-login input::placeholder {
  color: var(--reshet-login-hint);
  opacity: 1;
}

#form-login label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Focus. */
#form-login input:focus {
  border-color: rgba(255, 255, 255, .82);
  background-color: rgba(10, 18, 14, .52);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .22), 0 1px 3px rgba(0, 0, 0, .24);
}

/* A field Authelia marks as wrong (sign-in pressed with the field empty). */
#form-login input[aria-invalid="true"] {
  border-color: var(--reshet-login-alarm);
  box-shadow: 0 0 0 3px rgba(255, 130, 110, .3), 0 1px 3px rgba(0, 0, 0, .24);
}

#form-login input[aria-invalid="true"]::placeholder {
  color: var(--reshet-login-alarm);
}

/* Autofill. A browser paints a field it filled with its own colour and does
   not let a page set another one. What a page may do: keep the colours the
   field had before (a transition that never starts) and name the colour of
   the text. Two rules, not one list: a browser drops a whole list for one
   name it does not know. */
#form-login input:-webkit-autofill {
  -webkit-text-fill-color: #fff;
  caret-color: #fff;
  transition: background-color 0s linear 9999999s, color 0s linear 9999999s;
}

#form-login input:autofill {
  -webkit-text-fill-color: #fff;
  caret-color: #fff;
  transition: background-color 0s linear 9999999s, color 0s linear 9999999s;
}

/* «Show the password». */
#form-login button[type="button"] {
  right: 8px;
  padding: 4px;
  border-radius: 50%;
  color: var(--reshet-login-hint);
}

#form-login button[type="button"]:hover {
  color: #fff;
}

#form-login button[type="button"]:focus-visible {
  outline: 2px solid rgba(255, 255, 255, .85);
  outline-offset: 1px;
}

#form-login button[type="button"] svg {
  width: 16px;
  height: 16px;
}

#password-textfield {
  padding-right: 38px;
}

/* The sign-in button. As a rule it is the arrow inside the password field
   (below). When the form is built another way — something stands between the
   password and the button — it is a small quiet button under the fields. */
#sign-in-button {
  width: auto;
  height: 30px;
  padding: 0 18px;
  border: 1px solid var(--reshet-login-edge);
  border-radius: 999px;
  background-color: var(--reshet-login-fill);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  color: #fff;
  font-size: 12px;
  letter-spacing: .04em;
}

#sign-in-button:hover {
  background-color: rgba(255, 255, 255, .22);
}

#sign-in-button:focus-visible {
  border-color: rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .22);
}

/* The arrow: the password field is the last but one row of the form and the
   button is the last one. The row of the button is laid over the right end
   of the password field; its caption stays for screen readers. */
#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child:has(> #sign-in-button) {
  position: absolute;
  right: 5px;
  bottom: 5px;
  width: calc(var(--reshet-login-field) - 10px);
  height: calc(var(--reshet-login-field) - 10px);
}

#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child > #sign-in-button {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, .22);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  color: transparent;
  font-size: 0;
}

#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child > #sign-in-button:hover {
  background-color: rgba(255, 255, 255, .38);
}

#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child > #sign-in-button:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .85);
}

#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child > #sign-in-button::before,
#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child > #sign-in-button::after {
  position: absolute;
  top: 50%;
  left: 50%;
  box-sizing: border-box;
  content: "";
}

/* the shaft */
#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child > #sign-in-button::before {
  width: 11px;
  height: 1.5px;
  margin: -.75px 0 0 -5.5px;
  border-radius: 1px;
  background-color: #fff;
}

/* the head */
#form-login > div:has(> div:nth-last-child(2) #password-textfield) > div:last-child > #sign-in-button::after {
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -2px;
  border-top: 1.5px solid #fff;
  border-right: 1.5px solid #fff;
  transform: rotate(45deg);
}

#form-login > div:has(> div:nth-last-child(2) #password-textfield):has(> div:last-child > #sign-in-button) #password-textfield {
  padding-right: 66px;
}

#form-login > div:has(> div:nth-last-child(2) #password-textfield):has(> div:last-child > #sign-in-button) button[type="button"] {
  right: 35px;
}

/* Phones: fields a finger hits, and text of the size at which a phone does
   not zoom the page on a tap into a field. */
@media (max-width: 760px) {
  :root {
    --reshet-login-page: calc(100vw - 36px);
    --reshet-login-field: 42px;
  }

  #form-login input {
    font-size: 16px;
  }
}

/* --- the message of the sign-in view («wrong user name or password») ---
   Authelia shows it as a notification in the corner of the screen. On the
   sign-in view it is light text right under the fields; it lies over the
   page, so the form does not move when it comes and goes. */
body:has(#first-factor-stage) [data-slot="toast-viewport"] {
  top: calc(var(--reshet-login-screen) * var(--reshet-login-centre) + var(--reshet-login-field) + var(--reshet-login-gap) / 2 + 16px);
  right: auto;
  left: 50%;
  width: min(340px, calc(100vw - 36px));
  transform: translateX(-50%);
}

body:has(#first-factor-stage) [data-slot="toast"] {
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: #fff;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6), 0 0 12px rgba(0, 0, 0, .45);
  translate: none;
}

body:has(#first-factor-stage) [data-slot="toast"] h2 {
  flex-grow: 0;
}

body:has(#first-factor-stage) [data-slot="toast"][data-type="error"] svg {
  color: var(--reshet-login-alarm);
}

/* --- the line of contacts, as on the participants' page --- */
.reshet-login-contacts {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: var(--reshet-login-page);
  margin: 0 auto;
  padding: 0 0 clamp(20px, 4vh, 36px);
  color: rgba(246, 243, 233, .62);
  font-family: Inter, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: .04em;
  text-align: left;
}

.reshet-login-contacts a {
  border-bottom: 1px solid rgba(255, 255, 255, .3);
  color: rgba(246, 243, 233, .82);
  text-decoration: none;
}

.reshet-login-contacts a:hover {
  color: #fff;
}

.reshet-login-contacts a:focus-visible {
  outline: 3px solid var(--reshet-login-acid);
  outline-offset: 5px;
}

/* --- the gatekeeper's own settings pages keep Authelia's look --- */
html:has(#settings-menu) {
  background-color: var(--background, #fff);
}

body:has(#settings-menu) {
  background-color: var(--background, #fff);
  color: var(--foreground, #111);
}

body:has(#settings-menu) .reshet-login-back,
body:has(#settings-menu) .reshet-login-contacts {
  display: none;
}
