/**
 * Sign-in experience — SCMI Administrator.
 *
 * Two columns sharing a top and bottom baseline: the Centre's navy plate, and
 * the sign-in on paper. Palette and the bar motif come from the Centre's own
 * assets — #0091d3 is sampled from logo.png, the plate carries the navy and the
 * ribbon artwork used by the in-app sidebar, and the rules echo the bar
 * terminals in the SCS letterforms.
 *
 * Everything is scoped under .scmi-auth / .scmi-auth-body so the shared
 * component styles used by the in-app screens stay untouched.
 */

.scmi-auth {
  --reg-navy: #0a1628;
  --reg-blue: #0091d3;
  --reg-blue-deep: #00659c;
  --reg-blue-deeper: #004f7b;
  --reg-ink: #101b2b;
  --reg-slate: #566274;
  --reg-line: #cfd6de;
  --reg-line-soft: #e4e9ee;
  --reg-paper-tint: #f5f7f9;
  --reg-danger: #b42318;
  --reg-warning: #8a5a00;
  --reg-ok: #4fd1c5;

  --reg-pad: clamp(1.75rem, 4.2vw, 3.5rem);
  --reg-logo-h: 3.25rem;
  --reg-plate-art:
    linear-gradient(178deg, rgba(7, 17, 30, 0.6) 0%, rgba(6, 15, 27, 0.76) 58%, rgba(4, 11, 20, 0.9) 100%),
    url("../images/sidebar-bg.jpg");
  --reg-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ─────────────────────────────── Shell ─────────────────────────────── */

.scmi-auth-body {
  margin: 0;
  min-block-size: 100vh;
  font-family: var(--scmi-font-sans);
  font-size: 1rem;
  color: var(--reg-ink);
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.scmi-auth {
  min-block-size: 100vh;
  min-block-size: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 43fr) minmax(0, 57fr);
}

.scmi-auth h1,
.scmi-auth h2,
.scmi-auth p {
  margin: 0;
}

/* ──────────────────── Institution plate (left column) ───────────────── */

.scmi-auth__plate {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: start;
  gap: clamp(1.75rem, 4vh, 3.25rem);
  padding: var(--reg-pad);
  color: #ffffff;
  background-color: var(--reg-navy);
  background-image: var(--reg-plate-art);
  background-size: cover, cover;
  background-position: center, center;
}

.scmi-auth__logo {
  display: block;
  align-self: start;
  inline-size: auto;
  block-size: var(--reg-logo-h);
  max-inline-size: 12.5rem;
  object-fit: contain;
  object-position: left center;
}

.scmi-auth__plate-body {
  align-self: center;
  inline-size: 100%;
  max-inline-size: 26rem;
}

/* Brand bar, at the weight of the terminals in the SCS letterforms */
.scmi-auth__rule {
  display: block;
  inline-size: 3.25rem;
  block-size: 3px;
  margin-block-end: 1.75rem;
  background: var(--reg-blue);
  transform-origin: left center;
}

.scmi-auth__system {
  font-size: clamp(2.1rem, 3.6vw, 3rem);
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: -0.023em;
  color: #ffffff;
}

.scmi-auth__operator {
  margin-block-start: 1.15rem;
  max-inline-size: 22rem;
  font-size: 1rem;
  line-height: 1.6;
  color: rgba(219, 231, 243, 0.8);
}

.scmi-auth__status {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.8125rem;
  color: rgba(196, 216, 234, 0.75);
}

.scmi-auth__status-dot {
  flex: none;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  border-radius: 50%;
  background: var(--reg-ok);
}

/* Brand rule on the seam between the plate and the paper */
.scmi-auth__seam {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  inline-size: 3px;
  background: var(--reg-blue);
  transform-origin: center top;
}

/* ──────────────────────── Sign-in (right column) ────────────────────── */

.scmi-auth__panel {
  display: flex;
  justify-content: center;
  padding: var(--reg-pad) clamp(1.5rem, 5vw, 4rem);
  background: #ffffff;
}

.scmi-auth__column {
  inline-size: min(27rem, 100%);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(2rem, 5vh, 3.25rem);
}

.scmi-auth__column:not(:has(.scmi-auth__gov)) {
  grid-template-rows: 1fr auto;
}

.scmi-auth__gov {
  display: block;
  align-self: start;
  justify-self: end;
  block-size: var(--reg-logo-h);
  inline-size: auto;
  max-inline-size: 13.5rem;
  object-fit: contain;
  object-position: right center;
}

.scmi-auth__form-block {
  align-self: center;
}

.scmi-auth__title {
  font-size: clamp(1.6rem, 2.6vw, 1.95rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.scmi-auth__intro {
  margin-block-start: 0.6rem;
  max-inline-size: 24rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--reg-slate);
}

/* Live region for validation and help feedback */
.scmi-auth__alert {
  display: none;
  align-items: flex-start;
  gap: 0.75rem;
  margin-block-start: 1.5rem;
  padding: 0.75rem 0.9rem;
  background: #fdf3f2;
  color: #8c2018;
  font-size: 0.875rem;
  line-height: 1.5;
}

.scmi-auth__alert.is-visible,
.scmi-auth__alert:not([hidden]) {
  display: flex;
  animation: reg-rise 0.3s var(--reg-ease) both;
}

.scmi-auth__alert-bar,
.scmi-auth__alert::before {
  content: "";
  flex: none;
  inline-size: 0.1875rem;
  align-self: stretch;
  min-block-size: 1.25rem;
  background: var(--reg-danger);
}

.scmi-auth__alert--info {
  background: var(--reg-paper-tint);
  color: #143b52;
}

.scmi-auth__alert--info .scmi-auth__alert-bar {
  background: var(--reg-blue);
}

/* ─────────────────────────────── Fields ────────────────────────────── */

.scmi-auth__field {
  margin-block-start: 1.35rem;
}

.scmi-auth__label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.scmi-auth__label {
  display: block;
  margin-block-end: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--reg-ink);
}

.scmi-auth .scsc-required-mark {
  color: var(--reg-danger);
  font-weight: 600;
}

.scmi-auth__input {
  inline-size: 100%;
  block-size: 3rem;
  padding-inline: 0.875rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--reg-ink);
  background: #ffffff;
  border: 1px solid var(--reg-line);
  border-radius: 2px;
  outline: none;
  appearance: none;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.scmi-auth__input:hover {
  border-color: #adb8c4;
}

.scmi-auth__input:focus {
  border-color: var(--reg-blue-deep);
  box-shadow: inset 0 0 0 1px var(--reg-blue-deep);
}

.scmi-auth__input.is-invalid {
  border-color: var(--reg-danger);
}

.scmi-auth__input.is-invalid:focus {
  box-shadow: inset 0 0 0 1px var(--reg-danger);
}

.scmi-auth__reveal {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--reg-blue-deep);
  cursor: pointer;
}

