/* Figures of the NCM post. Pills, the hierarchy and word marks follow the video (ncm/flextok/video); type is the
   page's. No colour is written here: they all come from /assets/css/palette.css. */

@property --c { syntax: "<color>"; inherits: true; initial-value: transparent; }

.post .katex { font-size: 1.1em; }

.fig { margin: 2rem 0 2.25rem; }
.fig--wide { margin-inline: calc((min(38rem, 100vw - 2rem) - min(54rem, 100vw - 2rem)) / 2); }
.fig--narrow .fig__frame { max-width: 25rem; }
.fig__frame { position: relative; color: var(--ink); font-weight: 400; font-size: 0.875rem; line-height: 1.375rem; }
.fig figcaption { max-width: 38rem; margin: 0.75rem auto 0; font-size: 0.8125rem; line-height: 1.25rem; color: var(--page-muted); }
.fig figcaption b { font-weight: 600; color: var(--page-soft); }
.fig__fallback { margin: 0; color: var(--page-muted); }
.fig button { font: inherit; color: inherit; }
.fig :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* the hierarchy: one row of codes per level; levels after k greyed out */
.pyr { display: flex; flex-direction: column; gap: 3px; }
.pyr__row { display: flex; height: 10px; }
.pyr__cells { flex: 1; display: flex; min-width: 0; --c: var(--on); transition: --c 450ms cubic-bezier(0.22, 1, 0.36, 1); }
.pyr__cells i { flex: 1; min-width: 0; border-radius: 2px; background: var(--c); }
.pyr__cells i.stripes { border-radius: 0; background: linear-gradient(90deg, var(--c) 68%, transparent 68%) 0 0 / calc(100% / var(--n)) 100%; }
.pyr__row[data-off="true"] .pyr__cells { --c: var(--off); }
.pyr__row--text { margin-top: 5px; }
.pyr--top { height: 166px; cursor: pointer; }
.pyr--control { cursor: ns-resize; touch-action: pan-y; border-radius: 3px; outline-offset: 4px; }

