/* callout.css: the callout of the blog posts (HST-304), ported from the highlighted sentence of learn (spec-op4).
   Contract of the post HTML: <div class="callout" data-callout data-helper="rama|bit"> … </div>.
   Without JavaScript the frame and the bold sentence show, already highlighted. With callout.js (class .is-live) the robot
   that peeks in on the right and the strip of flames along the bottom edge are added; the flames never cross the text.
   .is-seen plays the entrance of the robot and the highlighter once and .is-lit makes the flames rise once. .is-burning
   makes the fire flicker for about 2 seconds (two legs per layer) and then rest lit and still; callout.js puts it back
   every time the block is seen again (the AMO's choice for the blog, Ryan R-C1). Each flame layer is one static image
   (images/callout/flames-N.svg) moved with transform, so it runs on the compositor and repaints as a single item.
   prefers-reduced-motion leaves everything still and highlighted. Dark theme under html.dark, as in learn, for when the
   site has one. Own file, nothing inline. */

.callout {
    --callout-mark: #bbf7d0;
    position: relative;
    overflow: hidden;
    margin: 1.75em 0;
    padding: 14px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: rgba(148, 163, 184, .08);
}
html.dark .callout { --callout-mark: rgba(108, 191, 145, .38); border-color: #334155; }
/* Inside .prose the paragraphs bring their own margins: the frame keeps its padding as the only space. */
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout > * + * { margin-top: .75rem; }

/* The highlighter: a mint band under the lower half of the line; the text keeps its color (AA in both themes). */
.callout strong {
    background-image: linear-gradient(transparent 58%, var(--callout-mark) 58%, var(--callout-mark) 92%, transparent 92%);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* ---------- With JavaScript ----------
   The room for the robot and the flames and the undrawn highlighter come from the CSS when scripts run, not when the
   module mounts: the box measures the same before and after callout.js (no layout shift). .is-live repeats it for
   browsers without the scripting media query. */
@media (scripting: enabled) {
    .callout { padding: 14px 92px 34px 18px; }
    .callout strong { background-size: 0% 100%; }
}
.callout.is-live { padding: 14px 92px 34px 18px; }
.callout.is-live strong { background-size: 0% 100%; }

.callout-helper {
    position: absolute;
    right: 14px;
    top: calc(50% - 11px);
    width: 62px;
    height: 77px;
    margin-top: -38px;
    transform: scale(0);
    transform-origin: 50% 100%;
}
.callout-helper.is-bit { width: 66px; height: 68px; margin-top: -34px; }
.callout-helper .helper-pose { display: none; }
.callout-helper .helper-pose[data-pose~="explain"] { display: inline; }
/* Light theme: Rama gets a dark stroke on a white face; the outline of Bit, a mint that reads on white. */
html:not(.dark) .is-rama [stroke="#E8F1EC"] { stroke: #0f172a; }
html:not(.dark) .is-rama [fill="#E8F1EC"] { fill: #0f172a; }
html:not(.dark) .is-rama [fill="#0B1D2A"] { fill: #fff; }
html:not(.dark) .is-bit [stroke="#6CBF91"] { stroke: #2f8a5c; }

.callout-flames {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 22px;
    /* The image keeps its own preserveAspectRatio (xMinYMax slice): the flames sit on the bottom edge at any width. */
    background: no-repeat 0 100% / 100% 100%;
    transform-origin: 50% 100%;
    scale: 1 0;
}
.callout-flames.layer-1 { background-image: url("../images/callout/flames-1.svg?v=1"); --rise-delay: .25s; --layer-speed: .85s; --layer-delay: .8s; }
.callout-flames.layer-2 { background-image: url("../images/callout/flames-2.svg?v=1"); --rise-delay: .3s; --layer-speed: 1.1s; --layer-delay: .95s; }
.callout-flames.layer-3 { background-image: url("../images/callout/flames-3.svg?v=1"); --rise-delay: .35s; --layer-speed: 1.3s; --layer-delay: .85s; }
.callout-flames.layer-4 { background-image: url("../images/callout/flames-4.svg?v=1"); --rise-delay: .4s; --layer-speed: 1.5s; --layer-delay: 1s; }

.callout.is-seen .callout-helper { animation: callout-peek .35s cubic-bezier(.2, .7, .3, 1.3) both; }
.callout.is-seen strong { animation: callout-underline 1.3s ease-in-out .45s both; }
/* Each layer rises once (half a second, one after the other) with the scale property. While .is-burning, it also
   flickers with transform: two legs, alternate, so it ends where it started (scaleY(1), no skew) and rests still. Two
   different properties, so both animations stay on the compositor (two animations of transform on one element would not
   be). Adding .is-burning again keeps the finished rise and starts only the flicker. */
.callout.is-lit .callout-flames { animation: callout-rise .5s ease-out var(--rise-delay, .3s) both; }
.callout.is-lit.is-burning .callout-flames {
    will-change: transform;
    animation:
        callout-rise .5s ease-out var(--rise-delay, .3s) both,
        callout-flicker var(--layer-speed, 1s) ease-in-out var(--layer-delay, .8s) 2 alternate;
}
.callout.is-seen strong { background-size: 100% 100%; }
.callout.is-seen .callout-helper { transform: none; }

@keyframes callout-peek { from { transform: scale(.4) translateY(10px); } to { transform: none; } }
@keyframes callout-underline { from { background-size: 0% 100%; } to { background-size: 100% 100%; } }
@keyframes callout-rise { from { scale: 1 0; } to { scale: 1 1; } }
/* A soft loop: little amplitude and a slow pace, so it goes along with the reading without pulling the eye. */
@keyframes callout-flicker {
    0% { transform: scaleY(1) skewX(0deg); }
    50% { transform: scaleY(.9) skewX(-2deg); }
    100% { transform: scaleY(1.04) skewX(1.5deg); }
}

@media (max-width: 767px) and (scripting: enabled) {
    .callout { padding: 12px 60px 30px 14px; }
}
@media (max-width: 767px) {
    .callout.is-live { padding: 12px 60px 30px 14px; }
    .callout-flames { height: 18px; }
    .callout-helper { width: 44px; height: 55px; margin-top: -27px; right: 8px; top: calc(50% - 9px); }
    .callout-helper.is-bit { width: 46px; height: 48px; margin-top: -24px; }
}

/* Reduced motion: the robot shows, the sentence is highlighted and the flames stay low and still, with no animation. */
@media (prefers-reduced-motion: reduce) {
    .callout *, .callout *::after { animation: none !important; transition: none !important; }
    .callout strong, .callout.is-live strong { background-size: 100% 100%; }
    .callout-helper { transform: none; }
    .callout-flames { scale: 1 .3; opacity: .7; }
}

/* Windows high contrast: the frame takes the system color and the decoration hides. */
@media (forced-colors: active) {
    .callout { border-color: CanvasText; }
    .callout-helper, .callout-flames { display: none; }
}
