/* ==========================================================================
   Insights — listing (insights.html) + the three French posts
   (insight-autocomplete / insight-search-sorting / insight-search-filters)
   Layout and page set pieces only: tokens and components come from base.css.
   Signature pieces:
     1. .demo — the article cover as a large live search interface in the post
        hero (typing + suggestions / re-sorting / filtering), backlit by the
        prism light like the hexagon itself.
     2. Living post-card covers: the partials' mini-interfaces replay their
        topic when a card comes into view or is hovered (insights.js).
   ========================================================================== */

/* ---------- Listing hero ---------------------------------------------------- */
.insights-hero__title { max-width: 13ch; }
/* a search caret after the headline: blinks four times, then rests (WCAG 2.2.2) */
.insights-caret {
  display: inline-block; width: .055em; height: .78em; margin-left: .1em; vertical-align: -.02em;
  background: var(--spectrum); box-shadow: 0 0 22px var(--glow);
  animation: caret 1.1s steps(1) 4;
}

/* ---------- Post grids (listing + recent posts) ---------------------------- */
.insights-grid { display: grid; gap: clamp(1rem, .6rem + 1.4vw, 2rem); grid-template-columns: minmax(0, 1fr); }
.insights-grid .post-card__body { gap: .85rem; }

/* horizontal cards from 720px: cover | text */
@media (min-width: 720px) {
  .insights-grid .post-card { flex-direction: row; }
  .insights-grid .post-card__cover {
    flex: 0 0 50%; aspect-ratio: auto; min-height: 17.5rem;
    border-bottom: 0; border-right: 1px solid rgb(240 237 247 / .08);
  }
  .insights-grid .post-card__body { padding: clamp(1.25rem, .9rem + 1.3vw, 2.25rem); }
  .insights-grid .ui-cover > * { width: min(100%, 23rem); justify-self: center; }
  .insights-grid .ui-cover > .ui-select { justify-self: start; width: auto; margin-left: max(0px, (100% - 23rem) / 2); }
}
@media (min-width: 1200px) {
  .insights-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .insights-grid .post-card__cover { flex-basis: 44%; }
  .insights-grid .post-card__body { padding: clamp(1.25rem, .8rem + 1.1vw, 2rem); }
  /* listing: the first article leads, full width */
  .insights-list .insights-grid > .post-card:first-child { grid-column: 1 / -1; }
  .insights-list .insights-grid > .post-card:first-child .post-card__cover { flex-basis: 58%; min-height: clamp(24rem, 14rem + 12vw, 30rem); }
  .insights-list .insights-grid > .post-card:first-child .ui-cover > * { zoom: 1.28; width: min(100%, 22rem); }
  .insights-list .insights-grid > .post-card:first-child .post-card__body { padding: clamp(2rem, 1rem + 2.4vw, 3.5rem); justify-content: center; }
  .insights-list .insights-grid > .post-card:first-child .post-card__title { font-size: var(--step-3); line-height: 1.08; letter-spacing: -.028em; }
  .insights-list .insights-grid > .post-card:first-child .post-card__excerpt { font-size: var(--step-0); max-width: 42ch; }
  .insights-list .insights-grid > .post-card:first-child .post-card__cta { margin-top: var(--space-s); }
}

/* living covers: the mini-interfaces animate between states (insights.js) */
.page-insights .ui-rank__bar::after { transition: width .9s var(--ease-out); }
.page-insights .ui-range__fill { transition: left .9s var(--ease-out), right .9s var(--ease-out); }
.page-insights .ui-chip { transition: background-color .35s var(--ease-out), color .35s var(--ease-out), border-color .35s var(--ease-out); }
.page-insights .ui-list li { transition: background-color .25s, box-shadow .25s, color .25s; }
.page-insights .ui-select { transition: border-color .3s, box-shadow .3s; }
.page-insights .ui-select.is-flash { border-color: rgb(166 140 255 / .75); box-shadow: 0 0 0 3px rgb(166 140 255 / .18); }

