/* =====================================================================================
   Page-builder element appearance.

   Every rule here is driven by the document in Element.strParameter10, read by
   Models/Elements/ElementStyle.cs. That class emits class names and --hb-el-* custom
   properties and nothing else; all the actual design is in this file, which is what lets
   a new preset or animation ship without touching the app, the service and the portal.

   TWO COPIES. This file is duplicated byte for byte at
   HeartBeatPortal/HeartBeatPortalBlazor/wwwroot/css/hb-elements.css so the portal's style
   builder previews the real thing rather than an imitation of it. Same arrangement as
   css/fonts.css <-> the portal's css/brand-fonts.css. Change one, change the other.

   FALLBACKS ARE THE COMPATIBILITY STORY. Every button, picture and container saved before
   the style builder existed has an empty slot, so ElementStyle emits nothing for it and
   every var() below falls through to the value that element already had. If you change a
   fallback you are changing what those elements look like, live, without anyone editing
   them. Don't.

   COLOURS COME FROM THE CLIENT. --hb-el-c1 and friends are only emitted when the author
   has deliberately taken the colours over. Otherwise the brand chain (--_b1/--_b2, used by
   the presets that are explicitly about the client's colours) resolves to the client's brand
   palette (--hb-brand-c1/c2, set by setBrandPalette) and then to the theme tokens, while the
   default chain (--_c1/--_c2) resolves to the pinned --hb-theme-* accents in app.css. Both
   flip with light and dark. See the base rule below for why the two chains differ.

   ORDER MATTERS BELOW. Custom properties resolve wherever they are used, so a preset can
   redefine --_bg from anywhere. Ordinary properties don't: presets and animations set
   real declarations that have to beat the host rules, and every one of these selectors is
   a single class. So the running order is base -> fills -> hosts -> presets -> motion.
   ===================================================================================== */


/* -------------------------------------------------------------------------------------
   Every element starts with a clean sheet of spacing.

   These properties are written into a style attribute, which means they inherit — and a
   Columns band is an element with elements inside it. Without this, a band that set its
   own gutter or its own inner padding handed both to every button in it, on top of
   whatever that button asked for, and there was no way for the button to say "not that".
   Resetting on the host div can't touch the band's own copy: that goes on .hb-container,
   which is inside this div, and a child always beats an inherited value.

   `initial` on a custom property is the guaranteed-invalid value, so every var() reading
   one of these falls through to the fallback written beside it — which is exactly the
   look an element with nothing set has always had.
   ------------------------------------------------------------------------------------- */

.hb-element {
    --hb-el-gx: initial;
    --hb-el-gy: initial;
    --hb-el-px: initial;
    --hb-el-py: initial;
}


/* -------------------------------------------------------------------------------------
   The wrappers a tappable element sits in.

   These used to live in ButtonView.razor and ImageView.razor as inline <style> blocks,
   which meant one copy per element drawn on the page. They are unchanged, only moved.

   The gutter lives out here rather than on the button because it has to sit outside the
   thing being aligned: put it on the button and a right-aligned one would push itself
   away from the very margin the padding exists to hold.

   It defaults to nothing. The page's own gutter (.content) already holds both margins, so
   a default of 16px here was a second right-hand margin stacked on the first — the element
   ended 40px from the right and 24px from the left, which is the unevenness this had.
   ------------------------------------------------------------------------------------- */

.hb-btn-wrap,
.hb-image-wrap {
    display: flex;
    padding: var(--hb-el-gy, 8px) var(--hb-el-gx, 0px) var(--hb-el-gy, 8px) 0;
}

.hb-btn-wrap.center,
.hb-image-wrap.center { justify-content: center; }

.hb-btn-wrap.right,
.hb-image-wrap.right { justify-content: flex-end; }

.hb-btn-wrap.full > .hb-btn { width: 100%; }
.hb-image-wrap.full .hb-image { width: 100%; }


/* -------------------------------------------------------------------------------------
   1. The base. Resolves every stored value — or the value the element had before there
   was anywhere to store one — into a private local. Nothing below reads --hb-el-*
   directly except where a single declaration needs it.
   ------------------------------------------------------------------------------------- */

.hb-el {
    /* THE DEFAULT CHAIN falls back to the theme's own tokens, NOT to the client's brand, and
       that is deliberate. A button with nothing set has always been theme-primary with
       theme-on-primary — a matched pair that reads correctly in both themes — and pointing this
       chain at the brand instead would repaint every button already out there, live, in a colour
       nobody asked for and with a text colour no longer matched to it.

       It reads --hb-theme-* (app.css) rather than --color-sf-* to keep that promise. It used to
       read --color-sf-primary directly, which was the same thing back when setBrandPalette only
       ever set --hb-brand-*. It no longer is: the brand is now mapped onto --color-sf-primary so
       the rest of the app follows it, and this chain would have been dragged along with it. */
    --_c1: var(--hb-el-c1, rgb(var(--hb-theme-primary)));
    --_c2: var(--hb-el-c2, rgb(var(--hb-theme-secondary)));
    --_c3: var(--hb-el-c3, var(--_c1));
    --_fg: var(--hb-el-fg, rgb(var(--hb-theme-on-primary)));
    --_bc: var(--hb-el-bc, var(--_c1));

    /* THE BRAND CHAIN is for the presets that are explicitly about the client's own colours.
       Choosing one of those is a deliberate act, so it is allowed to look like the branding;
       arriving at a button by adding one is not. */
    --_b1: var(--hb-el-c1, var(--hb-brand-c1, rgb(var(--color-sf-primary))));
    --_b2: var(--hb-el-c2, var(--hb-brand-c2, rgb(var(--color-sf-secondary))));
    --_b3: var(--hb-el-c3, var(--_b1));

    /* A fourth, for the treatments that blend rather than run between two ends — the mesh wants
       four corners of colour and a two-stop gradient hasn't got them. There is no fourth brand
       token to fall back on, so it lands on the second colour: a mesh of two colours twice over
       still moves, because what makes it move is noise at four different frequencies. */
    --_b4: var(--hb-el-c4, var(--_b2));

    /* What actually gets painted. Fill classes and presets override this one property, so
       every host below paints with var(--_bg) and never needs to know which fill is in
       play. */
    --_bg: var(--_c1);

    --_rtl: var(--hb-el-rtl, 11px);
    --_rtr: var(--hb-el-rtr, 11px);
    --_rbr: var(--hb-el-rbr, 11px);
    --_rbl: var(--hb-el-rbl, 11px);

    --_bw: var(--hb-el-bw, 0px);
    --_bs: var(--hb-el-bs, solid);

    --_fit: cover;
    --_pos: var(--hb-el-pos, center);
    --_anim-s: var(--hb-el-anim-s, 8s);

    border-radius: var(--_rtl) var(--_rtr) var(--_rbr) var(--_rbl);

    /* A styled element must not blow out the column it sits in. Same floor as the rich
       description container in the player. */
    overflow-wrap: break-word;
    min-width: 0;
}

/* Type. Untouched, an element inherits the client's fonts and moves when they change them
   on the Branding screen; --hb-el-font and friends only appear once the author has
   deliberately taken type over. */
.hb-el {
    font-family: var(--hb-el-font, inherit);
    font-weight: var(--hb-el-weight, 600);
    letter-spacing: var(--hb-el-ls, normal);
}

.hb-el-tt--uppercase { text-transform: uppercase; }
.hb-el-tt--capitalize { text-transform: capitalize; }

.hb-el-align--left { text-align: left; }
.hb-el-align--center { text-align: center; }
.hb-el-align--right { text-align: right; }

.hb-el-ar { aspect-ratio: var(--hb-el-ar); }
.hb-el-minh { min-height: var(--hb-el-minh); }
.hb-el-bordered { border: var(--_bw) var(--_bs) var(--_bc); }
.hb-el-fit--contain { --_fit: contain; }


/* -------------------------------------------------------------------------------------
   2. Fills
   ------------------------------------------------------------------------------------- */

.hb-el-fill--solid { --_bg: var(--_c1); }
.hb-el-fill--none { --_bg: transparent; }

/* An image fill still keeps a colour underneath: "contain" leaves the edges showing, and
   a picture that hasn't loaded yet should be the brand rather than a hole. */
.hb-el-fill--image { --_bg: var(--_c1); }

/* Asking for a gradient is asking for two colours, and the honest pair is the client's own —
   there is no second theme token that reads as "the other brand colour". White label, because a
   gradient dark enough to need dark text isn't one anyone builds. */
.hb-el-fill--gradient {
    --_bg: linear-gradient(var(--hb-el-ga, 135deg), var(--_b1), var(--_b2));
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
}

.hb-el-fill--gradient.hb-el-grad--radial { --_bg: radial-gradient(circle at 30% 20%, var(--_b1), var(--_b2)); }
.hb-el-fill--gradient.hb-el-grad--conic { --_bg: conic-gradient(from var(--hb-el-ga, 135deg), var(--_b1), var(--_b2), var(--_b3), var(--_b1)); }


/* -------------------------------------------------------------------------------------
   3. The two decoration layers.

   ::before is the picture, on its own so it can be scaled without dragging anything else
   with it. ::after is everything painted over the top — the scrim that makes a label
   legible against a photograph, and the moving parts of the animations, which compose as
   extra background layers rather than fighting each other for the pseudo-element.
   ------------------------------------------------------------------------------------- */

