/* ════════════════════════════════════════════════════════════════════
   EXPLORE FEED — v313.154.152 (restored native mobile gallery)
   Mobile: overlay full-screen + hero motivazionale aspect 16/10.
   Desktop: sidebar 640px sinistra, mappa visibile a destra.
   ════════════════════════════════════════════════════════════════════ */

/* === BASE === */
#archeoExploreFeed {
  position: fixed;
  inset: 0;
  z-index: 8800;
  background: #f8f7f4;
  display: none;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#archeoExploreFeed.aef-visible { display: flex; }

.aef-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Sidebar header (desktop only — nascosto mobile) */
.aef-sidebar-head {
  display: none;
}

/* Search header */
.aef-header {
  position: sticky;
  top: 0;
  background: #f8f7f4;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  z-index: 5;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
}
.aef-search {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 999px;
  padding: 12px 18px; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.aef-search-icon { font-size: 16px; opacity: 0.6; }
.aef-search-input {
  flex: 1; border: 0; background: transparent;
  font-size: 15px; font-weight: 500; color: #1a1a1a; outline: none;
}
.aef-search-input::placeholder { color: #999; font-weight: 400; }

/* === HERO MOTIVAZIONALE === */
.aef-hero {
  position: relative;
  margin: 16px 16px 8px;
  aspect-ratio: 16/10;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(135deg, #2a1810 0%, #6b3f1a 35%, #b3771f 70%, #e8b454 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  padding: 18px 20px;
}
.aef-hero-decor {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 18% 82%, rgba(255,255,255,0.18) 1.4px, transparent 1.6px),
    radial-gradient(circle at 78% 22%, rgba(255,255,255,0.14) 1.4px, transparent 1.6px),
    radial-gradient(circle at 42% 50%, rgba(255,255,255,0.10) 1px, transparent 1.2px);
  background-size: 90px 90px, 110px 110px, 60px 60px;
  opacity: 0.85;
  pointer-events: none;
}
.aef-hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at top right, rgba(255,222,150,0.28) 0%, transparent 55%);
  pointer-events: none;
}
.aef-hero-content { position: relative; text-align: center; z-index: 2; }
.aef-hero-globe {
  font-size: 36px; line-height: 1; margin-bottom: 8px;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}
