/* The index: every chapter on one screen, as a contents page. Each row carries its number, its name,
   and its headline figure, in one list; a monitor beside the list shows the chapter pointed at. The page
   behind the index never changes.
   Type is the site's own: --sans for names, --mono for numbers and marks, Chakra Petch for figures. */

.menu {
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
  padding: 96px clamp(20px, 5vw, 72px) 30px;
  overflow-y: auto;
  background: rgba(4, 2, 8, 0.86);
}

.m-view {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.m-view i {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 0.7s ease;
}

.m-view i.on {
  opacity: 0.5;
}

/* The picture stays behind the reading: dark where the rows are, open at the edges. */
.m-view::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 50% 50%, rgba(4, 2, 8, 0.78), rgba(4, 2, 8, 0.35) 70%, rgba(4, 2, 8, 0.6));
}

.m-head,
.menu ul,
.m-foot {
  position: relative;
  width: 100%;
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
}

.m-head {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #fabdf9;
}

.menu ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(7, auto);
  grid-auto-flow: column;
  column-gap: clamp(28px, 5vw, 88px);
  text-align: left;
}

.menu li a {
  display: grid;
  grid-template-columns: 3ch minmax(0, 1fr) auto;
  column-gap: 18px;
  align-items: baseline;
  justify-content: normal;
  padding: 13px 10px 13px 0;
  border-top: 1px solid rgba(250, 189, 249, 0.2);
  font-size: clamp(22px, 2.3vw, 34px);
  line-height: 1.08;
  transition: opacity 0.3s, color 0.3s, background 0.3s, border-color 0.3s, padding 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.menu li:nth-child(7n) a {
  border-bottom: 1px solid rgba(250, 189, 249, 0.2);
}

.menu .m-n {
  min-width: 0;
  margin: 0;
  text-align: left;
}

.menu .m-d,
.menu li a:hover .m-d,
.menu li a:focus-visible .m-d {
  grid-column: 2;
  display: block;
  max-width: none;
  margin: 6px 0 0;
  overflow: visible;
  white-space: normal;
  opacity: 1;
  font-size: 13px;
  line-height: 1.3;
  letter-spacing: 0;
}

.m-f {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: center;
  font-family: 'Chakra Petch', var(--mono);
  font-weight: 900;
  font-size: clamp(17px, 1.7vw, 26px);
  letter-spacing: 0;
  color: #fabdf9;
  transition: text-shadow 0.3s, color 0.3s;
}

.menu li a:hover,
.menu li a:focus-visible {
  padding-left: 10px;
  border-top-color: #fabdf9;
  background: linear-gradient(90deg, rgba(250, 189, 249, 0.14), rgba(250, 189, 249, 0) 70%);
}

.menu li a:hover .m-f,
.menu li a:focus-visible .m-f {
  color: #fff;
  text-shadow: 0 0 12px #fabdf9, 0 0 34px rgba(250, 189, 249, 0.7);
}

/* Where the reader is now. */
.menu li a[aria-current='true'] {
  border-top-color: #fabdf9;
  box-shadow: inset 2px 0 0 #fabdf9;
  padding-left: 10px;
}

.menu li a[aria-current='true'] .m-t {
  color: #fabdf9;
}

.menu .m-foot {
  justify-content: space-between;
  margin-top: 22px;
  margin-bottom: auto;
}

.m-log::before {
  content: '> ';
}

@media (max-height: 780px) {
  .menu {
    padding-top: 78px;
    padding-bottom: 18px;
  }

  .menu li a {
    padding-top: 9px;
    padding-bottom: 9px;
    font-size: clamp(20px, 2vw, 28px);
  }

  .menu .m-d {
    margin-top: 4px;
    font-size: 12px;
  }

  .m-head {
    margin-bottom: 8px;
  }

  .menu .m-foot {
    margin-top: 14px;
  }
}

@media (max-width: 760px) {
  .menu {
    padding: 84px 20px 22px;
  }

  .m-view {
    display: none;
  }

  .menu ul {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .menu li a {
    column-gap: 12px;
    padding: 10px 0;
    font-size: 21px;
  }

  .menu li:nth-child(7n) a {
    border-bottom: 0;
  }

  .menu li:last-child a {
    border-bottom: 1px solid rgba(250, 189, 249, 0.2);
  }

  .menu .m-d,
  .menu li a:hover .m-d,
  .menu li a:focus-visible .m-d {
    display: none;
  }

  .m-f {
    grid-row: 1;
    font-size: 16px;
  }

  .menu .m-foot {
    gap: 10px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .m-view i,
  .menu li a {
    transition: none;
  }
}

/* Rows not pointed at step back, but stay readable over the picture. */
.menu ul:hover a:not(:hover) {
  opacity: 0.55;
}

/* ------------------------------------------------------------------ */
/* The index as one list and one monitor. The backdrop is still: only   */
/* the monitor changes with the row pointed at.                         */
/* ------------------------------------------------------------------ */

.menu {
  background: rgba(6, 2, 10, 0.94);
}

.m-view::after {
  content: none;
}

.m-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(250, 189, 249, 0.45);
  background: #0a0410;
}

.m-view i.on {
  opacity: 1;
}

.m-view i {
  transition: opacity 0.35s ease;
}

/* The tube's lines over the picture. */
.m-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.m-cap {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fabdf9;
}

.m-cap b {
  font-weight: 500;
  white-space: nowrap;
}

.m-cap span {
  text-align: right;
  opacity: 0.75;
}

@media (min-width: 761px) {
  .m-view {
    inset: auto;
    top: 50%;
    right: clamp(20px, 5vw, 72px);
    width: min(44vw, 720px);
    transform: translateY(-50%);
  }

  .m-head,
  .menu ul,
  .m-foot {
    width: calc(100% - min(44vw, 720px) - clamp(28px, 5vw, 80px));
    max-width: 620px;
    margin-left: 0;
    margin-right: 0;
  }

  .menu ul {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .menu li a {
    padding: 8px 10px 8px 0;
    font-size: clamp(17px, 1.5vw, 22px);
  }

  .menu li:nth-child(7n) a {
    border-bottom: 0;
  }

  .menu li:last-child a {
    border-bottom: 1px solid rgba(250, 189, 249, 0.2);
  }

  /* What a chapter says is read on the monitor, so the rows stay one line each. */
  .menu .m-d,
  .menu li a:hover .m-d,
  .menu li a:focus-visible .m-d {
    display: none;
  }

  .m-f {
    grid-row: 1;
    font-size: clamp(14px, 1.2vw, 18px);
  }
}

@media (min-width: 761px) and (max-height: 780px) {
  .menu li a {
    padding-top: 5px;
    padding-bottom: 5px;
    font-size: clamp(15px, 1.3vw, 19px);
  }
}
