/* ============================================================
   CATEGORY CHIP — a bir.ch blog category in its own outline
   Requires: tokens.css (and patterns.css for the .chip it usually sits on)

   Each blog category has its own shape, as on the live blog (bir.ch/blog filters, post pages and cards;
   measured 21.10.2026): Product updates — a pill; Ad Performance — a square box; Creative Testing — a dashed pill (1.25× the line, an optical correction);
   Tracking & Attribution — a pill of round dots (1.75× the line); Ad Reporting — a box slanted 15°; Inspiration and Inside Birch — drawn
   shapes (inline SVG from category-chip.mjs). A category without a shape keeps its host's box.

   <span class="chip cat-chip t-para-sm" data-cat="ad-performance">Ad Performance</span>
   The site: CategoryChip.astro (the slug and the drawn outlines: category-chip.mjs). The blog post page:
   .post-pill.cat-chip (blog/theme.css sets the size). Size and padding come from the host (.chip M / S, .post-pill);
   this file owns the outline and the hover.

   One line for all: every outline is --border-thin (Tracking's dots 1.75×, Creative Testing's dashes 1.25×, so they read as heavy as a solid line), the drawn shapes too — a real SVG stroke that does not scale with
   the shape (vector-effect: non-scaling-stroke), so it never thickens with the chip's size.
   Colour: at rest the outline is the text's colour (currentColor), so it works on any fill.

   Hover — the category's colour, as the live blog's filters (bir.ch/blog, 19.11.2026): the shape fills, the line
   and the text turn black or white on it. On a link chip (a.cat-chip) on its own hover, on a chip inside
   .cat-chip-host when the host is hovered (a card that opens), and always on .cat-chip--on (the chosen filter).
   Fills are the nearest DS tokens to the live colours (the live hex in each comment).
   --cat-chip-pad-x: the host's side padding, read by the notched «Inspiration» shape to add room at its sides.
   ============================================================ */

.cat-chip {
  --cat-chip-pad-x: var(--chip-pad-x);
  --cat-line: currentColor;
  --cat-fill: transparent;
  position: relative;
  isolation: isolate;
  border: var(--border-thin) solid var(--cat-line);
  transition: background-color var(--duration-hover) var(--ease-hover), color var(--duration-hover) var(--ease-hover), border-radius var(--duration-hover) var(--ease-hover);
}
.cat-chip[data-cat="product-updates"] { border-radius: var(--radius-pill); }
.cat-chip[data-cat="ad-performance"] { border-radius: 0; }

/* drawn outlines: the box's own border goes clear (it keeps the chip's size) and a layer under the text draws the
   shape — Tracking and Ad Reporting a box of their own (::before), Inspiration and Inside Birch an inline SVG
   (.cat-chip__shape, from categoryShape in category-chip.mjs): a stroke of --border-thin stretched to the chip.
   Each layer takes the fill on hover. */
.cat-chip:is([data-cat="creative-testing"], [data-cat="tracking-attribution"], [data-cat="ad-reporting"], [data-cat="inspiration"], [data-cat="inside-birch"]) { border-color: transparent; }
.cat-chip:is([data-cat="creative-testing"], [data-cat="tracking-attribution"], [data-cat="ad-reporting"])::before {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--border-thin)); /* the chip's border box */
  z-index: -1;
  border: var(--border-thin) solid var(--cat-line);
  background: var(--cat-fill);
  pointer-events: none;
  transition: background-color var(--duration-hover) var(--ease-hover);
}
/* dots 1.75× the line (3.5 at 1440): --border-thin read too light, 1.5× still light, --border-thick (4) too heavy
   (Liliya, 24.11.2026; live dots ~3.6 px) */
.cat-chip[data-cat="tracking-attribution"]::before { border: calc(1.75 * var(--border-thin)) dotted var(--cat-line); border-radius: var(--radius-pill); }
/* dashes 1.25× the line (2.5 at 1440): half a dashed line is gaps, so at --border-thin it read lighter than the solid
   boxes, at 1.5× heavier — an optical correction (Liliya, 24.11.2026); the browser lengthens the dashes and gaps with
   the width */
