/*
  sotapoc mark — the scroll-closing logo for the sign page.

  Geometry, mask and distances are lifted from the animated demo in
  "Sotapoc Logo Mark.html" (see also logo-scroll.html, logo-open.svg and
  logo-closed.svg at the top of the repository).

  Every rule is scoped to body[data-scroll-mark], and the layout that hides the
  form is further scoped to .has-mark, which mark-scroll.js adds. So:
    - thanks.html is untouched,
    - with JavaScript off the mark is a still, open logo and the sign-in form
      stays in the flow, visible and usable.
*/

body[data-scroll-mark] {
  --mark-ink: #10264e;                    /* same navy as the page text */
  --mark-w: clamp(96px, 30vmin, 230px);   /* one circle's width */
  --card-pad: clamp(28px, 7vw, 48px);     /* re-declared copy of .card's padding */
  --travel: 2.5;                          /* screens of scrolling it takes to close */
  --tail: 0.5;                            /* screens of scroll left after it is shut */
  /* The pair rides up by half of what the form adds below the mark, which keeps
     the closed mark and the form together optically centred. mark-scroll.js
     measures the form into --form-h; 114px is the input + button fallback. */
  --lift: min(calc((var(--card-pad) + 8px + var(--form-h, 114px)) / 2), 24vh);
  --smooth: 7;                            /* 1/s catch-up rate on the scroll */
  --progress: 0;                          /* 0 open .. 1 closed   — written by mark-scroll.js */
  --reveal: 0;                            /* 0 hidden .. 1 shown  — written by mark-scroll.js */
}

/* Without the script the mark is a still open logo and the form sits under it.
   Keep that version small enough that the whole card still fits one screen. */
body[data-scroll-mark]:not(.has-mark) { --mark-w: clamp(80px, 20vmin, 168px); }

/* the invisible runway the visitor scrolls through */
body[data-scroll-mark].has-mark .scroll-runway {
  height: calc((1 + var(--travel) + var(--tail)) * 100vh);
}

/* keep the page still while the runway scrolls */
body[data-scroll-mark].has-mark .page-shell {
  position: fixed;
  inset: 0;
}

/* the mark replaces the 384px logo image */
body[data-scroll-mark] .brand {
  display: block;
  min-height: 0;
  width: var(--mark-w);
  margin-inline: auto;
}

.brand-mark {
  display: block;
  width: var(--mark-w);
  height: calc(var(--mark-w) * 2);        /* the viewBox is 1:2 — the open mark fills it */
  fill: var(--mark-ink, #10264e);
}
.brand-mark svg { display: block; width: 100%; height: 100%; overflow: visible; }

/*
  With the form pulled out of the flow the card is just the mark, so the grid in
  .page-shell puts the open mark dead centre on the screen. The card then rides
  up while the form comes in underneath it.
*/
body[data-scroll-mark].has-mark .card {
  position: relative;
  padding: var(--card-pad);               /* same value styles.css already uses */
  transform: translateY(calc(var(--reveal) * var(--lift) * -1));
}

body[data-scroll-mark].has-mark #email-form {
  position: absolute;
  top: 100%;
  left: var(--card-pad);
  right: var(--card-pad);
  /*
    The mark's box is sized for the open mark, so below the closed mark there is
    (400 - 267.7) / 2 / 200 = 0.33075 of --mark-w of empty space. Pull the form
    back up through it; the gap that is left is the card's own padding.
  */
  margin-top: calc(8px - var(--mark-w) * 0.33075);
  /* left/right size it: width:auto, because a width of 100% would win and the
     form would stick out past the card's right padding by --card-pad */
  width: auto;
  opacity: var(--reveal);
  transform: translateY(calc((1 - var(--reveal)) * 24px));
}

/* out of the tab order while it is still invisible */
body[data-scroll-mark].has-mark #email-form[data-mark-hidden] {
  visibility: hidden;
  pointer-events: none;
}
