/* Handover meetup entry in the notifications inbox (js/home-page.js): the owner and
   finder of an approved claim can ask each other for a one-time location. */

.notif-item--meetup .meetup-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.meetup-label {
  margin: 0 0 0.4rem;
  color: var(--blue-dark);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.meetup-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  color: var(--text-main);
  font-size: 0.9375rem;
}
.meetup-hint {
  margin: 0.4rem 0 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.meetup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
:root .meetup-btn {
  min-height: 2.4rem;
  padding: 0.45rem 1rem;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
}

/* Someone is asking for my location: the part that needs an answer stands out. */
.meetup-incoming {
  margin-top: 0.75rem;
  padding: 0.85rem;
  border: 1px solid color-mix(in srgb, var(--blue-main) 45%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--blue-main) 10%, transparent);
  animation: meetup-attention 0.5s ease-out;
}
@keyframes meetup-attention {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}
.meetup-incoming-title {
  margin: 0 0 0.6rem;
  color: var(--text-main);
  font-size: 0.9375rem;
  line-height: 1.5;
}
:root .meetup-note {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--field-border, var(--border));
  border-radius: 10px;
  background: var(--field-bg, transparent);
  color: var(--text-main);
}
.meetup-sharing {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(34, 197, 94, 0.4);
  border-radius: 14px;
  background: rgba(34, 197, 94, 0.08);
}

/* Small live dots: green while my location is shared, blue while waiting. */
.meetup-live,
.meetup-waiting {
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
}
.meetup-live {
  background: #22c55e;
  animation: meetup-pulse 1.6s ease-out infinite;
}
.meetup-waiting {
  background: var(--blue-main);
  animation: meetup-pulse 1.6s ease-out infinite;
}
@keyframes meetup-pulse {
  0% {
    box-shadow: 0 0 0 0 currentColor;
    opacity: 1;
  }
  70% {
    box-shadow: 0 0 0 8px transparent;
    opacity: 0.6;
  }
  100% {
    opacity: 1;
  }
}
.meetup-live {
  color: rgba(34, 197, 94, 0.5);
}
.meetup-waiting {
  color: color-mix(in srgb, var(--blue-main) 50%, transparent);
}

/* ── The map: a live, pannable/zoomable Leaflet map (js/home-page.js's initMeetupMaps) ── */
.meetup-map {
  position: relative;
  height: 210px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #e5e7eb;
}
/* The accuracy circle is drawn by Leaflet itself (L.circle), not CSS. */

/* Pin: a blue dot with a white ring that drops in, then pulses. Leaflet positions the
   wrapper (.meetup-pin-wrap) at the right pixel coordinates itself via its own inline
   transform, so this inner span is the only element the drop/pulse animation touches.
   The transition below is what makes a moved pin glide to its new spot instead of
   jumping there: updateMeetupMapInPlace() (js/home-page.js) calls marker.setLatLng()
   on live-tracking updates, which only changes that inline transform - the browser
   animates the rest. */
.meetup-pin-wrap {
  background: transparent;
  border: none;
  transition: transform 1.2s linear;
}
@media (prefers-reduced-motion: reduce) {
  .meetup-pin-wrap {
    transition: none;
  }
}
.meetup-pin {
  display: block;
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  animation:
    meetup-pin-drop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.4) both,
    meetup-pin-pulse 2s ease-out 0.5s infinite;
}
@keyframes meetup-pin-drop {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
}
@keyframes meetup-pin-pulse {
  0% {
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.35),
      0 0 0 0 rgba(37, 99, 235, 0.45);
  }
  70% {
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.35),
      0 0 0 16px rgba(37, 99, 235, 0);
  }
}
.meetup-attribution {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 0.1rem 0.4rem;
  border-top-left-radius: 6px;
  background: rgba(255, 255, 255, 0.85);
  color: #334155;
  font-size: 0.6875rem;
  text-decoration: none;
}
.meetup-note-text {
  margin: 0.55rem 0 0;
  color: var(--text-main);
  font-size: 0.9375rem;
  font-style: italic;
}

