/* Millennium problems page. Loads after site.css. */

/* one colour per problem */
.c-pvsnp    { --pc: var(--c0); }
.c-riemann  { --pc: var(--c6); }
.c-poincare { --pc: var(--c2); }
.c-navier   { --pc: var(--c4); }
.c-yang     { --pc: var(--c5); }
.c-hodge    { --pc: var(--c1); }
.c-bsd      { --pc: var(--jot); }

.hero-words { grid-template-columns: minmax(0, 1fr); padding-bottom: 32px; }

.lede {
  margin: 0;
  max-width: 38em;
  font-size: 20px;
  font-weight: 500;
  color: var(--chalk-dim);
}

.jump {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 40px;
}

.jump-pill {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--pc);
  color: var(--ink);
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
  transition: transform 180ms var(--spring), box-shadow 180ms;
}

.jump-pill:hover { transform: translateY(-2px) rotate(-1.5deg); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3); }

.rules {
  max-width: 48em;
  margin: 0 0 48px;
  padding: 22px 26px;
  border-radius: 14px;
  background: rgba(255, 248, 236, 0.07);
  border: 2px solid rgba(255, 248, 236, 0.18);
}

.rules h2 { margin: 0 0 8px; font-size: 22px; }
.rules p { margin: 0; color: var(--chalk-dim); font-weight: 500; line-height: 1.5; }
.rules a { color: var(--jot); font-weight: 700; }
.problem-text a { color: var(--jot); font-weight: 700; }

/* ---- a problem ---- */

.problem {
  position: relative;
  background: var(--chalk);
  color: var(--ink);
  border-radius: 16px;
  border-top: 14px solid var(--pc);
  box-shadow: 6px 8px 0 rgba(0, 0, 0, 0.24);
  padding: 22px 30px 34px;
  margin: 0 0 44px;
  scroll-margin-top: 20px;
}

.problem::before {
  /* tape */
  content: "";
  position: absolute;
  top: -24px;
  left: 50%;
  width: 110px;
  height: 26px;
  background: rgba(255, 255, 255, 0.55);
  transform: translateX(-50%) rotate(-2deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.problem:nth-of-type(even)::before { transform: translateX(-50%) rotate(2.5deg); }

.problem-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.field-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--pc);
  font-weight: 800;
  font-size: 14px;
}

.state {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
  border: 2px solid var(--ink);
}

.state.solved { background: var(--c2); border-color: transparent; }

.problem-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
}

.problem-title {
  margin: 0 0 12px;
  font-family: "Permanent Marker", cursive;
  font-weight: 400;
  font-size: clamp(30px, 4.5vw, 44px);
  line-height: 1.1;
}

.question {
  margin: 0 0 8px;
  font-size: clamp(19px, 2.2vw, 23px);
  font-weight: 700;
  line-height: 1.3;
  max-width: 30em;
}

.problem-text h3 {
  margin: 26px 0 6px;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.problem-text h3::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--pc);
  transform: rotate(8deg);
}

.problem-text p {
  margin: 0 0 12px;
  font-size: 17px;
  line-height: 1.55;
  max-width: 62ch;
}

.problem-side {
  position: sticky;
  top: 24px;
  padding: 18px 20px 20px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--pc) 42%, white);
}

.doodle {
  display: block;
  width: 100%;
  height: auto;
  color: var(--ink);
  margin-bottom: 8px;
}

.problem-side h4 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 800;
}

.formal {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 600;
}

@media (max-width: 820px) {
  .problem-body { grid-template-columns: minmax(0, 1fr); }
  .problem-side { position: static; }
  .doodle { max-width: 220px; margin: 0 auto 8px; }
  .problem { padding: 18px 20px 26px; }
}

/* ---- generic explainer additions ---- */

.problem-body.no-side { grid-template-columns: minmax(0, 1fr); }

.steps {
  margin: 8px 0 14px;
  padding-left: 0;
  list-style: none;
  counter-reset: step;
  max-width: 62ch;
}