.hb-el::before,
.hb-el::after {
    border-radius: inherit;
    pointer-events: none;
}

.hb-el-has-image::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: var(--hb-el-image);
    background-size: var(--_fit);
    background-position: var(--_pos);
    background-repeat: no-repeat;
}

/* The overlay only exists when something asks for it: an empty ::after stretched over a
   container would sit on top of its children for no reason. */
.hb-el-scrim--flat::after,
.hb-el-scrim--bottom::after,
.hb-el-anim--sheen::after,
.hb-el-anim--aurora::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background-image: var(--_overlay, none);
    background-repeat: no-repeat;
}

/* A flat wash: honest and predictable over a busy photo. */
.hb-el-scrim--flat {
    --_overlay: linear-gradient(rgba(0,0,0,var(--hb-el-scrim-o, 0.32)),
                                rgba(0,0,0,var(--hb-el-scrim-o, 0.32)));
}

/* Weighted to the bottom, where the label sits — the top of the picture stays a picture.
   This is the one the tiles this feature was built for use. */
.hb-el-scrim--bottom {
    --_overlay: linear-gradient(to top,
                rgba(0,0,0,var(--hb-el-scrim-o, 0.62)) 0%,
                rgba(0,0,0,calc(var(--hb-el-scrim-o, 0.62) * 0.45)) 45%,
                rgba(0,0,0,0) 85%);
}

.hb-el-scrim--none { --_overlay: none; }

/* Anything the element actually contains has to clear both layers. */
.hb-el > * { position: relative; z-index: 2; }

/* Except the mesh canvas, which is a third decoration layer that happens to be a real element
   rather than a pseudo-one — WebGL has to paint into something the DOM can hold. It sits where
   ::before would, underneath the scrim and underneath the label.

   Two classes and an element name, so it beats the rule above without !important. */
.hb-el > canvas.hb-el-mesh {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    pointer-events: none;
    /* Fades up as the first frame lands. Before that the CSS treatment underneath is what's on
       screen, and cutting straight from one to the other is a visible flash on every page load. */
    opacity: 0;
    transition: opacity 420ms ease;
}

.hb-el > canvas.hb-el-mesh.isLoaded { opacity: 1; }


/* -------------------------------------------------------------------------------------
   4. The hosts that paint with all of the above.

   These come before the presets and the animations on purpose: those set real
   declarations — a border, an overflow, a whole background-image stack — that have to
   beat what a host sets, and every selector involved is one class deep.
   ------------------------------------------------------------------------------------- */

.hb-btn {
    position: relative;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: var(--hb-el-py, 11px) var(--hb-el-px, 22px);
    border: none;
    cursor: pointer;
    background: var(--_bg);
    color: var(--_fg);
    text-align: center;
    font-size: var(--hb-el-size, inherit);
    /* Never wider than the column it lands in, whatever the label says. */
    max-width: 100%;
}

/* With a picture behind it the label needs its own contrast: what's underneath is a
   photo, not a colour the theme controls. Unchanged from the original ButtonView. */
.hb-btn.hb-el-has-image {
    color: var(--hb-el-fg, #fff);
    text-shadow: 0 1px 3px rgba(0,0,0,0.55);
    min-height: var(--hb-el-minh, 92px);
}

.hb-btn-label {
    position: relative;
    z-index: 2;
}

/* color: inherit, said out loud: MiniPlayerComponent's unscoped style paints every span the
   theme's on-surface colour, and the form page does the same to its own spans
   (.formfill-page span), which put a near-black label on a coloured button in the light theme
   and a pale one on the dark theme's lilac. Scoped under .hb-btn so it outweighs both; the
   shine animation's transparent label, later in this file at the same weight, still wins. */
.hb-btn .hb-btn-label,
.hb-btn .hb-btn-sub,
.hb-btn .hb-btn-divider {
    color: inherit;
}

.hb-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--_rtl) var(--_rtr) var(--_rbr) var(--_rbl);
    object-fit: var(--_fit);
    object-position: var(--_pos);
}

/* Once a picture is given a shape of its own it stops being "an image at its natural
   size" and becomes a tile, so it fills what it was given. */
.hb-image.hb-el-ar,
.hb-image.hb-el-minh { width: 100%; height: 100%; }

.hb-image.tappable { cursor: pointer; }

/* A container only gets a background once someone asks for one — an unstyled Columns
   block is a layout, not a panel, and always has been. */
.hb-container.hb-el-fill--solid,
.hb-container.hb-el-fill--gradient,
.hb-container.hb-el-fill--image,
.hb-container.hb-el--glass,
.hb-container.hb-el--ghost,
.hb-container.hb-el--neon {
    background: var(--_bg);
    padding: var(--hb-el-py, 14px) var(--hb-el-px, 14px);
    position: relative;
    /* A painted band runs to both edges unless it is told otherwise, which is what it has always
       done and usually what a band of colour wants. Its gutter has to be margin, not padding —
       padding here is the space between the panel's edge and the columns inside it. */
    margin: var(--hb-el-gy, 0px) var(--hb-el-gx, 0px) var(--hb-el-gy, 0px) 0;
}


/* -------------------------------------------------------------------------------------
   5. Shadows
   ------------------------------------------------------------------------------------- */

.hb-el-shadow--soft { box-shadow: 0 2px 6px rgba(0,0,0,0.16); }

/* The same pair the media cards use, so a styled tile sits at the same depth as the rest
   of the page rather than inventing its own. */
.hb-el-shadow--lift { box-shadow: 0 4px 8px rgba(0,0,0,0.2), 0 6px 20px rgba(0,0,0,0.19); }

.hb-el-shadow--glow {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--_c1) 55%, transparent),
                0 0 18px color-mix(in srgb, var(--_c1) 45%, transparent);
}


/* -------------------------------------------------------------------------------------
   6. Presets.

   A starting point, not a lock: each one only changes the fallback in a chain, so anything
   the author then sets by hand still wins.

   Every preset except "photo" is built out of the client's own colours and ships with the
   branding switches left on, so applying one can never be the thing that breaks a rebrand.
   "photo" pins its label to white because what sits behind it is a photograph, which is
   not something the theme has any control over — the same reasoning the original
   .hb-btn.has-image rule was written with.
   ------------------------------------------------------------------------------------- */

.hb-el--solid { /* the look every button had before this file existed */ }