/* ── Claim conversation modal (js/home-page.js's claim-thread functions) ──────── */
.thread-card {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}
/* Layout. The card is a fixed-height flex column that never scrolls itself:
   header on top (flex: none), then .thread-layout fills the rest
   (flex: 1; min-height: 0). Inside it, one CSS grid places the same four
   regions in two arrangements:

   narrow (default)             wide (>= 860px)
   ┌───────────────────┐        ┌──────────┬──────────────────┐
   │ handover bar  ▾   │ auto   │ handover │ messages (1fr,   │
   ├───────────────────┤        │ panel    │ scrolls)         │
   │ messages (1fr,    │ 1fr    │          │                  │
   │ scrolls)          │        ├──────────┼──────────────────┤
   ├───────────────────┤        │ confirm  │ composer         │
   │ composer          │ auto   └──────────┴──────────────────┘
   │ confirm           │ auto
   └───────────────────┘

   The message row is minmax(0, 1fr), so a long thread scrolls inside
   .thread-messages instead of growing the card. The composer and confirm
   button sit in auto rows outside that scroller, so they are always visible. */
#claimThreadModal .thread-card {
  height: min(85vh, 48rem);
  height: min(85dvh, 48rem);
  max-height: none;
  padding: 1.25rem 1.25rem 1rem;
  overflow: hidden;
}
#claimThreadModal .thread-card > .modal-header {
  flex: none;
  margin-bottom: 0;
  padding-bottom: 0.75rem;
}
#claimThreadModal .thread-layout {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    'handover'
    'messages'
    'compose'
    'confirm';
  row-gap: 0.6rem;
  padding-top: 0.75rem;
}
#claimThreadModal .thread-messages {
  grid-area: messages;
  min-height: 0;
  max-height: none;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: 0.75rem;
}
#claimThreadModal .thread-compose-wrap {
  grid-area: compose;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}
#claimThreadModal .thread-confirm {
  grid-area: confirm;
  margin-top: 0;
  padding-top: 0.6rem;
}
#claimThreadModal .thread-confirm:empty {
  display: none;
}

/* ── Handover region: a collapsible bar on narrow screens, a side panel on wide ── */
.thread-handover {
  grid-area: handover;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--blue-main) 5%, transparent);
}
.thread-handover-toggle {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.thread-handover-toggle:focus-visible {
  outline: 2px solid var(--blue-main);
  outline-offset: -2px;
  border-radius: 12px;
}
.thread-handover-toggle:disabled {
  color: var(--text-main);
  opacity: 1;
  cursor: default;
}
.thread-handover-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.thread-handover-label {
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
}
.thread-handover-summary {
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-handover-summary:empty {
  display: none;
}
/* Status dot: grey = nothing pending, blue = waiting, green = live/complete,
   amber = something needs your answer. */
.thread-handover-dot {
  flex: none;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.6;
}
.thread-handover[data-tone='waiting'] .thread-handover-dot {
  background: var(--blue-main);
  opacity: 1;
}
.thread-handover[data-tone='live'] .thread-handover-dot,
.thread-handover[data-tone='done'] .thread-handover-dot {
  background: #22c55e;
  opacity: 1;
}
.thread-handover[data-tone='live'] .thread-handover-dot {
  color: rgba(34, 197, 94, 0.5);
  animation: meetup-pulse 1.6s ease-out infinite;
}
.thread-handover[data-tone='attention'] .thread-handover-dot {
  background: #f59e0b;
  color: rgba(245, 158, 11, 0.55);
  opacity: 1;
  animation: meetup-pulse 1.6s ease-out infinite;
}
.thread-handover[data-tone='attention'] {
  border-color: rgba(245, 158, 11, 0.5);
}
.thread-handover-chevron {
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  margin: 0 0.2rem 0.2rem 0;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}
.thread-handover:not(.is-collapsed) .thread-handover-chevron {
  margin: 0.2rem 0.2rem 0 0;
  transform: rotate(-135deg);
}
.thread-handover-body {
  min-height: 0;
  max-height: 45vh;
  max-height: 45dvh;
  padding: 0.65rem 0.75rem 0.75rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid var(--border);
}
.thread-handover.is-collapsed .thread-handover-body {
  display: none;
}
@media (prefers-reduced-motion: reduce) {
  .thread-handover-dot {
    animation: none !important;
  }
  .thread-handover-chevron {
    transition: none;
  }
}

/* Item + two-sided confirmation progress at the top of the handover region. */
.thread-summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0;
}
.thread-summary-kicker {
  color: var(--text-muted);
  font-size: 0.75rem;
}
.thread-summary-item strong {
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: 0.9375rem;
}
.thread-steps {
  display: grid;
  gap: 0.3rem;
  margin: 0.6rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
}
.thread-steps li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
}
.thread-steps li::before {
  flex: none;
  box-sizing: border-box;
  width: 0.9rem;
  height: 0.9rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  content: '';
}
.thread-steps li.is-done {
  color: var(--text-main);
}
.thread-steps li.is-done::before {
  border-color: #22c55e;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.5l4.5-5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
      center / 0.65rem no-repeat,
    #22c55e;
}
#claimThreadModal .thread-handover .thread-meetup:not(:empty) {
  margin: 0.75rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ── Wide screens: handover panel beside the chat ── */
