/* The "go in order" note over a question list (noteviewer/_order_hint.html),
   on the topic questions and multiple choice pages, the first time a student
   opens each (owner, 2026-10-07), redrawn the same day in the language of the
   subject cap overlay and the profile's shelf ("do the same thing you did.
   make it better").

   One flat card with a crisp edge (no glow, no wash: owner, 2026-10-07). On
   its left the notebook's dotted paper holds the question pager in small:
   1 to 5 are set down one by one, the blue route draws through them in
   order, each number nodding as the line reaches it, and a "Start" flag drops
   onto 1, which fills blue. A number under the pointer lifts; a later number
   pressed knocks back into its place while the flag waves. On the right the
   words: a kicker, the title in the display face with its last words blue,
   one plain sentence, and "Start at question 1" (a rounded rectangle, never a
   capsule). The X and the button fold the card away: it lifts and fades, its
   row closes, and the questions rise into its place. Everything arrives once
   and finishes; tokens only, both themes from the same rules; reduced motion
   gets the finished picture. */

/* It stands where the first question stood, and the question keeps its own
   distance under it: on topic questions the 36px the masthead leaves, on
   multiple choice the card's own padding (so 36px above the note there too). */
.nb-order-hint {
  display: grid;
  grid-template-rows: 1fr;
  margin: 0;
  transition:
    grid-template-rows 360ms var(--nb-ease) 120ms,
    opacity 240ms var(--nb-ease),
    margin 360ms var(--nb-ease) 120ms;
}
.nb-order-hint[hidden] { display: none; }
.nb-qg-body > .nb-order-hint { margin-bottom: calc(var(--nb-s7) + var(--nb-s1)); }
.nb-mcq-body > .nb-order-hint { margin-top: calc(var(--nb-s7) + var(--nb-s1)); }
.nb-order-hint.is-closing {
  grid-template-rows: 0fr;
  overflow: hidden;
  opacity: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.nb-order-card {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  border: 1px solid var(--nb-border);
  border-radius: var(--nb-r-lg);
  background: var(--nb-paper-raised);
  transition: transform 280ms var(--nb-ease);
}
.nb-order-hint:not(.is-settled) .nb-order-card { animation: nb-order-arrive 560ms var(--nb-ease) 60ms both; }
.nb-order-hint.is-closing .nb-order-card { transform: translateY(-8px) scale(0.985); }

/* ── The scene: the pager in small on the dotted paper ───────────────── */
.nb-order-scene {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 248px;
  padding: var(--nb-s7) var(--nb-s6) var(--nb-s6);
  border-right: 1px solid var(--nb-border);
  background:
    radial-gradient(circle at 1px 1px, var(--nb-grid-dot) 1px, transparent 1.5px) 9px 9px / 18px 18px,
    color-mix(in srgb, var(--nb-paper) 70%, var(--nb-paper-raised));
}
.nb-order-steps {
  position: relative;
  display: inline-flex;
  align-items: center;
  font: 600 var(--nb-text-sm)/1 var(--nb-sans);
  color: var(--nb-ink);
}
.nb-order-steps b {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--nb-border-strong);
  border-radius: var(--nb-r-md);
  background: var(--nb-paper-raised);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: translate 220ms var(--nb-ease), border-color 160ms var(--nb-ease);
}
/* 1 is where to start: blue (as it lands it is outlined, and it fills as the flag comes down on it) */
.nb-order-steps b:first-child { border-color: var(--nb-blue); background: var(--nb-blue); color: var(--nb-on-blue); }
.nb-order-hint:not(.is-settled) .nb-order-steps b { animation: nb-order-drop 440ms var(--nb-ease) both, nb-order-nod 320ms var(--nb-ease) both; }
.nb-order-hint:not(.is-settled) .nb-order-steps b:first-child { animation: nb-order-drop 440ms var(--nb-ease) both, nb-order-start 320ms var(--nb-ease) 1560ms both; }
@media (hover: hover) {
  .nb-order-steps b:hover { translate: 0 -3px; border-color: var(--nb-blue); }
}
.nb-order-steps b:active { translate: 0 -1px; }
/* the route between them, drawn in order like a pen stroke */
.nb-order-steps i {
  width: 16px;
  height: 2px;
  border-radius: var(--nb-r-sm);
  background: var(--nb-blue);
  transform-origin: left center;
}
.nb-order-hint:not(.is-settled) .nb-order-steps i { animation: nb-order-draw 150ms linear both; }
/* set down one by one (from 200ms, 70ms apart) */
.nb-order-hint:not(.is-settled) .nb-order-steps b:nth-child(1) { animation-delay: 200ms, 1560ms; }
.nb-order-hint:not(.is-settled) .nb-order-steps b:nth-child(3) { animation-delay: 270ms, 980ms; }
.nb-order-hint:not(.is-settled) .nb-order-steps b:nth-child(5) { animation-delay: 340ms, 1130ms; }
.nb-order-hint:not(.is-settled) .nb-order-steps b:nth-child(7) { animation-delay: 410ms, 1280ms; }
.nb-order-hint:not(.is-settled) .nb-order-steps b:nth-child(9) { animation-delay: 480ms, 1430ms; }
/* the route reaches each number in turn, which nods (see the delays above) */
.nb-order-hint:not(.is-settled) .nb-order-steps i:nth-child(2) { animation-delay: 840ms; }
.nb-order-hint:not(.is-settled) .nb-order-steps i:nth-child(4) { animation-delay: 990ms; }
.nb-order-hint:not(.is-settled) .nb-order-steps i:nth-child(6) { animation-delay: 1140ms; }
.nb-order-hint:not(.is-settled) .nb-order-steps i:nth-child(8) { animation-delay: 1290ms; }

