/**
 * Full-bleed split-panel sign-in page (page--user-login.html.twig).
 * Loaded only on that page via ji_bootstrap/login-styling -- not global.
 * Uses the design tokens from css/tokens.css.
 *
 * Sizes are px, not rem: this theme's html font-size is 10px
 * (Bootstrap 3 62.5% pattern), so rem would render at 62.5% of intent.
 *
 * The desktop layout must fit one screen at 100% zoom, from a 1280x720
 * laptop (~600px of viewport after browser chrome) to 1080p. Vertical
 * spacing therefore scales with vh via clamp(), and the height-based
 * media queries at the end shed detail on shorter viewports.
 */

/* Brand colour as an RGB triple so the translucent overlays below track
 * --ji-p-900 (#04424F) instead of repeating its literal value. */
body.jc-login-page {
  --jc-login-brand-rgb: 4, 66, 79;
}

/* style.css paints .not-logged-in body with a remote photo; the brand
 * panel shows a local copy of it instead. drupal-bootstrap.css (CDN) adds
 * `body { margin-top: 15px }` from 768px up, which pushed a 100vh page
 * 15px past the fold. */
body.jc-login-page {
  margin: 0;
  background: var(--ji-n-50);
}

.jc-login {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--ji-font);
  font-size: 14px;
  color: var(--ji-n-700);
  background: var(--ji-n-50);
}

/* ---------------------------------------------------------------------
 * Left panel -- brand, over the site's existing login background image.
 * --------------------------------------------------------------------- */

.jc-login__panel--brand {
  position: relative;
  flex: 0 0 46%;
  max-width: 640px;
  min-width: 0;
  overflow: hidden;
  background: var(--ji-p-900);
  color: #fff;
  padding: clamp(20px, 4.5vh, 44px) clamp(24px, 3vw, 44px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 0;
}

.jc-login__art-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Deep teal through the middle keeps the vertically centred brand copy
 * readable (white on --ji-p-900 is 11:1); it fades out so the photo
 * shows at the bottom. */
.jc-login__art-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    rgba(var(--jc-login-brand-rgb), .96) 0%,
    rgba(var(--jc-login-brand-rgb), .9) 55%,
    rgba(var(--jc-login-brand-rgb), .45) 85%,
    rgba(var(--jc-login-brand-rgb), .2) 100%
  );
}

.jc-login__art {
  display: block;
  width: 100%;
  height: 100%;
  animation: jc-login-drift 32s ease-in-out infinite alternate;
}

/* A CSS background, and only from 900px up: the stacked layout hides the
 * photo, and an <img> there would still be downloaded (loading="lazy" does
 * not defer it in Chrome). */
@media (min-width: 900px) {
  .jc-login__art {
    background: url('../images/login-bg.jpg') 40% center / cover no-repeat;
  }
}

/* Slow drift on the photo only; copy never animates, so it stays visible
 * where animations do not run. */
@keyframes jc-login-drift {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to { transform: scale(1.06) translate3d(0, -2%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .jc-login__art {
    animation: none;
  }
}

.jc-login__brand-copy {
  position: relative;
  z-index: 2;
  max-width: 460px;
}

/* Mark beside the name, not above it: saves ~60px of height. */
.jc-login__identity {
  display: flex;
  align-items: center;
  gap: var(--ji-s-5);
}

.jc-login__mark-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--ji-s-3);
  background: #fff;
  border-radius: var(--ji-r-lg);
  box-shadow: var(--ji-sh-sm);
}

.jc-login__mark {
  display: block;
  width: clamp(32px, 5vh, 44px);
  height: auto;
}

.jc-login__org {
  margin: 0 0 2px;
  font-size: var(--ji-fs-xs);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .92);
}

.jc-login__wordmark {
  margin: 0;
  font-size: clamp(20px, 3vh, 26px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
}

.jc-login__headline {
  margin: clamp(16px, 4vh, 36px) 0 0;
  font-size: clamp(22px, 3.6vh, 32px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
}

.jc-login__tagline {
  margin: clamp(6px, 1.2vh, 12px) 0 0;
  font-size: clamp(13px, 1.7vh, 15px);
  line-height: 1.45;
  font-weight: 500;
  color: rgba(255, 255, 255, .94);
}

/* Feature highlights sit on a translucent card so they stay readable where
 * the gradient has faded and the photo shows through. No backdrop blur: it
 * would repaint every frame under the drifting photo, which stutters on
 * older office PCs. */
.jc-login__features {
  margin: clamp(12px, 2.6vh, 24px) 0 0;
  padding: clamp(10px, 1.8vh, 16px) clamp(12px, 1.8vh, 18px);
  list-style: none;
  display: grid;
  gap: clamp(8px, 1.6vh, 14px);
  background: rgba(var(--jc-login-brand-rgb), .74);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--ji-r-lg);
}

.jc-login__feature {
  display: flex;
  align-items: flex-start;
  gap: var(--ji-s-5);
  font-size: 13px;
  line-height: 1.4;
}

.jc-login__feature strong {
  display: block;
  font-weight: 700;
  color: #fff;
}

.jc-login__feature-text {
  display: block;
  color: rgba(255, 255, 255, .9);
}

.jc-login__feature-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--ji-r-md);
  background: rgba(255, 255, 255, .14);
  color: #fff;
}

