/* CTA pair: "Prendre rendez-vous" and "Diagnostic en ligne" share one pill.
   The booking is the fern pill; the diagnostic is a sheet of paper tucked over its far end, its
   cut edge slanted and a brass corner folded back. At rest each shows its icon and a short name.
   Hovering or focusing either one stretches it to its full name. Bringing the paper forward also
   pushes the booking back under it (it shrinks to its icon, sinks and darkens). Each link's two
   label widths are measured by CtaPair (--w-short, --w-full); without them the labels simply
   keep their natural width. */

.cta-pair {
  --pair-h: var(--size-touch);
  --pair-ease: var(--ease-fold);
  --pair-time: 0.45s;
  --overlap: 22px;
  display: inline-flex;
  align-items: stretch;
  isolation: isolate;
}

.cta-pair__book,
.cta-pair__test {
  display: inline-flex;
  align-items: center;
  min-height: var(--pair-h);
  font: 600 var(--text-sm) / 1.2 var(--font-body);
  text-decoration: none;
  white-space: nowrap;
}

.cta-pair__icon {
  flex: none;
  width: 18px;
  height: 18px;
}

.cta-pair__label {
  display: grid;
  overflow: hidden;
  width: var(--w-short, auto);
  transition: width var(--pair-time) var(--pair-ease), opacity var(--pair-time) var(--pair-ease);
}

/* A link's short and full names share one cell; only one shows at a time. */
.cta-pair__text {
  grid-area: 1 / 1;
  width: max-content;
}

/* ─── The booking pill ─── */

.cta-pair__book {
  position: relative;
  z-index: 1;
  gap: var(--space-2);
  padding: 0 calc(var(--overlap) + var(--space-4)) 0 var(--space-5);
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  transform-origin: 0 50%;
  transition: transform var(--pair-time) var(--pair-ease), background-color var(--duration-hover) ease, box-shadow var(--pair-time) var(--pair-ease), padding var(--pair-time) var(--pair-ease);
}

/* The colour is restated: the global a:hover would otherwise paint the label fern on fern. */
.cta-pair__book:hover {
  background: var(--color-primary-hover);
  color: var(--color-primary-contrast);
}

/* ─── The diagnostic tab: paper laid over the pill's end ─── */

.cta-pair__test {
  position: relative;
  z-index: 2;
  gap: var(--space-2);
  margin-left: calc(-1 * var(--overlap));
  padding: 0 var(--space-4) 0 calc(var(--space-4) + 6px);
  color: var(--color-text);
  filter: drop-shadow(-3px 2px 3px color-mix(in srgb, var(--shadow-ink) 18%, transparent));
}

/* The paper itself, cut on a slant where it lies over the pill. */
.cta-pair__test::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  background: var(--color-surface);
  clip-path: polygon(12px 0, 100% 0, 100% 100%, 0 100%);
  transition: background-color var(--duration-hover) ease;
}

/* The folded corner: its brass back shows. */
.cta-pair__test::after {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  width: 9px;
  height: 9px;
  background: linear-gradient(135deg, var(--brass-400), var(--brass-600));
  clip-path: polygon(0 0, 100% 0, 0 100%);
  transition: transform var(--pair-time) var(--pair-ease);
  transform-origin: 0 0;
}

.cta-pair__test .cta-pair__icon {
  color: var(--color-primary);
}

.cta-pair__text--full {
  opacity: 0;
}

.cta-pair__text--short,
.cta-pair__text--full {
  transition: opacity var(--pair-time) var(--pair-ease);
}

.cta-pair__arrow {
  flex: none;
  width: 0;
  height: 16px;
  margin-left: calc(-1 * var(--space-2));
  color: var(--color-primary);
  opacity: 0;
  transition: width var(--pair-time) var(--pair-ease), margin var(--pair-time) var(--pair-ease), opacity var(--pair-time) var(--pair-ease);
}

/* ─── Hover or focus: the link stretches to its full name ─── */

:is(.cta-pair__book, .cta-pair__test):is(:hover, :focus-visible) .cta-pair__label {
  width: var(--w-full, auto);
}

:is(.cta-pair__book, .cta-pair__test):is(:hover, :focus-visible) .cta-pair__text--short {
  opacity: 0;
}

:is(.cta-pair__book, .cta-pair__test):is(:hover, :focus-visible) .cta-pair__text--full {
  opacity: 1;
}

/* ─── Forward: the paper comes over, the booking is pushed back ─── */

.cta-pair__test:is(:hover, :focus-visible) .cta-pair__arrow {
  width: 16px;
  margin-left: 0;
  opacity: 1;
}

.cta-pair__test:is(:hover, :focus-visible)::after {
  transform: scale(1.45);
}

.cta-pair:has(.cta-pair__test:is(:hover, :focus-visible)) .cta-pair__book {
  padding-left: var(--space-4);
  background: var(--fern-700);
  box-shadow: inset 0 0 0 999px color-mix(in srgb, var(--shadow-ink) 14%, transparent);
  transform: scale(0.92);
}

.cta-pair:has(.cta-pair__test:is(:hover, :focus-visible)) .cta-pair__book .cta-pair__label {
  width: 0;
  opacity: 0;
}

/* The current page's tab (diagnostic.html) stays forward and reads as "you are here". */
.cta-pair__test[aria-current="page"] .cta-pair__arrow {
  display: none;
}

.cta-pair__book:focus-visible,
.cta-pair__test:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

.cta-pair__test:focus-visible {
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

/* The booking pill stays fern in every header state (at rest too), so pushing it back only
   darkens it and its icon always shows. */

/* ─── Small screens: the tab keeps its icon only; its name stays in aria-label ─── */

@media (max-width: 520px) {
  .cta-pair {
    --overlap: 18px;
  }

  .cta-pair__book {
    padding-left: var(--space-4);
  }

  .cta-pair__test {
    padding-right: var(--space-3);
  }

  .cta-pair__test .cta-pair__label,
  .cta-pair__test:is(:hover, :focus-visible) .cta-pair__label {
    width: 0;
  }

  .cta-pair__arrow {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cta-pair__book,
  .cta-pair__label,
  .cta-pair__text--short,
  .cta-pair__text--full,
  .cta-pair__arrow,
  .cta-pair__test::after {
    transition: none;
  }
}