/* the flag: a small rounded label with a point, standing over 1 */
.nb-order-flag {
  position: absolute;
  left: 17px;
  bottom: calc(100% + 9px);
  translate: -50% 0;
  padding: 3px 7px;
  border-radius: var(--nb-r-sm);
  background: var(--nb-blue);
  color: var(--nb-on-blue);
  font: 600 var(--nb-text-xs)/1.2 var(--nb-sans);
  letter-spacing: 0.02em;
  transform-origin: 50% 100%;
  white-space: nowrap;
  pointer-events: none;
}
.nb-order-hint:not(.is-settled) .nb-order-flag { animation: nb-order-flag 640ms var(--nb-ease) 1420ms both; }
.nb-order-flag::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -4px;
  border: 4px solid transparent;
  border-bottom: 0;
  border-top-color: var(--nb-blue);
  transform: translateX(-50%);
}

/* a later number pressed knocks back into its place; the flag waves */
.nb-order-steps b.is-knocked { animation: nb-order-knock 520ms var(--nb-ease); }
.nb-order-flag.is-waving { animation: nb-order-wave 720ms var(--nb-ease); }

/* ── The words ───────────────────────────────────────────────────────── */
.nb-order-text {
  min-width: 0;
  padding: var(--nb-s5) calc(var(--nb-s9) + var(--nb-s2)) var(--nb-s5) var(--nb-s6);
}
.nb-order-kicker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 var(--nb-s2);
  font: 600 var(--nb-text-sm)/1.2 var(--nb-sans);
  color: var(--nb-ink);
}
.nb-order-hint:not(.is-settled) .nb-order-kicker { animation: nb-order-rise 480ms var(--nb-ease) 240ms both; }
.nb-order-kicker svg { flex: none; color: var(--nb-blue); }
.nb-order-title {
  margin: 0;
  font: 600 var(--nb-text-xl)/1.2 var(--nb-display);
  letter-spacing: -0.015em;
  color: var(--nb-ink);
  text-wrap: balance;
}
.nb-order-hint:not(.is-settled) .nb-order-title { animation: nb-order-rise 520ms var(--nb-ease) 300ms both; }
.nb-order-title em { font-style: normal; color: var(--nb-blue); }
.nb-order-line {
  margin: var(--nb-s2) 0 0;
  max-width: 62ch;
  font: 400 var(--nb-text-base)/1.55 var(--nb-sans);
  color: var(--nb-ink);
  text-wrap: pretty;
}
.nb-order-hint:not(.is-settled) .nb-order-line { animation: nb-order-rise 520ms var(--nb-ease) 360ms both; }
.nb-order-acts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--nb-s2);
  margin-top: var(--nb-s4);
}
.nb-order-hint:not(.is-settled) .nb-order-acts { animation: nb-order-rise 520ms var(--nb-ease) 420ms both; }
.nb-order-go {
  display: inline-flex;
  align-items: center;
  gap: var(--nb-s2);
  height: 38px;
  padding: 0 var(--nb-s4);
  border: 1px solid var(--nb-blue);
  border-radius: var(--nb-r-md);
  background: var(--nb-blue);
  color: var(--nb-on-blue);
  font: 600 var(--nb-text-base)/1 var(--nb-sans);
  cursor: pointer;
  transition: background-color 160ms var(--nb-ease), border-color 160ms var(--nb-ease), transform 200ms var(--nb-ease);
}
.nb-order-go svg { flex: none; transition: transform 240ms var(--nb-ease); }
@media (hover: hover) {
  .nb-order-go:hover { background: var(--nb-blue-strong); border-color: var(--nb-blue-strong); transform: translateY(-1px); }
  .nb-order-go:hover svg { transform: translateY(2px); }
}
.nb-order-go:active { transform: scale(0.98); }
.nb-order-go:focus-visible { outline: 2px solid var(--nb-blue); outline-offset: 2px; }

/* the X: the site's shared close button, quiet on the card until pointed at */
html .nb-order-hint .nb-order-x.x-close {
  position: absolute;
  top: var(--nb-s3);
  right: var(--nb-s3);
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--nb-r-md);
  background: transparent;
  box-shadow: none;
  color: var(--nb-ink);
  transition:
    background-color var(--nb-dur-1) var(--nb-ease),
    border-color var(--nb-dur-1) var(--nb-ease),
    color var(--nb-dur-1) var(--nb-ease),
    transform var(--nb-dur-2) var(--nb-ease);
}
html .nb-order-hint .nb-order-x.x-close:hover {
  border-color: var(--nb-border-strong);
  color: var(--nb-blue);
  transform: rotate(90deg);
}
html .nb-order-hint .nb-order-x.x-close:active { transform: scale(0.94); }
html .nb-order-hint .nb-order-x.x-close:focus-visible {
  outline: 2px solid var(--nb-blue);
  outline-offset: 2px;
}