.insights-list__foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 2rem;
  margin-top: var(--space-xl); padding-top: var(--space-m); border-top: 1px solid var(--line); color: var(--fg-2);
}

/* ---------- Expertise (paper chapter) -------------------------------------- */
.insights-expertise__links { margin-top: var(--space-xl); }

/* ---------- Post hero ------------------------------------------------------- */
.post-hero { padding-bottom: var(--space-2xl); }
/* the light sits behind the live interface: it leaks around the bevelled frame */
.post-hero .prism-lite { --lx: 76%; --ly: 46%; --ls: clamp(120px, 13vw, 210px); }
.post-hero__inner { position: relative; display: grid; gap: var(--space-xl); align-items: start; }
.post-hero__text { display: grid; gap: var(--space-m); justify-items: start; align-content: start; }
.post-hero__title { font-size: clamp(2.3rem, 1.25rem + 3vw, 4.25rem); line-height: 1; max-width: 20ch; }
.post-hero__lead { max-width: 40ch; }
.post-hero__eyebrow .badge { margin-right: .5rem; padding: .12rem .45rem; }
.post-hero__media { width: 100%; }
.post-hero__caption { align-items: center; }
.post-hero__caption-end { display: inline-flex; align-items: center; gap: .75rem; }
@media (min-width: 1080px) {
  .post-hero__inner { grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr); column-gap: clamp(2.5rem, 1rem + 4vw, 6rem); }
}
@media (max-width: 1079px) {
  .post-hero .prism-lite { --lx: 72%; --ly: 74%; --ls: 150px; }
}
@media (min-width: 600px) and (max-width: 1079px) {
  .post-hero .demo { aspect-ratio: 3 / 2; }
}
@media (max-width: 599px) {
  .post-hero .prism-lite { --lx: 70%; --ly: 76%; --ls: 110px; }
}

/* byline: author, date, reading time */
.post-byline {
  display: flex; flex-wrap: wrap; align-items: center; gap: .9rem 1.5rem;
  width: 100%; max-width: 38rem; margin-top: .35rem; padding-top: var(--space-m); border-top: 1px solid var(--line);
}
.post-byline__photo {
  --cut: 9px; flex: none; width: 3.5rem; height: 3.5rem; object-fit: cover; object-position: 50% 22%;
  clip-path: var(--bevel); filter: var(--grade); background: var(--surface-2);
}
.post-byline__who { display: grid; gap: .1rem; line-height: 1.3; margin-left: -.4rem; }
.post-byline__name { color: var(--fg); font-weight: 560; }
.post-byline__role { color: var(--fg-3); font-size: var(--step--1); }
.post-byline__meta { display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; font-size: var(--step--1); color: var(--fg-2); }
.post-byline__meta li { display: inline-flex; align-items: center; gap: .45rem; }
.post-byline__meta svg { width: .95rem; height: .95rem; flex: none; color: var(--accent); }
@media (min-width: 480px) {
  .post-byline__meta { padding-left: 1.5rem; border-left: 1px solid var(--line-2); }
}

/* ---------- The live search interface (post hero set piece) ---------------- */
/* Drawn in HTML (crisp text), fixed dark palette like .ui-cover: it is a picture
   of an interface (role="img" + a French description), not a control. */
