/* ==========================================================================
   Crescent Air -- sign-in experience
   A split console rather than a centred box: the brand panel carries a
   single large crescent mark bleeding off the edge, and the form sits on a
   plain working surface beside it.

   Both halves share one vertical rhythm (top row / centred body / bottom
   row) with the same padding, so the headline and the form centre on the
   same line and the two footers sit on the same baseline.
   ========================================================================== */

.auth {
  --auth-pad-y: var(--s-9);
  --auth-pad-x: clamp(var(--s-7), 5vw, var(--s-10));

  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.auth__panel,
.auth__form-side {
  display: grid;
  grid-template-rows: minmax(auto, 1fr) auto minmax(auto, 1fr);
  row-gap: var(--s-8);
  padding: var(--auth-pad-y) var(--auth-pad-x);
}

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

.auth__panel {
  position: relative;
  background: var(--c-ink-900);
  color: var(--c-ink-200);
  overflow: hidden;
}

/* A faint engineered grid, the texture of a wiring diagram. Kept at very
   low contrast so it never competes with the type, and faded out towards
   the form side so the seam between the halves stays quiet. */
.auth__panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(100deg, #000 40%, transparent 100%);
  mask-image: linear-gradient(100deg, #000 40%, transparent 100%);
  pointer-events: none;
}

/* The crescent, oversized and cropped by the panel edge. */
.auth__mark {
  position: absolute;
  right: -180px;
  bottom: -160px;
  width: 640px;
  height: 640px;
  color: var(--c-cool-600);
  opacity: 0.14;
  pointer-events: none;
}

.auth__panel > * {
  position: relative;
  z-index: var(--z-base);
}

/* Re-asserted after the rule above, which would otherwise pull the mark
   into the grid flow and push the panel content down the page. */
.auth__panel > .auth__mark {
  position: absolute;
  z-index: 0;
}

.auth__brand {
  display: flex;
  align-items: center;
  align-self: start;
  gap: var(--s-3);
}

.auth__brand-name {
  font-size: var(--fs-18);
  font-weight: var(--fw-semibold);
  color: var(--c-white);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-snug);
}

.auth__brand-line {
  font-size: var(--fs-13);
  color: #8ea3b8;
}

.auth__pitch {
  grid-row: 2;
  max-width: 30rem;
}

.auth__headline {
  font-size: clamp(var(--fs-30), 2.6vw + 0.5rem, 2.75rem);
  font-weight: var(--fw-semibold);
  line-height: 1.1;
  letter-spacing: -0.022em;
  color: var(--c-white);
  text-wrap: balance;
}

.auth__lede {
  max-width: 40ch;
  margin-top: var(--s-4);
  font-size: var(--fs-16);
  line-height: var(--lh-relaxed);
  color: #a3b5c7;
  text-wrap: pretty;
}

/* Footer row: operational facts and the licence number, pinned to the
   bottom so they line up with the legal line on the form side. */
.auth__panel-foot,
.auth__panel > .auth__licence {
  grid-row: 3;
  align-self: end;
}

/* Operational facts, not marketing claims. */
.auth__facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--s-5) var(--s-6);
  margin: 0;
  padding-top: var(--s-5);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.auth__fact {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-width: 0;
}

.auth__fact-label {
  font-size: var(--fs-11);
  font-weight: var(--fw-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8ea3b8;
}

.auth__fact-value {
  margin: 0;
  font-size: var(--fs-18);
  font-weight: var(--fw-semibold);
  color: var(--c-white);
  font-variant-numeric: tabular-nums;
}

.auth__fact-value--text {
  font-size: var(--fs-15);
  line-height: var(--lh-snug);
  overflow-wrap: anywhere;
}

.auth__licence {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-12);
  color: #8ea3b8;
}

.auth__facts + .auth__licence {
  margin-top: var(--s-5);
}

/* --- Form side ----------------------------------------------------------- */

.auth__form-side {
  justify-items: center;
  background: var(--surface-card);
}

.auth__form {
  grid-row: 2;
  width: 100%;
  max-width: 400px;
}

.auth__form-head {
  margin-bottom: var(--s-7);
}

.auth__title {
  font-size: var(--fs-30);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  line-height: var(--lh-tight);
}

