/*
 * A — brand finishing: the wordmark's entrance, the grid cursor, magnetic buttons and the 404
 * page. Loaded just before motion.css (VARIANTS.a.css). The wordmark's type and place are the
 * header's (layout.css). What moves is staged under `.js.motion` only, and an entrance under
 * `.js.motion.is-opening`: only when the page had not painted before its script ran
 * (js/shared/entrance.js), so an entrance never replays over a wordmark already painted.
 */

/* ---------------------------------------------------------------- wordmark entrance */

/*
 * The wordmark is set into its cells as the page opens, on the grid's clock (--cell): the Korean
 * inks in, its weight stepping up to 900, then the English steps out to its set width, Archivo's
 * width axis opening to fill its measure. Hard steps, no easing; no glyph is ever hidden, faded or
 * moved out of its cell, so nothing waits on this to be read.
 */
.js.motion.is-opening .site-header__brand-ko {
  animation: a-ink calc(4 * var(--cell)) steps(4, jump-end) calc(2 * var(--cell)) backwards;
}

.js.motion.is-opening .site-header__brand-en {
  animation: a-fit calc(3 * var(--cell)) steps(3, jump-end) calc(5 * var(--cell)) backwards;
}

@keyframes a-ink {
  from {
    font-weight: 300;
  }

  to {
    font-weight: 900;
  }
}

@keyframes a-fit {
  from {
    font-stretch: 62%;
  }

  to {
    font-stretch: 100%;
  }
}

/* ---------------------------------------------------------------- magnetic buttons */

/* magnetic.js eases the lean (--mx, --my) and marks the element while it is off its place. */
.js.motion [data-magnetic].is-pulled {
  transform: translate(var(--mx, 0px), var(--my, 0px));
}

/* ---------------------------------------------------------------- the grid cursor */

/*
 * cursor.js writes --x, --y (the point, or the box's corner) and --w, --h (the box; 0 for the
 * crosshair). The crosshair is two hairlines; locked onto a column line its vertical runs on along
 * it, a row up and a row down, and locked onto a row line its horizontal does the same. Over a link
 * or a button it is a box around the target's cell. Drawn in difference, so it reads on paper, on
 * night and on the lens alike; it never takes a click.
 */
.cursor {
  --arm-x: 21px;
  --arm-y: 21px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--w, 0px);
  height: var(--h, 0px);
  transform: translate(var(--x, 0px), var(--y, 0px));
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  visibility: hidden;
}

.cursor.is-on {
  visibility: visible;
}

.cursor::before,
.cursor::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  background: currentColor;
}

.cursor::before {
  width: var(--arm-x);
  height: 1px;
  translate: -50% -0.5px;
}

.cursor::after {
  width: 1px;
  height: var(--arm-y);
  translate: -0.5px -50%;
}

.cursor.is-snap-x {
  --arm-y: calc(2 * var(--row));
}

.cursor.is-snap-y {
  --arm-x: calc(2 * var(--row));
}

.cursor.is-box {
  border: 1px solid currentColor;
}

.cursor.is-box::before,
.cursor.is-box::after {
  display: none;
}

/* ---------------------------------------------------------------- 404 */

/*
 * The page that lost its subject, on the same grid with its column lines drawn: the chapter mono,
 * the title in Pretendard 800, then the sentence parsed the way the anatomy parses, where red
 * brackets hold an empty cell (two columns wide) labelled S, the verb is underlined V, and the full
 * stop is red. Red stays grammar only.
 */
.nf {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-content: start;
  min-height: calc(100svh - var(--head));
  padding: 3.5rem var(--m) 5.5rem;
  background: repeating-linear-gradient(90deg, var(--guide) 0 1px, transparent 1px var(--col)) var(--m) 0 /
    calc(100% - 2 * var(--m) + 1px) 100% no-repeat;
}

.nf > * {
  grid-column: 1 / -1;
  min-width: 0;
  padding-left: var(--pad);
}

.nf-code {
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1;
  color: var(--fg-mute);
}

.nf-title {
  padding-left: calc(var(--pad) - 0.04em);
  font-weight: 800;
  font-size: max(2.5rem, calc(var(--col) * 1.02));
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.nf-sentence {
  margin-top: 3rem;
  padding-top: 0.25em;
  border-top: 1px solid var(--rule);
  font-weight: 500;
  font-stretch: 94%;
  font-size: max(1.5rem, calc(var(--col) * 0.46));
  line-height: 2.1;
  letter-spacing: -0.02em;
}

/* The subject's slot: an empty cell, two columns from the sentence's column line to the next but
   one, its red brackets on the cell's edges and a blank rule between them. */
.nf-s {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  width: calc(2 * var(--col) - var(--pad));
  margin-right: 0.15em;
  line-height: 1.2;
}

.nf-br {
  color: var(--signal);
  font-weight: 400;
}

.nf-blank {
  flex: 1;
  align-self: stretch;
  margin: 0 0.12em 0.16em;
  border-bottom: 1px solid var(--fg-mute);
  color: transparent;
  user-select: none;
}

.nf-v {
  position: relative;
  text-decoration: underline 0.07em var(--signal);
  text-underline-offset: 0.2em;
}

/* Role letters drop under the start of what they label, as in the anatomy. */
.nf-role {
  position: absolute;
  top: 100%;
  left: 0.1em;
  margin-top: 0.5em;
  font-weight: 700;
  font-stretch: 100%;
  font-size: 0.42em;
  line-height: 1;
  letter-spacing: 0;
  color: var(--signal);
}

.nf-stop {
  color: var(--signal);
}

.nf-home {
  margin-top: 2.5rem;
}

.nf-home a {
  display: inline-block;
  padding: 0.5rem 0;
  font-weight: 700;
  font-size: 1.0625rem;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

@media (min-width: 768px) {
  .nf {
    padding-top: 6rem;
  }

  .nf-title {
    grid-column: 1 / 10;
    font-size: max(2.75rem, calc(var(--col) * 0.86));
    line-height: 1.02;
  }

  .nf-sentence {
    margin-top: 4.5rem;
    font-size: calc(var(--col) * 0.42);
  }
}
