/*
Component: LVD Accordion
Version: 2.0.0
Author: Live Design
*/

/* --- Accordion --- */
/* Local design tokens. Hairlines and hover tints derive from currentColor, so a row
   reads correctly on ANY surface (white, light, accent, dark) without a per-appearance
   token in app-theme. The rgba fallback is a neutral grey that works both ways. */
.lvd-cm-accordion                                       {position:relative;
                                                         --lvd-accordion-row-x:24px;
                                                         --lvd-accordion-row-y:12px;
                                                         --lvd-accordion-num-w:40px;
                                                         --lvd-accordion-ease:cubic-bezier(0.32, 0.72, 0, 1);
                                                         --lvd-accordion-speed:0.32s;
                                                         --lvd-accordion-hairline:rgba(128,128,128,0.3);
                                                         --lvd-accordion-tint:rgba(128,128,128,0.09);}

@supports (color:color-mix(in srgb, currentColor 10%, transparent)) {
.lvd-cm-accordion                                       {--lvd-accordion-hairline:color-mix(in srgb, currentColor 14%, transparent);
                                                         --lvd-accordion-tint:color-mix(in srgb, currentColor 6%, transparent);}
}

/* Section head */
.lvd-cm-accordion .lvd-section-head .lvd-badge          {margin-bottom:16px;}
.lvd-cm-accordion .lvd-section-intro                    {max-width:80%;}
.lvd-cm-accordion .lvd-section-intro.lvd-text-center    {margin-left:auto; margin-right:auto;}

/* --- List --- */
.lvd-cm-accordion .lvd-accordion-list                   {display:flex; flex-direction:column;}

/* Inset (default) — ONE card, rows separated by hairlines. The list padding does two
   jobs: it insets the hairlines from the card edges (iOS grouped-list look) AND keeps
   the hover tint of the first/last row off the card's own edge — without the vertical
   half, hovering the top row paints right up against the rounded corner. */
.lvd-cm-accordion .lvd-accordion-inset                  {border-radius:var(--lvd-rounded-md); padding:16px;}
/* The list already contributes the top inset here, so the leading group label needs
   almost none of its own. */
.lvd-cm-accordion .lvd-accordion-inset .lvd-accordion-group-first {padding-top:4px;}
.lvd-cm-accordion .lvd-accordion-inset:not(.lvd-dividers-off) .lvd-accordion-item + .lvd-accordion-item {border-top:1px solid var(--lvd-accordion-hairline);}

/* Cards — one card per question, spaced. No hairlines: the gap already separates them. */
.lvd-cm-accordion .lvd-accordion-cards                  {gap:12px;}
.lvd-cm-accordion .lvd-accordion-cards .lvd-accordion-item {border-radius:var(--lvd-rounded);}

/* Plain — no surface at all, hairlines carry the structure (also above the first row,
   so the list reads as a bounded block against the section background). */
.lvd-cm-accordion .lvd-accordion-plain:not(.lvd-dividers-off) .lvd-accordion-item {border-bottom:1px solid var(--lvd-accordion-hairline);}
/* Top line on the first row of the list AND on the first row after a group title —
   otherwise a leading group label would leave the block visually open at the top. */
.lvd-cm-accordion .lvd-accordion-plain:not(.lvd-dividers-off) .lvd-accordion-item:first-child,
.lvd-cm-accordion .lvd-accordion-plain:not(.lvd-dividers-off) .lvd-accordion-group-title + .lvd-accordion-item {border-top:1px solid var(--lvd-accordion-hairline);}
/* Rows sit flush with the section title (no inline padding), so a background tint on
   hover would have nothing to breathe into — the question dims instead. */
.lvd-cm-accordion .lvd-accordion-plain                  {--lvd-accordion-row-x:0px;}
.lvd-cm-accordion .lvd-accordion-plain .lvd-accordion-trigger:hover {background:transparent;}
.lvd-cm-accordion .lvd-accordion-plain .lvd-accordion-trigger:hover .lvd-accordion-question {opacity:0.7;}

