Transitioning from height: 0 to height: auto never worked, so everyone faked it with a large max-height. One property on the root changes that.
:root {
interpolate-size: allow-keywords;
}
.panel {
height: 0;
overflow: hidden;
transition: height 0.3s ease;
}
.panel.open {
height: auto;
}
interpolate-size: allow-keywords allows the browser to animate between a length and an intrinsic size keyword such as auto, min-content or fit-content. The property is inherited, so setting it once on :root opts in the whole page. It is opt in for backwards compatibility, so existing sites keep behaving the way they did.
It also works for a details element if you transition the ::details-content part, which is how I would build an animated accordion now.
Support is the catch. Only Chromium browsers have it (Chrome 129 and later), Safari has it in a preview and Firefox not at all. Elsewhere the panel simply opens without animation, which is fine as a fallback. If the animation matters a lot, the calc-size() function is the per property alternative, with the same support limits.
Further reading: MDN: interpolate-size