.cat-chip[data-cat="creative-testing"]::before { border: calc(1.25 * var(--border-thin)) dashed var(--cat-line); border-radius: var(--radius-pill); }
/* a box slanted 15° (live: skewX on the button, the text skewed back); here the outline alone slants */
.cat-chip[data-cat="ad-reporting"]::before { transform: skewX(15deg); }
.cat-chip > .cat-chip__shape {
  position: absolute;
  /* the stroke's outer edge on the chip's edge; the size set, not auto — an auto SVG takes its viewBox's proportions
     and runs past a chip of another shape (the S chips, 19.11.2026) */
  top: calc(-0.5 * var(--border-thin));
  left: calc(-0.5 * var(--border-thin));
  z-index: -1;
  width: calc(100% + var(--border-thin));
  height: calc(100% + var(--border-thin));
  margin: 0;
  overflow: visible;
  fill: var(--cat-fill);
  stroke: var(--cat-line);
  /* a border is drawn in whole screen pixels (rounded down: 1.63 → 1 on a 1× screen, → 1.5 on a 2× one), a stroke is
     not — rounded the same way, so the drawn shapes are never heavier than the boxes (24.11.2026, 1.63 vs 1 at 1024) */
  stroke-width: var(--border-thin);
  stroke-width: round(down, var(--border-thin), 1px);
  stroke-linejoin: round;
  pointer-events: none;
  transition: fill var(--duration-hover) var(--ease-hover);
}
@media (min-resolution: 2dppx) {
  .cat-chip > .cat-chip__shape { stroke-width: round(down, var(--border-thin), 0.5px); }
}
.cat-chip[data-cat="inspiration"] { padding-inline: calc(var(--cat-chip-pad-x) + var(--space-xs)); } /* the notched ends eat into the sides */

/* ---------- Hover: the category's colour ---------- */
.cat-chip[data-cat="product-updates"]      { --cat-on: var(--color-accent-indigo);     --cat-on-ink: var(--color-text); } /* live #4450F2 */
.cat-chip[data-cat="ad-performance"]       { --cat-on: var(--color-accent-green-deep); --cat-on-ink: var(--color-text-inverted); } /* live #32CC5B */
.cat-chip[data-cat="ad-reporting"]         { --cat-on: var(--color-accent-green-deep); --cat-on-ink: var(--color-text-inverted); } /* live #23711A, a dark green with white text: not in the DS — Green Deep, as Ad Performance (Liliya, 19.11.2026) */
.cat-chip[data-cat="creative-testing"]     { --cat-on: var(--color-accent-orange);     --cat-on-ink: var(--color-text-inverted); } /* live #FFA73B */
.cat-chip[data-cat="tracking-attribution"] { --cat-on: var(--color-accent-pink);       --cat-on-ink: var(--color-text); } /* live #FF21A6 */
.cat-chip[data-cat="inspiration"]          { --cat-on: var(--color-accent-light-blue); --cat-on-ink: var(--color-text-inverted); } /* live #1DECFF */
.cat-chip[data-cat="inside-birch"]         { --cat-on: var(--color-primary);           --cat-on-ink: var(--color-text-inverted); } /* live #FFE243 */

.cat-chip--on {
  --cat-fill: var(--cat-on, var(--color-text-inverted));
  --cat-line: var(--color-text-inverted);
  color: var(--cat-on-ink, var(--color-text));
}
/* the plain boxes fill themselves; the drawn ones fill their layer (::before, the SVG) */
.cat-chip--on:not([data-cat="creative-testing"], [data-cat="tracking-attribution"], [data-cat="ad-reporting"], [data-cat="inspiration"], [data-cat="inside-birch"]) { background-color: var(--cat-fill); }
.cat-chip--on[data-cat="ad-performance"] { border-radius: var(--radius-pill); } /* live: the square turns a pill */
@media (hover: hover) {
  a.cat-chip:hover,
  .cat-chip-host:hover .cat-chip {
    --cat-fill: var(--cat-on, var(--color-text-inverted));
    --cat-line: var(--color-text-inverted);
    color: var(--cat-on-ink, var(--color-text));
  }
  :is(a.cat-chip:hover, .cat-chip-host:hover .cat-chip):not([data-cat="creative-testing"], [data-cat="tracking-attribution"], [data-cat="ad-reporting"], [data-cat="inspiration"], [data-cat="inside-birch"]) { background-color: var(--cat-fill); }
  :is(a.cat-chip:hover, .cat-chip-host:hover .cat-chip)[data-cat="ad-performance"] { border-radius: var(--radius-pill); }
}