/* a story or board figure: hierarchy and code count on the left, content on the right */
.sfig { display: grid; grid-template-columns: 10.5rem minmax(0, 1fr); gap: 18px; align-items: start; }
.sfig__side { position: sticky; top: 12px; display: grid; grid-template-columns: 1fr; gap: 8px; }
.sfig__count { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.lvl__n { font-size: 1.75rem; line-height: 2rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.lvl__of { color: var(--muted); font-size: 0.8125rem; }
.sfig .pyr__row { height: 11px; }
.sfig__side .pyr { order: 2; }
.sfig__next {
  order: 3; justify-self: start; appearance: none; border: 1px solid var(--line); background: transparent; border-radius: 8px;
  padding: 2px 10px; font-size: 0.8125rem; line-height: 1.375rem; cursor: pointer; margin-top: 4px;
  transition: border-color 140ms ease-out;
}
.sfig__next:hover, .sfig__refresh:hover { border-color: var(--muted); }
.sfig__refresh {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
  border: 1px solid var(--line); background: var(--card); border-radius: 50%; padding: 0; cursor: pointer; color: var(--ink);
  transition: border-color 140ms ease-out;
}
.sfig__refresh:active svg { transform: rotate(60deg); }
.sfig__refresh svg { transition: transform 200ms ease-out; }

/* rows of text: the original, then each decoder */
.row { background: var(--panel); border-radius: 10px; padding: 9px 14px 10px; }
.row + .row { margin-top: 8px; }
.row--orig { background: var(--card); border: 1px solid var(--line); }
.row__head { display: flex; align-items: center; justify-content: space-between; gap: 6px 14px; flex-wrap: wrap; min-height: 26px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 1px 10px; border-radius: 7px; background: var(--pill2);
  font-size: 0.8125rem; line-height: 1.375rem; font-weight: 600;
}
.pill--ncm { background: var(--pillN); }
.pill--ours { background: var(--pillO); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot--ncm { background: var(--ncm); border-radius: 2px; }
.dot--ours { background: var(--ours); }
.row__side { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; font-size: 0.75rem; color: var(--soft); }
.row__side strong { color: var(--ink); font-size: 0.9375rem; font-weight: 650; font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: right; }
.row__txt { margin: 6px 0 0; font-size: 0.84375rem; line-height: 1.375rem; font-weight: 300; overflow-wrap: anywhere; }
[data-fig="stories"] .row__txt { min-height: 9.625rem; }   /* 7 lines: the slider must not jump as the text changes */
.key { color: var(--ink); white-space: nowrap; }
.g4, .g3, .g2 { text-decoration-line: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-skip-ink: none; }
.g4 { text-decoration-color: var(--place); }
.g3 { text-decoration-color: var(--same); }
.g2 { text-decoration-color: var(--same); text-decoration-style: dotted; }
.rep { background: var(--rep); border-radius: 3px; padding: 1px 2px; margin: 0 -2px; }
.chg { background: var(--chg); border-radius: 3px; padding: 1px 2px; margin: 0 -2px; }

/* sudoku boards */
.sdk__pair { display: grid; grid-template-columns: repeat(2, minmax(0, 17rem)); gap: 18px; align-items: end; }
.sdk .pill { max-width: 100%; }
.sdk__board { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; margin-top: 8px; }
.sdk__cell {
  position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; font-family: var(--mono); font-size: clamp(0.625rem, 2.6vw, 0.8125rem); line-height: 1;
  background: var(--solution); color: var(--ink);
}
.sdk__cell[data-wrong="true"] { background: var(--problem); }
.sdk__cell[data-clue="true"]::after { content: ""; position: absolute; top: 2px; right: 2px; width: 4px; height: 4px; border-radius: 50%; background: var(--ink); }
.sdk__cell:nth-child(9n + 4), .sdk__cell:nth-child(9n + 7) { margin-left: 3px; }
.sdk__cell:nth-child(n + 28):nth-child(-n + 36), .sdk__cell:nth-child(n + 55):nth-child(-n + 63) { margin-top: 3px; }
.sdk__right { margin: 6px 0 0; font-size: 0.75rem; line-height: 1.125rem; color: var(--soft); font-variant-numeric: tabular-nums; }

/* chips (the two views of the curves) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: transparent; border-radius: 8px;
  padding: 2px 10px; font-size: 0.8125rem; line-height: 1.375rem; cursor: pointer;
  transition: background-color 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
}
.chip:hover { border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--control-bg); border-color: var(--control-bg); color: var(--control-ink); }

/* charts */
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; font-size: 0.8125rem; line-height: 1.25rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 3px solid; border-radius: 2px; }
.legend i.faint { opacity: 0.5; }
.panels { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.panel { min-width: 0; }
.panel h4 { margin: 0 0 2px; font-size: 0.8125rem; line-height: 1.25rem; font-weight: 600; }
.panel h4 small { display: block; font-weight: 400; font-size: 0.75rem; line-height: 1.125rem; color: var(--muted); }
.panel svg { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.panel svg text { font-family: var(--mono); font-size: 9px; fill: var(--muted); }
.panel svg text.lab { font-family: var(--sans); font-size: 10.5px; fill: var(--ink); }
.tip {
  position: absolute; z-index: 2; pointer-events: none; min-width: 140px;
  background: var(--tip-bg); color: var(--tip-ink); border-radius: 8px; padding: 6px 9px;
  font-size: 0.75rem; line-height: 1.125rem; box-shadow: var(--shadow-lift);
  opacity: 0; transition: opacity 120ms ease-out;
}
.tip[data-on="true"] { opacity: 1; }
.tip div { display: flex; align-items: center; gap: 6px; }
.tip div i { display: inline-block; width: 12px; border-top: 3px solid; border-radius: 2px; flex: none; }
.tip div strong { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 3em; }
.tip .tip__head { color: var(--tip-muted); font-size: 0.6875rem; }

@media (max-width: 860px) {
  [data-fig="stories"] .row__txt { min-height: 12.375rem; }   /* 9 lines */
}
@media (max-width: 700px) {
  /* no room on the left: count and button in one line, the hierarchy below them at full width */
  .sfig { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .sfig__side { position: static; grid-template-columns: 1fr auto; align-items: center; }
  .sfig__side .pyr { grid-column: 1 / -1; gap: 2px; }
  .sfig .pyr__row { height: 6px; }
  .sfig__next { order: 1; margin-top: 0; }
  [data-fig="stories"] .row__txt { min-height: 17.875rem; }   /* 13 lines */
  .sdk__pair { gap: 10px; }
}
@media (max-width: 480px) {
  .row { padding: 8px 10px 9px; }
  [data-fig="stories"] .row__txt { min-height: 20.625rem; }   /* 15 lines */
  .pyr--top { height: 166px; }
}
@media (prefers-reduced-motion: reduce) {
  .fig *, .site-nav a { transition: none !important; }
}
