/* ================================================================
   LOKADO — App mobile / Charte claire Royan Shopping
   v2 : ajout styles visites, progression, partage, celebration
   ================================================================ */

:root {
  --bg:         #F7FAFC;
  --bg-card:    #FFFFFF;
  --bg-accent:  #EBF2FA;
  --border:     #E3E8EF;
  --brand:      #1a3a6b;
  --brand-2:    #142d55;
  --green:      #059669;
  --green-bg:   #D1FAE5;
  --green-bd:   #6EE7B7;
  --amber:      #F59E0B;
  --amber-bg:   #FEF3E0;
  --amber-bd:   #F5D48C;
  --amber-tx:   #B97A0A;
  --text:       #0D1B2A;
  --text-2:     #3D5166;
  --text-3:     #5A7A95;
  --text-4:     #A8B5C3;
  --nav-h:      58px;
  --radius:     14px;
  --radius-sm:  10px;

  /* === HAUTEUR D'ÉCRAN FIABLE — fix Safari iOS === */
  /* Cascade de fallback :
     1. --app-height-js (calculé en JS, marche sur tout iOS)
     2. 100dvh (Safari iOS 15.4+, Chrome 108+, Firefox 101+)
     3. 100vh (legacy)
  */
  --app-height: 100vh;
  --app-height: 100dvh;

  /* === SAFE AREA iPhone (encoche / barre Home) === */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height-js, 100dvh);
  background: var(--bg); color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400; font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  /* Empêche le bounce iOS qui peut faire apparaître la barre d'outils */
  position: fixed;
  width: 100%;
  overflow: hidden;
}

h1, h2, h3 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 700; margin: 0; color: var(--text);
}

#app {
  /* Hauteur fiable via flexbox vertical : main (flex:1) + bottom-nav (fixe) */
  height: 100vh;
  height: 100dvh;
  height: var(--app-height-js, 100dvh);
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

#main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
  /* Espace en bas pour la nav fixe + safe-area iPhone */
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom));
}

/* ===== SCREENS ===== */

.screen { padding: 20px 18px 24px; }

.screen-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.screen-header .back {
  background: transparent; border: none; padding: 4px 8px;
  font-size: 22px; color: var(--brand); cursor: pointer; line-height: 1;
}
.screen-header .title { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }

/* ===== HOME ===== */

.home-logo { text-align: center; padding: 24px 0 18px; }
.home-logo svg { height: 50px; }

.event-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px 18px;
  margin-bottom: 14px; text-align: center;
}
.event-card .emoji { font-size: 42px; line-height: 1; margin-bottom: 10px; }
.event-card .title {
  font-size: 17px; font-weight: 500;
  font-family: 'Bricolage Grotesque', sans-serif;
  color: var(--text); margin-bottom: 4px;
}
.event-card .date { font-size: 12px; color: var(--text-3); margin-bottom: 14px; }
.event-card .desc { font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 0; }

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-row .stat-card {
  margin-bottom: 0;
  padding: 16px 10px;
}
.stat-row .stat-card .number { font-size: 36px; }
.stat-row .stat-card .label { font-size: 10px; letter-spacing: 1px; margin-top: 6px; }

.stat-card {
  background: var(--bg-accent); border: 1px solid #C8DCF0;
  border-radius: 18px; padding: 18px;
  text-align: center; margin-bottom: 14px;
}
.stat-card .number {
  font-size: 44px; font-weight: 500;
  color: var(--brand); line-height: 1;
  font-family: 'Bricolage Grotesque', sans-serif;
}
.stat-card .label {
  font-size: 11px; color: var(--brand);
  text-transform: uppercase; letter-spacing: 1.5px;
  margin-top: 8px; font-weight: 500;
}

.stat-card.stat-open {
  background: #D1FAE5;
  border-color: #6EE7B7;
}
.stat-card.stat-open .number,
.stat-card.stat-open .label {
  color: #047857;
}

/* ===== PROGRESSION (nouveau v2) ===== */