.hb-el--photo {
    --_rtl: var(--hb-el-rtl, 14px);
    --_rtr: var(--hb-el-rtr, 14px);
    --_rbr: var(--hb-el-rbr, 14px);
    --_rbl: var(--hb-el-rbl, 14px);
    --_fg: var(--hb-el-fg, #fff);
    overflow: hidden;
    color: var(--hb-el-fg, #fff);
    font-weight: var(--hb-el-weight, 800);
    text-shadow: 0 1px 3px rgba(0,0,0,0.55);
    align-items: flex-end;
    padding: var(--hb-el-py, 14px) var(--hb-el-px, 16px);
    line-height: 1.1;
}

/* A photo tile puts its label along the bottom of the picture, so the alignment classes
   go back to meaning left/centre/right rather than the pill's single centred label. */
.hb-el--photo.hb-btn { justify-content: flex-start; }
.hb-el--photo.hb-el-align--center.hb-btn { justify-content: center; }
.hb-el--photo.hb-el-align--right.hb-btn { justify-content: flex-end; }

/* The three below paint from the brand chain and take their text colour from the same value, so
   the label contrasts against the page rather than against a fill that isn't there. */
.hb-el--outline {
    --_bg: transparent;
    --_fg: var(--hb-el-fg, var(--_b1));
    --_bc: var(--hb-el-bc, var(--_b1));
    color: var(--_fg);
    border: var(--hb-el-bw, 2px) var(--_bs) var(--_bc);
}

.hb-el--ghost {
    --_bg: color-mix(in srgb, var(--_b1) 12%, transparent);
    --_fg: var(--hb-el-fg, var(--_b1));
    color: var(--_fg);
}

.hb-el--gradient {
    --_bg: linear-gradient(var(--hb-el-ga, 135deg), var(--_b1), var(--_b2));
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
}

/* Frosted, the same idea as the app bar. backdrop-filter needs the -webkit- prefix in
   WKWebView; where it isn't supported at all the @supports block leaves a plain
   translucent surface, which still reads correctly in both themes. */
.hb-el--glass {
    --_bg: color-mix(in srgb, rgb(var(--color-sf-surface-variant)) 55%, transparent);
    --_fg: var(--hb-el-fg, rgb(var(--color-sf-on-surface)));
    color: var(--_fg);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    border: var(--hb-el-bw, 1px) var(--_bs) color-mix(in srgb, rgb(var(--color-sf-on-surface)) 18%, transparent);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .hb-el--glass { --_bg: color-mix(in srgb, rgb(var(--color-sf-surface-variant)) 88%, transparent); }
}

.hb-el--neon {
    --_bg: color-mix(in srgb, rgb(var(--color-sf-background)) 88%, var(--_b1));
    --_fg: var(--hb-el-fg, var(--_b1));
    --_bc: var(--hb-el-bc, var(--_b1));
    color: var(--_fg);
    border: var(--hb-el-bw, 1.5px) var(--_bs) var(--_bc);
    box-shadow: 0 0 12px color-mix(in srgb, var(--_b1) 45%, transparent),
                inset 0 0 12px color-mix(in srgb, var(--_b1) 18%, transparent);
}


/* -------------------------------------------------------------------------------------
   7. Motion.

   Deliberately no @property-registered custom properties for interpolating gradient
   stops: support is too recent for the oldest WebView this app runs in, and an animation
   that silently does nothing on someone's phone is worse than one built the long way.
   Everything below animates background-position, transform or box-shadow, which have
   worked everywhere for years.

   Every one of these is switched off under prefers-reduced-motion at the end of the
   section. That is not optional here — it is how every other animation in this app
   behaves, and a page built entirely out of animated tiles is exactly the page that
   setting exists for.
   ------------------------------------------------------------------------------------- */

/* EVERYTHING THAT PAINTS INTO A PSEUDO-ELEMENT NEEDS THE ELEMENT ITSELF TO BE WHAT THAT
   PSEUDO-ELEMENT MEASURES AGAINST — and this is the whole list, not most of it.

   `position: absolute; inset: 0` resolves against the nearest POSITIONED ancestor. A button and
   a painted panel are already positioned; a node that has only been given a scrim, or only a
   picture, is not — and its overlay then stretches to whatever ancestor happens to be positioned,
   which in a page with none is the page. That is a full-screen black gradient with
   pointer-events: none over the entire app: everything still works, everything looks dimmed, and
   nothing in the styling of the element it came from suggests where to look.

   The animations were on this list from the start. The scrim and the picture were not, because
   until the appearance became universal they only ever appeared on hosts that were positioned for
   other reasons. Any new class that paints into ::before or ::after belongs here on the same day
   it is written. */
.hb-el-scrim--flat,
.hb-el-scrim--bottom,
.hb-el-has-image,
.hb-el-anim--sheen,
.hb-el-anim--aurora,
.hb-el-anim--ken-burns,
.hb-el-anim--sweep,
.hb-el-anim--stripe { position: relative; }

/* A gradient slowly drifting across the element. Oversized so there is somewhere to drift
   to, and five stops so the loop doesn't visibly snap. */
.hb-el-anim--gradient-drift {
    --_bg: linear-gradient(var(--hb-el-ga, 120deg), var(--_b1), var(--_b2), var(--_b3), var(--_b2), var(--_b1));
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
    background-size: 300% 300%;
    animation: hb-el-drift var(--_anim-s) ease-in-out infinite;
}

@keyframes hb-el-drift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* A highlight passing over, like light across glass. It composes with the scrim because
   it is a second background layer on the same overlay rather than a second overlay. */
.hb-el-anim--sheen::after {
    background-image: var(--_overlay, none),
                      linear-gradient(105deg, transparent 38%, rgba(255,255,255,0.34) 50%, transparent 62%);
    background-size: auto, 220% 100%;
    animation: hb-el-sheen var(--_anim-s) ease-in-out infinite;
}

@keyframes hb-el-sheen {
    0% { background-position: 0 0, -120% 0; }
    /* The pause is the point: a highlight crossing every few seconds reads as a surface,
       one crossing continuously reads as a progress bar. */
    55%, 100% { background-position: 0 0, 220% 0; }
}

/* Colour drifting under the surface, the same idea as the aurora treatment in app.css. */
.hb-el-anim--aurora::after {
    background-image: var(--_overlay, none),
                      radial-gradient(40% 60% at 20% 30%, color-mix(in srgb, var(--_b2) 55%, transparent), transparent 70%),
                      radial-gradient(45% 55% at 80% 70%, color-mix(in srgb, var(--_b3) 50%, transparent), transparent 70%);
    background-size: auto, 160% 160%, 160% 160%;
    animation: hb-el-aurora var(--_anim-s) ease-in-out infinite alternate;
}

@keyframes hb-el-aurora {
    0% { background-position: 0 0, 0% 0%, 100% 100%; }
    100% { background-position: 0 0, 60% 40%, 30% 20%; }
}

.hb-el-anim--pulse { animation: hb-el-pulse var(--_anim-s) ease-in-out infinite; }

@keyframes hb-el-pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--_c1) 45%, transparent); }
    50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--_c1) 0%, transparent); }
}

/* A lit edge travelling round. Painted as two layers clipped to different boxes — the
   interior to the padding box, the moving gradient to the border box — so the border is
   the only part the second one shows through. A conic gradient rotated with @property is
   the obvious way to do this, and is the reason this isn't done that way. Note that it
   takes the fill over: the interior becomes the page's own background tinted with the
   first colour, which is what makes the edge read as lit. */
.hb-el-anim--border-glow {
    --_glow-in: color-mix(in srgb, rgb(var(--color-sf-background)) 82%, var(--_b1));
    /* The interior is the page's own background, so the label has to be the colour that reads
       against a page rather than the one that reads against a filled button. Without this it
       inherits on-primary and comes out white on near-white in a light theme. */
    color: var(--hb-el-fg, rgb(var(--color-sf-on-surface)));
    border: var(--hb-el-bw, 2px) solid transparent;
    background-image: linear-gradient(var(--_glow-in), var(--_glow-in)),
                      linear-gradient(90deg, var(--_b1), var(--_b2), var(--_b3), var(--_b2), var(--_b1));
    background-clip: padding-box, border-box;
    background-origin: padding-box, border-box;
    background-size: auto, 300% 100%;
    background-repeat: no-repeat;
    animation: hb-el-edge var(--_anim-s) linear infinite;
}

@keyframes hb-el-edge {
    from { background-position: 0 0, 0% 50%; }
    to { background-position: 0 0, 300% 50%; }
}

/* Slow push into the picture. On ::before, so the scrim and the label stay still. */
.hb-el-anim--ken-burns { overflow: hidden; }

.hb-el-anim--ken-burns::before {
    transform-origin: center;
    animation: hb-el-ken var(--_anim-s) ease-in-out infinite alternate;
}

@keyframes hb-el-ken {
    from { transform: scale(1); }
    to { transform: scale(1.12); }
}

.hb-el-anim--float { animation: hb-el-float var(--_anim-s) ease-in-out infinite; }

@keyframes hb-el-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* The four-corner loop: the gradient travels round the element rather than back and forth, so
   there is no point where it visibly reverses. Bigger and slower than the drift, and the one
   people mean when they say "animated gradient". */
.hb-el-anim--gradient-wave {
    --_bg: linear-gradient(var(--hb-el-ga, 110deg), var(--_b1), var(--_b2), var(--_b3), var(--_b1), var(--_b2));
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
    background-size: 400% 400%;
    animation: hb-el-wave var(--_anim-s) ease-in-out infinite;
}

@keyframes hb-el-wave {
    0% { background-position: 0% 50%; }
    25% { background-position: 50% 0%; }
    50% { background-position: 100% 50%; }
    75% { background-position: 50% 100%; }
    100% { background-position: 0% 50%; }
}

/* A conic gradient turning behind the element — the spinning-gradient look.
   On ::before rather than ::after, which costs it the background picture but keeps the scrim:
   of the two, the scrim is the one a label depends on to stay readable. The pseudo-element is
   oversized so its corners never swing into view as it turns. */
.hb-el-anim--sweep {
    overflow: hidden;
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
    position: relative;
}

.hb-el-anim--sweep::before {
    content: "";
    position: absolute;
    inset: -75%;
    z-index: 0;
    border-radius: 0;
    background-image: conic-gradient(from 0deg, var(--_b1), var(--_b2), var(--_b3), var(--_b2), var(--_b1));
    animation: hb-el-sweep var(--_anim-s) linear infinite;
}