.scmi-auth__reveal:hover {
  color: var(--reg-blue-deeper);
  text-decoration: underline;
}

.scmi-auth__reveal .scmi-auth__reveal-hide {
  display: none;
}

.scmi-auth__reveal[aria-pressed="true"] .scmi-auth__reveal-hide {
  display: inline;
}

.scmi-auth__reveal[aria-pressed="true"] .scmi-auth__reveal-show {
  display: none;
}

.scmi-auth__error,
.scmi-auth__hint {
  display: block;
  margin-block-start: 0.4rem;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.scmi-auth__error {
  color: var(--reg-danger);
}

.scmi-auth__hint {
  color: var(--reg-warning);
}

.scmi-auth__error[hidden],
.scmi-auth__hint[hidden] {
  display: none;
}

/* ───────────────────────── Options and submit ───────────────────────── */

.scmi-auth__options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-block-start: 1.5rem;
}

.scmi-auth__remember {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.875rem;
  color: var(--reg-ink);
  cursor: pointer;
  user-select: none;
}

.scmi-auth__remember input {
  position: absolute;
  opacity: 0;
  inline-size: 1px;
  block-size: 1px;
}

.scmi-auth__box {
  position: relative;
  flex: none;
  inline-size: 1.125rem;
  block-size: 1.125rem;
  border: 1px solid var(--reg-line);
  border-radius: 2px;
  background: #ffffff;
  transition:
    background 0.16s ease,
    border-color 0.16s ease;
}