.jc-login__feature-icon svg {
  width: 16px;
  height: 16px;
}

/* Copy of the features shown below the form in the stacked layout only. */
.jc-login__features-stacked {
  display: none;
}

/* Footer region (the "A Product of Jagriti InnoHealth" block), pinned
 * to the bottom of the form panel. */
.jc-login__footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ji-s-4);
  padding-top: clamp(12px, 2vh, 20px);
  font-size: 12px;
}

/* Jagriti logo (a PNG on white) sits on a white tile, like the
 * eBloodBanking mark. */
.jc-login__vendor-chip {
  flex: 0 0 auto;
  display: inline-flex;
  padding: 3px;
  background: #fff;
  border-radius: var(--ji-r-md);
  box-shadow: var(--ji-sh-sm);
}

.jc-login__vendor-mark {
  display: block;
  width: 28px;
  height: auto;
}

.jc-login__footer .block {
  margin: 0;
}

.jc-login__footer div[align="center"] {
  text-align: left;
}

.jc-login__footer a {
  color: var(--ji-n-600);
}

.jc-login__footer a:hover,
.jc-login__footer a:focus {
  color: var(--ji-p-700);
}

/* ---------------------------------------------------------------------
 * Right panel -- form
 * --------------------------------------------------------------------- */

.jc-login__panel--form {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vh, 40px) clamp(20px, 3vw, 40px) clamp(12px, 2vh, 20px);
}

/* Auto margins centre the form vertically and push the footer down. */
.jc-login__form-inner {
  width: 100%;
  max-width: 380px;
  margin: auto 0;
}

.jc-login__heading {
  margin: 0 0 var(--ji-s-2);
  font-size: clamp(22px, 3.2vh, 26px);
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--ji-n-900);
}

.jc-login__subheading {
  margin: 0 0 clamp(12px, 2.4vh, 20px);
  color: var(--ji-n-600);
}

.jc-login__messages {
  margin-bottom: var(--ji-s-5);
}

.jc-login__messages .alert {
  margin: 0;
  padding: var(--ji-s-4) var(--ji-s-5);
}

/* Bootstrap 3 pulls .close 21px right to sit in the alert's 35px padding;
 * this alert has less padding, so keep the button inside the box. */
.jc-login__messages .alert .close {
  right: 0;
}

.jc-login__card {
  padding: clamp(16px, 2.6vh, 24px);
  background: #fff;
  border: 1px solid var(--ji-n-200);
  border-radius: var(--ji-r-lg);
  box-shadow: var(--ji-sh-md);
}

.jc-login__card .region-content > .block,
.jc-login__card .block-user-login-block {
  margin: 0;
}

/* The front-page "User login" block brings its own reset-password list;
 * the template's reset link below the card replaces it. */
.jc-login__card .block-user-login-block > ul {
  display: none;
}

/* Beat style.css's legacy .not-logged-in login rules (200px-wide form,
 * padded form, centred white text). */
.not-logged-in .jc-login__card form#user-login-form,
.jc-login__card #user-login-form {
  width: auto;
  margin: 0;
  padding: 0;
}

.jc-login__card .form-group {
  margin-bottom: clamp(10px, 1.8vh, 16px);
}

/* style.css's `form .control-label` is a 180px right-aligned column. */
.jc-login__card .control-label {
  display: block;
  width: auto;
  margin: 0 0 var(--ji-s-2);
  text-align: left;
  font-weight: 600;
  color: var(--ji-n-900);
}

/* 16px input text stops iOS Safari zooming the page on focus. */
.not-logged-in .jc-login__card form#user-login-form input.form-control,
.jc-login__card .form-control {
  width: 100%;
  height: 40px;
  min-height: 40px;
  font-size: 16px;
  border-color: var(--ji-n-300);
  border-radius: var(--ji-r-md);
  box-shadow: none;
}

