/* ============================================================
   HOVER CARDS — Unified card system for feature interactions
   Used by feature-interactions.js (custom DOM overlay)
   States: single | peek | picker
   ============================================================ */

/* ── Inner card (.gp-hp) ── */
.gp-hp {
  display: flex;
  flex-direction: column;
  width: 260px;
  max-width: 280px;
}
.gp-hp-img {
  width: 100%;
  height: 120px;
  overflow: hidden;
  position: relative;
  background: var(--surface-overlay, #F1F5F9);
}
.gp-hp-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gp-hp-body {
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gp-hp-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--primary, #14AE5C);
  opacity: .8;
}
.gp-hp-tag--travaux { color: var(--warning, #F59E0B); }

.gp-hp-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary, #0F172A);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-clamp: 2;
  overflow: hidden;
}
.gp-hp-cta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary, #475569);
  margin-top: 2px;
}
.gp-hp-cta i { font-size: 10px; opacity: .6; }

/* ============================================================
   OVERLAY — root container (position: fixed on body)
   JS sets left/top to the map feature screen position
   ============================================================ */
.gp-fan-overlay {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
}

/* ── Cards container (0×0 anchor point) ── */
.gp-fan-cards {
  position: relative;
  width: 0;
  height: 0;
  transition: all .4s cubic-bezier(.34,1.56,.64,1);
}

/* ── Base card ── */
.gp-fan-card {
  position: absolute;
  bottom: 16px;
  left: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface-base, #fff);
  border: 1px solid var(--border-light, rgba(0,0,0,.06));
  pointer-events: none;

  /* Transition-driven positioning (key for fluid 1→2→3) */
  transition:
    transform .35s cubic-bezier(.22,1,.36,1),
    opacity .25s ease,
    box-shadow .25s ease,
    filter .25s ease;
}

/* New card entering */
.gp-fan-card.entering {
  opacity: 0;
  transform: translate(-50%, 8px) scale(.92) !important;
}
/* Card leaving */
.gp-fan-card.leaving {
  opacity: 0;
  transform: translate(-50%, 8px) scale(.92) !important;
  pointer-events: none;
}

/* ============================================================
   SINGLE — 1 card + tip arrow, follows cursor
   ============================================================ */
.gp-fan-overlay.single .gp-fan-card {
  width: 260px;
  transform: translate(-50%, 0);
  box-shadow:
    0 4px 24px rgba(0,0,0,.12),
    0 1px 4px rgba(0,0,0,.08);
}
.gp-fan-overlay.single .gp-fan-card .gp-hp { width: 260px; }
.gp-fan-overlay.single .gp-fan-card .gp-hp-img { height: 120px; }

/* Tip arrow — hidden */
.gp-fan-tip {
  display: none;
}

/* ============================================================
   PEEK — cards in fan layout (rotation around bottom center)
   ============================================================ */
.gp-fan-overlay.peek .gp-fan-card {
  width: 260px;
  z-index: calc(10 - var(--i));
  transform-origin: bottom center;
  transform:
    translateX(-50%)
    rotate(calc((var(--i) - var(--mid)) * 8deg));
  box-shadow:
    0 4px 24px rgba(0,0,0,.12),
    0 1px 4px rgba(0,0,0,.08);
  /* Enable smooth transition to picker grid */
  transition: 
    transform .5s cubic-bezier(.34,1.56,.64,1),
    width .4s ease,
    box-shadow .3s ease,
    position 0s;
}
.gp-fan-overlay.peek .gp-fan-card .gp-hp { 
  width: 260px;
  transition: width .4s ease;
}
.gp-fan-overlay.peek .gp-fan-card .gp-hp-img { 
  height: 120px;
  transition: height .4s ease;
}

/* ============================================================
   PICKER — grid of visual cards (on click)
   ============================================================ */
.gp-fan-overlay.picker {
  /* Full screen centered */
  left: 0 !important;
  top: 0 !important;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

/* Backdrop */
.gp-fan-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
  z-index: -1;
  animation: gp-backdrop-in .3s ease;
}
@keyframes gp-backdrop-in { from { opacity: 0; } }

/* Grid container for picker */
.gp-fan-overlay.picker .gp-fan-cards {
  position: relative;
  width: auto;
  height: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 280px));
  gap: 20px;
  max-width: min(90vw, 900px);
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  justify-content: center;
}

