/* ==========================================================================
   M2 Building palettes — module styles. Every class is prefixed .m2-
   Chrome comes from tokens only. Taught colours are set inline by the lesson.
   ========================================================================== */

/* ---- layout -------------------------------------------------------------- */

.m2-split {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: var(--s5);
  align-items: start;
  min-width: 0;
}
.m2-split > * { min-width: 0; }
@media (min-width: 1001px) {
  .m2-split--sticky > .panel { position: sticky; top: var(--s4); }
}
@media (max-width: 1000px) {
  .m2-split { grid-template-columns: minmax(0, 1fr); }
}

.m2-center { display: grid; place-items: center; }

.m2-mock { display: block; width: 100%; min-width: 0; }

.m2-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s4) var(--s6);
}
.m2-toolbar > .sb-toggle { margin-bottom: 5px; }

/* ---- small shared parts -------------------------------------------------- */

.m2-presets { display: flex; flex-wrap: wrap; gap: var(--s2); }
.m2-preset {
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--sw);
  box-shadow: inset 0 0 0 2px var(--surface);
  transition: transform 0.12s;
}
.m2-preset:hover { transform: translateY(-2px); }

.m2-state, .m2-fb {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s2);
  align-items: start;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--ink);
}
.m2-state .icon, .m2-fb .icon { margin-top: 3px; color: var(--ink-2); }
.m2-state { min-height: 2.9em; }
.m2-fb { font-size: 0.9375rem; flex: 1 1 220px; }
.m2-fb:empty { display: none; }
.m2-fb.is-good .icon { color: var(--good); }
.m2-fb.is-bad .icon { color: var(--bad); }

.m2-dots { display: inline-flex; gap: 6px; }
.m2-dots > span {
  width: 18px; height: 6px;
  border-radius: 1px;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.m2-dots > .is-current { background: var(--surface); box-shadow: inset 0 0 0 2px var(--ink); }
.m2-dots > .is-done { background: var(--ink); box-shadow: none; }

.m2-rounds { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.m2-rounds__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s4); }
.m2-rounds__foot:not(:has(> :not([hidden]):not(:empty))) { display: none; }

/* click-to-pick tiles (2.2 and 2.5) */
.m2-pick { position: relative; cursor: pointer; }
.m2-pick[aria-disabled="true"] { cursor: default; }
.m2-pick__mark {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.75rem;
}
.m2-pick.is-right .m2-pick__mark { background: var(--good); border-color: var(--surface); color: var(--surface); }

/* ---- 2.1 harmony ---------------------------------------------------------- */

.m2-rule { font-size: 0.9375rem; line-height: 1.45; min-height: 4.35em; }

.m2-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: var(--s2);
}
.m2-swatches .sb-swatch--lg { min-width: 0; }
.m2-swatches .sb-swatch--lg .sb-swatch__block { height: 112px; }
.m2-swatches .sb-swatch--inside .sb-swatch__block .sb-swatch__text { padding: 10px; }

.m2-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s4);
  align-items: start;
}
.m2-preview > * { min-width: 0; }
@media (max-width: 620px) {
  .m2-preview { grid-template-columns: minmax(0, 1fr); }
}

.m2-quizrow { display: flex; align-items: center; gap: var(--s5); min-width: 0; }
.m2-quizpal {
  flex: 1 1 0;
  display: flex;
  min-width: 0;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.m2-quizpal > span { flex: 1 1 0; }

.m2-dial {
  position: relative;
  flex: none;
  width: 112px;
  aspect-ratio: 1;
}
.m2-dial::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--m2-ring);
  -webkit-mask: radial-gradient(farthest-side, transparent 63%, #000 65%);
  mask: radial-gradient(farthest-side, transparent 63%, #000 65%);
}
.m2-dial__dot {
  position: absolute;
  width: 16px; height: 16px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--ink);
}
.m2-dial__dot.is-base { width: 22px; height: 22px; border-width: 3px; }
@media (max-width: 480px) {
  .m2-quizrow { gap: var(--s3); }
  .m2-quizpal { height: 88px; }
  .m2-dial { width: 88px; }
}

/* ---- 2.2 scales ----------------------------------------------------------- */

.m2-ramps { display: grid; gap: var(--s5); min-width: 0; }
.m2-rampblock { display: grid; gap: var(--s2); min-width: 0; }
.m2-rampblock__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s3); }
.m2-rampblock__head strong { font-size: 0.9375rem; }

