/* heading — <heading> tag: kicker, badge and section bar at a heading

   Usage (rendered by src/content/tags/heading.ts):
     <div class="hx hx--accent">
       <p class="hx-kicker">DSGVO Art. 6</p>
       <h2>Einwilligung einholen</h2>
       <span class="hx-badge"><svg …/>Pflicht</span>
     </div>
     variant="bar": <section class="hx-section hx--accent"><div class="hx">…</div>…content…</section>

   Themes: .hx--accent, .hx--orange, .hx--green, .hx--neutral (default navy)
   Modifiers: .hx-kicker--plain (no dot)
── */

/* ── Theme
   One class on the outermost element colours kicker, dot/icon, badge and bar.
   Each theme sets text (--hx-fg) and bar/dot (--hx-bar) colour only. Badge border
   and tint are derived from --hx-fg; --hx-mix evens out the lighter hues (green,
   orange, grey) so every badge border has the same contrast against white.
   Defaults sit on the outermost element only, so inner elements inherit. ── */
article :where(.hx-section, .hx:not(.hx-section > .hx)) {
  --hx-fg:  var(--color-primary);
  --hx-bar: var(--color-primary-dark);
  --hx-mix: 30%;
}
article .hx--accent  { --hx-fg: var(--color-accent-dark); --hx-bar: var(--color-accent);       --hx-mix: 30%; }
article .hx--orange  { --hx-fg: var(--status-warning-text);   --hx-bar: var(--status-warning-border);   --hx-mix: 42%; }
article .hx--green   { --hx-fg: var(--status-success-text); --hx-bar: var(--status-success-border); --hx-mix: 41%; }
article .hx--neutral { --hx-fg: var(--color-text-muted);  --hx-bar: var(--color-neutral-300); --hx-mix: 45%; }

/* ── Layout: kicker on its own row, heading + badge share a row.
   The badge wraps below the heading when the line gets too narrow – no media query. ── */
article .hx {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  column-gap: 1rem;
  row-gap: 0.375rem;
  margin: 24px 0 16px;
}
article .hx > :is(h2, h3, h4) { flex: 1 1 16rem; margin: 0; }

/* ── Kicker ── */
article .hx-kicker {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hx-fg);
}
article .hx-kicker::before {
  content: '';
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--hx-bar);
}
/* kicker-icon replaces the dot (same colour); kicker-icon="none" drops it */
article .hx-kicker > svg { flex: none; color: var(--hx-bar); }
article .hx-kicker:has(> svg)::before,
article .hx-kicker--plain::before { display: none; }

/* ── Badge ── */
article .hx-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.5rem; /* centres on the first h2 line (28px × 1.5) */
  padding: 0.125rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--hx-fg) var(--hx-mix), var(--color-surface));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--hx-fg) 6%, var(--color-surface));
  color: var(--hx-fg);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
article .hx-badge svg { flex: none; }
article .hx > :is(h3, h4) ~ .hx-badge { margin-top: 0.2rem; }

/* ── variant="bar": the bar carries heading and content. It hangs in the left
   gutter, so the text stays flush with the surrounding content. ── */
article .hx-section {
  --hx-bar-w: 4px;
  --hx-bar-gap: 1rem;
  margin: 24px 0 24px calc(-1 * (var(--hx-bar-w) + var(--hx-bar-gap)));
  padding: 0 0 0 var(--hx-bar-gap);  /* resets the global "section" padding */
  border: 0;                         /* … and its border-bottom */
  border-left: var(--hx-bar-w) solid var(--hx-bar);
}
@media (max-width: 640px) { article .hx-section { --hx-bar-gap: 0.75rem; } }
article .hx-section > .hx:first-child { margin-top: 0; }
article .hx-section > :last-child { margin-bottom: 0; }
