/* =====================================================================
   mobile_ux.css — V8.26 Prompt 3 WS-F
   Mobile-native UX bundle: bottom-sheet modal, swipe-dismiss feedback,
   pull-to-refresh spinner, long-press tooltip, tap-target enforcement.
   All styles scoped under .sd-* class names. Uses brand_tokens.html vars.
   No external CDNs, no frameworks, no new color introductions.
   ===================================================================== */

/* ── Bottom-sheet backdrop ── */
.sd-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(10, 10, 12, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--dur-quick, 200ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  -webkit-tap-highlight-color: transparent;
}
.sd-sheet-backdrop.sd-sheet-open { opacity: 1; }

/* ── Bottom-sheet container ── */
.sd-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9001;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-raised, #17171c);
  color: var(--ink-primary, #e4e4e7);
  font-family: var(--ff-sans, system-ui, sans-serif);
  border-top: 1px solid var(--hairline, #27272a);
  border-radius: var(--r-md, 8px) var(--r-md, 8px) 0 0;
  box-shadow: var(--shadow-modal, 0 24px 60px -12px rgba(0,0,0,0.8));
  transform: translateY(100%);
  transition: transform var(--dur-deliberate, 400ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.sd-sheet.sd-sheet-open { transform: translateY(0); }
.sd-sheet.sd-sheet-dragging { transition: none; }

/* ── Sheet handle (drag-to-dismiss affordance) ── */
.sd-sheet-handle {
  flex: 0 0 auto;
  width: 100%;
  padding: var(--sp-3, 12px) 0 var(--sp-2, 8px);
  display: flex;
  justify-content: center;
  cursor: grab;
  touch-action: none;
}
.sd-sheet-handle::before {
  content: '';
  width: 36px;
  height: 4px;
  border-radius: var(--r-full, 9999px);
  background: var(--hairline-strong, #3f3f46);
}
.sd-sheet.sd-sheet-dragging .sd-sheet-handle { cursor: grabbing; }

/* ── Sheet header ── */
.sd-sheet-header {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  background: var(--bg-raised, #17171c);
  padding: 0 var(--sp-4, 16px) var(--sp-3, 12px);
  border-bottom: 1px solid var(--hairline, #27272a);
  z-index: 1;
}
.sd-sheet-title {
  margin: 0;
  font-family: var(--ff-serif, Georgia, serif);
  font-size: var(--type-lg, 19px);
  font-weight: 400;
  color: var(--ink-primary, #e4e4e7);
  line-height: 1.25;
}

/* ── Sheet body (scrollable) ── */
.sd-sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-4, 16px);
  font-size: var(--type-sm, 13px);
  color: var(--ink-secondary, #a1a1aa);
  line-height: 1.5;
}
.sd-sheet-body:empty { display: none; }

/* ── Sheet footer ── */
.sd-sheet-footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  background: var(--bg-raised, #17171c);
  padding: var(--sp-3, 12px) var(--sp-4, 16px);
  border-top: 1px solid var(--hairline, #27272a);
  display: flex;
  gap: var(--sp-2, 8px);
  justify-content: flex-end;
}
.sd-sheet-footer:empty { display: none; }

/* ── Desktop: center as a regular modal ── */
@media (min-width: 769px) {
  .sd-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, calc(-50% + 24px));
    max-width: 600px;
    width: calc(100% - 48px);
    max-height: calc(100vh - 96px);
    border-radius: var(--r-md, 8px);
    border: 1px solid var(--hairline, #27272a);
    opacity: 0;
  }
  .sd-sheet.sd-sheet-open {
    transform: translate(-50%, -50%);
    opacity: 1;
  }
  .sd-sheet-handle { display: none; }
}

/* ── Pull-to-refresh spinner ── */
.sd-ptr-spinner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  z-index: 8500;
  display: flex;
  align-items: center;
  gap: var(--sp-2, 8px);
  padding: var(--sp-2, 8px) var(--sp-4, 16px);
  background: var(--bg-raised, #17171c);
  border: 1px solid var(--hairline, #27272a);
  border-top: none;
  border-radius: 0 0 var(--r-md, 8px) var(--r-md, 8px);
  font-family: var(--ff-mono, ui-monospace, monospace);
  font-size: var(--type-2xs, 11px);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--signal-live, #00e676);
  box-shadow: var(--shadow-card, 0 8px 24px -8px rgba(0,0,0,0.7));
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-quick, 200ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}
.sd-ptr-spinner.sd-ptr-visible { opacity: 1; }
.sd-ptr-spinner-icon {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: sd-ptr-spin 0.8s linear infinite;
}
.sd-ptr-spinner.sd-ptr-pulling .sd-ptr-spinner-icon { animation: none; }
@keyframes sd-ptr-spin {
  to { transform: rotate(360deg); }
}

/* ── Swipe-dismiss visual feedback ── */
.sd-swipe-active {
  transition: none !important;
  will-change: transform, opacity;
}
.swipe-dismissible {
  touch-action: pan-y;
}

/* ── Long-press tooltip ── */
.sd-long-press-tip {
  position: absolute;
  z-index: 9100;
  padding: var(--sp-2, 8px) var(--sp-3, 12px);
  background: var(--bg-overlay, #1c2028);
  color: var(--ink-primary, #e4e4e7);
  border: 1px solid var(--hairline-strong, #3f3f46);
  border-radius: var(--r-sm, 4px);
  font-family: var(--ff-mono, ui-monospace, monospace);
  font-size: var(--type-2xs, 11px);
  line-height: 1.4;
  letter-spacing: 0.04em;
  max-width: 240px;
  pointer-events: none;
  box-shadow: var(--shadow-card, 0 8px 24px -8px rgba(0,0,0,0.7));
  opacity: 0;
  transition: opacity var(--dur-instant, 100ms) var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}
.sd-long-press-tip.sd-tip-visible { opacity: 1; }

/* ── Tap-target enforcement (touch devices only) ── */
@media (pointer: coarse) {
  .mobile-tap-target {
    min-height: 44px;
    min-width: 44px;
    padding: var(--sp-2, 8px) var(--sp-3, 12px);
    box-sizing: border-box;
  }
}

/* ── Reduced-motion: kill animations ── */
@media (prefers-reduced-motion: reduce) {
  .sd-sheet-backdrop,
  .sd-sheet,
  .sd-ptr-spinner,
  .sd-long-press-tip {
    transition: none !important;
  }
  .sd-ptr-spinner-icon { animation: none !important; }
  .sd-sheet-backdrop.sd-sheet-open { opacity: 1; }
  .sd-sheet.sd-sheet-open { transform: translateY(0); }
  @media (min-width: 769px) {
    .sd-sheet.sd-sheet-open { transform: translate(-50%, -50%); opacity: 1; }
  }
}

/* ── Standard breakpoint utility helpers (scoped to .sd-mobile-*) ── */
@media (max-width: 320px) {
  .sd-mobile-hide-xs { display: none !important; }
  .sd-sheet-title { font-size: var(--type-md, 15px); }
}
@media (max-width: 375px) {
  .sd-mobile-hide-sm { display: none !important; }
}
@media (max-width: 414px) {
  .sd-mobile-hide-md { display: none !important; }
}
@media (max-width: 768px) {
  .sd-mobile-hide-tablet { display: none !important; }
}
@media (max-width: 1024px) {
  .sd-mobile-hide-tablet-lg { display: none !important; }
}
