/* ==========================================================
   nawa home — "Choose your path" flip cards
   Front and back: white → lavender diagonal (each runs opposite to the other), navy text.
   Front icon: a small 3D model in dots (js/path-dots.js), drawn on a canvas over the
   face; the SVG keeps its box as the model's anchor and is the no-JS fallback.
   Back: navy button with white text.
   Only transform and opacity animate.

   Alignment: when the cards sit side by side, all three share the same
   row tracks through CSS subgrid (icon / title / tagline), so each element
   lines up across cards at any width. Each back uses a two-row grid:
   text from a fixed top line, button pinned to the bottom.

   The flip styles switch on only once js/flip-cards.js has run and added
   .is-ready to .flips. Without it (no JS, or the script failed) the two
   faces simply stack, so every word and link stays usable.
   ========================================================== */

.flips {
  --flip-pad-y: var(--space-4);
  --flip-pad-x: var(--space-2);
  --flip-icon-w: 220px;
  --flip-icon-h: 120px;
  display: grid;
  gap: var(--grid-gap);
}

.flip { perspective: 1400px; }

/* Hover tilt + lift lives on its own wrapper, so it can be quicker than the flip */
.flip__tilt {
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 260ms var(--ease);
}

.flip__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  height: 100%;
}

.flip__face {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  padding: var(--flip-pad-y) var(--flip-pad-x);
  border-radius: 20px;
  text-align: center;
}

/* ---------- Front ---------- */
.flip__front {
  border: 0;
  color: var(--navy);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 30px 70px -32px rgba(0, 0, 0, 0.7);
  padding-bottom: calc(var(--flip-pad-y) + var(--space-3)); /* room for the "Learn more" hint */
  /* white in one corner → lavender (#DCD5FF) in the opposite corner */
  background: linear-gradient(var(--front-angle, 135deg), #ffffff 10%, #dcd5ff 100%);
}
/* Identical icon box on every card */
.flip__icon {
  width: var(--flip-icon-w);
  max-width: 100%;
  height: var(--flip-icon-h);
  fill: none;
  stroke: var(--navy);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.flip__icon .flip__icon-fill { fill: #6a4cff; }
/* Dot icon: the canvas covers the face; the SVG stays in place (hidden) as its anchor */
.flip__dots {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  pointer-events: none;
}
html.js .flips.has-dots svg.flip__icon { visibility: hidden; }
.flip__label {
  margin-top: var(--space-2);
  max-width: 13em;
  text-wrap: balance;
  font-size: clamp(1.5rem, 1.25rem + 0.9vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--navy);
}
.flip__tagline {
  margin-top: var(--space-1);
  max-width: 18em;
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  font-weight: 500;
  line-height: 1.45;
  color: rgba(7, 0, 48, 0.7); /* ≈8:1 even on the lavender corner */
}
.flip__hint {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #5f5c79; /* ≥5.2:1 anywhere on the front gradient */
}
.flip__hint-icon { font-size: 1rem; line-height: 1; color: var(--navy); }

/* ---------- Back ---------- */
.flip__back {
  gap: var(--space-3);
  color: var(--navy);
  /* the same white → lavender as the front, running the opposite way */
  background: linear-gradient(var(--back-angle, 315deg), #ffffff 10%, #dcd5ff 100%);
}
.flip__back:focus { outline: none; }
.flip__back:focus-visible { outline: 2px solid var(--navy); outline-offset: -6px; }
.flip__desc {
  max-width: 19em;
  font-size: 1.25rem;  /* 20 on the type scale, so the back no longer sets the card height */
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--navy);
}
.flip__cta {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--navy);
  color: #ffffff;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease);
}
.flip__cta:hover { transform: translateY(-1px); }
.flip__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--navy);
  border-radius: 50%;
  background: transparent;
  color: var(--navy);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
}
/* Bigger tap area (44px) without making the circle look bigger */
.flip__close::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; }
/* Focus rings on the light card use navy (the site default is lime) */
.flip__back :focus-visible { outline: 2px solid var(--navy); outline-offset: 3px; }

/* Gradient directions: the back always runs opposite to its front,
   and each card uses a different diagonal so the three don't look identical. */
.flip:nth-child(1) { --front-angle: 135deg; --back-angle: 315deg; }
.flip:nth-child(2) { --front-angle: 225deg; --back-angle: 45deg; }
.flip:nth-child(3) { --front-angle: 315deg; --back-angle: 135deg; }

/* Stacked fallback: the flip controls do nothing there, so hide them */
.flips:not(.is-ready) .flip__hint,
.flips:not(.is-ready) .flip__close { display: none; }
.flips:not(.is-ready) .flip__front { cursor: default; }

/* ==========================================================
   Flip mode (script ready)
   ========================================================== */