/* No dividers — the rows have to tighten. With a hairline, the eye reads it as the
   boundary and the 2×row padding around it looks intentional; take the line away and the
   same distance becomes an unexplained void. The answer gets a few pixels back so the
   question↔answer relationship stays where it was — only the row↔row gap closes.
   Scoped to inset/plain on purpose: the cards style never had hairlines (the gap does the
   separating), so there the toggle would only compress rows with nothing to explain it. */
.lvd-cm-accordion .lvd-accordion-inset.lvd-dividers-off,
.lvd-cm-accordion .lvd-accordion-plain.lvd-dividers-off {--lvd-accordion-row-y:8px;}
.lvd-cm-accordion .lvd-accordion-inset.lvd-dividers-off .lvd-accordion-answer,
.lvd-cm-accordion .lvd-accordion-plain.lvd-dividers-off .lvd-accordion-answer {padding-top:4px;}

/* --- Row --- */
.lvd-cm-accordion .lvd-accordion-item                   {position:relative;}

/* The heading is a pure semantic wrapper (h3 > button is the ARIA APG structure);
   all visual weight lives on the question span, so the SEO tag can change freely. */
.lvd-cm-accordion .lvd-accordion-heading                {margin:0; padding:0; font:inherit; line-height:inherit; color:inherit;}

/* min-height is the tap-target floor — Apple's 44pt minimum, nothing more. Set any
   higher and it silently overrides the row padding: at 48px the dividers-off density
   (8px padding → 43px natural) got rounded back up and the setting stopped showing. */
.lvd-cm-accordion .lvd-accordion-trigger                {display:flex; align-items:center; justify-content:space-between; gap:16px; width:100%; min-height:44px; margin:0; padding:var(--lvd-accordion-row-y) var(--lvd-accordion-row-x); border:0; background:transparent; color:inherit; font-family:inherit; font-size:inherit; text-align:left; cursor:pointer; border-radius:var(--lvd-rounded); transition:background-color 0.2s ease;}
.lvd-cm-accordion .lvd-accordion-trigger:hover          {background:var(--lvd-accordion-tint);}
/* Inset outline: a positive offset would be clipped by the card's own rounding.
   currentColor, not the brand primary — the ring has to stay visible on a primary-dark
   or accent card, where a primary-coloured outline would sink into its own background. */
.lvd-cm-accordion .lvd-accordion-trigger:focus-visible  {outline:2px solid currentColor; outline-offset:-2px;}

.lvd-cm-accordion .lvd-accordion-question               {flex:1 1 auto; font-weight:600; letter-spacing:-0.01em; line-height:1.35; color:var(--lvd-cc-title); transition:opacity 0.2s ease;}

/* --- Numbering (lvd-accordion-numbers) ---
   A CSS counter, so the sequence is continuous across group titles and needs no PHP
   bookkeeping: only question rows increment it. `decimal-leading-zero` gives 01…09 and
   plain 10+; tabular figures keep the questions on one optical line. */
.lvd-accordion-numbers .lvd-accordion-list              {counter-reset:lvd-accordion;}
.lvd-accordion-numbers .lvd-accordion-item              {counter-increment:lvd-accordion;}
/* Aligned to the FIRST line of the question (same line-height, self-start), not to the
   optical centre — a question that wraps to three lines would otherwise float its number
   in the middle of the block. */
.lvd-accordion-numbers .lvd-accordion-trigger::before   {content:counter(lvd-accordion, decimal-leading-zero); flex:0 0 auto; align-self:flex-start; min-width:var(--lvd-accordion-num-w); line-height:1.35; font-weight:500; font-variant-numeric:tabular-nums; letter-spacing:0.02em; opacity:0.4;}
/* The answer lines up with the question, not with the number. The column width is a fixed
   token, NOT `em`: the number sizes off the trigger, the answer off its own inherited body
   size, so an `em` on both sides drifts apart the moment those two differ — through a
   project override, a nested rich-text rule, anything. 16px = the trigger's flex gap.
   Specificity (0,3,0) is deliberate: the base `.lvd-cm-accordion .lvd-accordion-answer`
   rule sets the `padding` SHORTHAND at (0,2,0) further down the file, so an equal-weight
   selector here would be silently overwritten by it. */
.lvd-cm-accordion.lvd-accordion-numbers .lvd-accordion-answer {padding-left:calc(var(--lvd-accordion-row-x) + var(--lvd-accordion-num-w) + 16px);}