.aef-hero-overline {
  font-size: 9.5px; font-weight: 800; letter-spacing: 3px;
  text-transform: uppercase; opacity: 0.78; margin-bottom: 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.aef-hero-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px; font-weight: 400; line-height: 1.2;
  letter-spacing: -0.2px; margin: 0 0 4px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.aef-hero-italic { display: block; font-style: italic; font-weight: 500; opacity: 0.96; }
.aef-hero-bold {
  display: block; font-weight: 800; margin-top: 4px; font-style: normal;
  background: linear-gradient(180deg, #fff 0%, #ffe8b3 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.aef-hero-sub {
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 11.5px; font-weight: 600; opacity: 0.92;
  margin: 6px 0 0; line-height: 1.4;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
}

/* === SECTION HEAD === */
.aef-section-head { padding: 18px 16px 8px; }
.aef-section-title {
  font-size: 18px; font-weight: 800; color: #1a1a1a;
  margin: 0 0 2px; letter-spacing: -0.2px;
}
.aef-section-sub { font-size: 12.5px; color: #888; font-weight: 500; }

/* === LIST === */
.aef-list {
  padding: 0 16px 12px;
  display: flex; flex-direction: column; gap: 16px;
}
.aef-loading,
.aef-empty {
  text-align: center; padding: 60px 20px;
  color: #666; font-size: 14px; line-height: 1.5;
}
.aef-bottom-spacer { height: calc(env(safe-area-inset-bottom, 0px) + 100px); }

/* === CARD === */
.aef-card {
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.aef-card-photos-wrap {
  position: relative; width: 100%; aspect-ratio: 16/10;
  overflow: hidden; background: #e8e6e3;
}
.aef-card-photos {
  display: flex; width: 100%; height: 100%;
  overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  touch-action: pan-x pan-y pinch-zoom;
}
.aef-card-photos::-webkit-scrollbar { display: none; }
.aef-card-photo-link {
  flex: 0 0 100%; position: relative; width: 100%; height: 100%;
  scroll-snap-align: center; cursor: pointer; display: block;
  touch-action: pan-x pan-y pinch-zoom;
}
.aef-card-photo {
  width: 100%; height: 100%; object-fit: cover;
  display: block; pointer-events: none;
}
.aef-card-photo-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 14px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
  color: #fff; pointer-events: none;
}
.aef-card-photo-title {
  font-size: 16px; font-weight: 800;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  margin-bottom: 4px; letter-spacing: -0.2px;
}
.aef-card-photo-meta {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 12px; font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6); opacity: 0.95;
}
.aef-card-photos-dots {
  position: absolute; bottom: 6px; left: 50%;
  transform: translateX(-50%); display: flex; gap: 4px;
  z-index: 2; pointer-events: none;
}
.aef-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(255,255,255,0.55);
  transition: background .2s, width .2s;
}
.aef-dot.is-active { background: #fff; width: 16px; border-radius: 999px; }

.aef-card-heart {
  position: absolute; top: 12px; right: 12px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: rgba(255,255,255,0.92);
  font-size: 20px; color: #1a1a1a; cursor: pointer;
  z-index: 3; box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
.aef-card-heart.is-active { color: #e53935; }
.aef-card-heart:active { transform: scale(0.92); }

.aef-card-mini-map {
  position: absolute; top: 12px; left: 12px;
  width: 56px; height: 56px;
  border-radius: 12px; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  border: 2px solid #fff; z-index: 2; pointer-events: none;
}
.aef-card-mini-map img { width: 100%; height: 100%; object-fit: cover; display: block; }

.aef-card-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px 14px; cursor: pointer;
}
.aef-card-foot-info { flex: 1; min-width: 0; }
.aef-card-foot-title {
  font-size: 15px; font-weight: 800; color: #1a1a1a;
  letter-spacing: -0.1px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aef-card-foot-sub {
  font-size: 12.5px; color: #666; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aef-card-go {
  flex-shrink: 0; width: 32px; height: 32px;
  border-radius: 50%; border: 1px solid rgba(0,0,0,0.1);
  background: #fff; color: #555; font-size: 18px;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-weight: 700;
}

/* === FAB MAPPA (mobile only) === */
.aef-map-fab {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  left: 50%; transform: translateX(-50%);
  z-index: 9000;
  background: #2db150; color: #fff; border: 0;
  padding: 14px 28px; border-radius: 999px;
  font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 20px rgba(45,177,80,0.45), 0 2px 6px rgba(0,0,0,0.18);
  display: flex; align-items: center; gap: 8px;
}
.aef-map-fab:active { transform: translateX(-50%) scale(0.96); }

/* === REOPEN TAB (desktop only) === */

/* === MOBILE: nasconde FAB della mappa quando feed visible === */
body.aef-feed-on .topbar,
body.aef-feed-on #suBar,
body.aef-feed-on #am-tier-filter-bar,
body.aef-feed-on #petalFab,
body.aef-feed-on .fab-group,
body.aef-feed-on #v89AdminBar,
body.aef-feed-on #v109AdminLiveBar,
body.aef-feed-on .archeo-compass,
body.aef-feed-on #archeo-layer-switcher {
  visibility: hidden !important;
  pointer-events: none !important;
}

/* v119: 1 banner update unico */
html body #archeo-update-toast,
html body #__archeo_update_banner {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ════════════════════════════════════════════════════════════════════
   DESKTOP (≥760px): sidebar sinistra 640px, mappa visibile a destra
   ════════════════════════════════════════════════════════════════════ */
@media (min-width: 760px) {
  /* SLIDE animation: sidebar entra/esce da sinistra come tendina */
  #archeoExploreFeed {
    transform: translateX(-100%);
    transition: transform .3s cubic-bezier(.2,.8,.2,1);
  }
  #archeoExploreFeed.aef-visible {
    transform: translateX(0);
  }
  #archeoExploreFeed:not(.aef-visible) {
    pointer-events: none;
  }

  /* Overlay diventa sidebar fissa */
  #archeoExploreFeed {
    width: 380px;
    max-width: 88vw;
    inset: auto;
    top: 0; left: 0; bottom: 0;
    box-shadow: 0 0 32px rgba(0,0,0,0.28);
    border-right: 1px solid rgba(0,0,0,0.08);
  }

  /* === MANIGLIA LATERALE (desktop) ============================
     Sempre visibile sul bordo della sidebar.
     Quando sidebar APERTA: maniglia accanto al bordo destro, icon ◀ (chiudi)
     Quando sidebar CHIUSA: maniglia attaccata al bordo sinistro schermo, icon ▶ (apri) */
  #aefHandle {
    position: fixed;
    top: 50%;
    left: 380px;
    transform: translate(-50%, -50%);
    z-index: 9050;
    width: 36px;
    height: 64px;
    border-radius: 0 18px 18px 0;
    border: 0;
    background: #ffffff;
    color: #1a1a1a;
    box-shadow: 4px 0 14px rgba(0,0,0,0.18);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left .3s cubic-bezier(.2,.8,.2,1), background .15s, transform .25s;
    padding-left: 6px;
  }
  #aefHandle:hover {
    background: #f5f5f5;
  }
  #aefHandle svg {
    transition: transform .3s ease;
    margin-left: 6px;
  }
  /* Quando sidebar VISIBILE: maniglia sul bordo destro (a 380px), icon ◀ */
  body.aef-feed-on #aefHandle {
    left: 380px;
  }
  /* Quando sidebar CHIUSA: maniglia a sinistra schermo (left:0), icon ▶ (rotated) */
  body:not(.aef-feed-on) #aefHandle {
    left: 0;
    transform: translate(0, -50%);
    border-radius: 0 18px 18px 0;
  }
  body:not(.aef-feed-on) #aefHandle svg {
    transform: rotate(180deg);
  }

  /* Sidebar header visibile */
  .aef-sidebar-head {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 22px 22px 14px;
    background: #fff;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    position: sticky;
    top: 0;
    z-index: 6;
  }
  .aef-sidebar-title {
    font-size: 18px;
    font-weight: 800;
    color: #1a1a1a;
    margin: 0;
    letter-spacing: -0.3px;
  }

  /* Mappa interagibile a destra (no hidden) */
  body.aef-feed-on .topbar,
  body.aef-feed-on #suBar,
  body.aef-feed-on #am-tier-filter-bar,
  body.aef-feed-on #petalFab,
  body.aef-feed-on .fab-group,
  body.aef-feed-on .archeo-compass,
  body.aef-feed-on #archeo-layer-switcher {
    visibility: visible !important;
    pointer-events: auto !important;
  }
  /* Shift banner a destra della sidebar */
  body.aef-feed-on #suBar { left: 400px !important; }
  body.aef-feed-on .topbar { left: 400px !important; }
  body.aef-feed-on #am-tier-filter-bar { left: calc(50% + 190px) !important; }

  /* FAB Mappa nascosto (mappa già visibile a destra) */
  .aef-map-fab { display: none !important; }


  /* Hero motivazionale: COMPATTO in sidebar stretta */
  .aef-hero {
    aspect-ratio: auto !important;
    margin: 12px 14px 10px !important;
    padding: 22px 18px 20px !important;
    border-radius: 14px !important;
    min-height: 0 !important;
    display: block !important;
  }
  .aef-hero-content { max-width: none; text-align: center; }
  .aef-hero-globe { font-size: 40px !important; margin-bottom: 8px !important; }
  .aef-hero-overline { font-size: 10px !important; letter-spacing: 3px !important; margin-bottom: 6px !important; }
  .aef-hero-title { font-size: 18px !important; line-height: 1.18 !important; margin-bottom: 6px !important; }
  .aef-hero-sub { font-size: 11.5px !important; line-height: 1.4 !important; max-width: 280px; margin-left: auto !important; margin-right: auto !important; }

  /* Search header */
  .aef-header {
    padding: 12px 22px 10px !important;
    box-shadow: none;
    background: #f8f7f4;
  }

  /* Section head */
  .aef-section-head { padding: 8px 14px 8px !important; }
  .aef-section-title { font-size: 16px !important; }
  .aef-section-sub { font-size: 12.5px !important; }

  /* List padding */
  .aef-list { padding: 0 14px 24px !important; gap: 12px; }

  /* Card desktop: aspect 4/3 cinematografico */
  .aef-card { border-radius: 14px; }
  .aef-card-photos-wrap { aspect-ratio: 4/3; }
}
  /* DESKTOP large (≥1100px) */
@media (min-width: 1100px) {
  #archeoExploreFeed { width: 420px; }
  body.aef-feed-on #suBar { left: 440px !important; }
  body.aef-feed-on #aefHandle { left: 420px; }
  body.aef-feed-on .topbar { left: 440px !important; }
}

/* v158: BADGE numero foto su card (top-right, sotto heart) */
.aef-card-photo-count {
  position: absolute;
  top: 60px;
  right: 12px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  letter-spacing: 0.2px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  z-index: 3;
  pointer-events: none;
}