/* Question 1, lit for a moment after "Start at question 1" (the script). */
.nb-order-lit { animation: nb-order-lit 1600ms var(--nb-ease); }

@keyframes nb-order-arrive {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}
@keyframes nb-order-rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes nb-order-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes nb-order-drop {
  from { opacity: 0; transform: translateY(-16px) rotate(-8deg); }
  60% { opacity: 1; }
  to { opacity: 1; transform: none; }
}
@keyframes nb-order-nod {
  0%, 100% { scale: 1; }
  45% { scale: 1.14; }
}
@keyframes nb-order-start {
  from { border-color: var(--nb-border-strong); background: var(--nb-paper-raised); color: var(--nb-ink); }
  to { border-color: var(--nb-blue); background: var(--nb-blue); color: var(--nb-on-blue); }
}
@keyframes nb-order-draw {
  from { transform: scaleX(0); }
  to { transform: none; }
}
@keyframes nb-order-flag {
  0% { opacity: 0; transform: translateY(-14px) rotate(-12deg); }
  55% { opacity: 1; transform: translateY(1px) rotate(7deg); }
  78% { transform: rotate(-3deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes nb-order-knock {
  0%, 100% { translate: 0 0; }
  25% { translate: -9px -6px; }
  50% { translate: 4px 0; }
  72% { translate: -2px 0; }
}
@keyframes nb-order-wave {
  0%, 100% { transform: none; }
  25% { transform: rotate(-10deg); }
  50% { transform: rotate(8deg); }
  75% { transform: rotate(-4deg); }
}
@keyframes nb-order-lit {
  from { background-color: color-mix(in srgb, var(--nb-blue) 14%, transparent); }
}

/* a tablet: the scene narrows */
@media (max-width: 860px) {
  .nb-order-scene { min-width: 216px; padding-inline: var(--nb-s4); }
  .nb-order-steps b { width: 28px; height: 28px; }
  .nb-order-steps i { width: 12px; }
  .nb-order-flag { left: 14px; }
}
/* a phone: the scene across the top, the words and the button under it */
@media (max-width: 600px) {
  .nb-order-card { grid-template-columns: minmax(0, 1fr); }
  .nb-order-scene { min-width: 0; padding: calc(var(--nb-s6) + var(--nb-s1)) var(--nb-s4) var(--nb-s4); border-right: 0; border-bottom: 1px solid var(--nb-border); }
  .nb-order-text { padding: var(--nb-s4); }
  .nb-order-title { font-size: var(--nb-text-lg); }
  .nb-order-go { width: 100%; justify-content: center; height: 44px; }
  html .nb-order-hint .nb-order-x.x-close { top: var(--nb-s2); right: var(--nb-s2); }
}

/* A short window keeps the button above the fold (checked at 844x390, 320x568
   and 360x640, under the phone's thumb bar): a phone on its side loses the
   kicker and some air; a small phone also loses the kicker, and the smallest
   loses the sentence too (the title and the button still say it). */
@media (max-height: 500px) and (min-width: 601px) {
  .nb-order-kicker { display: none; }
  .nb-order-scene { padding-block: calc(var(--nb-s6) + var(--nb-s1)) var(--nb-s3); }
  .nb-order-text { padding-block: var(--nb-s2) var(--nb-s3); }
  .nb-order-title { font-size: var(--nb-text-md); }
  .nb-order-line { margin-top: var(--nb-s1); font-size: var(--nb-text-sm); }
  .nb-order-acts { margin-top: var(--nb-s2); }
}
@media (max-width: 600px) and (max-height: 700px) {
  .nb-order-kicker { display: none; }
  .nb-order-scene { padding: calc(var(--nb-s6) + var(--nb-s1)) var(--nb-s4) var(--nb-s3); }
  .nb-order-text { padding: var(--nb-s3) var(--nb-s4) var(--nb-s4); }
  .nb-order-title { font-size: var(--nb-text-md); }
  .nb-order-line { margin-top: var(--nb-s1); font-size: var(--nb-text-sm); }
  .nb-order-acts { margin-top: var(--nb-s3); }
  .nb-order-go { height: 42px; }
}
@media (max-width: 600px) and (max-height: 600px) {
  .nb-order-line { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nb-order-hint { transition: none; }
  .nb-order-hint .nb-order-card,
  .nb-order-hint .nb-order-steps b,
  .nb-order-hint .nb-order-steps i,
  .nb-order-hint .nb-order-flag,
  .nb-order-hint .nb-order-kicker,
  .nb-order-hint .nb-order-title,
  .nb-order-hint .nb-order-line,
  .nb-order-hint .nb-order-acts,
  .nb-order-lit { animation: none; }
}
