/**
 * File cards.css.
 *
 * Card deck section on the home page (used with js/cards.js).
 */

/* ---------- Settings ---------- */
.card-deck {
  --deck-bg: #fff;
  --deck-card-w: min(44vw, 250px);   /* 44% of screen width, max 280px */
  --deck-card-radius: 14px;
  --deck-flip-speed: 0.75s;
}

@media (min-width: 768px) {
  .card-deck { --deck-card-w: min(44vw, 280px); }
}

/* The whole section */
.card-deck {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 50px 0 0px;
  overflow: hidden;   /* hide cards that fan off the edges */
  background: var(--deck-bg);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- Stage ---------- */
.deck-stage {
  position: relative;
  width: 100%;
  height: calc(var(--deck-card-w) * 5 / 3 + 140px);
  touch-action: pan-y;   /* allow vertical scroll, we handle swipes */
  cursor: grab;
  outline: none;
}
.deck-stage.is-dragging { cursor: grabbing; }

/* One card (JavaScript sets its position) */
.deck-card {
  position: absolute;
  left: 50%;
  top: 30px;
  width: var(--deck-card-w);
  aspect-ratio: 3 / 5;          /* matches the 600×1000 card images */
  perspective: 1400px;          /* gives the flip real 3D depth */
  will-change: transform, opacity;
  transform-origin: 50% 100%;   /* tilt from the bottom middle */
}

/* The part that rotates when flipped */
.deck-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;   /* keep the two faces in 3D space */
  transition: transform var(--deck-flip-speed) cubic-bezier(.2,.75,.25,1);
}
/* JavaScript adds .is-flipped → the card turns over */
.deck-card.is-flipped .deck-card-inner { transform: rotateY(180deg); }

/* Front and back faces, stacked */
.deck-face {
  position: absolute;
  inset: 0;
  border-radius: var(--deck-card-radius);
  overflow: hidden;
  backface-visibility: hidden;   /* hide a face when turned away */
  -webkit-backface-visibility: hidden;
  box-shadow: 0 18px 40px rgba(0,0,0,.35), 0 4px 10px rgba(0,0,0,.25);
  background-color: #002d62;
  background-size: cover;
  background-position: center;
}

/* Front of card */
.deck-front {
  transform: rotateY(180deg);   /* starts turned away */
}

/* ---------- Pick for me ---------- */
.deck-pick {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: none;
  border: 0;
  color: #000000;
  font: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  font-weight: 600;
  text-transform: uppercase;
}
.deck-pick-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(180deg, #002e63, #5987bf);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 22px rgba(0,0,0,.3);
  transition: transform .25s ease, box-shadow .25s ease;
}
.deck-pick:hover .deck-pick-icon { transform: translateY(-3px) scale(1.04); box-shadow: 0 12px 28px rgba(0,0,0,.35); }
.deck-pick:active .deck-pick-icon { transform: scale(.96); }
.deck-pick:disabled { opacity: .6; cursor: default; }
.deck-pick:focus-visible .deck-pick-icon { outline: 3px solid #fff; outline-offset: 4px; }

/* Instant flip for reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  .card-deck { --deck-flip-speed: 0.01s; }
}

/* ---------- Share ---------- */

/* Button in the top-right corner of the card front, only usable once the card is face up */
.deck-share {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.92);
  color: #002e63;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.deck-card.is-flipped .deck-share {
  opacity: 1;
  pointer-events: auto;
  transition-delay: calc(var(--deck-flip-speed) * .6), 0s;   /* appear once the flip is mostly done */
}
.deck-share:hover { transform: scale(1.08); }
.deck-share:active { transform: scale(.95); }
.deck-share:focus-visible { outline: 3px solid #5987bf; outline-offset: 2px; }

/* Pop-up list of share options (added to <body> by cards.js) */
.deck-share-menu {
  position: fixed;
  z-index: 100000;
  min-width: 200px;
  padding: 6px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 40px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
}
.deck-share-menu[hidden] { display: none; }

.deck-share-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: #1a1a1a;
  font: inherit;
  font-size: .95rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.deck-share-item svg { flex: none; color: var(--share-color, #002e63); }
.deck-share-item:hover,
.deck-share-item:focus-visible { background: #f0f4fa; color: #1a1a1a; outline: none; }
/* "Share image" sits on top, set apart from the link options */
.deck-share-native { font-weight: 600; border-bottom: 1px solid #e6ebf2; border-radius: 8px 8px 0 0; margin-bottom: 4px; }