.flips.is-ready .flip__inner {
  display: grid;
  gap: 0;
  transform-style: preserve-3d;
  transition: transform 600ms cubic-bezier(0.22, 0.75, 0.25, 1);
}
.flips.is-ready .flip.is-flipped .flip__inner { transform: rotateY(180deg); }
/* Both faces share one grid cell, so a card is always as tall as its taller face */
.flips.is-ready .flip__face {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
/* translateZ keeps the back off the front's plane (avoids Safari flicker/z-fighting) */
.flips.is-ready .flip__back { transform: rotateY(180deg) translateZ(1px); cursor: pointer; }

/* Front: icon / title / tagline rows; Back: text from the top, button pinned to the bottom */
.flips.is-ready .flip__front {
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  align-content: center;
}
.flips.is-ready .flip__back {
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-content: stretch;
  padding-top: var(--space-6);
  padding-bottom: var(--space-4);
}
.flips.is-ready .flip__desc { align-self: start; }

/* ---------- Side by side (≥768px): shared rows across the three cards ---------- */
@media (min-width: 768px) {
  .flips {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--grid-gap);
  }
}

/* Shared rows need subgrid. Browsers without it keep the per-card centred
   layout above (still tidy, just not aligned across cards). */
@supports (grid-template-rows: subgrid) {
  @media (min-width: 768px) {
    .flips.is-ready {
      row-gap: 0;
      /* spacer · icon · title · tagline · spacer — the spacers keep the group centred.
         Both faces feed these tracks (the back spans all five), so the tallest
         back text can add a little to the spacers; the rows stay aligned. */
      /* The bottom spacer also clears the absolutely placed "Learn more" hint (32 + 24 = 56).
         Its 1.75 share (56 / 32) keeps the two spacers at their own minimums; equal 1fr
         shares would raise the top one to 56 as well. */
      grid-template-rows: minmax(var(--flip-pad-y), 1fr) auto auto auto minmax(calc(var(--flip-pad-y) + var(--space-3)), 1.75fr);
    }
    .flips.is-ready .flip {
      grid-row: 1 / span 5;
      display: grid;
      grid-template-rows: subgrid;
    }
    .flips.is-ready .flip__tilt,
    .flips.is-ready .flip__inner {
      grid-row: 1 / -1;
      display: grid;
      grid-template-rows: subgrid;
      grid-template-columns: minmax(0, 1fr);
      height: auto;
      align-self: stretch;
    }
    .flips.is-ready .flip__face { grid-row: 1 / -1; grid-column: 1; }
    .flips.is-ready .flip__front {
      grid-template-rows: subgrid;
      align-content: stretch;
      padding-block: 0;
      min-height: 0;
    }
    .flips.is-ready .flip__back { min-height: 290px; }
    .flips.is-ready .flip__icon { grid-row: 2; }
    .flips.is-ready .flip__label { grid-row: 3; align-self: start; }
    .flips.is-ready .flip__tagline { grid-row: 4; align-self: start; }
  }
}

/* Desktop hover: a slight tilt and lift to hint it's interactive (no hover flip) */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .flips.is-ready .flip:hover .flip__tilt { transform: translateY(-6px) rotateX(3deg) rotateY(-4deg); }
}

/* Reduced motion: no 3D turn; the faces swap with a quick opacity fade.
   (Opacity only, so the face being shown is focusable straight away.) */
@media (prefers-reduced-motion: reduce) {
  .flips.is-ready .flip__inner,
  .flips.is-ready .flip.is-flipped .flip__inner,
  .flips.is-ready .flip__back { transform: none; }
  .flips.is-ready .flip__face {
    transition-property: opacity !important;
    transition-duration: 180ms !important;
  }
  .flips.is-ready .flip__back { opacity: 0; pointer-events: none; }
  .flips.is-ready .flip.is-flipped .flip__front { opacity: 0; pointer-events: none; }
  .flips.is-ready .flip.is-flipped .flip__back { opacity: 1; pointer-events: auto; }
}

/* ---------- Secondary options: title | divider | two outline buttons ---------- */
.path__more {
  display: flex;
  align-items: center;
  gap: var(--space-4);     /* equal space either side of the divider */
  margin-top: var(--space-5);
}
/* Same type as the flip card titles ("For Businesses") */
.path__more-title {
  font-size: clamp(1.5rem, 1.25rem + 0.9vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
}
.path__more-divider {
  flex: none;
  width: 1px;
  height: 40px;            /* matches the 40px buttons */
  background: rgba(255, 255, 255, 0.2);
}
.path__more-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}
/* Let long labels (e.g. translations) wrap instead of overflowing at any width */
.path__more-actions .btn { white-space: normal; text-align: center; }
/* Outline buttons: 1px white border, white text, no lime */
.btn--outline-white {
  border-width: 1px;
  border-color: var(--text);
  color: var(--text);
}
.btn--outline-white:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--text); }

@media (max-width: 767px) {
  .path__more {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .path__more-divider { width: 48px; height: 1px; }
  .path__more-actions { width: 100%; }
  /* Side by side if they fit; otherwise each wraps to its own full-width row */
  .path__more-actions .btn { flex: 1 1 auto; white-space: normal; text-align: center; }
}

/* Wide screens: more room either side of the card text */
@media (min-width: 1024px) {
  .flips { --flip-pad-x: var(--space-3); }
}

/* Phones: stacked cards, smaller icon box */
@media (max-width: 767px) {
  .flips { --flip-icon-w: 200px; --flip-icon-h: 112px; --flip-pad-y: var(--space-4); }
  .flip__label { margin-top: var(--space-2); }
}
