/* --------------------------------------------------------------------------
   Flip Card
   Front: title, graphic, and a prompt that appears on hover (desktop) or is
   always shown (touch). Back: the same title over an optional blurb and a
   scrolling list of Link Button components dropped into the slot.
   Click or tap anywhere to flip; a click on a link on the back follows it.
   -------------------------------------------------------------------------- */

/* Webflow sets display: contents on the component's host inline, so layout
   lives on .fc rather than :host. */
:host {
  display: block;
}

.fc {
  --fc-oxford-blue: #07274b;
  --fc-polynesian-blue: #0e4c92;
  --fc-celestial-blue: #469dc8;
  --fc-alice-blue: #e0edf5;
  --fc-ice-white: #fcfcfc;

  --fc-pad: 7cqw;
  --fc-title: clamp(19px, 9cqw, 46px);
  --fc-prompt: clamp(13px, 5.4cqw, 28px);
  --fc-body: clamp(12px, 3.7cqw, 18px);

  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: var(--fc-max, 420px);
  /* The shape from the mocks; the card fills its column and takes its height
     from this, so a row of cards always matches. */
  aspect-ratio: 5 / 7;
  margin-inline: auto;
  /* cq units above resolve against this box. */
  container-type: inline-size;
  perspective: 1400px;
  font-family: Montserrat, "Helvetica Neue", Arial, sans-serif;
}

.fc *,
.fc *::before,
.fc *::after {
  box-sizing: border-box;
}

/* Lift and flip are separate elements: one transform each, so they compose
   instead of overwriting one another. preserve-3d keeps the tilt and the flip
   in the same 3D space. */
.fc-lift {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.fc-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.fc[data-flipped="true"] .fc-inner {
  transform: rotateY(180deg);
}

.fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--fc-pad);
  text-align: center;
  /* On the face, not on a wrapper: a shadow on a box that does not turn with
     the card stays flat on the page and shows through mid-flip. */
  box-shadow: 0 0.6cqw 1.8cqw rgba(7, 39, 75, 0.18);
  transition: box-shadow 0.4s ease;
  /* Hides whichever face is turned away mid-flip. */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* ---------- Front ---------- */

.fc-front {
  color: var(--fc-ice-white);
  background: var(--fc-oxford-blue);
}

.fc-title {
  flex: none;
  margin: 0;
  font-size: var(--fc-title);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-transform: uppercase;
  text-wrap: balance;
}

/* Takes the space between title and prompt, so the graphic stays centred
   whether or not the prompt is showing. */
.fc-art {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding-block: 4cqw;
}

.fc-graphic {
  display: block;
  max-width: 62%;
  max-height: 100%;
  object-fit: contain;
}

.fc-prompt {
  flex: none;
  font-size: var(--fc-prompt);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

/* The whole front is one button, laid over the face. */
.fc-hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.fc-hit:focus-visible {
  outline: 3px solid var(--fc-celestial-blue);
  outline-offset: -5px;
}

.fc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Desktop with a real pointer: the prompt is a hover reveal, and the card
   lifts, scales and tilts with the pointer (the tilt angles are set from JS).
   Touch devices keep the prompt visible and never lift — there, the flip is
   the only movement.

   :has(:focus-visible) rather than :focus-within, so clicking a card does not
   leave it stuck in its hover state afterwards. None of it applies once the
   card is flipped: the lift belongs to the front. */
@media (hover: hover) and (min-width: 768px) {
  .fc-prompt {
    opacity: 0;
    transform: translateY(0.5em);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }

  .fc:not([data-flipped="true"]):hover .fc-prompt,
  .fc:not([data-flipped="true"]):has(:focus-visible) .fc-prompt {
    opacity: 1;
    transform: none;
  }

  .fc:not([data-flipped="true"]):hover .fc-lift,
  .fc:not([data-flipped="true"]):has(:focus-visible) .fc-lift {
    transform: scale(1.035) translateZ(2cqw) rotateX(var(--fc-rx, 0deg)) rotateY(var(--fc-ry, 0deg));
    /* Quick while the pointer is on the card; the longer duration above takes
       over for levelling out once it leaves. */
    transition-duration: 0.12s;
  }

  .fc:not([data-flipped="true"]):hover .fc-face,
  .fc:not([data-flipped="true"]):has(:focus-visible) .fc-face {
    box-shadow: 0 2.6cqw 4.4cqw rgba(7, 39, 75, 0.3);
  }
}

/* ---------- Back ---------- */

.fc-back {
  transform: rotateY(180deg);
  background: var(--fc-alice-blue);
  color: var(--fc-oxford-blue);
  cursor: pointer;
}

.fc-back:focus-visible {
  outline: 3px solid var(--fc-celestial-blue);
  outline-offset: -5px;
}

/* Blurb and links scroll together, so a long blurb never squeezes the links
   out of reach. Containment stops a flick inside from scrolling the page too.
   The native scrollbar is hidden in favour of the drawn one below. */
.fc-scroll-wrap {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  margin-top: 4cqw;
}

.fc-scroll {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding-inline: 1cqw 3cqw;
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: left;
  scrollbar-width: none;
}

.fc-scroll::-webkit-scrollbar {
  display: none;
}

/* Only there when the list actually overflows. */
.fc-bar {
  position: absolute;
  inset-block: 0;
  right: 0;
  width: 0.9cqw;
  min-width: 4px;
  border-radius: 999px;
  background: rgba(76, 88, 112, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.fc-scroll-wrap[data-scrollable="true"] .fc-bar {
  opacity: 1;
  pointer-events: auto;
}

.fc-bar-thumb {
  width: 100%;
  border-radius: inherit;
  background: rgba(76, 88, 112, 0.55);
  cursor: grab;
}

.fc-bar-thumb:active {
  cursor: grabbing;
  background: rgba(76, 88, 112, 0.75);
}

.fc-blurb {
  width: 100%;
  margin-bottom: 6.5cqw;
  font-size: var(--fc-body);
  font-weight: 400;
  line-height: 1.45;
}

/* No blurb written: it takes no space at all. */
.fc-blurb[data-empty="true"] {
  display: none;
}

.fc-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3.4cqw;
  width: 100%;
}

/* Webflow delivers each slot's content inside one unclassed wrapper. The links
   wrapper is made transparent so every Link Button inside becomes an item in
   the list; the blurb keeps its own block so its text flows normally. */
::slotted([slot="links"]) {
  display: contents;
}

::slotted([slot="blurb"]) {
  display: block;
  font-size: inherit;
  line-height: inherit;
}

@media (prefers-reduced-motion: reduce) {
  .fc-inner,
  .fc-lift,
  .fc-face,
  .fc-prompt {
    transition: none;
  }
}