.auth__subtitle {
  margin-top: var(--s-3);
  font-size: var(--fs-15);
  line-height: var(--lh-normal);
  color: var(--text-secondary);
  text-wrap: pretty;
}

.auth__subtitle strong {
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}

/* Slightly taller controls than the console default: this is the one form
   everybody fills in, often on a phone or with gloves just off. */
.auth .field + .field {
  margin-top: var(--s-5);
}

.auth .input {
  min-height: 44px;
  font-size: var(--fs-15);
}

.auth__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-1) var(--s-3);
  margin: var(--s-3) 0 var(--s-6);
}

/* Both controls in the row get a full 44px hit area without adding
   visual weight. */
.auth__row .checkbox {
  align-items: center;
  min-height: 44px;
  color: var(--text-secondary);
}

.auth__row .checkbox input[type="checkbox"] {
  margin-top: 0;
}

.auth__row a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
}

.auth__submit {
  width: 100%;
  min-height: 48px;
  font-size: var(--fs-15);
}

.auth__submit-idle,
.auth__submit-busy {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

/* Pending state, driven by the data-submitting flag app.js sets on the
   form. The label changes as well as the icon, so it is not colour or
   motion alone that says the request is in flight. */
.auth__submit-busy {
  display: none;
}

form[data-submitting="1"] .auth__submit {
  pointer-events: none;
  opacity: 0.85;
}

form[data-submitting="1"] .auth__submit-idle {
  display: none;
}

form[data-submitting="1"] .auth__submit-busy {
  display: inline-flex;
}

.auth__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--c-white);
  border-radius: 50%;
  animation: auth-spin 700ms linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

.auth__foot {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--fs-13);
  color: var(--text-muted);
}

/* Legal line, pinned to the bottom row opposite the panel's facts. */
.auth__legal {
  grid-row: 3;
  align-self: end;
  width: 100%;
  max-width: 400px;
  font-size: var(--fs-12);
  color: var(--text-muted);
}

.auth__alert {
  margin-bottom: var(--s-5);
}

/* Password field with a reveal toggle. */
.password-field {
  position: relative;
}

.password-field .input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.password-toggle:hover {
  background: var(--c-ink-100);
  color: var(--text-primary);
}

/* Development credentials panel. Rendered only when APP_ENV is local, so it
   can never appear on the Plesk deployment. */
.auth__devbox {
  margin-top: var(--s-6);
  padding: var(--s-3) var(--s-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  font-size: var(--fs-12);
  color: var(--text-secondary);
}

.auth__devbox strong {
  display: block;
  margin-bottom: var(--s-2);
  color: var(--text-primary);
}

.auth__devbox dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px var(--s-3);
  margin: 0;
}

.auth__devbox dt {
  color: var(--text-muted);
}

.auth__devbox dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-11);
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1024px) {
  .auth {
    --auth-pad-y: var(--s-8);
    --auth-pad-x: var(--s-7);
  }

  .auth__mark {
    width: 460px;
    height: 460px;
    right: -150px;
  }
}

/* Short laptop screens: tighten the vertical rhythm before anything has
   to scroll. */
@media (max-height: 720px) and (min-width: 861px) {
  .auth {
    --auth-pad-y: var(--s-7);
  }

  .auth__panel,
  .auth__form-side {
    row-gap: var(--s-6);
  }

  .auth__form-head {
    margin-bottom: var(--s-5);
  }
}

/* On a phone the panel becomes a compact masthead and the form takes the
   rest of the screen; nothing is cut off and nothing scrolls sideways. */
@media (max-width: 860px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr;
  }

  .auth__panel {
    display: block;
    padding: var(--s-6) var(--s-5);
  }

  .auth__pitch,
  .auth__panel-foot,
  .auth__panel > .auth__licence {
    display: none;
  }

  .auth__mark {
    width: 280px;
    height: 280px;
    right: -110px;
    bottom: -150px;
  }

  .auth__form-side {
    grid-template-rows: auto 1fr;
    row-gap: var(--s-8);
    padding: var(--s-7) var(--s-5) var(--s-6);
  }

  .auth__form {
    grid-row: 1;
  }

  .auth__legal {
    grid-row: 2;
  }

  .auth__title {
    font-size: var(--fs-24);
  }

  .auth__form-head {
    margin-bottom: var(--s-6);
  }
}
