@layer reset {
  /* This would be really common to see in a reset stylesheet */
  img {
    /* This is today's enemy. */
    max-width: 100%;
    height: auto;
  }
  html {
    font: 100%/1.5 system-ui;
    background: #546e7a;
  }

  body {
    margin: 0;
  }

  main {
    min-block-size: 100dvh;
    background: white;
    max-inline-size: 60ch;
    margin-inline: auto;
    padding: 2rem;
  }
}

@layer demo-setup {
  figure {
    border: 2px solid black;
    margin-inline: auto;
    padding: 1rem;
  }
  figcaption {
    opacity: 0.75;
    font-size: small;
  }
}

/* Chef's kiss */
figure.inline-size-solution {
  inline-size: fit-content;
  margin-inline: auto;
  figcaption {
    contain: inline-size;
  }
}

.contain-solution-wrap {
  text-align: center;
}
figure.contain-solution {
  display: inline-block;
  figcaption {
    contain: inline-size;
    text-align: start;
  }
}

figure.table-solution {
  /* This works, unless, we do the common reset stylesheet thing where we set a max-width on images. */
  /* inline-size: min-content; */

  /* This is a potential design solution, but it's pretty narrow */
  /* max-inline-size: 250px; */

  /* Figure images could be excempt from max-width situation? */
  /* img {
    max-width: unset;
  } */

  display: table;

  figcaption {
    /* This is a possible design decision, but it's not quite what we're going for. */
    /* max-inline-size: 300px; */

    /* This is a fascinating solution */
    display: table-caption;
    caption-side: bottom;
    padding: 0.5rem 1rem 0 0.5rem;
  }
}

.minzero-solution-wrap {
  text-align: center;
}
figure.minzero-solution {
  display: inline-block;

  figcaption {
    /* next two lines are basically the same as contain: inline-size */
    inline-size: 0;
    min-inline-size: 100%;
    text-align: start;
  }
}