@keyframes hb-el-sweep {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* The flowing mesh — the treatment Stripe's home page made everyone want.

   THIS ONE IS TWO IMPLEMENTATIONS. The real thing is WebGL: four colours blended across a plane
   deformed by simplex noise, which is Stripe's own code, vendored at src/meshGradient.js. That
   script finds the <canvas class="hb-el-mesh"> the renderer puts inside the element and takes
   over, marking the element .hb-mesh-live when it does.

   What follows is the other implementation, and it is not a placeholder — it is what is on
   screen whenever the real one isn't, which is more often than you would think: no WebGL at
   all, a page already running its four contexts, or an element that never scrolled into view.
   Four big soft colour clouds, blown up well past the element so no cloud edge reaches a
   corner, blurred until the shapes stop being shapes, and blended into the fill underneath
   rather than laid on top of it.

   On ::before, so it costs the background picture and keeps the scrim — of the two, the scrim
   is the one a label depends on to stay readable. `isolation` on the host confines the blend to
   this element; without it hard-light reaches through to whatever the element is sitting on. */
.hb-el-anim--stripe {
    --_bg: linear-gradient(var(--hb-el-ga, 135deg), var(--_b1), var(--_b2));
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
    overflow: hidden;
    isolation: isolate;
}

.hb-el-anim--stripe::before {
    content: "";
    position: absolute;
    inset: -45%;
    z-index: 0;
    border-radius: 0;
    background-image: radial-gradient(circle at 50% 50%, var(--_b2) 0%, transparent 48%),
                      radial-gradient(circle at 50% 50%, var(--_b3) 0%, transparent 44%),
                      radial-gradient(circle at 50% 50%, var(--_b1) 0%, transparent 50%),
                      radial-gradient(circle at 50% 50%, var(--_b2) 0%, transparent 42%);
    background-size: 95% 95%, 80% 80%, 105% 105%, 88% 88%;
    background-repeat: no-repeat;
    filter: blur(26px) saturate(170%);
    mix-blend-mode: hard-light;
    animation: hb-el-stripe var(--_anim-s) ease-in-out infinite alternate;
}

/* Four paths that never repeat together, which is the whole trick — equal paths would read as
   one shape wobbling. `alternate` means the loop has no seam to hide. */
@keyframes hb-el-stripe {
    0% { background-position: 0% 0%, 100% 0%, 50% 100%, 0% 100%; }
    50% { background-position: 65% 45%, 15% 65%, 5% 15%, 85% 25%; }
    100% { background-position: 25% 90%, 75% 95%, 95% 5%, 35% 55%; }
}

/* Where hard-light isn't supported the clouds would sit on the fill as flat colour, which is
   both wrong and worse than the gradient alone. Softened rather than dropped. */
@supports not (mix-blend-mode: hard-light) {
    .hb-el-anim--stripe::before { opacity: 0.7; }
}

/* The four colours the WebGL mesh actually paints with, handed over as the property names that
   script reads. It resolves them off the canvas's own computed style, so this is the entire
   interface between the two halves: the same brand chain everything else on the element uses,
   under different names.

   THE LITERAL FALLBACKS ARE LOAD-BEARING, and they are the one place in this file where a colour
   is written out rather than resolved. The brand chain ends at rgb(var(--color-sf-primary)), and a
   var() with no fallback pointing at a property that isn't defined makes the whole declaration
   invalid — not wrong, *empty*. Every other rule here survives that by falling back to a plain CSS
   value, but this one is read by a script that needs four real colours or it has no shader to
   build. So if the theme tokens aren't present where this element sits, these are what it paints
   with: Material 3's own primary and secondary, which is what the tokens would have said. */
.hb-el-anim--stripe > .hb-el-mesh {
    --gradient-color-1: var(--_b1, #6750a4);
    --gradient-color-2: var(--_b2, #625b71);
    --gradient-color-3: var(--_b3, #6750a4);
    --gradient-color-4: var(--_b4, #625b71);
}

/* Once the canvas is up it covers the element completely and opaquely, so the cloud layer below
   is invisible — and a 26px blur nobody can see is the most expensive thing on the page. The
   delay lets the canvas finish fading in first, so the two never cross while both are partly
   transparent. */
.hb-el-anim--stripe.hb-mesh-live::before {
    opacity: 0;
    transition: opacity 420ms ease 200ms;
    animation-play-state: paused;
}

/* A gradient flowing across, slowly, through five colours with no seam — the wide, deep,
   unhurried one. Six hundred percent is what makes it that: the gradient is so much larger than
   the element that only a small window of it is on screen at a time, so what you see is colours
   arriving rather than a gradient sliding. Repeating the first colour last is what closes the
   loop invisibly, and the uneven keyframe spacing is what stops it reading as a metronome.

   The inset shadow is not decoration. It is what makes this a lit surface rather than a flat
   fill, and without it the whole thing looks like a screensaver. */
.hb-el-anim--gradient-flow {
    --_bg: linear-gradient(to right, var(--_b1), var(--_b2), var(--_b3), var(--_b4), var(--_b1));
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
    background-size: 600% 100%;
    background-position: 0 0;
    box-shadow: inset 0 0 5em rgba(0, 0, 0, 0.5);
    /* Not --_anim-s. Its eight seconds is right for a highlight crossing a button and far too
       quick for this, where the whole point is that you notice it changed rather than watch it
       change. An author who sets a speed still wins; leaving it alone gets twenty. */
    animation: hb-el-flow var(--hb-el-anim-s, 20s) ease infinite;
}

@keyframes hb-el-flow {
    0% { background-position: 0 0; }
    25% { background-position: 50% 0; }
    50% { background-position: 90% 0; }
    60% { background-position: 60% 0; }
    75% { background-position: 40% 0; }
    100% { background-position: 0 0; }
}

/* Colour cycling all the way round the wheel. The cheapest big effect there is, and the only
   one that also carries a background photograph with it. Applied to the element, so the label
   turns with it — which is why the label is pinned to white: white has no hue to rotate. */
.hb-el-anim--hue-cycle {
    --_bg: linear-gradient(var(--hb-el-ga, 135deg), var(--_b1), var(--_b2), var(--_b3));
    --_fg: var(--hb-el-fg, #fff);
    color: var(--_fg);
    background-size: 200% 200%;
    animation: hb-el-hue var(--_anim-s) linear infinite;
}

@keyframes hb-el-hue {
    from { filter: hue-rotate(0deg); }
    to { filter: hue-rotate(360deg); }
}

/* The words themselves are the gradient, with a highlight travelling through them. Buttons
   only — it needs a run of text to clip to, and a picture or a column band hasn't got one. */
.hb-el-anim--shine .hb-btn-label {
    background-image: linear-gradient(100deg,
                      var(--_fg) 25%, #ffffff 42%, var(--_b2) 55%, var(--_fg) 72%);
    background-size: 250% 100%;
    background-repeat: no-repeat;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    animation: hb-el-shine var(--_anim-s) linear infinite;
}

@keyframes hb-el-shine {
    from { background-position: 200% 0; }
    to { background-position: -60% 0; }
}

/* ---------------------------------------------------------------------------------------
   Standing still, and the one place that is allowed to override it.

   Pausing rather than removing. "animation: none" would drop back to the element's own
   declarations, which for the sheen means its highlight parked across the middle of the
   button; frame zero of each loop is the still image these were designed around. It also
   leaves one custom property as the single switch, which is what lets the portal's style
   builder turn motion back on inside its preview pane — an author who has asked their own
   computer for less motion still has to be able to see what they are choosing for everybody
   else. Nothing in the app ever sets it.

   This rule has to stay below every `animation:` shorthand above, or the shorthand resets the
   play state straight back to running.
   --------------------------------------------------------------------------------------- */

.hb-el,
.hb-el::before,
.hb-el::after,
.hb-el .hb-btn-label { animation-play-state: var(--_play, running); }

@media (prefers-reduced-motion: reduce) {
    .hb-el { --_play: paused; }

    .hb-el,
    .hb-el::before,
    .hb-el::after {
        transition: none !important;
    }
}


/* -------------------------------------------------------------------------------------
   8. Hover and press.

   Hover is a mouse idea; on a phone the same rules fire on tap and then stick, which is
   why they sit behind (hover: hover). The press response applies everywhere.
   ------------------------------------------------------------------------------------- */

.hb-el-hover--lift,
.hb-el-hover--brighten,
.hb-el-hover--zoom { transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease; }

.hb-el-hover--zoom::before { transition: transform 260ms ease; }

@media (hover: hover) {
    .hb-el-hover--lift:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(0,0,0,0.28); }
    .hb-el-hover--brighten:hover { filter: brightness(1.12); }
    .hb-el-hover--zoom:hover::before { transform: scale(1.06); }
}

.hb-el-hover--lift:active { transform: translateY(0); }


/* =====================================================================================
   Designed blocks (the GrapesJS element).

   .hb-richhtml is the container. The design's own stylesheet is scoped to this class at
   render time and injected after this file, so it wins wherever the two overlap — these
   rules are only a floor for what a design doesn't set.
   ===================================================================================== */

.hb-richhtml {
    line-height: 1.5;
    overflow-wrap: break-word;
    /* Not "inherit": the body colour underneath is Bootstrap's near-black in both themes,
       so a design that inherited would be unreadable in dark. */
    color: rgb(var(--color-sf-on-surface));
    font-family: var(--hb-font-body, inherit);
    /* No side padding by default, like every other home element: the page's edges are set by
       the media list and a block that inset itself would sit out of line with it.

       This block has no inner and outer to tell apart — it is the box AND its contents —
       so what it takes is the gutter, and px/py stay in the chain underneath because that
       is what drove this padding before the gutter existed. A block saved back then keeps
       exactly the spacing it has; setting the gutter takes over from it. */
    padding: var(--hb-el-gy, var(--hb-el-py, 10px))
             var(--hb-el-gx, var(--hb-el-px, 0px))
             var(--hb-el-gy, var(--hb-el-py, 10px)) 0;
}

/* Off when the author has taken type over, so their own stack stands. */
.hb-richhtml.hb-rt-own-type,
.hb-richhtml.hb-rt-own-type h1,
.hb-richhtml.hb-rt-own-type h2,
.hb-richhtml.hb-rt-own-type h3,
.hb-richhtml.hb-rt-own-type h4 { font-family: inherit; }

.hb-richhtml h1,
.hb-richhtml h2,
.hb-richhtml h3,
.hb-richhtml h4 {
    font-family: var(--hb-font-heading, inherit);
    color: rgb(var(--color-sf-on-surface));
}

.hb-richhtml img,
.hb-richhtml video,
.hb-richhtml iframe,
.hb-richhtml canvas,
.hb-richhtml svg { max-width: 100%; height: auto; }

.hb-richhtml table,
.hb-richhtml pre { display: block; max-width: 100%; overflow-x: auto; }

.hb-richhtml a { color: rgb(var(--color-sf-primary)); }


/* -------------------------------------------------------------------------------------
   The block palette the designer offers.

   A design assembled from these flips between light and dark for free, because not one of
   them names a colour — they are all expressed through the theme's tokens and the client's
   brand. A hand-picked hex in the designer stays the author's own risk, and the dialog
   says so.
   ------------------------------------------------------------------------------------- */

.hb-rt-h { margin: 0 0 8px; font-family: var(--hb-font-heading, inherit); font-weight: 700; color: rgb(var(--color-sf-on-surface)); }
.hb-rt-p { margin: 0 0 12px; color: rgb(var(--color-sf-on-surface)); }
.hb-rt-muted { color: rgb(var(--color-sf-on-surface)); opacity: 0.75; }

.hb-rt-card {
    padding: 16px;
    border-radius: 12px;
    background: color-mix(in srgb, rgb(var(--color-sf-on-surface)) 6%, transparent);
    border: 1px solid color-mix(in srgb, rgb(var(--color-sf-on-surface)) 14%, transparent);
}

.hb-rt-callout {
    padding: 14px 16px;
    border-radius: 10px;
    border-left: 4px solid var(--hb-brand-c1, rgb(var(--color-sf-primary)));
    background: color-mix(in srgb, var(--hb-brand-c1, rgb(var(--color-sf-primary))) 8%, transparent);
}

.hb-rt-divider {
    height: 1px;
    border: 0;
    margin: 18px 0;
    background: color-mix(in srgb, rgb(var(--color-sf-on-surface)) 18%, transparent);
}

/* Scoped to the container, not left as a bare class: .hb-richhtml a above is a class plus an
   element and would otherwise out-specify it, painting the button's label link-coloured. */
.hb-richhtml .hb-rt-btn,
.hb-rt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 11px;
    font-weight: 600;
    text-decoration: none;
    background: var(--hb-brand-c1, rgb(var(--color-sf-primary)));
    color: rgb(var(--color-sf-on-primary));
}

.hb-rt-cols {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
    align-items: start;
}


/* -------------------------------------------------------------------------------------
   Height across screens.

   Late in the file on purpose. Everything above — the hosts, the presets, the animations —
   is one or two classes deep and several of them state a height of their own
   (.hb-btn's 46px floor, .hb-btn.hb-el-has-image's 92px, .hb-image's height:auto). An
   author who has said "this band is 180px tall" has to win over all of them, and winning
   on source order is cheaper than a specificity war spelled out selector by selector.

   WIDTH IS NOT HERE. It is flex-basis on the node, in section 10, and it is the only
   answer to the question — the twelfths that used to live here were the second one, and
   which of the two won depended on the element type.

   Phone first: the bare rule is the phone, md takes over at 768px, lg at 992px, and each
   falls back to the one below through the var() chain rather than through three copies of
   the same number in the stored document.

   These are viewport queries, not container queries — same as Bootstrap. A node inside a
   narrow stack is still asking about the screen, not about its column.
   ------------------------------------------------------------------------------------- */

/* The resolved value, kept as a local so the declarations below can be written once each
   however many selectors have to carry them.

   The chain bottoms out at `auto`: a height set only for the desktop must leave the phone
   exactly as it was, and "as it was" is as tall as the content. */
.hb-el.hb-el-h--fixed,
.hb-el.hb-el-h--min { --_h: var(--hb-el-h, auto); }

@media (min-width: 768px) {
    .hb-el.hb-el-h--fixed,
    .hb-el.hb-el-h--min { --_h: var(--hb-el-h-md, var(--hb-el-h, auto)); }
}

@media (min-width: 992px) {
    .hb-el.hb-el-h--fixed,
    .hb-el.hb-el-h--min { --_h: var(--hb-el-h-lg, var(--hb-el-h-md, var(--hb-el-h, auto))); }
}

/* Exactly this tall — the one that makes a row of tiles line up whatever is in them. The
   min-height reset is what lets a fixed height go below a host's own floor; without it a
   120px button would still be the 46px floor's height plus whatever it grew to. */
.hb-el.hb-el-h--fixed {
    height: var(--_h);
    min-height: 0;
}

/* At least this tall, and taller if the content needs it. */
.hb-el.hb-el-h--min { min-height: var(--_h); }

/* Once a picture is given a height of its own it stops being "an image at its natural
   size" and becomes a tile, exactly as an aspect ratio already made it one. */
.hb-image.hb-el-h--fixed,
.hb-image.hb-el-h--min { width: 100%; }

.hb-image.hb-el-h--fixed { object-fit: var(--_fit); }


/* -------------------------------------------------------------------------------------
   9. A second line on a button.

   The words are a parameter slot; the arrangement is here. A button without one carries
   none of these classes and is untouched by every rule below, which is what keeps the
   ones already out there exactly as they are.

   Markup order is always label, rule, subtitle. Which of the four sides the subtitle
   lands on is decided by the flex direction alone, and the rule between them is a real
   element rather than a border on one of the two — that is what lets a single set of
   styles serve a horizontal rule and a vertical one, and what keeps the rule out of the
   way when there isn't one.

   After the size rules, because a two-line button changes what .hb-btn's own
   `align-items: center` was doing and has to win over it.
   ------------------------------------------------------------------------------------- */

.hb-btn.hb-el-sub {
    display: inline-flex;
    /* Not the label's line-height: the two lines are one block and want to read as one,
       so the gap is deliberate and small, and the rule sits in the middle of it. */
    gap: var(--hb-el-subgap, 6px);
}

.hb-btn.hb-el-sub--bottom { flex-direction: column; }
.hb-btn.hb-el-sub--top { flex-direction: column-reverse; }
.hb-btn.hb-el-sub--right { flex-direction: row; }
.hb-btn.hb-el-sub--left { flex-direction: row-reverse; }

/* Stacked, the two lines centre on each other by default and follow the alignment classes
   when one has been chosen — the same left/centre/right the single-line button uses, which
   on a column means the cross axis rather than the main one. */
.hb-btn.hb-el-sub--bottom,
.hb-btn.hb-el-sub--top { align-items: center; }

.hb-btn.hb-el-sub--bottom.hb-el-align--left,
.hb-btn.hb-el-sub--top.hb-el-align--left { align-items: flex-start; }

.hb-btn.hb-el-sub--bottom.hb-el-align--right,
.hb-btn.hb-el-sub--top.hb-el-align--right { align-items: flex-end; }

/* Side by side, the pair centres as a group and each line keeps its own baseline area.
   A little more air than the stacked case: a vertical rule with 6px either side reads as
   crowding rather than as separation. */
.hb-btn.hb-el-sub--left,
.hb-btn.hb-el-sub--right {
    align-items: center;
    gap: var(--hb-el-subgap, 10px);
}

/* The subtitle itself. Smaller and quieter than the label, in em and in currentColor, so
   it follows whatever the label was given — a hand-picked ink, a photo tile's white, a
   preset's own colour — without any of them having to know it exists. */
.hb-btn-sub {
    position: relative;
    z-index: 2;
    font-size: var(--hb-el-subsize, 0.78em);
    font-weight: var(--hb-el-subweight, 400);
    line-height: 1.3;
    opacity: var(--hb-el-subo, 0.82);
    /* The label may be uppercased or tracked out; the second line rarely wants either. */
    text-transform: none;
    letter-spacing: normal;
}

/* The rule.

   Its colour resolves to the label's own at 38% when nothing has been picked, which is why
   this works in both themes, over a photograph and inside every preset without a single
   one of them naming a colour for it. */
.hb-btn-divider {
    position: relative;
    z-index: 2;
    flex: none;
    align-self: stretch;
    border: 0 var(--_subds, solid) var(--_subdc);
    --_subdc: var(--hb-el-subdc, color-mix(in srgb, currentColor 38%, transparent));
}

/* color-mix is recent enough to be worth a floor. Without it the whole custom property is
   invalid and the rule is drawn in the initial border colour, which is the text colour at
   full strength — a hard black line across a button. */
@supports not (color: color-mix(in srgb, currentColor 38%, transparent)) {
    .hb-btn-divider { --_subdc: var(--hb-el-subdc, currentColor); opacity: 0.38; }
}

/* Which edge carries the width is the only thing that differs between the two axes. */
.hb-el-sub--bottom > .hb-btn-divider,
.hb-el-sub--top > .hb-btn-divider { border-top-width: var(--_subdw, 1px); }

.hb-el-sub--left > .hb-btn-divider,
.hb-el-sub--right > .hb-btn-divider { border-left-width: var(--_subdw, 1px); }

.hb-el-subdiv--line { --_subds: solid; --_subdw: 1px; }
.hb-el-subdiv--thick { --_subds: solid; --_subdw: 3px; }
.hb-el-subdiv--dashed { --_subds: dashed; --_subdw: 1px; }
.hb-el-subdiv--dotted { --_subds: dotted; --_subdw: 2px; }
.hb-el-subdiv--double { --_subds: double; --_subdw: 3px; }

/* A rule that fades out at both ends rather than stopping. No border at all — a gradient
   can't be a border — so it is drawn as the element's own background and given a size,
   which is also why it needs one rule per axis. */
.hb-el-subdiv--fade > .hb-btn-divider {
    border: 0;
    background-repeat: no-repeat;
}

.hb-el-sub--bottom.hb-el-subdiv--fade > .hb-btn-divider,
.hb-el-sub--top.hb-el-subdiv--fade > .hb-btn-divider {
    height: 1px;
    background-image: linear-gradient(to right, transparent, var(--_subdc), transparent);
}

.hb-el-sub--left.hb-el-subdiv--fade > .hb-btn-divider,
.hb-el-sub--right.hb-el-subdiv--fade > .hb-btn-divider {
    width: 1px;
    background-image: linear-gradient(to bottom, transparent, var(--_subdc), transparent);
}

/* A short rule centred between the two, rather than one running the whole width. The
   `align-self` is what takes it out of the stretch above; without it the length would have
   nothing to do. */
.hb-el-subdiv--short > .hb-btn-divider {
    align-self: center;
    --_subds: solid;
    --_subdw: 2px;
}

.hb-el-sub--bottom.hb-el-subdiv--short > .hb-btn-divider,
.hb-el-sub--top.hb-el-subdiv--short > .hb-btn-divider { width: var(--hb-el-subdlen, 32px); }

.hb-el-sub--left.hb-el-subdiv--short > .hb-btn-divider,
.hb-el-sub--right.hb-el-subdiv--short > .hb-btn-divider { height: var(--hb-el-subdlen, 20px); }

/* The photo tile lays its label along the bottom of the picture and pushes it to one end,
   which is the one preset a two-line button has to argue with: its `justify-content` would
   push the label and the subtitle apart to opposite ends of the tile. Held together, and
   the pair as a whole still sits where the preset put it. */
.hb-el--photo.hb-btn.hb-el-sub--bottom,
.hb-el--photo.hb-btn.hb-el-sub--top { justify-content: flex-end; }


/* ============================================================================================
   10. Stacks — the layout primitive
   ============================================================================================

   One nestable box that arranges what it holds, replacing the grid container with its fixed
   column counts, its auto-fit mode and its sideways-scrolling mode. Those were three answers to
   one question, and none of them could say "this one takes half and that one takes what's left".

   LAYOUT ONLY. Not one declaration in this section sets a colour, a font or a border. That is
   deliberate: an element's appearance resolves through two separate chains — the theme tokens
   that flip with light and dark, and the client's brand — and a layout rule that touched either
   would repaint every page that already exists. A stack decides where things go and nothing else.

   The two-step var() dance is the same one widths and heights use above: --hb-fx-* comes in from
   the document, only for the screen sizes actually set, and these rules resolve it into a private
   local per breakpoint. Writing only what was set is what keeps "unset" meaning "whatever the
   smaller screen said" — which is why the fallbacks live here rather than being filled in when
   the document is written. Change a default in this file and every page that never overrode it
   follows; fill the gaps in C# and none of them ever would. */

.hb-stack {
    display: flex;
    flex-direction: var(--_fx-dir, column);
    flex-wrap: var(--_fx-wrap, nowrap);
    justify-content: var(--_fx-justify, flex-start);
    align-items: var(--_fx-align, stretch);
    gap: var(--_fx-gap, 0px);

    /* A stack is itself something inside a stack, so it has to be allowed to be narrower than
       what it holds. Without this a long row of cards inside a column stretches its parent and
       the whole page gains a horizontal scrollbar. */
    min-width: 0;
}

.hb-stack {
    --_fx-dir: var(--hb-fx-dir, column);
    --_fx-wrap: var(--hb-fx-wrap, nowrap);
    --_fx-justify: var(--hb-fx-justify, flex-start);
    --_fx-align: var(--hb-fx-align, stretch);
    --_fx-gap: var(--hb-fx-gap, 0px);
}

@media (min-width: 768px) {
    .hb-stack {
        --_fx-dir: var(--hb-fx-dir-md, var(--hb-fx-dir, column));
        --_fx-wrap: var(--hb-fx-wrap-md, var(--hb-fx-wrap, nowrap));
        --_fx-justify: var(--hb-fx-justify-md, var(--hb-fx-justify, flex-start));
        --_fx-align: var(--hb-fx-align-md, var(--hb-fx-align, stretch));
        --_fx-gap: var(--hb-fx-gap-md, var(--hb-fx-gap, 0px));
    }
}

@media (min-width: 992px) {
    .hb-stack {
        --_fx-dir: var(--hb-fx-dir-lg, var(--hb-fx-dir-md, var(--hb-fx-dir, column)));
        --_fx-wrap: var(--hb-fx-wrap-lg, var(--hb-fx-wrap-md, var(--hb-fx-wrap, nowrap)));
        --_fx-justify: var(--hb-fx-justify-lg, var(--hb-fx-justify-md, var(--hb-fx-justify, flex-start)));
        --_fx-align: var(--hb-fx-align-lg, var(--hb-fx-align-md, var(--hb-fx-align, stretch)));
        --_fx-gap: var(--hb-fx-gap-lg, var(--hb-fx-gap-md, var(--hb-fx-gap, 0px)));
    }
}

/* One node inside a stack.

   flex-basis is the single answer to "how wide". The old model had two — a pixel width on the row
   and a twelfths width in the style document — and which one won depended on the element type.

   `auto` as the basis default means "as wide as your content", which is what an unsized thing in a
   column should be. Shrink defaults to 1, the browser's own answer, so a row that runs out of room
   squeezes rather than overflowing. */

.hb-node {
    flex-basis: var(--_it-basis, auto);
    flex-grow: var(--_it-grow, 0);
    flex-shrink: var(--_it-shrink, 1);
    align-self: var(--_it-self, auto);
    order: var(--_it-order, 0);

    /* Same reason as the stack above: a flex item's default minimum is its content, so anything
       with a wide child refuses to shrink and pushes the row off the screen. */
    min-width: 0;
}

.hb-node {
    --_it-basis: var(--hb-it-basis, auto);
    --_it-grow: var(--hb-it-grow, 0);
    --_it-shrink: var(--hb-it-shrink, 1);
    --_it-self: var(--hb-it-self, auto);
    --_it-order: var(--hb-it-order, 0);
}

@media (min-width: 768px) {
    .hb-node {
        --_it-basis: var(--hb-it-basis-md, var(--hb-it-basis, auto));
        --_it-grow: var(--hb-it-grow-md, var(--hb-it-grow, 0));
        --_it-shrink: var(--hb-it-shrink-md, var(--hb-it-shrink, 1));
        --_it-self: var(--hb-it-self-md, var(--hb-it-self, auto));
        --_it-order: var(--hb-it-order-md, var(--hb-it-order, 0));
    }
}

@media (min-width: 992px) {
    .hb-node {
        --_it-basis: var(--hb-it-basis-lg, var(--hb-it-basis-md, var(--hb-it-basis, auto)));
        --_it-grow: var(--hb-it-grow-lg, var(--hb-it-grow-md, var(--hb-it-grow, 0)));
        --_it-shrink: var(--hb-it-shrink-lg, var(--hb-it-shrink-md, var(--hb-it-shrink, 1)));
        --_it-self: var(--hb-it-self-lg, var(--hb-it-self-md, var(--hb-it-self, auto)));
        --_it-order: var(--hb-it-order-lg, var(--hb-it-order-md, var(--hb-it-order, 0)));
    }
}

/* A stack that scrolls sideways instead of wrapping — the shelf of shortcuts across the top of a
   home page. Six of them stacked is a wall that pushes everything else off the screen; in a row
   it is one line you swipe along, and the item half-showing at the edge is the only thing telling
   anyone there is more. */
.hb-stack.scrolls {
    flex-wrap: nowrap;
    overflow-x: auto;
    /* A swipe that runs off the end must stop there, not carry on into the page behind it or into
       the browser's own back gesture. */
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    /* Proximity, not mandatory: a row shorter than the screen must not be dragged back into line,
       and a half-shown item at the end is the point rather than a mistake. */
    scroll-snap-type: x proximity;
    /* This is a phone gesture on a phone-shaped app; a desktop bar does nothing a trackpad or a
       swipe doesn't already do. */
    scrollbar-width: none;
}

.hb-stack.scrolls::-webkit-scrollbar { display: none; }

.hb-stack.scrolls > .hb-node { scroll-snap-align: start; }

/* Something in a scrolling row must keep the width it asked for. Flex would otherwise shrink every
   item until they all fit, which is exactly what a row meant to overflow must not do — a shelf of
   180px shortcuts on a 390px phone would quietly become four 88px ones and never scroll.

   This redefines the private local rather than setting flex-shrink directly, so an author who did
   ask for shrinking still gets it and the per-screen chain keeps working. Setting the property
   would have overridden both. The earlier version fell back on `--_it-shrink`, which is always
   defined a few rules up, so its `0` never applied at all. */
.hb-stack.scrolls > .hb-node { --_it-shrink: var(--hb-it-shrink, 0); }

@media (min-width: 768px) {
    .hb-stack.scrolls > .hb-node { --_it-shrink: var(--hb-it-shrink-md, var(--hb-it-shrink, 0)); }
}

@media (min-width: 992px) {
    .hb-stack.scrolls > .hb-node {
        --_it-shrink: var(--hb-it-shrink-lg, var(--hb-it-shrink-md, var(--hb-it-shrink, 0)));
    }
}


/* ============================================================================================
   11. A node with an appearance
   ============================================================================================

   The appearance document used to be read by four element types out of sixteen, so twelve widgets
   ignored padding, corners, fills and the client's type controls entirely. It is the same document
   and the same classes; what changed is that every node is offered them, and the box they land on
   for a widget that isn't itself the thing being styled is the box AROUND it.

   That box is .hb-node, which is also the flex item — so a styled panel is sized by the same
   flex-basis as an unstyled one and there is still exactly one answer to "how wide".

   NOTHING HERE IS EMITTED UNLESS SOMEONE STYLED THE NODE. NodeCss.AppearanceClasses returns null
   for a node with an empty style document, so a page nobody has touched carries no .hb-el at all
   and cannot pick up the base rule's corner radius or its 600 weight by simply existing. The two
   resets below are for the case where something HAS been set — a fill, say — and the rest of the
   base rule comes along with it. */

/* A panel is painted, and given room to hold what's inside it, only once someone asks for one. An
   unstyled node is a layout, not a surface — the same rule the Columns block always followed. */
.hb-node.hb-el-fill--solid,
.hb-node.hb-el-fill--gradient,
.hb-node.hb-el-fill--image,
.hb-node.hb-el--solid,
.hb-node.hb-el--photo,
.hb-node.hb-el--outline,
.hb-node.hb-el--ghost,
.hb-node.hb-el--gradient,
.hb-node.hb-el--glass,
.hb-node.hb-el--neon {
    background: var(--_bg);
    padding: var(--hb-el-py, 14px) var(--hb-el-px, 14px);
    position: relative;
    /* The picture and the scrim are absolutely positioned layers; without this they run past the
       corners the panel was given. It is also what makes an animated fill stay inside its box. */
    overflow: hidden;
}

/* A border without a fill is a real thing to want — an outlined panel over whatever is behind it —
   so it gets the room to hold its contents without the paint. */
.hb-node.hb-el-bordered {
    padding: var(--hb-el-py, 14px) var(--hb-el-px, 14px);
    position: relative;
}

/* The gutter is margin rather than padding: padding here is the space between the panel's edge and
   the widget inside it, and both have to be sayable. Right only, for the same reason as everywhere
   else — the page's left edge is set by the column these sit in, and a node that inset itself there
   would sit out of line with everything above and below it. */
.hb-node.hb-el {
    margin: var(--hb-el-gy, 0px) var(--hb-el-gx, 0px) var(--hb-el-gy, 0px) 0;
}

/* THE TYPE RESET, and it is the one thing that would otherwise repaint a page.

   The base .hb-el rule states font-family, font-weight: 600 and letter-spacing, because it was
   written for a button — where 600 is what a label has always been. Around a row of collections it
   would quietly embolden every card title on the page. So a node that has NOT taken its type over
   hands all three back to whatever it inherits, which is the client's branding. */
.hb-node.hb-el:not(.hb-el-own-type) {
    font-family: inherit;
    font-weight: inherit;
    letter-spacing: inherit;
}

/* And a node that HAS taken it over means it for everything inside, which is the whole of what
   making this universal buys: one place to set the type on a widget that never had the control. */
.hb-node.hb-el.hb-el-own-type {
    font-size: var(--hb-el-size, inherit);
}

/* Ink is opt-in for the same reason. --_fg falls back to on-primary, which is right for a button
   painted in the primary colour and wrong for a panel that is only a background — so the colour
   applies when one was actually chosen and not before. */
.hb-node.hb-el-ink { color: var(--_fg); }


/* ============================================================================================
   12. Forms

   A form is the same document a page is — stacks, nodes, one appearance — with one more kind of
   node: a question. Everything above applies unchanged (a section with a fill is a painted
   .hb-node, a row of two half-width questions is a stack with two 50% items), so this section only
   says what the form-specific pieces look like: the card the form sits on, the questions, the
   words between them, and the messages after sending.

   Three renderers read these rules — the portal's public form page, the website embed (a trimmed
   copy in embed.css) and the app — so nothing here states a colour of its own. Inputs paint from
   the Material tokens the app already runs on; the accent follows the client's brand through the
   same chain every styled element uses.
   ============================================================================================ */

/* The card. It is the root node, so a fill/border/shadow chosen for it paints here through the
   .hb-node rules above; unstyled it is a layout and nothing more. --hb-form-max is the author's
   "widest" setting; the renderer writes it, and the fallback is the width every form had. */
.hb-form {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    max-width: var(--hb-form-max, 640px);
    margin: 0 auto;
    /* Questions are body copy, whatever weight the base .hb-el rule would hand a styled card. */
    font-weight: 400;
}

/* The card sits in the middle of whatever holds it. Two classes, and below the .hb-node.hb-el
   margin rule in section 11, so a styled card (which is a .hb-node.hb-el) keeps its auto margins
   rather than taking that rule's gutter. */
.hb-form.hb-node { margin: 0 auto; }

/* Every stack on a form has room between what it holds by default — a form is read down the page
   and questions jammed together read as one. Said as the stack's gap fallback rather than as a
   margin on each node, so two questions across a row line up (a margin on the first child only
   did not), and so an author's own gap still wins at every screen size: the same three-step chain
   as section 10, with 12px where that has 0. */
.hb-form .hb-stack { --_fx-gap: var(--hb-fx-gap, 12px); }

@media (min-width: 768px) {
    .hb-form .hb-stack { --_fx-gap: var(--hb-fx-gap-md, var(--hb-fx-gap, 12px)); }
}

@media (min-width: 992px) {
    .hb-form .hb-stack { --_fx-gap: var(--hb-fx-gap-lg, var(--hb-fx-gap-md, var(--hb-fx-gap, 12px))); }
}

/* A question: label above, box below, note under. */
.hb-ff {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.hb-ff-label {
    display: block;
    font-weight: 600;
    font-size: 0.94em;
    line-height: 1.3;
}

.hb-ff-req { opacity: 0.7; margin-left: 2px; }

.hb-ff-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: var(--hb-ff-radius, 10px);
    border: 1px solid rgba(var(--color-sf-outline), 0.5);
    background: rgb(var(--color-sf-surface-container, var(--color-sf-background)));
    color: rgb(var(--color-sf-on-surface));
    font-family: inherit;
    font-size: var(--hb-body-size, 1rem);
    font-weight: 400;
    letter-spacing: normal;
    line-height: 1.4;
    /* The browser's own look for a select on some platforms — a grey gradient — fights every card
       colour it is put on. */
    appearance: none;
    -webkit-appearance: none;
}

textarea.hb-ff-input { min-height: 96px; resize: vertical; }

select.hb-ff-input {
    padding-right: 36px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23888' d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
}

.hb-ff-input:focus {
    outline: 2px solid var(--hb-brand-c1, rgb(var(--color-sf-primary)));
    outline-offset: 0;
    border-color: transparent;
}

.hb-ff-input::placeholder { color: rgb(var(--color-sf-on-surface-variant)); opacity: 0.7; }

.hb-ff-help {
    font-size: 0.8em;
    line-height: 1.4;
    opacity: 0.72;
}

/* The box for a choice question's own "Other" answer, under the list or choices it belongs to. */
.hb-ff-other { margin-top: 8px; }

/* Two short questions side by side where there is room — a guest's first and last name on an event's form, laid
   out as a form's own "for each person" section lays them — and one under the other on a phone. Wrapping on the
   row's own width rather than the screen's, so a narrow website widget on a wide screen stacks them too. */
.hb-ff-row { display: flex; flex-wrap: wrap; gap: 12px; min-width: 0; }
.hb-ff-row > .hb-ff { flex: 1 1 220px; }

/* A section that repeats "for each person": the copies stand one under another, each titled with who it is for
   ("Adult 2"). The section's own style is the look of each copy, so a card style gives every person a card. */
.hb-repeat { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hb-repeat-item { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hb-repeat-title { margin: 0; }
/* "Adult 1: you, with the details above." — says the person filling the form in is already counted. */
.hb-repeat-you { display: flex; align-items: center; gap: 8px; font-size: 0.88em; opacity: 0.8; }
.hb-repeat-you i { color: var(--hb-brand-c1, rgb(var(--color-sf-primary))); }

/* Choices — radios, tick boxes, and the single tick box that is a question on its own. */
.hb-ff-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hb-ff-choice,
.hb-ff-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    line-height: 1.3;
}

.hb-ff-check { font-weight: 600; }

.hb-ff-choice input,
.hb-ff-check input {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--hb-brand-c1, rgb(var(--color-sf-primary)));
}

/* Words between the questions. Headings take the client's heading face, as every heading in the
   app does; a node that has taken its own type over wins through the .hb-el rules. */
.hb-fh {
    margin: 0;
    font-family: var(--hb-font-heading, inherit);
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: break-word;
}

.hb-fh--large { font-size: 1.75em; }
.hb-fh--medium { font-size: 1.35em; }
.hb-fh--small { font-size: 1.1em; }

.hb-ft {
    margin: 0;
    line-height: 1.5;
    /* Line breaks are kept exactly as typed, like the page Text widget. */
    white-space: pre-line;
    overflow-wrap: break-word;
}

.hb-fd {
    display: block;
    width: 100%;
    height: 0;
    margin: 6px 0;
    border: 0;
    border-top: 1px solid currentColor;
    opacity: 0.18;
}

/* The send button is a .hb-btn with .hb-el always on, so an unstyled one has the theme's own
   colour rather than no colour at all; the wrapper stretches it to the row it sits in. */
.hb-form .hb-btn-wrap { padding: 0; }
.hb-form .hb-btn-wrap.full > .hb-btn { width: 100%; }
.hb-btn[disabled] { opacity: 0.6; cursor: default; }

/* What is said after sending, and what is said when it could not be. */
.hb-form-msg {
    border-radius: 12px;
    padding: 12px 14px;
    line-height: 1.4;
}

.hb-form-msg--ok { background: color-mix(in srgb, var(--hb-brand-c1, rgb(var(--color-sf-primary))) 14%, transparent); }
.hb-form-msg--err { background: rgba(200, 60, 60, 0.16); }

/* The bot check sits in its own row with the same spacing as a question. */
.hb-form-captcha { display: flex; justify-content: center; margin: 6px 0; min-height: 0; }

/* In the builder's canvas a picked node shows an outline, and every node is something to click. */
.hb-form.editing .hb-node { cursor: pointer; }
.hb-form.editing .hb-node.picked { outline: 2px solid var(--hb-brand-c1, rgb(var(--color-sf-primary))); outline-offset: 2px; border-radius: 6px; }
.hb-form.editing .hb-node.hb-node-off { opacity: 0.4; }


/* =====================================================================================
   Media inside a design (the Media block of the GrapesJS editors).

   HeartBeat.PageModel.MediaEmbed writes this markup: a heading, then a row of cards that
   are links to the player. It is filled in where the design is shown (the app, the public
   pages, a website), and in the editor's canvas the same classes draw a stand-in, so what
   the author arranges is what is drawn. Nothing here names a colour: it resolves through the
   theme's tokens and the client's brand, like the rest of the designer's palette.
   ===================================================================================== */

.hb-media-embed { margin: 18px 0 14px; }

.hb-media-embed-h { margin: 0 0 10px; }

/* A row you swipe along, or a grid that wraps. */
.hb-media-embed-row {
    display: grid;
    gap: 12px;
}

.hb-media-embed--rail .hb-media-embed-row {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 64%);
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
}

.hb-media-embed--rail .hb-media-card { scroll-snap-align: start; }

@media (min-width: 640px) {
    .hb-media-embed--rail .hb-media-embed-row { grid-auto-columns: 240px; }
}

.hb-media-embed--grid .hb-media-embed-row {
    grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
}

/* One chosen item reads as a feature, not as a card in a row. */
.hb-media-embed--one .hb-media-embed-row { grid-template-columns: minmax(0, 560px); }

.hb-media-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border-radius: 12px;
    text-decoration: none;
    color: rgb(var(--color-sf-on-surface));
    background: color-mix(in srgb, rgb(var(--color-sf-on-surface)) 6%, transparent);
    border: 1px solid color-mix(in srgb, rgb(var(--color-sf-on-surface)) 14%, transparent);
}

.hb-media-card:hover,
.hb-media-card:focus-visible {
    border-color: color-mix(in srgb, var(--hb-brand-c1, rgb(var(--color-sf-primary))) 55%, transparent);
}

.hb-richhtml a.hb-media-card { color: rgb(var(--color-sf-on-surface)); }

.hb-media-thumb {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    background: color-mix(in srgb, rgb(var(--color-sf-on-surface)) 14%, transparent);
}

.hb-media-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hb-media-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 7px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: rgba(10, 10, 15, 0.72);
}

.hb-media-badge--live { background: #d63a44; }

.hb-media-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 11px 11px;
    min-width: 0;
}

.hb-media-title {
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hb-media-meta {
    font-size: 0.82em;
    opacity: 0.72;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The editor's canvas draws the same cards from sample words, so the author sees the arrangement. */
.hb-media-ph { position: relative; }

.hb-media-ph::after {
    content: attr(data-hb-ph);
    position: absolute;
    bottom: -9px;
    right: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.5;
    color: #fff;
    background: var(--hb-brand-c1, rgb(var(--color-sf-primary)));
}


/* =====================================================================================
   Event, bundle and collection cards inside a design (the Events, Bundles and Collections
   blocks of the GrapesJS editors).

   HeartBeat.PageModel.CardsEmbed writes this markup: an optional heading, then a row of cards, each
   a picture (an event's date as a badge on it), a name, the details under it, and for an event two
   buttons. How much of that is drawn is the block's own setting; where the words sit is too. The
   editor's canvas draws a stand-in from the same classes, so what the author arranges is what is
   drawn. Nothing here names a colour: it resolves through the theme's tokens and the client's brand.
   ===================================================================================== */

.hb-cards-embed { margin: 18px 0 14px; }

.hb-cards-embed-h { margin: 0 0 10px; }

.hb-cards-embed-row {
    display: grid;
    gap: 12px;
}

.hb-cards-embed--rail .hb-cards-embed-row {
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 64%);
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 6px;
}

.hb-cards-embed--rail .hb-xcard { scroll-snap-align: start; }

@media (min-width: 640px) {
    .hb-cards-embed--rail .hb-cards-embed-row { grid-auto-columns: 240px; }
}

.hb-cards-embed--grid .hb-cards-embed-row {
    grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr));
}

/* One chosen event or bundle is a single card, not a row's width. */
.hb-cards-embed--one .hb-cards-embed-row { grid-template-columns: minmax(0, 420px); }
.hb-cards-embed--one.hb-cards-embed--center .hb-cards-embed-row { justify-content: center; }
.hb-cards-embed--one.hb-cards-embed--right .hb-cards-embed-row { justify-content: end; }

.hb-xcard {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    border-radius: 12px;
    color: rgb(var(--color-sf-on-surface));
    background: color-mix(in srgb, rgb(var(--color-sf-on-surface)) 6%, transparent);
    border: 1px solid color-mix(in srgb, rgb(var(--color-sf-on-surface)) 14%, transparent);
}

.hb-xcard-link {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

a.hb-xcard-link:hover,
a.hb-xcard-link:focus-visible { background: color-mix(in srgb, rgb(var(--color-sf-on-surface)) 5%, transparent); }

.hb-richhtml a.hb-xcard-link { color: rgb(var(--color-sf-on-surface)); }

.hb-xcard-art {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 16 / 10;
    background: color-mix(in srgb, rgb(var(--color-sf-on-surface)) 14%, transparent);
}

.hb-xcard-art img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hb-xcard-icon {
    font-size: 1.8rem;
    color: var(--hb-brand-c1, rgb(var(--color-sf-primary)));
}

.hb-xcard-date {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 5px 9px;
    border-radius: 9px;
    text-align: center;
    line-height: 1.1;
    color: #fff;
    background: rgba(10, 10, 15, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.hb-xcard-day { display: block; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.hb-xcard-mon { display: block; font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.85; }

.hb-xcard-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 9px 11px 11px;
    min-width: 0;
}

.hb-xcard--textonly .hb-xcard-body { padding: 14px; }

.hb-xcard-title {
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hb-xcard-meta {
    font-size: 0.85em;
    opacity: 0.72;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* An event's two buttons, under the picture and name. */
.hb-xcard-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 11px 12px;
}

.hb-xcard-btn {
    padding: 6px 14px;
    border-radius: 9px;
    font-size: 0.85em;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    color: var(--hb-brand-c1, rgb(var(--color-sf-primary)));
    border: 1px solid var(--hb-brand-c1, rgb(var(--color-sf-primary)));
    background: transparent;
}

.hb-xcard-btn.is-primary {
    background: var(--hb-brand-c1, rgb(var(--color-sf-primary)));
    color: rgb(var(--color-sf-on-primary, 255 255 255));
}

.hb-richhtml a.hb-xcard-btn { color: var(--hb-brand-c1, rgb(var(--color-sf-primary))); }
.hb-richhtml a.hb-xcard-btn.is-primary { color: rgb(var(--color-sf-on-primary, 255 255 255)); }

/* Where the words sit on every card in the block. */
.hb-cards-embed--center .hb-xcard-body { text-align: center; align-items: center; }
.hb-cards-embed--right .hb-xcard-body { text-align: right; align-items: flex-end; }
.hb-cards-embed--center .hb-xcard-actions { justify-content: center; }
.hb-cards-embed--right .hb-xcard-actions { justify-content: flex-end; }

/* Alignment of a piece of text in a design (the editor's "Alignment" control): carried as an attribute
   on the element, so it needs no class and works in the app, the public pages and a website alike. */
[data-hb-ta="center"] { text-align: center; }
[data-hb-ta="right"] { text-align: right; }