.progress-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 18px; padding: 18px;
  margin-bottom: 14px;
}
.progress-card.complete {
  background: var(--green-bg); border: 1px solid var(--green-bd);
  text-align: center;
  padding: 22px 18px;
}
.progress-top {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.progress-count {
  font-size: 24px; font-weight: 500; color: var(--brand);
  font-family: 'Bricolage Grotesque', sans-serif;
}
.progress-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; }
.progress-bar {
  height: 8px; background: var(--bg-accent);
  border-radius: 4px; overflow: hidden; margin-bottom: 14px;
}
.progress-fill {
  height: 100%; background: var(--brand);
  border-radius: 4px; transition: width .4s ease;
}

.confettis { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.complete-title {
  font-size: 18px; font-weight: 700; color: #065F46;
  font-family: 'Bricolage Grotesque', sans-serif;
  margin-bottom: 4px;
}
.complete-sub { font-size: 12px; color: #065F46; margin-bottom: 16px; }
.progress-card.complete .btn-primary {
  background: var(--green); margin-bottom: 8px;
}
.progress-card.complete .btn-primary:hover { background: #047857; }

.btn-link {
  display: block; width: 100%;
  background: transparent; color: #065F46;
  border: none; padding: 6px; cursor: pointer;
  font-family: inherit; font-size: 12px;
  text-decoration: underline;
}

/* ===== CTA ===== */

.btn-primary, .cta {
  display: block; width: 100%;
  background: var(--brand); color: #fff;
  border: none; padding: 15px; border-radius: var(--radius);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; text-align: center; text-decoration: none;
  transition: background .15s;
}
.btn-primary:hover, .cta:hover { background: var(--brand-2); }

.btn-secondary {
  display: block; width: 100%;
  background: var(--bg-card); color: var(--brand);
  border: 1px solid var(--border); padding: 13px;
  border-radius: var(--radius); font-family: inherit;
  font-size: 14px; font-weight: 500; cursor: pointer;
  text-align: center; text-decoration: none;
}

.btn-sm { padding: 10px; font-size: 12px; }

/* Bouton visite — état "marque comme visite" */
.btn-visit {
  background: var(--green) !important;
}
.btn-visit:hover { background: #047857 !important; }

.btn-visited {
  display: block; width: 100%;
  background: var(--green-bg); color: #065F46;
  border: 1px solid var(--green-bd);
  padding: 13px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: center;
}
.btn-visited .check {
  display: inline-block; width: 18px; height: 18px; line-height: 18px;
  border-radius: 50%; background: var(--green); color: #fff;
  font-size: 11px; font-weight: 700; margin-right: 6px;
  vertical-align: middle;
}

.footer-brand {
  text-align: center; padding: 18px 0 4px;
  font-size: 10px; color: var(--text-4);
}

/* ===== INSTAGRAM CARD (home) ===== */

.insta-card {
  background: linear-gradient(135deg, #FDF4F0 0%, #FCE8F3 50%, #EBE5FD 100%);
  border: 1px solid #F3D5E5;
  border-radius: 18px;
  padding: 18px;
  margin-top: 18px;
  text-align: center;
}
.insta-header {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 12px;
}
.insta-icon { font-size: 22px; line-height: 1; }
.insta-title {
  font-size: 14px; font-weight: 600;
  color: #4B2954;
  font-family: 'Bricolage Grotesque', sans-serif;
}
.insta-tags {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin-bottom: 10px;
}
.insta-tag {
  display: inline-block;
  padding: 5px 11px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  background: #fff;
  border: 1px solid #EAD0DC;
}
.insta-tag.hashtag { color: #8B2E5C; }
.insta-tag.mention { color: #4B2954; }
.insta-hint {
  font-size: 11px; color: #6B4C5C;
  margin-bottom: 14px;
}
.insta-concours {
  display: flex; align-items: flex-start; gap: 10px;
  background: #fff;
  border: 1px solid #EAD0DC;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  text-align: left;
}
.insta-concours-icon {
  font-size: 18px; line-height: 1.3; flex-shrink: 0;
}
.insta-concours-text {
  font-size: 11px; color: #4B2954;
  line-height: 1.45;
}
.btn-insta {
  display: block; width: 100%;
  background: #fff; color: #4B2954;
  border: 1px solid #EAD0DC;
  padding: 11px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: center;
}
.btn-insta:active { transform: scale(.98); }

/* ===== SEARCH ===== */

.search-wrap { padding: 12px 14px; background: var(--bg); border-bottom: 1px solid var(--border); }
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
}
.search-bar .icon { font-size: 13px; color: var(--text-4); }
.search-bar input {
  flex: 1; background: transparent; border: none; outline: none;
  font-family: inherit; font-size: 13px; color: var(--text);
}
.search-bar input::placeholder { color: var(--text-4); }

/* ===== FILTER CHIPS ===== */

.chips { display: flex; gap: 6px; padding: 10px 14px; overflow-x: auto; background: var(--bg); border-bottom: 1px solid var(--border); }
.chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--bg-card); color: var(--text-3);
  border: 1px solid var(--border);
  padding: 5px 12px; border-radius: 20px;
  font-size: 11px; white-space: nowrap; cursor: pointer;
  font-family: inherit;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 500; }

/* ===== SHOP LIST ===== */

.shops-list { padding: 12px 14px; }
.shop-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
  margin-bottom: 10px; cursor: pointer;
  transition: transform .1s;
  text-decoration: none; color: var(--text);
  position: relative;
}
.shop-card:active { transform: scale(0.98); }

.shop-card.visited {
  background: var(--green-bg);
  border-color: var(--green-bd);
}
.shop-card.visited .name { color: #065F46; }

.shop-icon {
  width: 46px; height: 46px; flex-shrink: 0;
  background: var(--amber-bg); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; position: relative;
}
.shop-card.visited .shop-icon { background: #fff; }

.visited-badge {
  position: absolute; top: -4px; right: -4px;
  width: 18px; height: 18px;
  background: var(--green); color: #fff;
  border-radius: 50%; border: 2px solid #fff;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

.shop-info { flex: 1; min-width: 0; }
.shop-info .name { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.shop-info .meta { font-size: 10px; color: var(--text-3); }
.shop-card .chevron { color: var(--text-4); font-size: 16px; }

.empty-state {
  text-align: center; color: var(--text-4);
  font-size: 12px; padding: 24px 10px;
}

/* ===== SHOP DETAIL ===== */

.shop-detail { padding: 18px 18px 24px; }
.shop-detail-head {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
}
.shop-detail-head .icon-big {
  width: 64px; height: 64px; background: var(--amber-bg);
  border-radius: 18px; display: flex; align-items: center;
  justify-content: center; font-size: 32px; position: relative;
}
.visited-badge-lg {
  position: absolute; top: -6px; right: -6px;
  width: 24px; height: 24px;
  background: var(--green); color: #fff;
  border-radius: 50%; border: 3px solid #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.shop-detail-head .name { font-size: 17px; font-weight: 500; color: var(--text); }
.shop-detail-head .type { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.surprise-block {
  background: var(--amber-bg); border: 1px solid var(--amber-bd);
  border-radius: 14px; padding: 14px; margin-bottom: 16px;
}
.surprise-block .label {
  font-size: 10px; color: var(--amber-tx);
  text-transform: uppercase; letter-spacing: 1px;
  font-weight: 600; margin-bottom: 6px;
}
.surprise-block .text { font-size: 13px; line-height: 1.5; color: var(--text); }

.info-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; font-size: 12px; color: var(--text); }
.info-row .ico { width: 16px; flex-shrink: 0; color: var(--text-4); font-size: 12px; margin-top: 1px; }
.info-row .sub { font-size: 10px; color: var(--text-3); margin-top: 2px; }

.detail-actions { margin-top: 20px; }
.detail-actions .btn-primary, .detail-actions .btn-secondary, .detail-actions .btn-visited { margin-bottom: 8px; }

/* ===== MAP ===== */

/* ===== MAP ===== */
/* Conteneur écran Map : prend toute la hauteur dispo de #main */
#main > div:has(.map-wrap) {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.map-wrap {
  flex: 1;
  min-height: 300px;
  position: relative;
}
/* Fallback pour les navigateurs sans :has() */
@supports not selector(:has(*)) {
  .map-wrap {
    height: calc(var(--app-height) - var(--nav-h) - var(--safe-bottom) - 70px);
    min-height: 300px;
  }
}
#map { width: 100%; height: 100%; background: #E8EEF2; }

.leaflet-container { background: #E8EEF2; font-family: inherit; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 10px 12px; font-size: 12px; color: var(--text); }

.lokado-pin {
  width: 34px; height: 34px;
  background: var(--amber);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  display: flex; align-items: center; justify-content: center;
}
.lokado-pin.visited { background: var(--green); }
.lokado-pin span { transform: rotate(45deg); font-size: 15px; line-height: 1; }

.pin-check {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px;
  background: #fff; color: var(--green);
  border-radius: 50%; border: 2px solid var(--green);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ===== BOTTOM NAV ===== */

#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-card); border-top: 1px solid var(--border);
  display: flex;
  max-width: 520px; margin: 0 auto; z-index: 100;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  background: transparent; border: none; cursor: pointer; padding: 0;
  color: var(--text-4); font-family: inherit;
}
.tab.active { color: var(--brand); }
.tab.active .tab-label { font-weight: 600; }
.tab-icon { font-size: 18px; line-height: 1; }
.tab-label { font-size: 9px; font-weight: 500; }

/* ===== CELEBRATION (chasse terminee) ===== */

.celebration-overlay {
  position: fixed; inset: 0;
  background: rgba(13,27,42,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn .2s ease;
}
.celebration-content {
  text-align: center;
  animation: popIn .4s cubic-bezier(.17,.67,.32,1.43);
}
.celebration-emoji {
  font-size: 80px; line-height: 1; margin-bottom: 12px;
  animation: bounce 1s ease infinite;
}
.celebration-text {
  color: #fff; font-size: 22px; font-weight: 700;
  font-family: 'Bricolage Grotesque', sans-serif;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ===== UTILS ===== */

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(245,158,11,.15); color: var(--amber-tx);
  padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 500;
}
.status-badge .dot { width: 6px; height: 6px; background: var(--amber); border-radius: 50%; }

/* ===== OPEN/CLOSED BADGES ===== */

.name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
  flex-wrap: wrap;
}
.name-row .name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.open-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.open-badge.open {
  background: #D1FAE5;
  color: #047857;
}
.open-badge.closed {
  background: #FEE2E2;
  color: #B91C1C;
}

.open-badge-wrap {
  margin-top: 4px;
}
.open-badge-lg {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.open-badge-lg.open {
  background: #D1FAE5;
  color: #047857;
}
.open-badge-lg.closed {
  background: #FEE2E2;
  color: #B91C1C;
}

/* === Bouton "ma position" === */
.map-locate-btn { color: var(--text); }
.map-locate-btn svg { display: block; transition: transform .3s var(--easing); }
.map-locate-btn.is-loading svg {
  animation: locate-spin 1s linear infinite;
}
.map-locate-btn.is-active {
  color: #1A73E8;
  background: rgba(232, 240, 254, 0.95);
}
.map-locate-btn.is-error { color: #DC2626; }

@keyframes locate-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* === Marker position utilisateur (point bleu pulsant) === */
.user-location-icon {
  position: relative;
  width: 22px;
  height: 22px;
  pointer-events: none;
}
.user-location-dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  background: #1A73E8;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  z-index: 2;
}
.user-location-pulse {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 22px; height: 22px;
  background: rgba(26, 115, 232, 0.4);
  border-radius: 50%;
  animation: user-pulse 2s ease-out infinite;
  z-index: 1;
}
@keyframes user-pulse {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0;   }
}

/* === Toast d'erreur geoloc === */
.locate-toast {
  position: fixed;
  bottom: calc(var(--nav-h, 58px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: rgba(15, 23, 42, 0.95);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 500;
  text-align: center;
  z-index: 5000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: locate-toast-in .25s var(--easing);
}
.locate-toast.is-leaving {
  animation: locate-toast-out .3s var(--easing) forwards;
}
@keyframes locate-toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0);    }
}
@keyframes locate-toast-out {
  from { opacity: 1; transform: translate(-50%, 0);    }
  to   { opacity: 0; transform: translate(-50%, 12px); }
}

/* === Distance live (calcul GPS depuis position utilisateur) === */
.dist-live {
  display: inline-block;
  color: #1A73E8;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
