/*
 * A — hero: the title stair, then the wall of words and the lens.
 *
 * The title parses itself. Its six syllables are locked one to each two-column module: the
 * letter-spacing tops each Hangul advance (0.8643em in Pretendard) up to exactly two columns,
 * and a half-step of padding centres every glyph in its module. On wide screens a negative
 * indent builds the stair (영어의 on modules 1–3, 통찰력 one line lower on 4–6) and a red elbow
 * carries the modifier down into its head; on phones the stair folds and a drop runs down the
 * right margin instead.
 *
 * The wall is the lens passage, one word per cell with a mono word index (counter w). Only a
 * window of whole rows is shown around the lens, picked by each word's distance from it (data-d,
 * written by the renderer), never by the text: the hidden words stay in the flow of counting
 * (absolute, invisible) so every index is the word's true position in the passage. This file is
 * the no-JS and reduced-motion final frame; Task 11 moves the lens.
 */

.hero {
  --t: calc(var(--col) * 2.3);
  --ls: calc(2 * var(--col) - 0.8643 * var(--t));
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-content: start;
  padding: 18px var(--m) 3.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;
  overflow-x: clip;
}

.hero > * {
  grid-column: 1 / -1;
  min-width: 0;
}

/* ---------------------------------------------------------------- title */

.hero__text {
  position: relative;
  display: grid;
  grid-template-columns: subgrid;
  align-content: start;
}

.hero__text > * {
  grid-column: 1 / -1;
}

.hero__title {
  position: relative;
  padding-left: calc(var(--ls) / 2);
  font-family: var(--font-ko);
  font-weight: 900;
  font-size: var(--t);
  line-height: 0.84;
  letter-spacing: var(--ls);
  overflow-wrap: normal;
  text-wrap: wrap;
}

.hero__title-en {
  display: block;
  margin-top: 1.25rem;
  padding-left: calc(var(--pad) - var(--ls) / 2);
  font-family: var(--font-en);
  font-weight: 800;
  font-stretch: 100%;
  font-size: calc(var(--col) * 0.67);
  line-height: 0.9;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

/* The arrow box covers the title; its parts are placed in percentages of it. */
.hero__arrow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: calc(var(--t) * 0.84 * 2);
  overflow: visible;
  pointer-events: none;
  fill: var(--signal);
  stroke: var(--signal);
  stroke-width: 3;
}

.hero__arrow path {
  stroke: none;
}

.hero__arrow text {
  fill: var(--fg-mute);
  stroke: none;
  font-family: var(--font-mono);
  font-size: 11px;
}

.hero__arrow-elbow {
  display: none;
}

.hero__lede {
  padding: 1rem var(--pad) 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: -0.02em;
  max-width: 34em;
}

.hero__sign {
  margin: 1rem var(--pad) 0;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg-mute);
}

@media (min-width: 768px) {
  .hero {
    padding-top: 28px;
  }

  .hero__text {
    grid-template-rows: calc(var(--t) * 0.84) auto;
  }

  .hero__title {
    grid-row: 1 / 3;
    padding-left: calc(6 * var(--col) + var(--ls) / 2);
    text-indent: calc(-6 * var(--col));
  }

  /* Insight English hangs from the cap line of 영, in the columns 통찰력 leaves free above it. */
  .hero__title-en {
    position: absolute;
    top: -0.19em;
    left: calc(7 * var(--col) + var(--pad));
    margin: 0;
    padding: 0;
    text-indent: 0;
    font-size: calc(var(--col) * 0.6);
  }

  .hero__arrow {
    left: calc(5 * var(--col));
    width: calc(3 * var(--col));
    height: calc(var(--t) * 0.84);
  }

  .hero__arrow-elbow {
    display: inline;
  }

  .hero__arrow-drop {
    display: none;
  }

  .hero__lede,
  .hero__sign {
    grid-column: 1 / 8;
    grid-row: 3;
  }

  .hero__lede {
    padding-top: 1.5rem;
  }

  .hero__sign {
    grid-row: 4;
  }
}

@media (min-width: 1200px) {
  /* The lede takes the free step under 영어의, beside 통찰력. */
  .hero__lede,
  .hero__sign {
    grid-column: 1 / 6;
    grid-row: 2;
  }

  .hero__lede {
    align-self: start;
    padding-top: 26px;
    font-size: 1.4375rem;
    line-height: 1.5;
  }

  .hero__sign {
    align-self: end;
    margin-bottom: 2px;
    font-size: 0.8125rem;
  }
}

/* ---------------------------------------------------------------- wall of words */

.hero__passage {
  margin-top: 22px;
  counter-reset: w;
}

.hero__passage > p {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: minmax(var(--row), auto);
  background: repeating-linear-gradient(var(--hair) 0 1px, transparent 1px var(--row));
}

/* Outside the lens the sentences dissolve into cells: one word each, no marks, no punctuation. */
.hero__passage .sentence:not([data-lens-target]),
.hero__passage .sentence:not([data-lens-target]) .span {
  display: contents;
  text-decoration: none;
}

.hero__passage .sentence:not([data-lens-target]) :is(.br, .note, .role-label, .tok[data-punct]) {
  display: none;
}

.hero__passage .tok:not([data-punct]) {
  counter-increment: w;
}

