/*
 * A — the grid and the running parts: the header, the section shell, section heads and margin
 * notes. Every section is the same 12-column grid (6 on phones) with no gutters; column lines are
 * drawn only where they carry meaning (hero, anatomy sentence, results table), never everywhere.
 */

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-items: center;
  height: var(--head);
  padding-inline: var(--m);
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}

.site-header__brand {
  grid-column: 1 / 3;
  padding-left: var(--pad);
  font-weight: 800;
  font-size: 0.9375rem;
  letter-spacing: -0.02em;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.site-header__brand-en {
  display: none;
}

/* Phones: the seven chapters scroll sideways inside the bar. */
.site-nav {
  grid-column: 3 / -1;
  min-width: 0;
  height: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}

.site-nav::-webkit-scrollbar {
  display: none;
}

.site-nav__list {
  display: flex;
  height: 100%;
}

.site-nav__list a {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 12px 0 var(--pad);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav__num {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.6875rem;
  color: var(--fg-mute);
}

.site-nav__list a:hover {
  text-decoration: underline;
}

@media (min-width: 768px) {
  .site-header__brand {
    grid-column: 1 / 5;
    display: grid;
    grid-template-columns: subgrid;
    align-items: baseline;
    padding-left: 0;
  }

  .site-header__brand-ko {
    grid-column: 1 / 3;
    padding-left: var(--pad);
  }

  .site-header__brand-en {
    display: block;
    grid-column: 3 / 5;
    padding-left: var(--pad);
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.75rem;
    letter-spacing: 0;
  }

  /* One chapter per column, from column 6 to the edge. */
  .site-nav {
    grid-column: 6 / -1;
    display: grid;
    grid-template-columns: subgrid;
    overflow: visible;
    mask-image: none;
  }

  .site-nav__list {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
  }

  .site-nav__list a {
    padding-right: 0;
    font-size: 0.8125rem;
  }
}

@media (min-width: 1200px) {
  .site-nav__list a {
    font-size: 0.875rem;
  }
}

/* ---------------------------------------------------------------- sections */

.section {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  align-content: start;
  padding: 5.5rem var(--m) 0;
}

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

.section:last-child {
  padding-bottom: 5.5rem;
}

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

  .section:last-child {
    padding-bottom: 8rem;
  }
}

/* Head: the chapter index in mono, then the title in Pretendard 800 across eight columns.
   On wide screens the lead takes the last four and sits on the title's baseline row; on
   tablets it runs under the title. */
.section__head {
  display: grid;
  grid-template-columns: subgrid;
  align-content: end;
}

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

.section__chapter {
  display: block;
  padding-left: var(--pad);
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1;
  color: var(--fg-mute);
}

.section__chapter::after {
  content: " / 07";
}

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

.section__subtitle {
  padding: 0.9rem var(--pad) 0;
  font-weight: 700;
  font-stretch: 112%;
  font-size: clamp(1.25rem, calc(var(--col) * 0.4), 2.75rem);
  line-height: 1;
  letter-spacing: -0.035em;
}

.section__lead {
  padding: 1.5rem var(--pad) 0;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: -0.01em;
  max-width: 38em;
}

@media (min-width: 768px) {
  .section__head {
    grid-column: 1 / 9;
    grid-row: 1;
  }

  .section__title {
    font-size: max(2.75rem, calc(var(--col) * 0.86));
    line-height: 1.02;
  }

  .section__lead {
    grid-column: 1 / 10;
  }
}

@media (min-width: 1200px) {
  .section__lead {
    grid-column: 9 / -1;
    grid-row: 1;
    align-self: end;
    padding-top: 0;
    padding-bottom: 0.3em;
    font-size: 1.0625rem;
  }
}

/* ---------------------------------------------------------------- margin notes */

/* A teacher's gloss, typeset: a short rule, then the remark. In the margin column on wide
   screens (each section places it), under its text on phones. */
.margin-note {
  position: relative;
  justify-self: start;
  max-width: 18em;
  margin-top: 1.5rem;
  padding: 0.7rem var(--pad) 0;
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.margin-note::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--pad);
  width: 1.5rem;
  border-top: 2px solid currentColor;
}

/* Inside a block that already sits --pad in from its column line. */
:is(.program, .method) > .margin-note {
  padding-left: 0;
}

:is(.program, .method) > .margin-note::before {
  left: 0;
}
