/* Keycloak pieces grasp-ui has no component for. grasp-ui (gui/runtime.css)
   draws the page, sheet, fields, buttons and messages; this file only lays
   out what Keycloak adds, with --gui-* tokens and no colours of its own, except
   the page background (the Earth from space) and the text on it. It sets no
   background or box-shadow on grasp-ui components (grasp-ui draws button
   edges with box-shadow inside its own @layer). */

/* Page background: the Earth seen from space, the same in light and dark
   (the sheet keeps the grasp-ui surface). A dark veil keeps the text below the
   sheet readable over the bright horizon. Longhands only: the page colour of
   grasp-ui (.gui-shell) stays as the colour under the image while it loads,
   replaced here by the space black. */
.gui-auth-page {
  background-color: #02060f;
  background-image:
    linear-gradient(rgb(2 6 15 / 0.35), rgb(2 6 15 / 0.65)),
    url("../img/space.jpg");
  background-image:
    linear-gradient(rgb(2 6 15 / 0.35), rgb(2 6 15 / 0.65)),
    image-set(
      url("../img/space.avif") type("image/avif"),
      url("../img/space.webp") type("image/webp"),
      url("../img/space.jpg") type("image/jpeg")
    );
  background-size: cover;
  background-position: center 30%;
}

/* Sheet content: one vertical rhythm between the blocks of a form (fields,
   option rows, buttons), the --gui-space-4 grasp-ui uses between fields. */
.gui-auth__sheet form {
  margin: 0;
}

.gui-auth__sheet form > * + * {
  margin-block-start: var(--gui-space-4);
}

/* Full-width main action, the last block of a form. */
.kc-button-block,
.gui-auth__sheet form > .gui-button--primary,
.kc-form-buttons > .gui-button--primary {
  inline-size: 100%;
}

.kc-form-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gui-space-2);
}

/* "Remember me" and "Forgot password?" on one row, wrapping on phones. */
.kc-form-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gui-space-2) var(--gui-space-4);
}

.kc-form-settings > .gui-field {
  margin: 0;
}

/* Show-password toggle inside grasp-ui's input group: one icon per state. */
.kc-password__toggle[aria-pressed="true"] .kc-password__show,
.kc-password__toggle:not([aria-pressed="true"]) .kc-password__hide {
  display: none;
}

/* Icon classes for the base theme's passwordVisibility.js (pages this theme
   does not override). */
.kc-icon {
  display: inline-block;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  background-color: currentcolor;
  mask: var(--kc-icon) center / contain no-repeat;
}

.kc-icon--eye {
  --kc-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}

.kc-icon--eye-off {
  --kc-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.6 5.1A10.4 10.4 0 0 1 12 5c6.5 0 10 7 10 7a17.6 17.6 0 0 1-2.6 3.6M6.6 6.6C3.7 8.4 2 12 2 12s3.5 7 10 7a10 10 0 0 0 5.4-1.6M9.9 9.9a3 3 0 0 0 4.2 4.2M2 2l20 20'/%3E%3C/svg%3E");
}

/* Field errors rendered by base templates as a bare <span>. */
.kc-field-error {
  display: block;
}

/* "Signing in as <user>" with the restart link. */
.kc-username {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--gui-space-2);
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 600;
}

.kc-required-note {
  margin: 0;
}

/* Choice lists: OTP device, authenticator ("try another way"). The radio or
   link fills the row; the whole row is the target. */
.kc-choice-list {
  display: flex;
  flex-direction: column;
  gap: var(--gui-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.kc-choice {
  display: flex;
  align-items: center;
  gap: var(--gui-space-3);
  min-block-size: var(--gui-control-height-md);
  padding: var(--gui-space-3);
  border: 1px solid var(--gui-color-border-control);
  border-radius: var(--gui-radius-control);
  color: var(--gui-color-text);
  text-decoration: none;
  cursor: pointer;
}

.kc-choice__input {
  accent-color: var(--gui-color-primary);
}

.kc-choice__input:checked + .kc-choice,
.kc-choice:has(.kc-choice__input:checked) {
  border-color: var(--gui-color-primary-text);
}

.kc-choice__input:focus-visible + .kc-choice {
  outline: var(--gui-focus-width) solid var(--gui-focus-color);
  outline-offset: var(--gui-focus-offset);
}

.kc-choice__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--gui-space-1);
}

.kc-choice__title {
  font-weight: 600;
}

@media (hover: hover) {
  .kc-choice:hover {
    border-color: var(--gui-color-border-strong);
  }
}

/* OTP setup: QR code and secret. */
.kc-totp-qr {
  display: block;
  inline-size: min(100%, 12rem);
  block-size: auto;
  margin-inline: auto;
  border-radius: var(--gui-radius-sm);
}

.kc-totp-secret {
  font-family: var(--gui-font-mono);
  overflow-wrap: anywhere;
}

.kc-steps {
  display: flex;
  flex-direction: column;
  gap: var(--gui-space-3);
  margin: 0;
  padding-inline-start: var(--gui-space-6);
}

.kc-steps ul {
  display: flex;
  flex-direction: column;
  gap: var(--gui-space-1);
  margin: var(--gui-space-2) 0 0;
  padding-inline-start: var(--gui-space-4);
}

.kc-recovery-codes {
  font-family: var(--gui-font-mono);
}

.kc-locale ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.kc-disabled {
  opacity: 0.6;
  pointer-events: none;
}

/* Required marker printed by base templates (user profile, OTP setup) in
   the colour grasp-ui uses for its own marker. */
.gui-field__label .required,
.kc-required-note > span {
  color: var(--gui-color-danger);
}

/* Sheet and maintainer footer stay together in the middle of the page
   (grasp-ui's .gui-auth grid centres a single sheet). */
.gui-auth {
  align-content: center;
  gap: var(--gui-space-4);
}

/* "Developed and maintained by GRASP-EARTH": the GRASP-EARTH mark above the
   text, linking to grasp-earth.com, as the portals' "Powered by GRASP-EARTH". */
.kc-maintainer a {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gui-space-1);
  /* On the dark space background in both colour schemes. */
  color: rgb(255 255 255 / 0.85);
  font-size: var(--gui-font-size-small);
  text-decoration: none;
}

.kc-maintainer .gui-brand-logo {
  block-size: 2rem;
  inline-size: auto;
}

/* grasp-ui shows only the GRASP Open mark under data-gui-brand="open"; this
   footer always carries the GRASP-EARTH mark, in its brand green. */
.kc-maintainer .gui-brand-logo--earth {
  display: block;
}

.kc-maintainer .gui-shell__brand-mark {
  color: #83c751;
}

@media (hover: hover) {
  .kc-maintainer a:hover span {
    text-decoration: underline;
  }
}