.steps li {
  position: relative;
  padding: 10px 14px 10px 52px;
  margin: 0 0 8px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--pc) 22%, white);
  font-size: 16px;
  line-height: 1.5;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 9px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--chalk);
  font-family: "Permanent Marker", cursive;
  font-size: 16px;
  display: grid;
  place-items: center;
  transform: rotate(-6deg);
}

.meta-lines {
  display: grid;
  grid-template-columns: fit-content(45%) minmax(0, 1fr);
  gap: 4px 14px;
  margin: 10px 0 0;
  font-size: 15px;
}

.meta-lines dt { font-weight: 800; }
.meta-lines dd { margin: 0; }

/* grid layout: many smaller cards */

.xcards {
  list-style: none;
  margin: 0;
  padding: 8px 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 26px;
}

.xcard {
  position: relative;
  background: var(--chalk);
  color: var(--ink);
  border-radius: 14px;
  border-top: 12px solid var(--pc);
  box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.22);
  padding: 16px 20px 20px;
  transition: transform 260ms var(--spring), box-shadow 260ms;
  scroll-margin-top: 20px;
}

.xcard:hover { transform: translateY(-4px) rotate(-0.5deg); box-shadow: 6px 10px 0 rgba(0, 0, 0, 0.26); }

.xcard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.xcard .field-pill, .xcard .state { font-size: 12px; padding: 3px 11px; }

.xcard-title {
  margin: 0 0 4px;
  font-family: "Permanent Marker", cursive;
  font-weight: 400;
  font-size: 26px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.xcard-sub {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}

.xcard .question {
  font-size: 16px;
  margin: 0 0 6px;
}

.xcard-text h3 {
  margin: 14px 0 4px;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 7px;
}

.xcard-text h3::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--pc);
  transform: rotate(8deg);
}

.xcard-text p {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.5;
}

.xcard .steps li { font-size: 14px; padding: 8px 12px 8px 46px; }
.xcard .steps li::before { width: 24px; height: 24px; font-size: 14px; top: 8px; left: 10px; }

.xcard-aside {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--pc) 42%, white);
  font-size: 14px;
  line-height: 1.45;
}

.xcard .meta-lines { font-size: 14px; }

.list-count { margin: 0 0 20px; font-weight: 600; color: var(--chalk-dim); }

/* ---- illustrations ---- */

.side-figure, .problem-figure, .xcard-figure { margin: 0; }

.side-figure img, .problem-figure img, .xcard-figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 3px solid var(--chalk);
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.18);
  transform: rotate(-1deg);
  background: var(--chalk);
}

.side-figure img, .problem-figure img, .xcard-figure img { cursor: zoom-in; }

.zoom {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: rgb(20, 12, 52);
  animation: zoom-in 0.18s ease-out;
}
.zoom img {
  display: block;
  width: 100%;
  max-width: 1100px;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 8px;
  background: var(--chalk);
}
.zoom-hint { margin: 0; font-size: 13px; font-weight: 600; color: var(--chalk-dim); }
@keyframes zoom-in { from { opacity: 0; transform: scale(0.96); } }
@media (prefers-reduced-motion: reduce) { .zoom { animation: none; } }

figcaption {
  margin: 10px 2px 0;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--ink-soft);
}

.side-figure { margin: 0 0 14px; }
.side-figure img { transform: rotate(1.2deg); }
.problem-figure { max-width: 520px; margin: 4px 0 18px; }
.xcard-figure { margin: 0 0 12px; }
.xcard-figure img { transform: rotate(-0.8deg); }
.xcard:nth-child(even) .xcard-figure img { transform: rotate(0.9deg); }

@media (max-width: 820px) {
  .side-figure { max-width: 420px; margin: 0 auto 14px; }
}