@media (min-width: 860px) {
  #claimThreadModal .thread-card {
    width: 94%;
    max-width: 920px;
    height: min(85vh, 44rem);
    height: min(85dvh, 44rem);
  }
  #claimThreadModal .thread-layout {
    grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      'handover messages'
      'confirm  compose';
    column-gap: 1rem;
  }
  /* Always open: the panel is the context column, not a disclosure. */
  .thread-handover.is-collapsed .thread-handover-body {
    display: block;
  }
  .thread-handover-chevron {
    display: none;
  }
  .thread-handover-body {
    flex: 1 1 auto;
    max-height: none;
  }
  /* Confirm sits under the panel, level with the composer. */
  #claimThreadModal .thread-confirm {
    align-self: end;
    padding-top: 0;
    border-top: none;
  }
  #claimThreadModal .thread-confirm .btn {
    width: 100%;
  }
  #claimThreadModal .thread-confirm .thread-waiting,
  #claimThreadModal .thread-confirm .thread-readonly {
    margin-top: 0.35rem;
  }
  #claimThreadModal .meetup-map {
    height: 180px;
  }
  #claimThreadModal .meetup-actions .meetup-btn {
    flex: 1 1 100%;
  }
}
/* Background page stays still while the conversation is open. */
html:has(#claimThreadModal.open) {
  overflow: hidden;
}
#claimThreadModal .meetup-map {
  height: 160px;
}
.meetup-map-disclosure {
  margin-top: 0.5rem;
}
.meetup-map-toggle {
  margin-bottom: 0.5rem;
}
.meetup-map-panel[hidden] {
  display: none;
}
.thread-messages {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 18rem;
  margin: 0.75rem 0;
  padding: 0.75rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-main, #000) 3%, transparent);
}
/* A static one-line intro bubble (Connect & Notify form) rather than a live,
   scrolling thread - no fixed height or scrollbar needed. */
.thread-messages--preview {
  max-height: none;
  overflow: visible;
}
.thread-empty {
  margin: auto;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}
/* Spacing between bubbles: a normal gap between different senders, a tight
   one between consecutive messages from the same sender (set in
   claimThreadMessagesHtml, js/home-page.js). The touching corners are
   squared off a little so a run reads as one block. */