/* --- Group title ---
   A purely visual divider inside the list (and outside the JSON-LD). Renders as a small
   uppercase label; the tag comes from the row's SEO override, `div` by default. */
.lvd-cm-accordion .lvd-accordion-group-title            {margin:0; padding:24px var(--lvd-accordion-row-x) 8px; font-size:var(--lvd-text-s1); font-weight:600; line-height:1.3; letter-spacing:0.08em; text-transform:uppercase; color:var(--lvd-cc-title); opacity:0.45;}
.lvd-cm-accordion .lvd-accordion-group-first            {padding-top:16px;}
/* In the cards style the list has its own gap, so the label needs less of its own. */
.lvd-cm-accordion .lvd-accordion-cards .lvd-accordion-group-title {padding:16px var(--lvd-accordion-row-x) 0;}

/* --- Icon (pure CSS, no mask asset) ---
   Drawn from currentColor at a fixed 1.5px stroke: it inherits the row's colour on any
   appearance, and there is no relative asset path to break when the block moves. */
.lvd-cm-accordion .lvd-accordion-icon                   {position:relative; flex:0 0 auto; width:18px; height:18px; opacity:0.5; transition:transform var(--lvd-accordion-speed) var(--lvd-accordion-ease), opacity 0.2s ease;}
.lvd-cm-accordion .lvd-accordion-trigger:hover .lvd-accordion-icon {opacity:0.9;}

/* Chevron — one corner of a square, rotated 45°; the whole icon flips on open. */
.lvd-accordion-icon-chevron .lvd-accordion-icon::before {content:""; position:absolute; left:50%; top:50%; width:9px; height:9px; margin:-6px 0 0 -5px; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; border-radius:0 0 2px 0; transform:rotate(45deg);}
.lvd-accordion-icon-chevron .lvd-accordion-item.lvd-active .lvd-accordion-icon {transform:rotate(180deg);}

/* Plus — two bars; on open the vertical one rotates flat and fades, leaving a minus. */
.lvd-accordion-icon-plus .lvd-accordion-icon::before,
.lvd-accordion-icon-plus .lvd-accordion-icon::after     {content:""; position:absolute; left:50%; top:50%; width:15px; height:1.5px; margin:-0.75px 0 0 -7.5px; border-radius:1px; background:currentColor; transition:transform var(--lvd-accordion-speed) var(--lvd-accordion-ease), opacity var(--lvd-accordion-speed) var(--lvd-accordion-ease);}
.lvd-accordion-icon-plus .lvd-accordion-icon::after     {transform:rotate(90deg);}
.lvd-accordion-icon-plus .lvd-accordion-item.lvd-active .lvd-accordion-icon::after {transform:rotate(0deg); opacity:0;}

/* --- Panel ---
   grid-template-rows 0fr→1fr animates to the real height, on the GPU, with no JS
   measuring. `visibility` on the inner is what makes a closed answer genuinely inert:
   without it the links inside stay in the tab order and Ctrl+F still finds them.
   Visibility flips to hidden only at the END of the transition, so the collapse stays
   visible while it plays. */
.lvd-cm-accordion .lvd-accordion-panel                  {display:grid; grid-template-rows:0fr; transition:grid-template-rows var(--lvd-accordion-speed) var(--lvd-accordion-ease);}
.lvd-cm-accordion .lvd-accordion-inner                  {min-height:0; overflow:hidden; visibility:hidden; transition:visibility var(--lvd-accordion-speed);}
.lvd-cm-accordion .lvd-accordion-answer                 {padding:0 var(--lvd-accordion-row-x) var(--lvd-accordion-row-y); color:var(--lvd-cc-text); opacity:0; transform:translateY(-4px); transition:opacity 0.24s ease, transform 0.24s var(--lvd-accordion-ease);}
.lvd-cm-accordion .lvd-accordion-answer > *:first-child {margin-top:0;}
.lvd-cm-accordion .lvd-accordion-answer > *:last-child  {margin-bottom:0;}
.lvd-cm-accordion .lvd-accordion-answer img             {max-width:100%; height:auto; border-radius:var(--lvd-rounded);}