/* a side panel carrying a picture gets a little more room */
.problem-body:has(.side-figure) { grid-template-columns: minmax(0, 1fr) 360px; }
@media (max-width: 820px) {
  .problem-body:has(.side-figure) { grid-template-columns: minmax(0, 1fr); }
}

/* ---- test me ---- */

.testme {
  max-width: 560px;
  margin: 0 0 44px;
  padding: 18px 18px 20px;
  border-radius: 16px;
  background: rgba(255, 248, 236, 0.08);
  border: 2px dashed rgba(255, 248, 236, 0.3);
}

.testme-head { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 14px; }
.testme-title { margin: 0; font-size: 24px; }
.testme-line { grid-column: 1; margin: 0; font-size: 14px; font-weight: 600; color: var(--chalk-dim); }
.testme-head .pin-btn { grid-column: 2; grid-row: 1 / span 2; background: var(--jot); color: var(--ink); }
.testme-stage { margin-top: 18px; }

/* ---- the "read it" stamp ---- */

.stamp-row { display: flex; justify-content: center; padding: 8px 0 0; }

.stamp-btn {
  font: inherit;
  font-weight: 800;
  font-size: 16px;
  color: var(--chalk);
  background: transparent;
  border: 3px dashed rgba(255, 248, 236, 0.45);
  border-radius: 999px;
  padding: 14px 26px;
  cursor: pointer;
  transition: background-color 200ms, color 200ms;
}

.stamp-btn.is-on {
  width: 124px;
  height: 124px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--jot);
  background: var(--ink);
  color: var(--jot);
  font-family: "Permanent Marker", cursive;
  font-weight: 400;
  font-size: 26px;
  transform: rotate(-12deg);
  box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.3);
  animation: stamp 480ms var(--spring) both;
}

@keyframes stamp {
  from { opacity: 0; transform: rotate(10deg) scale(2.2); }
  to   { opacity: 1; transform: rotate(-12deg) scale(1); }
}

@media (max-width: 760px) {
  .jump { flex-wrap: nowrap; overflow-x: auto; margin: 4px -16px 28px; padding: 4px 16px 8px; scrollbar-width: none; }
  .jump::-webkit-scrollbar { display: none; }
  .jump-pill { flex: 0 0 auto; }
  .problem { padding: 16px 16px 24px; margin-bottom: 36px; }
  .xcards { grid-template-columns: minmax(0, 1fr); gap: 22px; }
}

/* nothing inside a card may push it wider than a narrow phone */
.problem-text, .problem-side, .xcard { min-width: 0; }

/* ---- long pages: let the browser skip laying out chapters that are off screen ---- */

.problem-body { content-visibility: auto; contain-intrinsic-size: auto 1600px; }
.xcard-text { content-visibility: auto; contain-intrinsic-size: auto 320px; }

/* ---- the song note at the top of a page (E.song in explain.js) ---- */

.song {
  max-width: 40em;
  margin: 0 0 36px;
  padding: 20px 24px 22px;
  border-radius: 6px;
  background: var(--c2);
  color: var(--ink);
  transform: rotate(-0.6deg);
  box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.3);
  min-width: 0;
}
.song-tag { margin: 0; font-family: "Permanent Marker", cursive; font-size: 15px; color: var(--ink-soft); }
.song-title { margin: 2px 0 4px; font-size: 26px; line-height: 1.15; }
.song-sub { margin: 0 0 12px; font-weight: 600; color: var(--ink-soft); }
.song-audio { display: block; width: 100%; margin: 4px 0 14px; }
.song-note { margin: 0 0 12px; font-weight: 500; line-height: 1.5; }
.song-stanza { margin: 0 0 12px; }
.song-stanza h3 { margin: 0 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); }
.song-stanza p { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.45; }
.song-more summary { cursor: pointer; font-weight: 800; margin: 4px 0 12px; }
.song-more[open] summary { margin-bottom: 14px; }

@media (max-width: 760px) {
  .song { padding: 16px 16px 18px; transform: none; }
  .song-title { font-size: 22px; }
}
