/* SKELA's name in the pages' headers, as the iPhone's start page draws it
   (mobile/ios/Runner/NativeLibraryScreen.swift `header`): the name in Avenir Next Heavy with the K
   raised over its open book, a hairline, and "Scaffolding Knowledge: / Explore, Learn, Anchor" on
   two lines, its initials bold, all in one grey. Every measure here is in em of the name's size
   (the font size of .lockup). On the iPhone the name is 24 pt, the line 15 pt, 14 pt lie between
   the parts and the hairline is 34 pt tall; the two lines are centred on the whole name, the raised
   K included.

   Once the page scrolls, the header collapses it to the name alone, at the smaller size the header
   had before; back at the top it opens again (shared/masthead.js puts .is-compact on the element
   with data-masthead). The name changes size, it is not scaled, so it stays sharp throughout.

   The page sets:
     --n-full, --n-compact   the name's size, open and collapsed
     --lockup-line           the line's grey (the iPhone's secondary grey)
     --lockup-rule           the hairline's colour (that grey at 35 %)
   and gives the header its own two heights. */

:root {
  --mh-curve: cubic-bezier(0.3, 0, 0.2, 1);   /* the iPhone's morph: 0.44 s on this curve */
  --mh-time: 0.44s;
}

.lockup {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;                /* short of room, the two lines are cut, never the name */
  font-size: var(--n-full, 24px);
  line-height: 1;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.lockup-name {
  display: block;
  flex: none;
  width: auto;
  height: 1.2013em;            /* the wordmark's box: the raised K's top to just under the line */
  overflow: visible;
  /* Centred as a box, the name's baseline would lie 0.57 em under the middle of the row; on the
     iPhone it lies 0.325 em under it, the raised K counting as part of the name. */
  transform: translateY(-0.2457em);
}
.lockup-more {
  display: flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  max-width: var(--lockup-more-w, 9em);   /* masthead.js measures the two lines */
  margin-left: 0.7em;          /* 14 pt, and the name's last letter spacing (0.12 em) */
  overflow: hidden;
  white-space: nowrap;
}
.lockup-rule {
  flex: none;
  width: 1px;
  height: 1.4167em;            /* 34 pt at 24 */
  background: var(--lockup-rule, currentColor);
}
.lockup-line {
  margin-left: 0.5833em;       /* 14 pt at 24 */
  font: 500 0.625em/1.42 "Avenir Next", "Avenir", "Mulish", system-ui, sans-serif;   /* 15 pt at 24 */
  letter-spacing: 0;
  text-align: left;
  color: var(--lockup-line, currentColor);
}
.lockup-line b { font-weight: 700; }

/* Collapsed: the name alone, at the header's earlier size. */
[data-masthead].is-compact .lockup { font-size: var(--n-compact, 18px); }
[data-masthead].is-compact .lockup-name { transform: none; }
[data-masthead].is-compact .lockup-more { max-width: 0; margin-left: 0; opacity: 0; }

[data-masthead] .lockup { transition: font-size var(--mh-time) var(--mh-curve); }
[data-masthead] .lockup-name { transition: transform var(--mh-time) var(--mh-curve); }
/* Opening, the words come back only once the name has nearly grown back; collapsing, they go at
   once, before the name shrinks past them (the iPhone: 0.2 s after 0.24 s, and 0.16 s). */
[data-masthead] .lockup-more {
  transition: max-width var(--mh-time) var(--mh-curve), margin-left var(--mh-time) var(--mh-curve), opacity 0.2s ease-in 0.24s;
}
[data-masthead].is-compact .lockup-more {
  transition: max-width var(--mh-time) var(--mh-curve), margin-left var(--mh-time) var(--mh-curve), opacity 0.16s ease-out;
}

/* What a change of state moves elsewhere (a menu of links coming into the collapsed row) fades in
   at its new place: masthead.js gives the header .mh-swap-a or .mh-swap-b for a moment after each
   change, by turns, so the animation starts again each time. Pages choose what to fade, and where. */
@keyframes mh-in-a { from { opacity: 0; } }
@keyframes mh-in-b { from { opacity: 0; } }

/* The first state, and a state set while the page is hidden, take no time. */
[data-masthead].mh-instant,
[data-masthead].mh-instant * { transition: none !important; animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  [data-masthead],
  [data-masthead] * { transition: none !important; animation: none !important; }
}
