/* ─────────────────────────────────────────────────────────────────────────
   To-Do Map · sharing UI (share button dialog, shared-view banner, list)
   Uses the page's own custom properties (--sage, --font-body, …).
   ───────────────────────────────────────────────────────────────────────── */

/* ── Sandbox view: the map is fully interactive; hide only what would
      leave the map screen. (The share button is never injected here —
      share.js skips it when a shared map is open.) ── */
body.shared-view .toolbar-item:has(#btn-back-to-top) {
  display: none;
}

/* ── Viewer banner ── */
.share-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--card-bg, #fff);
  border-bottom: 1px solid rgba(46, 52, 45, 0.1);
  font-family: var(--font-body, sans-serif);
  font-size: 13px;
  color: var(--text, #2e342d);
  box-shadow: 0 1px 6px rgba(46, 52, 45, 0.06);
}
.share-banner-title {
  font-family: var(--font-display, sans-serif);
  font-weight: 600;
}
.share-banner-meta { color: var(--text-dim, #888); }
.share-banner-spacer { flex: 1; }
.share-banner button,
.share-banner a {
  background: none;
  border: none;
  font-family: var(--font-body, sans-serif);
  font-size: 12px;
  color: var(--sage-interactive, #526347);
  cursor: pointer;
  text-decoration: none;
  padding: 4px 2px;
  white-space: nowrap;
}
.share-banner button:hover,
.share-banner a:hover { color: var(--sage, #526347); text-decoration: underline; }
.share-banner button:focus-visible,
.share-banner a:focus-visible { outline: 2px solid var(--sage, #526347); outline-offset: 2px; border-radius: 4px; }

/* The app lays out as a fixed 100vh .flow-container; in shared view give the
   banner its own band above it instead of overlapping the map. */
body.shared-view .flow-container {
  margin-top: 42px;
  height: calc(100vh - 42px);
  height: calc(100dvh - 42px);
}

@media (max-width: 560px) {
  .share-banner { flex-wrap: wrap; gap: 6px 12px; font-size: 12px; }
  body.shared-view .flow-container {
    margin-top: 68px;
    height: calc(100vh - 68px);
    height: calc(100dvh - 68px);
  }
}

/* ── Shared list panel ── */
.share-list-panel {
  position: fixed;
  top: 48px;
  right: 16px;
  z-index: 499;
  width: min(340px, calc(100vw - 32px));
  max-height: min(60vh, 480px);
  overflow-y: auto;
  background: var(--card-bg, #fff);
  border: 1px solid rgba(46, 52, 45, 0.1);
  border-radius: var(--radius, 12px);
  box-shadow: var(--card-shadow-lift, 0 8px 24px rgba(46, 52, 45, 0.16));
  padding: 10px 0;
  font-family: var(--font-body, sans-serif);
}
.share-list-panel[hidden] { display: none; }
.share-list-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 18px;
  font-size: 13px;
  color: var(--text, #2e342d);
  line-height: 1.4;
}
.share-list-item .dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--sage, #526347);
  position: relative;
  top: -2px;
}
.share-list-item.done { color: var(--text-muted, #999); }
.share-list-item.done .item-text { text-decoration: line-through; }
.share-list-item.done .dot { background: var(--text-ghost, #ccc); }

/* ── Share dialog (owner side) ── */
.share-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(46, 52, 45, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.share-dialog {
  width: min(420px, 100%);
  background: var(--card-bg, #fff);
  border-radius: var(--radius, 12px);
  box-shadow: var(--card-shadow-lift, 0 8px 24px rgba(46, 52, 45, 0.16));
  padding: 24px 24px 20px;
  font-family: var(--font-body, sans-serif);
  color: var(--text, #2e342d);
}
.share-dialog h2 {
  font-family: var(--font-display, sans-serif);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
}
.share-dialog p {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim, #666);
  margin: 0 0 16px;
}
.share-dialog .share-link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.share-dialog .share-link-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-body, sans-serif);
  font-size: 12px;
  color: var(--text, #2e342d);
  border: 1px solid rgba(46, 52, 45, 0.15);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--canvas-bg, #fafaf5);
}
.share-dialog-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.share-btn-primary {
  font-family: var(--font-display, sans-serif);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--sage, #526347);
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  transition: opacity 150ms;
}
.share-btn-primary:hover { opacity: 0.9; }
.share-btn-primary:disabled { opacity: 0.5; cursor: default; }
.share-btn-quiet {
  font-family: var(--font-body, sans-serif);
  font-size: 12px;
  color: var(--text-dim, #666);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 2px;
}
.share-btn-quiet:hover { color: var(--text, #2e342d); }
.share-btn-danger { color: #a05252; }
.share-btn-danger:hover { color: #7d3a3a; }
.share-dialog .share-status {
  font-size: 12px;
  color: var(--sage, #526347);
  margin-top: 12px;
  min-height: 16px;
}
.share-dialog .share-status.error { color: #a05252; }
.share-btn-primary:focus-visible,
.share-btn-quiet:focus-visible {
  outline: 2px solid var(--sage, #526347);
  outline-offset: 2px;
}

/* ── Update notice (owner published a newer version) ── */
.share-update-notice {
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 498;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg, #fff);
  border: 1px solid rgba(46, 52, 45, 0.12);
  border-radius: 999px;
  box-shadow: var(--card-shadow-lift, 0 8px 24px rgba(46, 52, 45, 0.16));
  padding: 8px 8px 8px 16px;
  font-family: var(--font-body, sans-serif);
  font-size: 12.5px;
  color: var(--text, #2e342d);
  max-width: calc(100vw - 32px);
}
.share-update-notice button {
  font-family: var(--font-display, sans-serif);
  font-size: 12px;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.share-update-notice .notice-load { background: var(--sage, #526347); color: #fff; font-weight: 600; }
.share-update-notice .notice-dismiss { background: none; color: var(--text-dim, #666); }
.share-update-notice .notice-dismiss:hover { color: var(--text, #2e342d); }

/* ── Loading indicator while the shared map is fetched ── */
.share-loading {
  position: fixed;
  inset: 0;
  z-index: 450;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-family: var(--font-body, sans-serif);
  font-size: 13px;
  color: var(--text-dim, #666);
  pointer-events: none;
}
.share-loading .spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(82, 99, 71, 0.2);
  border-top-color: var(--sage, #526347);
  animation: share-spin 800ms linear infinite;
}
@keyframes share-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .share-loading .spinner { animation: none; }
}

/* ── Shared-map error overlay ── */
.share-error-overlay {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: var(--canvas-bg, #fafaf5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body, sans-serif);
  color: var(--text, #2e342d);
  text-align: center;
  padding: 24px;
}
.share-error-overlay h2 {
  font-family: var(--font-display, sans-serif);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.share-error-overlay p { font-size: 13px; color: var(--text-dim, #666); margin: 0; }
.share-error-overlay a { color: var(--sage, #526347); }
