/* The problem (#book): a polished AI answer, judged by a human with a gold pen as you scroll. */
.problem { overflow: clip; }
.problem__grain {
  position: absolute; inset: -40px; pointer-events: none; opacity: .55;
  background:
    radial-gradient(60% 50% at 78% 40%, rgba(226, 176, 98, .16), transparent 70%),
    radial-gradient(40% 40% at 10% 90%, rgba(184, 135, 58, .08), transparent 70%);
}
.problem__grain::after {
  content: ''; position: absolute; inset: 0; opacity: .7;
  background-image: url('../img/problem-grain.svg');
  animation: problemGrain 9s steps(6) infinite;
}
@keyframes problemGrain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-14px, 9px); } 40% { transform: translate(10px, -12px); }
  60% { transform: translate(-6px, 16px); } 80% { transform: translate(15px, 4px); } 100% { transform: translate(0, 0); }
}

.problem__grid {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 0.78fr) minmax(0, 1.22fr);
  gap: clamp(32px, 3.6vw, 64px); align-items: center;
}
.problem__title { font-size: clamp(2rem, 3vw, 3.15rem); }
.problem__lede { margin-top: 26px; }
.problem__key {
  position: relative; margin-top: 28px; padding: 6px 0 6px 26px;
  font-family: var(--f-display); font-style: italic; font-weight: 500;
  font-size: clamp(1.3rem, 1.75vw, 1.7rem); line-height: 1.32; color: var(--ink);
}
.problem__key::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: linear-gradient(var(--gold-deep), rgba(184, 135, 58, .2));
}
.problem__key-text {
  background: linear-gradient(transparent 62%, rgba(226, 176, 98, .42) 62%, rgba(226, 176, 98, .42) 92%, transparent 92%) 0 0 / var(--hl, 100%) 100% no-repeat;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.js .problem__key-text { --hl: 0%; }
.problem__body { margin-top: 24px; font-size: 1.0625rem; color: var(--ink-soft); }

/* the desk: the answer panel and the margins the reader writes in */
.problem__desk {
  margin: 0; position: relative; perspective: 1400px;
  width: min(100%, calc((100svh - var(--head-h) - 110px) * 1.3333));
  justify-self: end;
}
.problem__float { will-change: transform; }
.problem__tilt { transform-style: preserve-3d; will-change: transform; }
.problem__svg { width: 100%; height: auto; overflow: visible; }

.problem__ui { font-family: var(--f-body); }
.problem__ui--chip { font-size: 10px; font-weight: 700; fill: #7FB0FF; }
.problem__ui--label { font-size: 15px; font-weight: 600; fill: #F7F3EA; }
.problem__ui--done { font-size: 14px; font-weight: 600; fill: #B4BFD2; }
.problem__ui--small { font-size: 13px; font-weight: 500; fill: #B4BFD2; }
.problem__ui--ref { font-size: 12px; font-weight: 600; fill: #7FB0FF; }
.problem__ui--high { font-size: 13px; font-weight: 700; fill: #F7F3EA; }
.problem__ui--btn { font-size: 15px; font-weight: 600; fill: #F7F3EA; }
.problem__ui--ghost { font-size: 14px; font-weight: 500; fill: #B4BFD2; }
.problem__ui--hint { font-size: 14px; font-weight: 400; fill: #B4BFD2; fill-opacity: .6; }

.problem__caret { animation: problemCaret 1.05s steps(1) infinite; }
@keyframes problemCaret { 50% { opacity: 0; } }

.problem__mark {
  fill: none; stroke: #C8913F; stroke-width: 3.3; stroke-linecap: round; stroke-linejoin: round;
}
.problem__mark--big { stroke-width: 3.8; }
.problem__nib { pointer-events: none; }
.problem__note {
  font-family: var(--f-display); font-style: italic; font-weight: 500; font-size: 20.5px; fill: var(--ink);
}
.problem__note--big { font-size: 25px; font-weight: 600; fill: #9A6C26; }

/* phone and narrow tablet list of the reader's notes (on desktop they sit in the margins of the drawing) */
.problem__notes { display: none; }

@media (min-width: 1000px) {
  .problem { padding: calc(var(--head-h) * .8 + 4vh) 0 5vh; min-height: 100vh; min-height: 100svh; display: flex; align-items: center; }
  .problem > .wrap { width: 100%; }
}
@media (min-width: 1000px) and (max-height: 820px) {
  .problem__title { font-size: clamp(1.9rem, 2.9vw, 2.9rem); }
  .problem__lede { margin-top: 18px; font-size: 1.06rem; }
  .problem__key { margin-top: 20px; font-size: 1.28rem; }
  .problem__body { margin-top: 16px; font-size: 1rem; }
}

@media (max-width: 999px) {
  .problem__grid { grid-template-columns: 1fr; gap: 36px; }
  .problem__desk { justify-self: center; width: min(100%, 720px); }
  /* the drawing crops to the answer panel; the notes follow as a list */
  .problem__notes-svg { display: none; }
  .problem__notes {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; margin-top: -8px;
    font-family: var(--f-display); font-style: italic; font-weight: 500; font-size: 1.2rem; line-height: 1.3; color: var(--ink);
  }
  .problem__notes li { position: relative; padding-left: 22px; }
  .problem__notes li::before {
    content: ''; position: absolute; left: 2px; top: .5em; width: 8px; height: 8px; background: var(--gold-deep); transform: rotate(45deg);
  }
  .problem__notes .problem__notes-last { grid-column: 1 / -1; padding: 12px 0 0 22px; font-size: 1.7rem; font-weight: 600; color: #8A5F1F; }
  .problem__notes-last span { position: relative; z-index: 1; display: inline-block; padding: 6px 14px; }
  .problem__notes-last svg { position: absolute; left: 14px; top: 4px; width: 230px; height: 64px; overflow: visible; }
  .problem__notes-last path { fill: none; stroke: #C8913F; stroke-width: 2.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
  .problem__notes .problem__notes-last::before { top: 1.05em; }
  .problem__notes-svg, .problem__lead { display: none; }
  /* phones: question, the answer being judged, then the book's reply */
  .problem__copy { display: contents; }
  .problem__title { order: 1; }
  .problem__lede { order: 2; margin-top: -12px; }
  .problem__desk { order: 3; }
  .problem__notes { order: 4; }
  .problem__key { order: 5; margin-top: 0; }
  .problem__body { order: 6; margin-top: -12px; }
}
@media (max-width: 600px) {
  .problem__notes { grid-template-columns: 1fr; font-size: 1.12rem; }
  .problem__key { font-size: 1.22rem; }
}

@media (prefers-reduced-motion: reduce) {
  .problem__grain::after, .problem__caret { animation: none; }
}