.jc-login__card .form-control:focus {
  border-color: var(--ji-p-600);
  outline: 0;
  box-shadow: var(--ji-focus-ring);
}

.jc-login__card .form-actions {
  margin: var(--ji-s-4) 0 0;
}

.jc-login__card #user-login-form .form-submit {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
  font-weight: 600;
  background-color: var(--ji-p-700);
  border-color: var(--ji-p-700);
  border-radius: var(--ji-r-md);
  color: #fff;
}

.jc-login__card #user-login-form .form-submit:hover,
.jc-login__card #user-login-form .form-submit:focus {
  background-color: var(--ji-p-900);
  border-color: var(--ji-p-900);
  color: #fff;
}

.jc-login__card #user-login-form .form-submit:focus-visible {
  outline: 3px solid var(--ji-p-100);
  outline-offset: 2px;
}

.jc-login__reset-link {
  margin: clamp(10px, 2vh, 16px) 0 0;
  text-align: center;
}

.jc-login__reset-link a {
  color: var(--ji-p-600);
}

/* ---------------------------------------------------------------------
 * Shorter desktop viewports (1536x864 / 1366x768 / 1280x720 laptops).
 * All four features keep their detail; a 2x2 grid halves their height.
 * --------------------------------------------------------------------- */

@media (min-width: 900px) and (max-height: 760px) {
  .jc-login__brand-copy {
    max-width: 540px;
  }

  .jc-login__features {
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
  }

  /* Icon beside the title, description full width underneath. */
  .jc-login__feature {
    display: grid;
    grid-template-columns: 22px 1fr;
    align-items: center;
    column-gap: var(--ji-s-4);
    row-gap: 2px;
    font-size: 12px;
    line-height: 1.35;
  }

  .jc-login__feature > span:last-child {
    display: contents;
  }

  .jc-login__feature strong {
    font-size: 13px;
  }

  .jc-login__feature-icon {
    width: 22px;
    height: 22px;
  }

  .jc-login__feature-icon svg {
    width: 14px;
    height: 14px;
  }

  .jc-login__feature-text {
    grid-column: 1 / -1;
  }
}

/* ---------------------------------------------------------------------
 * Stacked layout below 900px (phones, portrait tablets): a compact brand
 * bar above the form; the photo and pitch would push the form off screen.
 * --------------------------------------------------------------------- */

@media (max-width: 899px) {
  .jc-login {
    flex-direction: column;
  }

  .jc-login__panel--brand {
    flex: 0 0 auto;
    max-width: none;
    padding: var(--ji-s-5) var(--ji-s-6);
    justify-content: flex-start;
  }

  .jc-login__brand-copy {
    max-width: none;
  }

  .jc-login__mark {
    width: 32px;
  }

  .jc-login__wordmark {
    font-size: var(--ji-fs-lg);
  }

  /* The brand bar is a solid --ji-p-900 here. The photo is only defined from
   * 900px up (see .jc-login__art), so phones never download it. */
  .jc-login__art-wrap {
    display: none;
  }

  .jc-login__headline,
  .jc-login__features {
    display: none;
  }

  .jc-login__tagline {
    margin-top: var(--ji-s-3);
    font-size: 12px;
  }

  .jc-login__panel--form {
    flex: 1 1 auto;
    padding: var(--ji-s-8) var(--ji-s-6);
  }

  .jc-login__features-stacked {
    display: block;
  }

  .jc-login__features-stacked .jc-login__features {
    display: grid;
    background: var(--ji-p-900);
  }
}

/* Small phones (iPhone SE-class, ~568px tall). */
@media (max-width: 899px) and (max-height: 640px) {
  .jc-login__panel--form {
    padding: var(--ji-s-6);
  }

  .jc-login__subheading {
    margin-bottom: var(--ji-s-5);
  }

  .jc-login__footer {
    padding-top: var(--ji-s-6);
  }
}

/* Portrait tablets have the height for the pitch: show it in the brand
 * bar as a 2x2 grid above the form. */
@media (max-width: 899px) and (min-width: 600px) and (min-height: 900px) {
  .jc-login__panel--brand {
    padding: var(--ji-s-8) var(--ji-s-9);
  }

  .jc-login__headline {
    display: block;
    margin-top: var(--ji-s-7);
    font-size: 26px;
  }

  .jc-login__tagline {
    font-size: 14px;
  }

  .jc-login__features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
  }

  .jc-login__features-stacked {
    display: none;
  }

  .jc-login__brand-copy {
    max-width: 640px;
  }
}