.m2-ramp {
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
.m2-chip {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 92px;
  padding: 8px 4px 8px 8px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
}
.m2-chip__key { font-size: var(--fs-sm); font-weight: 700; }
.m2-chip__hex { font-size: 0.6875rem; opacity: 0.9; }
.m2-chip__cr {
  margin-top: auto;
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 0.6875rem;
  font-weight: 600;
}
.m2-chip__cr .icon { font-size: 0.75rem; stroke-width: 2.4; }

/* narrow: the two ramps stand side by side as columns, so rows line up */
@media (max-width: 760px) {
  /* heading row and ramp row are shared by both columns (subgrid), so the ramps start level
     even when one caption wraps to more lines than the other */
  .m2-ramps { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto; gap: var(--s2) var(--s3); }
  .m2-rampblock { grid-row: span 2; grid-template-rows: subgrid; }
  .m2-rampblock__head { align-self: start; }
  .m2-ramp { flex-direction: column; }
  .m2-chip {
    flex: none;
    display: grid;
    grid-template-columns: 3.2ch minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 4px 8px;
  }
  .m2-chip__cr { margin-top: 0; }
  .m2-rampblock__head .caption { font-size: var(--fs-xs); }
}
@media (max-width: 420px) {
  .m2-chip { grid-template-columns: 3.2ch minmax(0, 1fr); }
  .m2-chip__hex { display: none; }
  .m2-chip__cr { justify-self: end; }
}

.m2-chart { min-width: 0; }
.m2-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.m2-chart__grid { stroke: var(--line); stroke-width: 1; }
.m2-chart__tick { fill: var(--ink-2); font-family: var(--font-mono); font-size: 10px; }
.m2-chart__line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.m2-chart__line--a { stroke: var(--ink); stroke-width: 2; }
.m2-chart__line--b { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 4 4; }
.m2-chart__mark { stroke: var(--ink); stroke-width: 1; }

.m2-chartkey { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); font-size: var(--fs-sm); color: var(--ink); }
.m2-chartkey > span { display: inline-flex; align-items: center; gap: var(--s2); }
.m2-chartkey i { position: relative; display: block; width: 26px; height: 10px; flex: none; }
.m2-chartkey i::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 4px;
  border-top: 2px solid var(--ink);
}
.m2-chartkey i::after {
  content: "";
  position: absolute; left: 9px; top: 1px;
  width: 8px; height: 8px;
  background: var(--ink);
  border-radius: 50%;
}
.m2-chartkey .m2-chartkey__b::before { border-top: 2px dashed var(--ink-2); }
.m2-chartkey .m2-chartkey__b::after { border-radius: 0; background: var(--ink-2); }

.m2-legend { display: grid; gap: 6px; font-size: var(--fs-sm); }
.m2-legend li { display: grid; grid-template-columns: 34px 8ch minmax(0, 1fr); align-items: center; gap: var(--s2); }
.m2-legend__dots { display: inline-flex; gap: 2px; }
.m2-legend__dot { width: 16px; height: 16px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--line-strong); }
.m2-legend .mono { color: var(--ink-2); font-size: var(--fs-xs); }