#claimThreadModal .thread-messages {
  gap: 0;
}
#claimThreadModal .thread-messages > .thread-msg + .thread-msg {
  margin-top: 0.6rem;
}
#claimThreadModal .thread-messages > .thread-msg.thread-msg--grouped {
  margin-top: 0.15rem;
}
.thread-msg--mine.thread-msg--grouped {
  border-top-right-radius: 5px;
}
.thread-msg--mine.thread-msg--continued {
  border-bottom-right-radius: 5px;
}
.thread-msg--theirs.thread-msg--grouped {
  border-top-left-radius: 5px;
}
.thread-msg--theirs.thread-msg--continued {
  border-bottom-left-radius: 5px;
}
.thread-msg {
  max-width: 80%;
  padding: 0.5rem 0.75rem;
  border-radius: 14px;
  font-size: 0.9375rem;
  line-height: 1.45;
}
.thread-msg-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.thread-msg-time {
  display: block;
  margin-top: 0.15rem;
  color: inherit;
  font-size: 0.75rem;
  opacity: 0.85;
}
.thread-msg--theirs {
  align-self: flex-start;
  border: 1px solid var(--well-border);
  background: var(--well-bg);
  color: var(--text-main);
}
.thread-msg--mine {
  align-self: flex-end;
  background: var(--blue-main);
  color: #fff;
}
:root[data-theme='light'] .thread-msg--mine {
  background: #1e3a8a;
  color: #fff;
}
:root:not([data-theme='light']) .thread-msg--mine {
  color: #0f172a;
}
.thread-msg--theirs .thread-msg-text {
  color: var(--text-main) !important;
  -webkit-text-fill-color: var(--text-main);
}
:root[data-theme='light'] .thread-msg--mine .thread-msg-text {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}
:root:not([data-theme='light']) .thread-msg--mine .thread-msg-text {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
}
:root[data-theme='light'] .thread-msg--mine .thread-msg-time {
  color: #fff;
}
:root:not([data-theme='light']) .thread-msg--mine .thread-msg-time {
  color: #0f172a;
}
#claimThreadModal .thread-msg.thread-msg--mine > p.thread-msg-text {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  opacity: 1;
}
.thread-meetup:not(:empty) {
  margin-bottom: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.thread-compose {
  display: flex;
  gap: 0.5rem;
}
#claimThreadModal .thread-compose-wrap[hidden] {
  display: none;
}
.thread-compose input[type='text'] {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--field-border, var(--border));
  border-radius: 10px;
  background: var(--field-bg, transparent);
  color: var(--text-main);
}
.thread-photo-btn {
  flex: 0 0 auto;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
  font-size: 1.05rem;
  line-height: 1;
}
/* Messenger-style attachment preview: a small rounded thumbnail chip that sits
   just above the composer row, with a round remove button overlapping its
   top-right corner. */
.thread-photo-preview {
  display: flex;
}
.thread-photo-preview[hidden] {
  display: none;
}
.thread-photo-chip {
  position: relative;
  width: 64px;
  height: 64px;
}
.thread-photo-chip img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--well-bg);
}
.thread-photo-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--modal-bg);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.thread-photo-remove:hover {
  background: #000;
}

/* Image bubble: the photo fills the bubble edge-to-edge, with the padding
   usually around .thread-msg-text instead given to the image frame itself. */
.thread-msg--photo {
  padding: 4px;
}
.thread-msg-photo-btn {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  line-height: 0;
  cursor: zoom-in;
  border-radius: 10px;
  overflow: hidden;
}
.thread-msg-photo {
  display: block;
  width: 100%;
  max-width: 220px;
  max-height: 260px;
  object-fit: cover;
  border-radius: 10px;
}
.thread-msg--photo .thread-msg-text {
  margin: 0.4rem 0.2rem 0;
}
.thread-confirm {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
.thread-confirm .thread-resolved {
  margin: 0;
  color: #22c55e;
  font-weight: 700;
}
.thread-confirm .thread-readonly {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.thread-confirm .thread-waiting {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Phones: the conversation becomes a full-screen sheet (dynamic viewport
   height, so the composer is not hidden behind the mobile browser's toolbar
   or the on-screen keyboard), with the narrow grid above. */
@media (max-width: 600px) {
  #claimThreadModal.slip-overlay {
    align-items: stretch;
    padding: 0;
  }
  #claimThreadModal .thread-card {
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    padding: calc(0.85rem + env(safe-area-inset-top, 0px)) 0.85rem
      calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border: none;
    border-radius: 0;
  }
  #claimThreadModal .thread-layout {
    row-gap: 0.5rem;
    padding-top: 0.6rem;
  }
  #claimThreadModal .thread-messages {
    padding: 0.6rem;
  }
  /* Expanded handover never takes more than ~40% of the sheet, so the chat
     keeps the majority of the screen. */
  .thread-handover-body {
    max-height: 40vh;
    max-height: 40dvh;
  }
  #claimThreadModal .thread-msg {
    max-width: 86%;
  }
  #claimThreadModal .thread-compose {
    align-items: stretch;
  }
  /* 16px stops iOS Safari from zooming the page when the input is focused. */
  #claimThreadModal .thread-compose input {
    font-size: 1rem;
  }
}