/* Every word is counted; only the window below is shown. */
.hero__passage .sentence:not([data-lens-target]) .tok {
  position: absolute;
  visibility: hidden;
  display: block;
  grid-column: span 2;
  padding: 8px var(--pad) 0;
  font-weight: 500;
  font-stretch: 82%;
  /* Scales with the cell, so the longest word fits at every width (Understanding, 13 letters). */
  font-size: min(15px, calc(var(--col) * 0.25));
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--fg-mute);
  white-space: nowrap;
}

.hero__passage .sentence:not([data-lens-target]) .tok::after {
  content: counter(w, w3);
  position: absolute;
  right: 6px;
  bottom: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-stretch: 100%;
  line-height: 1;
  letter-spacing: 0;
  color: var(--faint);
}

/* The window, in words from the lens. Phones: one row of three cells above, two below. */
#top .hero__passage :is(
  [data-d="-3"], [data-d="-2"], [data-d="-1"],
  [data-d="1"], [data-d="2"], [data-d="3"], [data-d="4"], [data-d="5"], [data-d="6"]
) {
  position: relative;
  visibility: visible;
}

@media (min-width: 768px) {
  /* Tablets: six cells a row, one row above, two below. */
  #top .hero__passage :is(
    [data-d="-6"], [data-d="-5"], [data-d="-4"],
    [data-d="7"], [data-d="8"], [data-d="9"], [data-d="10"], [data-d="11"], [data-d="12"]
  ) {
    position: relative;
    visibility: visible;
  }

  .hero__passage .sentence:not([data-lens-target]) .tok {
    padding-top: 10px;
    font-size: 17px;
  }
}

@media (min-width: 1200px) {
  /* Desktop: twelve cells a row, two rows above, two below. */
  #top .hero__passage :is(
    [data-d="-24"], [data-d="-23"], [data-d="-22"], [data-d="-21"], [data-d="-20"], [data-d="-19"],
    [data-d="-18"], [data-d="-17"], [data-d="-16"], [data-d="-15"], [data-d="-14"], [data-d="-13"],
    [data-d="-12"], [data-d="-11"], [data-d="-10"], [data-d="-9"], [data-d="-8"], [data-d="-7"],
    [data-d="13"], [data-d="14"], [data-d="15"], [data-d="16"], [data-d="17"], [data-d="18"],
    [data-d="19"], [data-d="20"], [data-d="21"], [data-d="22"], [data-d="23"], [data-d="24"]
  ) {
    position: relative;
    visibility: visible;
  }

  /* One column a cell: the word scales with it (17px at 1440, never past 20px) and may run to
     4px short of the column line; the index sits below it. */
  .hero__passage .sentence:not([data-lens-target]) .tok {
    grid-column: span 1;
    padding-right: 4px;
    font-size: min(20px, calc(var(--col) * 0.15));
  }
}

/* ---------------------------------------------------------------- the lens */

/* The target sentence on the other ground, under one row of meta. Phones set it as one balanced
   block of up to three lines, four thirds of a row apart, in a band of five rows (the font scales
   with the column, so the lines break alike at every phone width). From 768px it is one line, two
   rows tall: three rows in all. Either way the band snaps to the wall's rows. */
#top [data-lens-target] {
  --leader: 12px;
  grid-column: 1 / -1;
  display: block;
  position: relative;
  min-height: calc(5 * var(--row));
  padding: var(--row) var(--pad) 0;
  background: repeating-linear-gradient(90deg, var(--lens-guide) 0 1px, transparent 1px var(--col)), var(--lens-bg);
  color: var(--lens-recede);
  font-weight: 500;
  font-stretch: 92%;
  font-size: min(24px, calc(var(--col) * 0.37));
  line-height: calc(var(--row) * 4 / 3);
  letter-spacing: -0.014em;
  text-wrap: balance;
}

#top [data-lens-target] .tok[data-i="0"] {
  counter-increment: none;
}

#top [data-lens-target] .span--role .tok,
#top [data-lens-target] .note {
  color: var(--lens-fg);
}

#top [data-lens-target] .role-label {
  font-size: 0.5em;
}

/* Meta row: LENS, and the word range the lens holds (W084–W100), counted, not typed. */
#top [data-lens-target]::before,
#top [data-lens-target]::after {
  position: absolute;
  top: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-stretch: 100%;
  line-height: var(--row);
  letter-spacing: 0;
  color: var(--lens-mute);
}

#top [data-lens-target]::before {
  counter-increment: w;
  content: "LENS W" counter(w, w3) "–";
  left: var(--pad);
  right: calc(var(--pad) + 4ch);
  text-align: justify;
  text-align-last: justify;
}

#top [data-lens-target]::after {
  content: "W" counter(w, w3);
  right: var(--pad);
}

@media (min-width: 768px) {
  #top [data-lens-target] {
    --leader: 16px;
    min-height: 0;
    font-size: calc(var(--col) * 0.305);
    line-height: calc(2 * var(--row));
    white-space: nowrap;
  }
}

@media (min-width: 1200px) {
  /* Crop marks, outside the band in the margin. */
  #top [data-lens-target] {
    --leader: 18px;
    border: 0 solid transparent;
    border-image: var(--crop) 18 / 18px / 24px;
  }
}

/* ---------------------------------------------------------------- next */

.hero__next {
  justify-self: start;
  margin-top: 1.25rem;
  padding: 0.5rem var(--pad);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.hero__next:hover {
  text-decoration: underline;
}