.m2-kit { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.m2-kit__cell { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.mock.m2-kit__stage {
  display: grid; place-items: center;
  min-height: 88px;
  padding: var(--s3) var(--s2);
  border-radius: var(--radius);
}
.m2-kit__cap { display: grid; gap: 3px; justify-items: start; font-size: var(--fs-sm); line-height: 1.3; }
.m2-kit__cap > span:first-child { font-weight: 600; }
.m2-kit__cap .mono { font-size: var(--fs-micro); color: var(--ink-2); }

.m2-spot { display: flex; min-width: 0; border-radius: var(--radius); overflow: hidden; }
.m2-spot__chip {
  flex: 1 1 0;
  min-width: 0;
  height: 104px;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0 0 8px;
  border: 0;
  border-radius: 0;
  font-size: var(--fs-xs);
}
.m2-spot__chip:hover:not([aria-disabled="true"]) { box-shadow: inset 0 -4px 0 currentColor; }
.m2-spot__chip:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }
.m2-spot__chip.is-right { box-shadow: inset 0 0 0 3px currentColor; }
.m2-spot__values { display: flex; font-size: var(--fs-xs); color: var(--ink-2); }
.m2-spot__values > span { flex: 1 1 0; min-width: 0; text-align: center; padding: 3px 0; border-bottom: 2px solid transparent; }
.m2-spot__values > .is-odd { color: var(--ink); font-weight: 700; border-bottom-color: var(--ink); }
@media (max-width: 480px) {
  .m2-spot__chip { height: 88px; }
  .m2-spot .m2-pick__mark { width: 18px; height: 18px; font-size: 0.625rem; }
}

/* ---- 2.3 neutrals --------------------------------------------------------- */

.m2-pairs { display: grid; gap: 6px; min-width: 0; }
.m2-pairs__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.m2-pairs__grid > span {
  display: flex; align-items: center; justify-content: center;
  min-width: 0;
  height: 64px;
  font-size: var(--fs-micro);
  overflow: hidden;
  white-space: nowrap;
}

.m2-nramp {
  display: flex;
  height: 56px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}
.m2-nramp > span { flex: 1 1 0; }
.m2-nramp > .m2-nramp__brand { flex: 0 0 22%; }

/* ---- 2.4 anatomy ---------------------------------------------------------- */

.m2-anat { display: grid; gap: 0; padding: 0; }
.m2-anat__row { display: grid; gap: var(--s3); padding: var(--s4) var(--s5); min-width: 0; }
.m2-anat__row + .m2-anat__row { border-top: 1px solid var(--line); }
.m2-anat__label { display: flex; align-items: center; gap: var(--s3); }
.m2-anat__label > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s2); }
.m2-anat__n {
  display: grid; place-items: center;
  min-width: 26px; height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.m2-anat__body { display: grid; gap: var(--s2); min-width: 0; }
.m2-anat__sems { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s2); }
.m2-anat__sems .sb-swatch--lg { min-width: 0; }
.m2-anat__sems .sb-swatch--lg .sb-swatch__block { height: 72px; }
.m2-anat__sems .sb-swatch--inside .sb-swatch__block .sb-swatch__text { padding: 8px 10px; }
@media (max-width: 520px) {
  .m2-anat__row { padding: var(--s4); }
  .m2-anat__sems { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.m2-warn {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--s3);
  align-items: start;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-left: 4px solid var(--good);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.9375rem;
  line-height: 1.45;
}
.m2-warn > .icon { margin-top: 2px; color: var(--good); }
.m2-warn.is-clash { border-left-color: var(--warn); border-left-style: double; border-left-width: 6px; }
.m2-warn.is-clash > .icon { color: var(--warn); }
.m2-warn p { max-width: none; }

.m2-duo { display: grid; gap: var(--s4); min-width: 0; align-items: start; }
.m2-duo > * { min-width: 0; }
@media (min-width: 1001px) {
  .sb-challenge__body > .m2-duo { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
}

.m2-fix { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s2); }
@media (max-width: 1000px) { .m2-fix { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }
.m2-fix__tile {
  display: flex; flex-direction: column;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  text-align: left;
  min-width: 0;
}
.m2-fix__tile:hover { border-color: var(--ink-2); }
.m2-fix__block { height: 48px; }
.m2-fix__text { display: grid; gap: 1px; padding: 8px 10px 9px; font-size: var(--fs-sm); line-height: 1.3; }
.m2-fix__state {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: var(--fs-micro);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
}
.m2-fix__state .icon { font-size: 0.75rem; }
.m2-fix__tile.is-removed { border-style: dashed; background: transparent; }
.m2-fix__tile.is-removed .m2-fix__block {
  opacity: 0.35;
  -webkit-mask: repeating-linear-gradient(135deg, #000 0 5px, transparent 5px 10px);
  mask: repeating-linear-gradient(135deg, #000 0 5px, transparent 5px 10px);
}
.m2-fix__tile.is-removed strong { text-decoration: line-through; color: var(--ink-2); }
.m2-fix__tile.is-removed .caption { opacity: 0.7; }

/* ---- 2.5 saturation budget ------------------------------------------------- */

.m2-readout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); align-items: start; }
.m2-readout .caption { font-size: var(--fs-xs); }
.m2-readout .meter { height: 6px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--line); }
.m2-readout .meter > span { background: var(--ink); }

.m2-loud { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--s2); }
@media (max-width: 720px) { .m2-loud { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.m2-loud__tile {
  display: flex; flex-direction: column;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  text-align: left;
  min-width: 0;
}
.m2-loud__tile:hover:not([aria-disabled="true"]) { border-color: var(--ink); }
.m2-loud__block { height: 76px; box-shadow: inset 0 -1px 0 var(--line); }
.m2-loud__text { display: grid; gap: 1px; padding: 7px 10px 8px; font-size: var(--fs-sm); line-height: 1.3; min-height: 3.6em; align-content: start; }
.m2-loud__c { font-size: var(--fs-micro); color: var(--ink-2); }
.m2-loud__tile.is-right { border: 2px solid var(--good); }
.m2-loud__tile.is-wrong { border-style: dashed; border-color: var(--bad); }

@media (prefers-reduced-motion: reduce) {
  .m2-preset { transition: none; }
  .m2-preset:hover { transform: none; }
}

.m2-chartpanel { align-self: start; }

@media (max-width: 560px) {
  .m2-fix { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m2-fix__tile { flex-direction: row; }
  .m2-fix__block { flex: 0 0 28px; height: auto; }
  .m2-fix__text { padding: 6px 8px 7px; min-width: 0; }
}

.m2-chip.is-yours { box-shadow: inset 0 0 0 3px currentColor; }
.m2-yours { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--ink); margin-top: calc(var(--s3) * -1); }
.m2-yours__dot { width: 14px; height: 14px; flex: none; border-radius: 3px; box-shadow: 0 0 0 1px var(--line-strong); }
@media (max-width: 480px) {
  .m2-kit { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .m2-kit__cell:last-child { grid-column: 1 / -1; }
}
.mock.m2-kit__stage > * { align-self: center; justify-self: center; }