.scmi-auth__box::after {
  content: "";
  position: absolute;
  inset-block-start: 0.1875rem;
  inset-inline-start: 0.3125rem;
  inline-size: 0.3125rem;
  block-size: 0.5625rem;
  border: 2px solid #ffffff;
  border-block-start: 0;
  border-inline-start: 0;
  transform: rotate(42deg);
  opacity: 0;
}

.scmi-auth__remember:hover .scmi-auth__box {
  border-color: #adb8c4;
}

.scmi-auth__remember input:checked + .scmi-auth__box {
  background: var(--reg-blue-deep);
  border-color: var(--reg-blue-deep);
}

.scmi-auth__remember input:checked + .scmi-auth__box::after {
  opacity: 1;
}

.scmi-auth__remember input:focus-visible + .scmi-auth__box {
  outline: 2px solid var(--reg-blue-deep);
  outline-offset: 2px;
}

.scmi-auth__link-btn {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--reg-blue-deep);
  cursor: pointer;
}

.scmi-auth__link-btn:hover {
  color: var(--reg-blue-deeper);
  text-decoration: underline;
}

.scmi-auth__submit {
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: 100%;
  block-size: 3rem;
  margin-block-start: 1.75rem;
  border: 0;
  border-radius: 2px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--reg-blue-deep);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.16s ease;
}

.scmi-auth__submit:hover,
.scmi-auth__submit:focus {
  color: #ffffff;
  text-decoration: none;
  background: var(--reg-blue-deeper);
}

a.scmi-auth__submit:visited {
  color: #ffffff;
}

.scmi-auth__submit:disabled {
  pointer-events: none;
  background: var(--reg-blue-deeper);
}

.scmi-auth__submit-busy {
  display: none;
  align-items: center;
  gap: 0.55rem;
}

.scmi-auth__spinner {
  inline-size: 0.875rem;
  block-size: 0.875rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-block-start-color: #ffffff;
  animation: reg-spin 0.7s linear infinite;
}

.scmi-auth.is-authenticating .scmi-auth__submit {
  pointer-events: none;
  background: var(--reg-blue-deeper);
}

.scmi-auth.is-authenticating .scmi-auth__submit-label {
  display: none;
}

.scmi-auth.is-authenticating .scmi-auth__submit-busy {
  display: flex;
}

/* ───────────────────────────── OTP step ────────────────────────────── */

.scmi-auth__otp-message {
  margin-block-start: 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--reg-slate);
}

.scmi-auth__otp-actions {
  display: flex;
  gap: 0.75rem;
  margin-block-start: 1.75rem;
}

.scmi-auth__otp-actions .scmi-auth__submit {
  flex: 1;
  margin-block-start: 0;
}

.scmi-auth__submit--secondary {
  color: var(--reg-blue-deeper);
  background: #ffffff;
  border: 1px solid var(--reg-line);
}

.scmi-auth__submit--secondary:hover,
.scmi-auth__submit--secondary:focus {
  color: var(--reg-blue-deeper);
  background: var(--reg-paper-tint);
  border-color: #adb8c4;
}

.scmi-auth__resend {
  display: block;
  inline-size: 100%;
  margin-block-start: 0.85rem;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--reg-blue-deep);
  cursor: pointer;
}

.scmi-auth__resend:hover {
  color: var(--reg-blue-deeper);
  text-decoration: underline;
}

.scmi-auth__resend[hidden] {
  display: none;
}

/* ───────────────────────────── Column foot ─────────────────────────── */

.scmi-auth__foot {
  align-self: end;
  padding-block-start: 1.15rem;
  border-block-start: 1px solid var(--reg-line-soft);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--reg-slate);
}

.scmi-auth__notice {
  color: var(--reg-ink);
}

.scmi-auth__prototype {
  margin-block-start: 0.65rem;
  padding-inline-start: 0.75rem;
  border-inline-start: 3px solid var(--reg-blue);
}

.scmi-auth__copyright {
  margin-block-start: 0.9rem;
  color: #7b8695;
}

/* ───────────────────────── Focus visibility ────────────────────────── */