.gp-fan-overlay.picker .gp-fan-card {
  position: static;
  width: 280px;
  pointer-events: auto;
  cursor: pointer;
  transform: none;
  transform-origin: center center;
  box-shadow:
    0 8px 32px rgba(0,0,0,.15),
    0 2px 8px rgba(0,0,0,.08);
  /* Smooth transition from fan to grid */
  transition: 
    transform .5s cubic-bezier(.34,1.56,.64,1),
    box-shadow .3s ease,
    opacity .3s ease;
  transition-delay: calc(var(--i) * 30ms);
}

.gp-fan-overlay.picker .gp-fan-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow:
    0 16px 48px rgba(0,0,0,.2),
    0 4px 12px rgba(0,0,0,.12);
  z-index: 10;
  transition-delay: 0ms;
}

.gp-fan-overlay.picker .gp-fan-card .gp-hp { width: 280px; }
.gp-fan-overlay.picker .gp-fan-card .gp-hp-img { height: 140px; }

/* Close button for picker */
.gp-fan-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-base, #fff);
  border: 1px solid var(--border-light, rgba(0,0,0,.1));
  color: var(--text-secondary, #475569);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  transition: transform .2s ease, background .2s ease;
  z-index: 10;
  animation: gp-close-in .3s cubic-bezier(.34,1.56,.64,1) .15s backwards;
}

.gp-fan-close:hover {
  transform: scale(1.1);
  background: var(--danger, #ef4444);
  color: #fff;
}

@keyframes gp-close-in {
  from { opacity: 0; transform: scale(.5) rotate(-90deg); }
}


/* ============================================================
   CLOSING — shared fade-out
   ============================================================ */
.gp-fan-overlay.closing .gp-fan-card,
.gp-fan-overlay.closing .gp-fan-tip {
  opacity: 0;
  transform: translate(-50%, 6px) scale(.95) !important;
  transition: all .2s cubic-bezier(.4,0,1,1);
}
/* Disable pointer capture immediately on close, even before DOM removal */
.gp-fan-overlay.closing {
  pointer-events: none;
}
.gp-fan-overlay.closing .gp-fan-backdrop {
  opacity: 0;
  transition: opacity .2s ease;
}
.gp-fan-overlay.closing .gp-fan-close {
  opacity: 0;
  transform: scale(.5) rotate(90deg);
  transition: all .15s ease;
}

/* ============================================================
   DARK THEME
   ============================================================ */
[data-theme="dark"] .gp-hp-title { color: var(--text-primary, #f8fafc); }
[data-theme="dark"] .gp-hp-cta { color: var(--text-secondary, #cbd5e1); }

[data-theme="dark"] .gp-fan-card {
  background: var(--surface-base, #0f172a);
  border-color: var(--border-light, rgba(255,255,255,.1));
}
[data-theme="dark"] .gp-fan-tip {
  border-top-color: var(--surface-base, #0f172a);
}
[data-theme="dark"] .gp-fan-backdrop { background: rgba(0,0,0,.4); }


/* ============================================================
   TOUCH DEVICES — make cards tappable
   ============================================================ */
@media (pointer: coarse) {
  .gp-fan-overlay.single .gp-fan-card,
  .gp-fan-overlay.peek .gp-fan-card {
    pointer-events: auto;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .gp-fan-overlay.single .gp-fan-card:active {
    filter: brightness(.95);
    transition-duration: 0s;
  }
}

/* ============================================================
   MOBILE — responsive card sizing + picker layout
   ============================================================ */
@media (max-width: 480px) {
  /* Single / peek: smaller cards */
  .gp-fan-overlay.single .gp-fan-card,
  .gp-fan-overlay.peek .gp-fan-card {
    width: 240px;
  }
  .gp-fan-overlay.single .gp-fan-card .gp-hp,
  .gp-fan-overlay.peek .gp-fan-card .gp-hp {
    width: 240px;
  }
  .gp-fan-overlay.single .gp-fan-card .gp-hp-img,
  .gp-fan-overlay.peek .gp-fan-card .gp-hp-img {
    height: 100px;
  }

  /* Picker: full-width single column */
  .gp-fan-overlay.picker .gp-fan-cards {
    grid-template-columns: 1fr;
    max-width: 100vw;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top, 0px));
    gap: 12px;
  }
  .gp-fan-overlay.picker .gp-fan-card,
  .gp-fan-overlay.picker .gp-fan-card .gp-hp {
    width: auto;
  }

  /* Close button: safe area aware */
  .gp-fan-close {
    top: max(12px, env(safe-area-inset-top, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}
