/* The illustrated world behind the login card (views/default/_login_world.html, ADR 0010).
   Loaded only when a scene is on; without this file the card keeps its plain, centred place. */
.clw-world img {
  display: block;
}

.clw-stage {
  position: absolute;
  opacity: 0;
  transition: opacity 0.5s ease;
  contain: layout paint;
}
.clw-stage-in {
  opacity: 1;
}
.clw-layer,
.clw-particles {
  position: absolute;
  pointer-events: none;
  will-change: transform;
}
.clw-layer > img,
.clw-breath > img,
.clw-node > img {
  width: 100%;
  height: 100%;
}
/* A layer that turns with the character's head, about the neck, and the one that breathes, about
   the counter's top, around it (scene.json "rig"). */
.clw-breath,
.clw-node {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}
.clw-blink,
.clw-face,
.clw-gaze {
  position: absolute;
  opacity: 0;
}

/* The card as near the centre of the screen as what matters allows. --clw-aspect, --clw-fx,
   --clw-fy and --clw-keep-x/y come from the scene (body's style). The first lines repeat what
   object-fit: cover does to the picture, whose box overscans by 16 px on each side. */
body.clw-on {
  --clw-aspect: 1.6;
  --clw-fx: 0.3;
  --clw-fy: 0.75;
  --clw-keep-x: 0.56;
  --clw-keep-y: 2;
  --clw-iw: max(calc(100vw + 32px), calc((100vh + 32px) * var(--clw-aspect)));
  --clw-ih: calc(var(--clw-iw) / var(--clw-aspect));
  --clw-keep-left: calc((100vw + 32px - var(--clw-iw)) * var(--clw-fx) - 16px + var(--clw-iw) * var(--clw-keep-x) + 28px);
  --clw-keep-top: calc((100vh + 32px - var(--clw-ih)) * var(--clw-fy) - 16px + var(--clw-ih) * var(--clw-keep-y) - 16px);
  /* Narrower on a small screen rather than over the character, within what the form can take. */
  --clw-card: clamp(320px, calc(100vw - var(--clw-keep-left) - 16px), 420px);
  --clw-left: clamp(16px, max(calc(50vw - var(--clw-card) / 2), var(--clw-keep-left)), calc(100vw - var(--clw-card) - 16px));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100vh;
  padding-top: 24px;
}
/* Space the card leaves below itself when the scene wants it higher; gives way to a tall form. */
body.clw-on::after {
  content: '';
  flex: 0 1 max(0px, calc(100vh - var(--clw-keep-top)));
}
body.clw-on .csa-login-card {
  flex: none;
  width: var(--clw-card);
  max-width: none;
  margin: auto 0 auto var(--clw-left);
  box-shadow: 0 10px 40px rgba(40, 24, 12, 0.28), 0 2px 8px rgba(40, 24, 12, 0.18);
}
.clw-greeting {
  position: relative;
  z-index: 10;
  flex: none;
  box-sizing: border-box;
  width: var(--clw-card, 420px);
  margin: auto 0 0 var(--clw-left, auto);
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: clamp(26px, 4vh, 38px);
  line-height: 1.2;
  text-align: center;
  color: var(--clw-greeting, #7a1c24);
  text-shadow: 0 1px 12px rgba(255, 248, 235, 0.45);
}
body.clw-on .clw-greeting + .csa-login-card {
  margin: 14px 0 auto var(--clw-left);
}

/* A phone: the art has its own crop with the mascot on top, the form below it. */
@media (max-aspect-ratio: 1/1) {
  body.clw-on {
    display: block;
    height: auto;
    padding-top: 0;
  }
  body.clw-on::after {
    content: none;
  }
  body.clw-on .csa-login-card,
  body.clw-on .clw-greeting + .csa-login-card {
    width: 420px;
    max-width: calc(100vw - 32px);
    margin: max(44vh, 240px) auto 16px auto;
  }
  .clw-greeting {
    position: absolute;
    top: 10px;
    left: 16px;
    right: 16px;
    width: auto;
    margin: 0;
    font-size: 25px;
  }
}