.scmi-auth .scmi-focus:focus-visible,
.scmi-auth__reveal:focus-visible,
.scmi-auth__link-btn:focus-visible {
  outline: 2px solid var(--reg-blue-deep);
  outline-offset: 2px;
}

.scmi-auth__submit:focus-visible {
  outline: 2px solid var(--reg-navy);
  outline-offset: 2px;
}

/* ───────── Arrival: the plate opens, then the seam draws down ───────── */

.scmi-auth__plate {
  animation: reg-open 0.65s cubic-bezier(0.7, 0, 0.2, 1) both;
}

.scmi-auth__seam {
  animation: reg-draw-down 0.5s var(--reg-ease) 0.5s both;
}

.scmi-auth__logo {
  animation: reg-rise 0.55s var(--reg-ease) 0.32s both;
}

.scmi-auth__rule {
  animation: reg-draw-across 0.45s var(--reg-ease) 0.4s both;
}

.scmi-auth__system {
  animation: reg-rise 0.6s var(--reg-ease) 0.46s both;
}

.scmi-auth__operator {
  animation: reg-rise 0.6s var(--reg-ease) 0.54s both;
}

.scmi-auth__status {
  animation: reg-rise 0.55s var(--reg-ease) 0.64s both;
}

.scmi-auth__column {
  animation: reg-rise 0.6s var(--reg-ease) 0.3s both;
}

/* ──────── Departure: the plate sweeps across as the console opens ────── */

/* The sign-in recedes so the plate reads as the thing coming forward. */
.scmi-auth.is-authenticating .scmi-auth__column {
  animation: reg-recede 0.7s var(--reg-ease) both;
}

.scmi-auth.is-authenticating .scmi-auth__panel {
  pointer-events: none;
}

.scmi-auth__handoff {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.75rem;
  padding: var(--reg-pad);
  text-align: center;
  color: #ffffff;
  background-color: var(--reg-navy);
  background-image: var(--reg-plate-art);
  background-size: cover, cover;
  background-position: center, center;
  clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
  visibility: hidden;
  pointer-events: none;
}

.scmi-auth.is-handing-off .scmi-auth__handoff {
  visibility: visible;
  pointer-events: auto;
  animation: reg-curtain 0.95s cubic-bezier(0.65, 0, 0.2, 1) forwards;
}

/* Light travelling across the navy field, as if catching a polished surface */
.scmi-auth__handoff::before {
  content: "";
  position: absolute;
  inset: -25% -45%;
  z-index: 0;
  background: linear-gradient(
    102deg,
    transparent 40%,
    rgba(0, 145, 211, 0.32) 49%,
    rgba(255, 255, 255, 0.2) 53%,
    rgba(79, 209, 197, 0.18) 57%,
    transparent 66%
  );
  filter: blur(34px);
  opacity: 0;
}

/* Bloom rising behind the emblem */
.scmi-auth__handoff::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(
    40% 44% at 50% 45%,
    rgba(0, 145, 211, 0.34) 0%,
    rgba(79, 209, 197, 0.12) 46%,
    transparent 74%
  );
  opacity: 0;
  transform: scale(0.7);
}

