/* GlobeSpotter final visual precedence layer.
 * Loaded after the historical stylesheet so old compatibility overrides cannot
 * regress the current mobile UI. */

:root {
  --gs-bg: #05090c;
  --gs-card: rgba(7, 13, 18, .96);
  --gs-card-soft: #0d1419;
  --gs-line: rgba(255, 255, 255, .11);
  --gs-muted: #98a0a7;
  --gs-accent: #ff694f;
  --gs-accent-2: #ff8456;
}

@media (max-width: 768px) {
  /* Spot details — hero and compact reference hierarchy. */
  body .detail-panel.gallery-panel {
    inset: 0 !important;
    width: 100% !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 30px 30px 0 0 !important;
    background: var(--gs-bg) !important;
    overflow: hidden !important;
  }

  body .gallery-panel #galleryHeader {
    position: absolute !important;
    z-index: 1 !important;
    inset: 0 0 auto !important;
    width: 100% !important;
    height: clamp(350px, 45dvh, 500px) !important;
    min-height: 350px !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    background: var(--gs-bg) !important;
  }

  body .gallery-panel #galleryHeader::after {
    content: "";
    position: absolute;
    z-index: 2;
    inset: auto 0 0;
    height: 42%;
    pointer-events: none;
    background: linear-gradient(180deg, transparent, rgba(5, 9, 12, .7) 75%, var(--gs-bg));
  }

  body .gallery-panel .spot-hero,
  body .gallery-panel .spot-hero-media,
  body .gallery-panel .spot-hero-image {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  body .gallery-panel .spot-hero-image {
    object-fit: cover !important;
    object-position: center !important;
    transform-origin: 50% 0 !important;
  }

  body .gallery-panel .spot-mini-gallery,
  body .gallery-panel .spot-hero-content,
  body .gallery-panel .spot-hero-close,
  body .gallery-panel .spot-hero-share {
    display: none !important;
  }

  body .gallery-panel .spot-hero-back,
  body .gallery-panel #spotHeroMoreBtn {
    position: absolute !important;
    z-index: 8 !important;
    top: calc(env(safe-area-inset-top, 0px) + 17px) !important;
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
    min-height: 46px !important;
    padding: 0 !important;
    border: 1px solid rgba(255,255,255,.12) !important;
    border-radius: 999px !important;
    color: #fff !important;
    background: rgba(7, 12, 16, .78) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    backdrop-filter: blur(14px) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,.24) !important;
  }

  body .gallery-panel .spot-hero-back { left: 18px !important; }
  body .gallery-panel #spotHeroMoreBtn { right: 18px !important; }
  body .gallery-panel .spot-hero-actions {
    position: static !important;
    width: 0 !important;
    height: 0 !important;
  }

  body .gallery-panel #galleryList {
    position: relative !important;
    z-index: 4 !important;
    height: 100dvh !important;
    max-height: none !important;
    margin: 0 !important;
    padding: calc(clamp(350px, 45dvh, 500px) - 64px) 16px calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain !important;
    background: transparent !important;
    scrollbar-width: none !important;
  }
  body .gallery-panel #galleryList::-webkit-scrollbar { display: none !important; }

  body .gallery-panel .spotastic-spot-overview {
    position: relative !important;
    z-index: 3 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 19px !important;
    border: 1px solid rgba(255,255,255,.13) !important;
    border-radius: 24px !important;
    color: #f7f8f9 !important;
    background: linear-gradient(145deg, rgba(8,14,19,.985), rgba(5,10,14,.95)) !important;
    box-shadow: 0 20px 44px rgba(0,0,0,.48) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    backdrop-filter: blur(24px) !important;
  }

  body .spotastic-detail-heading {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 10px !important;
    margin: 0 0 8px !important;
  }
  body .spotastic-detail-heading h2 {
    min-width: 0 !important;
    margin: 0 !important;
    color: #fff !important;
    font-size: clamp(24px, 6.6vw, 31px) !important;
    line-height: 1.05 !important;
    letter-spacing: -.04em !important;
    overflow-wrap: anywhere !important;
  }
  body .spotastic-detail-like {
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    border: 0 !important;
    color: var(--gs-accent) !important;
    background: transparent !important;
    font-size: 27px !important;
    box-shadow: none !important;
  }

  body .spotastic-detail-meta-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 6px !important;
    margin: 0 0 12px !important;
    color: #aeb5ba !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
  }
  body .spotastic-detail-meta-row > span {
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    min-width: 0 !important;
  }
  body .spotastic-detail-meta-row i { color: #fff !important; }
  body .spotastic-detail-distance em {
    color: inherit !important;
    font-style: normal !important;
    font-weight: 400 !important;
  }

  body .spotastic-spot-overview #spotDetailInfo {
    display: block !important;
    margin: 0 !important;
    padding: 13px 0 !important;
    border-top: 1px solid var(--gs-line) !important;
    border-bottom: 1px solid var(--gs-line) !important;
    color: #c2c7cb !important;
    font-size: 12.5px !important;
    line-height: 1.62 !important;
    white-space: normal !important;
  }

  body .spot-reference-stats {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto !important;
    align-items: center !important;
    gap: 6px !important;
    min-height: 62px !important;
    padding: 9px 0 !important;
    border-bottom: 1px solid var(--gs-line) !important;
  }
  body .spot-reference-stats > span:not(.spot-reference-visitors) {
    display: grid !important;
    grid-template-columns: 18px auto !important;
    grid-template-rows: auto auto !important;
    align-items: center !important;
    justify-content: start !important;
    column-gap: 4px !important;
    min-width: 0 !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 700 !important;
  }
  body .spot-reference-stats > span:not(.spot-reference-visitors) i {
    grid-row: 1 / span 2 !important;
    color: #fff !important;
    font-size: 14px !important;
  }
  body .spot-reference-stats small {
    display: block !important;
    color: #7f8990 !important;
    font-size: 8px !important;
    font-weight: 500 !important;
    line-height: 1 !important;
  }
  body .spot-reference-visitors {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    min-width: 64px !important;
  }
  body .spot-reference-visitors img,
  body .spot-reference-visitors .avatar {
    width: 29px !important;
    height: 29px !important;
    margin-left: -8px !important;
    border: 2px solid #11181d !important;
    border-radius: 50% !important;
    object-fit: cover !important;
  }
  body .spot-reference-visitors em {
    display: grid !important;
    place-items: center !important;
    width: 29px !important;
    height: 29px !important;
    margin-left: -8px !important;
    border: 2px solid #11181d !important;
    border-radius: 50% !important;
    color: #c4c9cd !important;
    background: #1a2126 !important;
    font-size: 9px !important;
    font-style: normal !important;
  }

  body .spot-reference-publisher {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    gap: 10px !important;
    padding-top: 10px !important;
  }
  body .spot-reference-owner {
    display: grid !important;
    grid-template-columns: 38px minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 9px !important;
    min-width: 0 !important;
    color: #fff !important;
    text-decoration: none !important;
  }
  body .spot-reference-owner img,
  body .spot-reference-owner .avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
  }
  body .spot-reference-owner b,
  body .spot-reference-owner small { display: block !important; min-width: 0 !important; }
  body .spot-reference-owner b { font-size: 11px !important; color: #fff !important; }
  body .spot-reference-owner small { margin-top: 2px !important; color: #8e979e !important; font-size: 9px !important; }
  body .spot-reference-club {
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    max-width: 128px !important;
    min-height: 40px !important;
    padding: 7px 10px !important;
    border: 1px solid var(--gs-line) !important;
    border-radius: 14px !important;
    color: #fff !important;
    background: rgba(255,255,255,.025) !important;
    font-size: 10px !important;
  }

  body .spotastic-live-checkin-slot {
    margin: 11px 2px 0 !important;
  }
  body .spotastic-inline-checkin {
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  body .spotastic-inline-checkin .checkin-cta {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
    width: 100% !important;
    min-height: 52px !important;
    padding: 10px 18px !important;
    border: 0 !important;
    border-radius: 999px !important;
    color: #07090b !important;
    background: linear-gradient(100deg, #f3583f, #ff7b54) !important;
    box-shadow: 0 12px 28px rgba(255,105,79,.2) !important;
    font-size: 17px !important;
    font-weight: 800 !important;
  }
  body .gallery-panel #checkinBar.spotastic-inline-checkin.is-too-far .checkin-cta,
  body .gallery-panel #checkinBar.spotastic-inline-checkin.is-ready .checkin-cta {
    border: 0 !important;
    color: #07090b !important;
    background: linear-gradient(100deg, #f3583f, #ff7b54) !important;
    opacity: 1 !important;
  }
  body .spotastic-inline-checkin .checkin-cta span { color: inherit !important; }
  body .spotastic-inline-checkin .checkin-cta small {
    display: block !important;
    margin-top: 1px !important;
    color: rgba(7,9,11,.72) !important;
    font-size: 9px !important;
  }

  body .spotastic-last-visit {
    display: grid !important;
    grid-template-columns: 36px minmax(0, 1fr) 18px !important;
    align-items: center !important;
    gap: 9px !important;
    min-height: 62px !important;
    margin: 10px 2px 0 !important;
    padding: 10px 12px !important;
    border: 1px solid var(--gs-line) !important;
    border-radius: 17px !important;
    color: #fff !important;
    background: var(--gs-card-soft) !important;
  }
  body .spotastic-last-visit-check {
    display: grid !important;
    place-items: center !important;
    width: 36px !important;
    height: 36px !important;
    border: 1px solid rgba(86, 207, 153, .3) !important;
    border-radius: 50% !important;
    color: #9ee4c0 !important;
    background: rgba(50, 141, 99, .25) !important;
    font-size: 15px !important;
  }
  body .spotastic-last-visit > .fa-chevron-right { color: #707980 !important; font-size: 12px !important; }
  body .spotastic-last-visit b { display: block !important; font-size: 12px !important; }
  body .spotastic-last-visit small { display: block !important; margin-top: 2px !important; color: #899299 !important; font-size: 9px !important; }

  body .gallery-panel .spotastic-moments {
    margin: 10px 2px 0 !important;
    padding: 13px !important;
    border: 1px solid var(--gs-line) !important;
    border-radius: 18px !important;
    background: var(--gs-card-soft) !important;
    box-shadow: none !important;
  }
  body .spotastic-moments .media-meta {
    margin: 0 0 10px !important;
    padding: 0 !important;
    border: 0 !important;
  }
  body .spotastic-moments .media-community-title,
  body .spotastic-moments .media-community-copy {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
  }
  body .spotastic-moments .media-community-copy > span {
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
  }
  body .spotastic-moments .media-community-copy > div,
  body .spotastic-moments .media-community-avatars { display: none !important; }
  body .spotastic-moments #communityAllBtn {
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    border: 0 !important;
    color: #9aa2a8 !important;
    background: transparent !important;
  }
  body .spotastic-moments .media-grid-wrapper {
    width: 100% !important;
    overflow: hidden !important;
  }
  body .spotastic-moments .spotastic-media-wall {
    display: flex !important;
    align-items: stretch !important;
    gap: 7px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }
  body .spotastic-moments .media-tile,
  body .spotastic-moments .grid-item {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    aspect-ratio: 1 / 1 !important;
    min-height: 0 !important;
    border: 0 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    background: #151b1f !important;
  }
  body .spotastic-moments .grid-item.more {
    display: grid !important;
    place-items: center !important;
    color: #d7dbde !important;
    font-size: 14px !important;
    font-weight: 600 !important;
  }
  body .spotastic-moments .media-tile img,
  body .spotastic-moments .media-tile video,
  body .spotastic-moments .grid-item img,
  body .spotastic-moments .grid-item video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
  body .spotastic-moment-add { display: none !important; }
  body .spotastic-moments .grid-item .badge,
  body .spotastic-moments .community-media-author { display: none !important; }

  /* Club overview/detail cleanup. */
  body .clubs-panel .clubs-header-inner .trips-header-row {
    grid-template-columns: 76px minmax(0, 1fr) auto !important;
    column-gap: 18px !important;
  }
  body .clubs-panel .trips-header-title,
  body .club-detail .club-title { overflow: visible !important; text-overflow: clip !important; }
  body .club-detail .club-dashboard {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }
  body .club-detail .club-dashboard-card { width: 100% !important; min-height: 210px !important; }
  body .club-detail > .tabs,
  body .club-detail .club-tabs {
    position: sticky !important;
    z-index: 12 !important;
    top: 0 !important;
    background: rgba(5,9,12,.96) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    backdrop-filter: blur(14px) !important;
  }
  body .club-detail .club-spot-list { padding-bottom: 130px !important; }
  body .club-detail .forum-topic {
    display: grid !important;
    gap: 12px !important;
    padding: 15px !important;
    border-radius: 18px !important;
  }
  body .club-detail .forum-topic-head {
    display: grid !important;
    grid-template-columns: 42px minmax(0,1fr) auto auto !important;
    align-items: center !important;
    gap: 10px !important;
  }
  body .club-detail .forum-topic-copy { padding: 0 !important; }
  body .club-detail .club-activity-item {
    width: 100% !important;
    margin-left: 0 !important;
    transform: none !important;
  }

  /* Trips are an embedded full page, with a compact two-column list. */
  body .trips-panel,
  body .trips-panel.open {
    inset: 0 !important;
    width: 100% !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 0 !important;
    overflow: hidden !important;
  }
  body .trips-panel .trips-list {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px !important;
    padding: 0 14px calc(140px + env(safe-area-inset-bottom,0px)) !important;
  }
  body .trips-panel .trip-card {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    min-height: 245px !important;
    overflow: hidden !important;
    border-radius: 20px !important;
  }
  body .trips-panel .trip-card-preview { width: 100% !important; aspect-ratio: 1.25 / 1 !important; }
  body .trips-panel .trip-card-preview img { width: 100% !important; height: 100% !important; object-fit: cover !important; }
  body .trips-panel .trip-card-head,
  body .trips-panel .trip-card-meta { padding-inline: 12px !important; }
  body .trip-detail-panel,
  body .trip-detail-panel.open,
  body .trips-detail-panel,
  body .trips-detail-panel.open {
    inset: 0 !important;
    height: 100dvh !important;
    max-height: none !important;
    border-radius: 30px 30px 0 0 !important;
  }

  /* Activity cards start flush; no pre-swipe offset. */
  body .activity-feed .activity-item,
  body .activity-list .activity-item,
  body .activity-card {
    margin-left: 0 !important;
    transform: translateX(0) !important;
  }

  /* Media comments mirror postcard comments and stay above all viewers. */
  body .lightbox-comments-overlay.postcard-comments-panel {
    position: fixed !important;
    z-index: 2147483000 !important;
    inset: auto 0 0 !important;
    width: 100% !important;
    max-height: min(72dvh, 680px) !important;
    padding: 17px 17px calc(14px + env(safe-area-inset-bottom,0px)) !important;
    border: 1px solid var(--gs-line) !important;
    border-radius: 28px 28px 0 0 !important;
    background: rgba(6,10,13,.985) !important;
    box-shadow: 0 -20px 50px rgba(0,0,0,.55) !important;
    transform: translateY(110%) !important;
    transition: transform .32s cubic-bezier(.2,.8,.2,1) !important;
  }
  body .lightbox-comments-overlay.postcard-comments-panel.is-open { transform: translateY(0) !important; }
  body .postcard-comment-form {
    position: sticky !important;
    bottom: 0 !important;
    display: grid !important;
    grid-template-columns: minmax(0,1fr) 50px !important;
    gap: 9px !important;
    padding-top: 12px !important;
    background: rgba(6,10,13,.985) !important;
  }
  body .postcard-comment-form input { min-width: 0 !important; border-color: var(--gs-line) !important; outline: 0 !important; box-shadow: none !important; }

  body .lightbox-like-burst {
    color: #ff3f55 !important;
    animation: gs-heart-flight 1.08s cubic-bezier(.18,.76,.28,1) forwards !important;
  }
}

@keyframes gs-heart-flight {
  0% { opacity: 0; transform: translate3d(-50%, 90px, 0) scale(.35); filter: blur(3px); }
  38% { opacity: 1; transform: translate3d(-50%, 0, 0) scale(1.08); filter: blur(0); }
  58% { opacity: 1; transform: translate3d(-50%, -8px, 0) scale(.94); }
  74% { opacity: 1; transform: translate3d(-50%, -15px, 0) scale(1.08); }
  100% { opacity: 0; transform: translate3d(-50%, -110px, 0) scale(.9); filter: blur(2px); }
}

/* Spot detail: final specificity guard against the legacy panel/gallery rules. */
@media (max-width: 768px) {
  html body #sidePanel.detail-panel.gallery-panel #galleryList.card-list.mobile-content {
    position: relative !important;
    z-index: 4 !important;
    width: 100% !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: calc(clamp(350px, 45dvh, 500px) - 64px) 16px calc(34px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    background: transparent !important;
    -webkit-overflow-scrolling: touch !important;
  }

  html body #sidePanel.detail-panel.gallery-panel #galleryHeader.panel-header {
    position: absolute !important;
    inset: 0 0 auto !important;
    z-index: 1 !important;
    width: 100% !important;
    height: clamp(350px, 45dvh, 500px) !important;
    border-radius: 30px 30px 0 0 !important;
    overflow: hidden !important;
  }

  html body #sidePanel.detail-panel.gallery-panel #galleryHeader.panel-header::after {
    content: "" !important;
    position: absolute !important;
    inset: auto 0 0 !important;
    height: 46% !important;
    pointer-events: none !important;
    background: linear-gradient(180deg, transparent, rgba(5, 9, 12, .86)) !important;
  }

  html body #sidePanel.detail-panel.gallery-panel #spotDetailCommunity.card.media-card.spotastic-moments {
    width: auto !important;
    margin: 10px 2px 0 !important;
    padding: 13px !important;
    border: 1px solid rgba(255, 255, 255, .11) !important;
    border-radius: 18px !important;
    background: rgba(10, 15, 18, .92) !important;
    box-shadow: none !important;
  }

  html body #sidePanel.detail-panel.gallery-panel #spotDetailCommunity .media-grid-wrapper {
    width: 100% !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  html body #sidePanel.detail-panel.gallery-panel #spotDetailCommunity .spotastic-media-wall.media-grid {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 7px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  html body #sidePanel.detail-panel.gallery-panel #spotDetailCommunity .spotastic-media-wall.media-grid > .grid-item {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    aspect-ratio: 1 / 1 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
  }

  html body #sidePanel.detail-panel.gallery-panel #spotDetailCommunity .spotastic-media-wall.media-grid > .grid-item img,
  html body #sidePanel.detail-panel.gallery-panel #spotDetailCommunity .spotastic-media-wall.media-grid > .grid-item video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
}