.demo {
  --cut: 18px;
  --d-fg: #f0edf7; --d-fg-2: #b4b7c9; --d-fg-3: #8b90a7; --d-line: rgb(240 237 247 / .09); --d-line-2: rgb(240 237 247 / .16);
  position: relative; isolation: isolate; container-type: inline-size;
  display: flex; flex-direction: column;
  aspect-ratio: 6 / 5;
  clip-path: var(--bevel);
  background: rgb(240 237 247 / .2);          /* 1px bevelled rim, drawn by the inset face below */
  color: var(--d-fg); font-size: .875rem; line-height: 1.3; text-align: left;
  box-shadow: 0 40px 90px -40px rgb(0 0 0 / .9);
}
.demo::before {                              /* the face */
  content: ""; position: absolute; inset: 1px; z-index: -1; clip-path: var(--bevel);
  background:
    radial-gradient(80% 60% at 92% 0%, rgb(166 140 255 / .2), transparent 62%),
    radial-gradient(70% 60% at 0% 100%, rgb(138 212 255 / .1), transparent 60%),
    linear-gradient(transparent 0 calc(100% - 1px), rgb(240 237 247 / .035) 0) 0 0 / 100% 24px,
    #090c18;
}
.demo::after {                               /* a spectral hairline where the light hits the top edge */
  content: ""; position: absolute; top: 0; left: 12%; width: 56%; height: 1px; z-index: 2; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgb(166 140 255 / .75), rgb(138 212 255 / .5), transparent);
}
.demo__bar {
  display: flex; align-items: center; gap: .6rem; padding: .85rem clamp(1rem, 4cqi, 1.6rem);
  border-bottom: 1px solid var(--d-line); font-size: .75rem; color: var(--d-fg-3);
}
.demo__mark { width: .9rem; height: .9rem; flex: none; color: #a68cff; }
.demo__title { color: var(--d-fg-2); font-weight: 560; letter-spacing: .02em; }
.demo__keys { margin-left: auto; display: flex; gap: .3rem; }
.demo kbd {
  font: inherit; font-size: .75rem; line-height: 1.2; padding: .14rem .45rem; min-width: 1.5rem; text-align: center;
  border: 1px solid var(--d-line-2); border-bottom-width: 2px; border-radius: 4px; color: var(--d-fg-2); background: rgb(240 237 247 / .04);
  transition: color .2s, background-color .2s, border-color .2s, transform .2s;
}
.demo kbd.is-pressed { color: #05060b; background: #f0edf7; border-color: #f0edf7; transform: translateY(1px); }
.demo__body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: .85rem; padding: clamp(1rem, 4.2cqi, 1.75rem); }
.demo__label { margin: 0 0 .45rem .1rem; font-size: .75rem; color: var(--d-fg-3); letter-spacing: .02em; }
.demo__count { color: var(--d-fg-2); font-size: .8125rem; }
.demo__count b { color: var(--d-fg); font-weight: 600; font-size: 1rem; margin-right: .15em; }
.demo .ui-caret { height: 1.1em; animation-iteration-count: infinite; }  /* the demo has a pause button (WCAG 2.2.2) */
.demo.is-paused .ui-caret { animation: none; }

/* product thumbnails: dark tiles lit from one corner, a faceted hex inside */
.demo__thumb {
  position: relative; display: block; aspect-ratio: 1; border-radius: 4px; overflow: hidden;
  background: radial-gradient(90% 80% at 25% 20%, rgb(228 156 242 / .36), transparent 62%), radial-gradient(90% 90% at 90% 100%, rgb(138 212 255 / .14), transparent 60%), #12162b;
  box-shadow: inset 0 0 0 1px rgb(240 237 247 / .08);
}
.demo__thumb[data-tone="2"] { background: radial-gradient(90% 80% at 75% 20%, rgb(166 140 255 / .42), transparent 62%), radial-gradient(90% 90% at 10% 100%, rgb(228 156 242 / .12), transparent 60%), #111529; }
.demo__thumb[data-tone="3"] { background: radial-gradient(90% 80% at 30% 85%, rgb(138 212 255 / .34), transparent 62%), radial-gradient(90% 90% at 90% 0%, rgb(166 140 255 / .16), transparent 60%), #10162a; }
.demo__thumb::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 36%; aspect-ratio: .866; translate: -50% -50%;
  clip-path: var(--hex); background: linear-gradient(160deg, rgb(240 237 247 / .42), rgb(240 237 247 / .06) 70%);
}
.demo__pname { display: grid; gap: .15rem; min-width: 0; color: var(--d-fg); font-size: .8125rem; line-height: 1.25; }
.demo__pname small { color: var(--d-fg-3); font-size: .75rem; }
.demo__price { color: var(--d-fg-2); font-size: .8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* — 1. Auto-complétion ------------------------------------------------------ */
.demo--auto .demo__body { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: .7rem; align-content: start; }
.demo__field { height: 3.25rem; padding: 0 1.1rem; font-size: 1.0625rem; gap: .75rem; }
.demo__field svg { width: 1.1rem; height: 1.1rem; }
.demo__query { display: inline-flex; align-items: center; white-space: pre; }
.demo--auto .demo__drop, .demo--auto .demo__results { grid-area: 2 / 1; align-self: start; }
.demo--auto .demo__drop { position: relative; z-index: 2; }
.demo__drop {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem;
  padding: .85rem .8rem .8rem; background: rgb(11 14 27 / .94); border: 1px solid var(--d-line-2); border-radius: 6px;
  box-shadow: 0 30px 60px -30px rgb(0 0 0 / .95);
  transition: opacity .3s var(--ease-out), transform .45s var(--ease-out), visibility 0s;
}
.demo__drop .ui-list { padding: 0; background: none; border: 0; gap: .15rem; }
.demo__drop .ui-list li { padding: .5rem .6rem; }
.demo__col--products { padding-left: 1rem; border-left: 1px solid var(--d-line); }
.demo__products { display: grid; gap: .55rem; list-style: none; padding: 0; }
.demo__products li { display: grid; grid-template-columns: 2.75rem minmax(0, 1fr) auto; align-items: center; gap: .7rem; }
/* the storefront behind the dropdown: dimmed while typing, lit once a suggestion is chosen */
.demo__results { display: grid; gap: .75rem; align-content: start; opacity: .3; filter: saturate(.6); transition: opacity .5s var(--ease-out), filter .5s var(--ease-out); }
.demo__status { color: var(--d-fg-2); font-size: .8125rem; padding: .15rem .1rem 0; }
.demo__status b { color: var(--d-fg); font-weight: 600; }
.demo__tiles, .demo__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; list-style: none; padding: 0; }
.demo__tiles li, .demo__grid li {
  display: grid; gap: .4rem; align-content: start; padding: .5rem .5rem .6rem;
  border: 1px solid var(--d-line); border-radius: 5px; background: rgb(240 237 247 / .03);
}
.demo__tiles .demo__thumb { aspect-ratio: 16 / 9; }
.demo__grid .demo__thumb { aspect-ratio: 16 / 10; }
.demo__grid .demo__pname { font-size: .75rem; }
.demo__tiles .demo__pname { font-size: .75rem; }
.demo[data-state="results"] .demo__drop, .demo[data-state="idle"] .demo__drop { opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .2s, transform .3s, visibility 0s .3s; }
.demo[data-state="results"] .demo__results { opacity: 1; filter: none; }

/* — 2. Tri ------------------------------------------------------------------ */
.demo__toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem 1rem; }
.demo__sort { position: relative; z-index: 3; }
.demo__sort .ui-select { height: 2.35rem; }
.demo__sort.is-open .ui-select { border-color: rgb(166 140 255 / .75); box-shadow: 0 0 0 3px rgb(166 140 255 / .16); }
.demo__menu {
  position: absolute; right: 0; top: calc(100% + .4rem); min-width: 100%; display: grid; gap: .1rem; padding: .3rem; list-style: none; margin: 0;
  background: #0e1122; border: 1px solid var(--d-line-2); border-radius: 5px; box-shadow: 0 30px 50px -20px rgb(0 0 0 / .95);
  opacity: 0; visibility: hidden; transform: translateY(-4px) scale(.98); transform-origin: 100% 0;
  transition: opacity .2s, transform .3s var(--ease-out), visibility 0s .3s;
}
.demo__sort.is-open .demo__menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.demo__menu li { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; padding: .45rem .65rem; border-radius: 3px; color: var(--d-fg-2); font-size: .8125rem; white-space: nowrap; transition: background-color .18s, color .18s; }
.demo__menu li.is-current { color: var(--d-fg); }
.demo__menu li.is-current::after { content: ""; width: .6rem; height: .32rem; border: 1.5px solid #a68cff; border-top: 0; border-right: 0; transform: rotate(-45deg) translateY(-2px); }
.demo__menu li.is-hover { background: rgb(166 140 255 / .16); color: var(--d-fg); }
.demo__rowhead { display: flex; justify-content: space-between; gap: 1rem; padding: 0 .6rem .45rem; border-bottom: 1px solid var(--d-line); font-size: .75rem; color: var(--d-fg-3); }
.demo__rows { display: grid; gap: .4rem; list-style: none; padding: 0; margin: 0; }
.demo__row {
  display: grid; grid-template-columns: 1.5rem 2.5rem minmax(0, 1fr) minmax(2.5rem, 20%) 3.75rem; align-items: center; gap: .75rem;
  padding: .45rem .6rem; border-radius: 5px; background: rgb(240 237 247 / .025); border: 1px solid var(--d-line);
  transition: background-color .5s, border-color .5s;
}
.demo__row:first-child { background: rgb(166 140 255 / .09); border-color: rgb(166 140 255 / .3); }
.demo__row:first-child .ui-rank__bar::after { background: var(--spectrum); box-shadow: 0 0 10px rgb(166 140 255 / .6); }
.demo__rank { color: var(--d-fg-3); font-size: .75rem; font-variant-numeric: tabular-nums; }
.demo__row:first-child .demo__rank { color: var(--d-fg); }
.demo__val { justify-self: end; color: var(--d-fg); font-size: .8125rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.demo .ui-rank__bar::after { transition: width .9s var(--ease-out); }

/* — 3. Filtres -------------------------------------------------------------- */
.demo__split { display: grid; grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); gap: 1.25rem; }
.demo__facets { display: grid; gap: 1rem; align-content: start; padding-right: 1.25rem; border-right: 1px solid var(--d-line); }
.demo__facet .ui-chips { gap: .35rem; }
.demo .ui-chip { height: 1.8rem; padding: 0 .7rem; font-size: .75rem; transition: background-color .35s var(--ease-out), color .35s var(--ease-out), border-color .35s var(--ease-out); }
.demo .ui-range { padding-top: .45rem; }
.demo .ui-range__fill { transition: left .9s var(--ease-out), right .9s var(--ease-out); }
.demo__more { font-size: .75rem; color: var(--d-fg-3); }
.demo__switch { display: inline-flex; align-items: center; gap: .55rem; color: var(--d-fg-2); font-size: .75rem; }
.demo__switch-track { position: relative; width: 2.1rem; height: 1.15rem; border-radius: 999px; border: 1px solid var(--d-line-2); background: rgb(240 237 247 / .06); }
.demo__switch-track::after { content: ""; position: absolute; left: .15rem; top: 50%; width: .75rem; height: .75rem; margin-top: -.375rem; border-radius: 50%; background: var(--d-fg-3); }
.demo__main { display: grid; gap: .7rem; align-content: start; min-width: 0; }
.demo__tags { display: flex; flex-wrap: wrap; gap: .35rem; min-height: 1.65rem; }
.demo__tag {
  display: inline-flex; align-items: center; gap: .45rem; height: 1.65rem; padding: 0 .55rem;
  border-radius: 4px; background: rgb(166 140 255 / .14); border: 1px solid rgb(166 140 255 / .38); color: var(--d-fg); font-size: .75rem; white-space: nowrap;
}
.demo__tag::after {
  content: ""; width: .5rem; height: .5rem; opacity: .75;
  background: linear-gradient(45deg, transparent 44%, currentColor 44% 56%, transparent 56%), linear-gradient(-45deg, transparent 44%, currentColor 44% 56%, transparent 56%);
}
.demo__grid li { transition: opacity .25s var(--ease-out), transform .25s var(--ease-out); }
.demo__grid li.is-leaving { opacity: 0; transform: scale(.94); }

/* — Narrow frames (container queries): keep the essential, drop the extras -- */
@container (max-width: 33rem) {
  .demo__keys kbd:nth-child(-n+2) { display: none; }
  .demo__drop { grid-template-columns: minmax(0, 1fr); }
  .demo__col--products { display: none; }
  .demo__row { grid-template-columns: 1.25rem 2.1rem minmax(0, 1fr) 3.4rem; gap: .6rem; }
  .demo__row .ui-rank__bar { grid-column: 3; grid-row: 2; margin-top: .1rem; }
  .demo__row .demo__val { grid-column: 4; grid-row: 1 / span 2; }
  .demo__row .demo__rank, .demo__row .demo__thumb { grid-row: 1 / span 2; }
  .demo__split { grid-template-columns: minmax(0, 1fr); gap: .9rem; }
  .demo__facets { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; padding: 0 0 .9rem; border-right: 0; border-bottom: 1px solid var(--d-line); }
  .demo__facets .demo__facet:nth-child(2) { order: 3; grid-column: 1 / -1; }
  .demo__more, .demo__facets .demo__facet:nth-child(4) { display: none; }
  /* one row of results on narrow frames (the 4th+ visible tile is not drawn): constant height */
  .demo__grid li:not([hidden]) ~ li:not([hidden]) ~ li:not([hidden]) ~ li:not([hidden]) { display: none; }
  .demo__facets .demo__facet:nth-child(3) .ui-chip:nth-child(3), .demo__facets .demo__facet:nth-child(1) .ui-chip:nth-child(3) { display: none; }
}
@media (max-width: 599px) {
  .demo { aspect-ratio: auto; }
  .demo--auto { min-height: 24rem; }
  .demo--tri { min-height: 25rem; }
  .demo--filtres { min-height: 27rem; }
}

/* pause / play for the looping interface (created by insights.js) */
.demo-toggle {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none; border-radius: 50%;
  color: var(--fg); background: var(--surface-2); border: 1px solid var(--line-2);
  transition: border-color var(--dur-1), background-color var(--dur-1);
}
.demo-toggle:hover { border-color: var(--line-3); background: var(--surface-3); }
.demo-toggle svg { width: .8rem; height: .8rem; }

/* ---------- Post body (paper chapter) -------------------------------------- */
.post-body { padding-block: var(--space-2xl); }
.post-body__grid { display: grid; gap: var(--space-xl); }
@media (min-width: 1000px) {
  .post-body__grid { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--space-m); align-items: start; }
  .post-prose { grid-column: 1 / span 7; }
  .post-foot { grid-column: 9 / -1; }
}
.post-prose { max-width: 60ch; font-size: var(--step-1); line-height: 1.7; letter-spacing: -.003em; }
.post-prose > p:first-child::first-letter {
  float: left; margin: .02em .12em 0 -.02em; font-family: var(--font-serif); font-style: italic; font-weight: 340;
  font-size: 3.55em; line-height: .82; color: var(--fg);
}
.post-prose .post-prose__close {
  position: relative; margin-top: var(--space-l); padding-top: var(--space-m);
  font-size: var(--step-2); line-height: 1.38; letter-spacing: -.014em; color: var(--fg);
}
.post-prose__close::before { content: ""; position: absolute; left: 0; top: 0; width: 3.5rem; height: 1px; background: var(--text-spectrum); }

.post-foot { display: grid; gap: var(--space-l); align-content: start; justify-items: start; padding-top: var(--space-m); border-top: 1px solid var(--line); }
@media (min-width: 1000px) { .post-foot { padding: .35rem 0 .35rem var(--space-l); border-top: 0; border-left: 1px solid var(--line); } }
.post-foot__label { margin-bottom: .75rem; font-size: var(--step--1); font-weight: 540; color: var(--fg-3); }
.post-share__actions { --cluster-gap: .6rem; }

/* ---------- Recent posts ---------------------------------------------------- */
.insights-recent__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 1rem 2rem; margin-bottom: var(--space-l); }
.insights-recent__title { font-size: var(--step-4); line-height: 1; letter-spacing: var(--track-h2); font-weight: 540; }