.scmi-auth.is-handing-off .scmi-auth__handoff::before {
  animation: reg-sweep 1.3s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.scmi-auth.is-handing-off .scmi-auth__handoff::after {
  animation: reg-bloom 1.2s var(--reg-ease) 0.28s both;
}

.scmi-auth__handoff-mark {
  position: relative;
  z-index: 1;
  inline-size: clamp(11.875rem, 22vw, 17rem);
  block-size: auto;
  opacity: 0;
}

.scmi-auth__handoff-note {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 1.1rem;
  font-size: 1.125rem;
  letter-spacing: 0.01em;
  color: rgba(232, 241, 249, 0.9);
}

.scmi-auth__handoff-bar {
  display: block;
  inline-size: 14rem;
  max-inline-size: 60vw;
  block-size: 2px;
  background: linear-gradient(90deg, transparent, var(--reg-blue) 22%, var(--reg-ok) 50%, var(--reg-blue) 78%, transparent);
  transform-origin: center;
  transform: scaleX(0);
}

.scmi-auth.is-handing-off .scmi-auth__handoff-mark {
  animation: reg-emblem 0.95s cubic-bezier(0.22, 0.8, 0.28, 1) 0.3s both;
}

.scmi-auth.is-handing-off .scmi-auth__handoff-note {
  animation: reg-rise 0.6s var(--reg-ease) 0.62s both;
}

.scmi-auth.is-handing-off .scmi-auth__handoff-bar {
  animation: reg-draw-across 0.85s cubic-bezier(0.4, 0, 0.2, 1) 0.72s forwards;
}

/* ───────────────────────────── Keyframes ───────────────────────────── */

@keyframes reg-open {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes reg-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes reg-draw-across {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes reg-draw-down {
  from {
    transform: scaleY(0);
  }
  to {
    transform: scaleY(1);
  }
}

@keyframes reg-spin {
  to {
    transform: rotate(360deg);
  }
}

/* A slanted curtain of navy, leading with its top edge */
@keyframes reg-curtain {
  from {
    clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
  }
  to {
    clip-path: polygon(0 0, 134% 0, 120% 100%, 0 100%);
  }
}

@keyframes reg-sweep {
  from {
    opacity: 0;
    transform: translateX(-75%);
  }
  35% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translateX(75%);
  }
}

@keyframes reg-bloom {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
  60% {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0.9;
    transform: scale(1.09);
  }
}

@keyframes reg-emblem {
  from {
    opacity: 0;
    transform: scale(0.88) translateY(14px);
    filter: blur(7px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes reg-recede {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0.45;
    transform: scale(0.975) translateY(-8px);
  }
}

/* ───────────────────────────── Responsive ──────────────────────────── */

@media (max-width: 1100px) {
  .scmi-auth {
    grid-template-columns: minmax(0, 47fr) minmax(0, 53fr);
  }
}

@media (max-width: 900px) {
  .scmi-auth {
    grid-template-columns: minmax(0, 1fr);
    min-block-size: 0;
  }

  .scmi-auth__plate {
    grid-template-rows: auto auto auto;
    gap: 1.5rem;
    padding-block: clamp(1.75rem, 6vw, 2.5rem);
  }

  .scmi-auth__logo {
    inline-size: auto;
    max-inline-size: 9.5rem;
  }

  .scmi-auth__rule {
    margin-block-end: 1.25rem;
  }

  .scmi-auth__seam {
    inset-block: auto 0;
    inset-inline: 0;
    inline-size: auto;
    block-size: 3px;
    transform-origin: left center;
    animation-name: reg-draw-across;
  }

  .scmi-auth__panel {
    padding-block: clamp(2rem, 8vw, 3rem);
  }

  .scmi-auth__column {
    grid-template-rows: auto auto auto;
    gap: 2rem;
  }

  .scmi-auth__column:not(:has(.scmi-auth__gov)) {
    grid-template-rows: auto auto;
  }

  .scmi-auth__gov {
    justify-self: start;
  }
}

@media (max-width: 480px) {
  .scmi-auth {
    --reg-pad: 1.25rem;
    --reg-logo-h: 2.5rem;
  }

  .scmi-auth__plate {
    gap: 0.75rem;
    padding-block: 1.15rem;
  }

  .scmi-auth__plate-body {
    max-inline-size: none;
  }

  .scmi-auth__rule {
    margin-block-end: 0.75rem;
  }

  .scmi-auth__system {
    font-size: 1.65rem;
  }

  .scmi-auth__operator {
    margin-block-start: 0.55rem;
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .scmi-auth__status {
    font-size: 0.75rem;
  }

  .scmi-auth__panel {
    padding-block: 1.35rem;
  }

  .scmi-auth__column {
    gap: 1.15rem;
  }
}

/* ──────────────────────── Motion preferences ───────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .scmi-auth *,
  .scmi-auth *::before,
  .scmi-auth *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  .scmi-auth__plate {
    clip-path: none;
  }

  .scmi-auth.is-handing-off .scmi-auth__handoff {
    clip-path: polygon(0 0, 134% 0, 120% 100%, 0 100%);
    visibility: visible;
  }

  .scmi-auth__handoff-bar {
    transform: scaleX(1);
  }

  .scmi-auth__handoff-mark {
    opacity: 1;
  }
}