/* Open state — the answer fades in slightly after the row starts expanding, and leaves
   with no delay: opening feels considered, closing feels immediate. */
.lvd-cm-accordion .lvd-accordion-item.lvd-active .lvd-accordion-panel  {grid-template-rows:1fr;}
.lvd-cm-accordion .lvd-accordion-item.lvd-active .lvd-accordion-inner  {visibility:visible;}
.lvd-cm-accordion .lvd-accordion-item.lvd-active .lvd-accordion-answer {opacity:1; transform:none; transition-delay:0.06s;}

/* Editor-only placeholder — an empty list would read as a broken block. */
.lvd-accordion-empty                                    {border:1px dashed var(--lvd-color-gray-300, #ccc); border-radius:var(--lvd-rounded-md); padding:24px; text-align:center; font-size:var(--lvd-text-s1); opacity:0.6;}

/* Animation (lvd-animation toggle) */
.lvd-cm-accordion.lvd-animate-on-scroll .lvd-section-title,
.lvd-cm-accordion.lvd-animate-on-scroll .lvd-section-intro,
.lvd-cm-accordion.lvd-animate-on-scroll .lvd-accordion-list {opacity:0; transform:translateY(16px); transition-property:opacity, transform; transition-duration:1s; transition-timing-function:cubic-bezier(0.65, 0, 0.35, 1);}
.lvd-cm-accordion.lvd-is-visible .lvd-section-title,
.lvd-cm-accordion.lvd-is-visible .lvd-section-intro,
.lvd-cm-accordion.lvd-is-visible .lvd-accordion-list    {opacity:1; transform:translateY(0);}
.lvd-cm-accordion.lvd-is-visible .lvd-section-intro     {transition-delay:0.15s;}
.lvd-cm-accordion.lvd-is-visible .lvd-accordion-list    {transition-delay:0.3s;}

/* --- Bm --- */
@media (min-width:1px) and (max-width:767px) {
/* Outer safety gutter — 8px on mobile: the card should sit close to the viewport edge,
   the breathing room comes from the row padding inside it, not from the page margin. */
.lvd-cm-accordion,
.lvd-cm-accordion.lvd-px,
.lvd-cm-accordion.lvd-pxy                               {padding-left:8px; padding-right:8px;}
/* Only the horizontal inset changes on mobile — the row's vertical rhythm (12px, 8px
   without dividers) is already at the bottom of the scale and holds at any width. */
.lvd-cm-accordion                                       {--lvd-accordion-row-x:16px; --lvd-accordion-num-w:32px;}
.lvd-cm-accordion .lvd-accordion-inset                  {padding:8px;}

/* Numbering on narrow screens — the number column costs real reading width here, so it
   shrinks (32px + an 8px gap instead of 40+16) and the answer stops honouring it. The
   hanging indent is a desktop luxury: on mobile the answer is the long text and needs
   every pixel, while the number still reads as a marker for the question row alone. */
.lvd-accordion-numbers .lvd-accordion-trigger           {gap:8px;}
.lvd-cm-accordion.lvd-accordion-numbers .lvd-accordion-answer {padding-left:var(--lvd-accordion-row-x);}
.lvd-cm-accordion .lvd-section-intro                    {max-width:100%;}
}

/* --- Bt --- */
@media (min-width:768px) and (max-width:1024px) {
.lvd-cm-accordion,
.lvd-cm-accordion.lvd-px,
.lvd-cm-accordion.lvd-pxy                               {padding-left:24px; padding-right:24px;}
}

/* Respect reduced motion — state still changes, nothing animates */
@media (prefers-reduced-motion: reduce) {
.lvd-cm-accordion .lvd-accordion-trigger,
.lvd-cm-accordion .lvd-accordion-icon,
.lvd-cm-accordion .lvd-accordion-icon::before,
.lvd-cm-accordion .lvd-accordion-icon::after,
.lvd-cm-accordion .lvd-accordion-panel,
.lvd-cm-accordion .lvd-accordion-inner,
.lvd-cm-accordion .lvd-accordion-answer                 {transition:none;}
.lvd-cm-accordion .lvd-accordion-answer                 {transform:none;}
}
