/**
 * Opening message overlay for the Auths.xyz homepage.
 * Full-viewport layer; content aligns to the normal Auths page container.
 * Does not own homepage layout or hero styling.
 *
 * Mobile (≤767px): three statements; CTA shifted down by 75% of the line-gap.
 * Desktop (≥768px): max-content column; equal gaps between statements;
 *   CTA shifted down by 75% of that statement gap.
 * Wide desktop (≥1200px): larger CTA; same column composition.
 */

#opening-message {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--auths-page-bg, #f8f4f1);
  color: #0a0a0a;
  opacity: 1;
  transition: opacity 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

html.opening-message-pending #opening-message {
  display: block;
}

html.opening-message-pending {
  overflow-y: scroll !important;
  overflow-x: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

html.opening-message-pending body {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100%;
}

#opening-message.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.opening-message__close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: #525252;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}

.opening-message__close:hover {
  color: #0a0a0a;
  background: rgba(0, 0, 0, 0.04);
}

.opening-message__close:focus-visible {
  outline: 2px solid #e6007a;
  outline-offset: 2px;
}

.opening-message__frame {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

.opening-message__inner {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding-left: 2.25rem; /* ~2–2.5rem page gutters */
  padding-right: 2.25rem;
  box-sizing: border-box;
}

.opening-message__lines {
  width: 100%;
}

.opening-message__line {
  position: relative;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.18;
  font-size: 1.75rem;
  text-align: left;
}

/* Invisible full sentence reserves final wrapped height so typing does not shift layout. */
.opening-message__sizer {
  display: block;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

.opening-message__typed {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
}

.opening-message__cursor {
  display: none;
  width: 0.42em;
  height: 0.65em;
  margin-left: 0.06em;
  vertical-align: -0.02em;
  background: #0a0a0a;
  border-radius: 1px;
}

.opening-message__cursor.is-active {
  display: inline-block;
  animation: opening-message-cursor 600ms steps(1, end) infinite;
}

.opening-message__cursor.is-hold {
  display: inline-block;
  animation: opening-message-cursor 600ms steps(1, end) infinite;
}

@keyframes opening-message-cursor {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.opening-message__actions {
  display: flex;
  align-items: center;
}

.opening-message__continue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 9999px;
  padding: 0.85rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(230, 0, 122, 0.15);
  opacity: 0;
  pointer-events: none;
  box-sizing: border-box;
  transition:
    opacity 350ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 150ms ease;
}

.opening-message__continue.is-ready {
  opacity: 1;
  pointer-events: auto;
}

.opening-message__continue:hover {
  filter: brightness(1.03);
}

.opening-message__continue:active {
  filter: brightness(0.98);
}

.opening-message__continue:focus-visible {
  outline: 2px solid #e6007a;
  outline-offset: 3px;
}

/* -------------------------------------------------------------------------- */
/* Mobile — deliberate viewport positions (mock-up)                           */
/* -------------------------------------------------------------------------- */

@media (max-width: 767px) {
  .opening-message__frame {
    display: block;
  }

  .opening-message__inner {
    position: absolute;
    inset: 0;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .opening-message__lines {
    display: contents;
  }

  .opening-message__line {
    position: absolute;
    left: 2rem;
    right: 2rem;
    /* Measure chosen so ~390–430px wraps like the mock without hard <br>s */
    max-width: 14.5em;
    font-size: 1.625rem;
  }

  .opening-message__line[data-opening-line="1"] {
    top: 16%;
  }

  .opening-message__line[data-opening-line="2"] {
    top: 30%;
  }

  .opening-message__line[data-opening-line="3"] {
    top: 44%;
  }

  .opening-message__actions {
    position: absolute;
    /* Line tops: 16% / 30% / 44% (14% apart). Shift CTA down by 75% of that gap. */
    top: 71%;
    left: 0;
    right: 0;
    justify-content: center;
    min-height: 3.5rem;
  }

  .opening-message__continue {
    width: 16.5rem;
    height: 3.5rem;
    max-width: calc(100% - 4rem);
    padding: 0 1.5rem;
    font-size: 1rem;
  }
}

/* Short mobile screens: compress positions, keep hierarchy */
@media (max-width: 767px) and (max-height: 720px) {
  .opening-message__line[data-opening-line="1"] {
    top: 14%;
  }

  .opening-message__line[data-opening-line="2"] {
    top: 27%;
  }

  .opening-message__line[data-opening-line="3"] {
    top: 40%;
  }

  .opening-message__actions {
    top: 66.25%;
  }
}

@media (max-width: 767px) and (max-height: 620px) {
  .opening-message__line[data-opening-line="1"] {
    top: 12%;
  }

  .opening-message__line[data-opening-line="2"] {
    top: 24%;
  }

  .opening-message__line[data-opening-line="3"] {
    top: 36%;
  }

  .opening-message__actions {
    top: 60%;
  }

  .opening-message__line {
    font-size: 1.5rem;
  }
}

/* -------------------------------------------------------------------------- */
/* Desktop / tablet — single vertical content column                          */
/* Equal gaps between the three statements; leftover space sits above.        */
/* -------------------------------------------------------------------------- */

@media (min-width: 768px) {
  .opening-message__frame {
    display: block;
    padding: 0;
  }

  /*
   * One max-content column, centred horizontally.
   * Statements stack with equal gaps; leftover viewport space sits above.
   * CTA sits below the last line, shifted down by 75% of the statement gap.
   */
  .opening-message__inner {
    --opening-line-gap: 4.25rem;
    --opening-cta-shift: calc(var(--opening-line-gap) * 0.75);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    height: calc(50dvh + 3.75rem + var(--opening-cta-shift));
    width: max-content;
    max-width: calc(100vw - 4rem);
    margin: 0;
    padding: 0 0 calc(var(--opening-line-gap) * 0.75 + var(--opening-cta-shift));
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: var(--opening-line-gap);
  }

  .opening-message__lines {
    display: contents;
  }

  .opening-message__line {
    /* Scale down so nowrap statements never overflow the viewport */
    font-size: min(3rem, calc((100vw - 4rem) / 28));
    white-space: nowrap;
    text-wrap: unset;
  }

  .opening-message__line .opening-message__typed {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    width: auto;
    max-width: none;
    padding: 0;
    transform: none;
  }

  .opening-message__actions {
    position: absolute;
    top: 100%; /* hangs from the column end after the 75% line-gap shift */
    right: 0;
    left: auto;
    width: auto;
    min-height: 3.25rem;
  }

  .opening-message__continue {
    flex: 0 0 auto;
    padding: 1rem 1.75rem;
    font-size: 1.0625rem;
  }
}

/* Wide desktop: larger CTA; same column composition */
@media (min-width: 1200px) {
  .opening-message__continue {
    width: 10rem;
    height: 3.75rem;
    padding: 0 1.75rem;
    font-size: 1.125rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  #opening-message {
    transition: opacity 220ms ease;
  }

  .opening-message__cursor,
  .opening-message__cursor.is-active,
  .opening-message__cursor.is-hold {
    animation: none;
    display: none;
  }

  .opening-message__continue {
    transition: opacity 220ms ease;
  }
}
