/* ============================================================
   NAZZA — "How to measure" guide
   ============================================================ */

.mg {
  width: min(980px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; border: 1px solid var(--ink);
  background: var(--bg); color: var(--ink); overflow: hidden;
}
.mg[open] { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); animation: mg-in .3s var(--ease); }
.mg::backdrop { background: rgba(0,0,0,.55); }
@keyframes mg-in { from { opacity: 0; transform: translateY(12px); } }

/* FIGURE */
.mg-stage { background: var(--surface); border-right: 1px solid var(--line); display: flex; align-items: center; justify-content: center; padding: 24px; min-height: 0; }
.mg-figure { width: 100%; height: min(70vh, 620px); display: block; }
.mg-line { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.mg-fill { fill: var(--surface); }
.mg-fill.mg-line { fill: var(--surface); }
.mg-floor { stroke: var(--line); stroke-width: 1.5; }

.mg-tape { opacity: 0; }
.mg-tape-band { fill: none; stroke: var(--tape); stroke-width: 9; stroke-linecap: butt; }
.mg-tape-ticks { fill: none; stroke: var(--ink); stroke-width: 5; stroke-dasharray: 1 5; }
.mg-back { fill: none; stroke: var(--tape); stroke-width: 9; opacity: 0; }
.mg-reveal { stroke-dasharray: 1; stroke-dashoffset: 1; }

.mg-tape.is-active { opacity: 1; }
.mg-reveal.is-active { animation: mg-draw 1.5s var(--ease) .15s forwards; }
.mg-back.is-active { animation: mg-fade .5s ease 1.4s forwards; }
@keyframes mg-draw { to { stroke-dashoffset: 0; } }
@keyframes mg-fade { to { opacity: .45; } }

/* CONTENT */
.mg-content { padding: 32px 40px 32px; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.mg-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.mg-title { font-size: 15px; font-weight: 500; }
.mg-close { background: none; border: none; color: var(--ink); cursor: pointer; width: 40px; height: 40px; margin-right: -11px; display: flex; align-items: center; justify-content: center; }
.mg-close:hover { opacity: .55; }
.mg-intro { font-size: 14px; color: var(--muted); line-height: 1.55; padding-bottom: 20px; border-bottom: 1px solid var(--line); }

.mg-panels { padding: 28px 0 24px; min-height: 250px; }
.mg-panel[hidden] { display: none; }
.mg-count { font-size: 14px; color: var(--muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.mg-name { font-size: clamp(32px, 3.6vw, 46px); font-weight: 300; letter-spacing: -.03em; line-height: 1.05; margin-bottom: 14px; }
.mg-how { font-size: 17px; line-height: 1.5; max-width: 40ch; margin-bottom: 14px; }
.mg-tip { font-size: 15px; color: var(--muted); line-height: 1.5; max-width: 44ch; }
.mg-tip strong { color: var(--ink); font-weight: 500; margin-right: 6px; }

/* STEP LIST — each step carries its own progress bar */
.mg-steps { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; margin-top: auto; }
.mg-step { width: 100%; position: relative; display: flex; align-items: baseline; gap: 10px; background: none; border: none; padding: 11px 0 12px; font-family: var(--font); font-size: 14px; color: var(--muted); text-align: left; cursor: pointer; }
.mg-step:hover, .mg-step.is-active { color: var(--ink); }
.mg-step-num { font-variant-numeric: tabular-nums; min-width: 12px; }
.mg-step-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line); overflow: hidden; }
.mg-step-bar i { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; }
.mg-step.is-done .mg-step-bar i, .mg-step.is-active .mg-step-bar i { transform: scaleX(1); }
.mg.is-playing .mg-step.is-active .mg-step-bar i { animation: mg-progress 6.5s linear forwards; }
.mg.is-paused .mg-step.is-active .mg-step-bar i { animation-play-state: paused; }
@keyframes mg-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.mg-controls { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; margin-top: 24px; }
.mg-ctl { background: none; border: none; border-bottom: 1px solid currentColor; padding: 4px 0; font-family: var(--font); font-size: 14px; color: var(--ink); cursor: pointer; }
.mg-ctl:hover { opacity: .55; }
.mg-enter { margin-left: auto; padding: 14px 22px; }
.mg-enter[hidden] { display: none; }

@media (max-width: 760px) {
  .mg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; }
  .mg[open] { grid-template-columns: 1fr; grid-template-rows: 40dvh minmax(0, 1fr); }
  .mg-stage { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px; }
  .mg-figure { height: 100%; }
  .mg-content { padding: 16px 20px 20px; }
  .mg-intro { display: none; }
  .mg-head { margin-bottom: 0; }
  .mg-panels { padding: 8px 0 16px; min-height: 0; }
  .mg-steps { grid-template-columns: repeat(6, 1fr); gap: 0 6px; }
  .mg-step { justify-content: center; padding: 8px 0 10px; }
  .mg-step-name { display: none; }
  .mg-controls { gap: 20px; margin-top: 16px; }
  .mg-enter { margin-left: 0; width: 100%; order: 5; }
}

@media (prefers-reduced-motion: reduce) {
  .mg[open] { animation: none; }
  .mg-reveal.is-active { animation: none; stroke-dashoffset: 0; }
  .mg-back.is-active { animation: none; opacity: .45; }
}
