/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 *
 */

/* iOS Safari zoom prevention - only on touch devices */
@media (pointer: coarse) {
  input,
  textarea {
    font-size: 16px;
  }
}

[x-cloak] {
  display: none !important;
}

.nl2br {
  white-space: pre-line;
}

/* Safe area padding for mobile navigation bars */
.pb-safe {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Message highlight for jump-to navigation */
.message-highlight {
  animation: highlight-fade 2s ease-out forwards;
  margin-left: -0.75rem;
  margin-right: -0.75rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

@media (min-width: 640px) {
  .message-highlight {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }
}

@keyframes highlight-fade {
  0% {
    background-color: color-mix(
      in oklch,
      var(--color-primary) 15%,
      transparent
    );
  }
  80% {
    background-color: color-mix(
      in oklch,
      var(--color-primary) 15%,
      transparent
    );
  }
  100% {
    background-color: transparent;
  }
}

/* Reusable highlight animation utility */
.animate-highlight-fade {
  animation: highlight-fade 3s ease-out forwards;
  border-radius: 0.5rem;
}

/* Offering reveal: full blur veil fades out after streaming completes */
@keyframes offering-reveal {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.animate-offering-reveal {
  animation: offering-reveal 700ms ease-out 200ms forwards;
}

/* Hide messages until JS resolves chat direction (chat-start/chat-end) to prevent layout shift.
   Only applies during initial load; removed by JS after processing so broadcast messages are unaffected. */
[data-direction-pending] [data-message-id] .chat {
  opacity: 0;
}

/* ---------------------------------------------------------------------------
 * Push notification toasts (macOS-style).
 * Separate visual language from flash messages (_flash_messages.html.erb).
 * Flash = user action feedback. Push toast = async event notifications.
 * ------------------------------------------------------------------------- */
.push-toast-stack {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
}

.push-toast {
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: 1rem;
  background-color: color-mix(in oklch, var(--color-base-100) 82%, transparent);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow:
    0 8px 24px -8px color-mix(in oklch, oklch(0 0 0) 25%, transparent),
    0 2px 6px -2px color-mix(in oklch, oklch(0 0 0) 15%, transparent);
  color: var(--color-base-content);
  cursor: default;
  transform: translateX(120%);
  opacity: 0;
  transition:
    transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 220ms ease-out;
  will-change: transform, opacity;
  touch-action: pan-y;
}

.push-toast[data-url] {
  cursor: pointer;
}

.push-toast[data-state='visible'] {
  transform: translateX(0);
  opacity: 1;
}

.push-toast[data-state='leaving'] {
  transform: translateX(120%);
  opacity: 0;
  transition:
    transform 240ms cubic-bezier(0.4, 0, 1, 1),
    opacity 200ms ease-in;
}

.push-toast[data-state='leaving'][data-exit-direction='left'] {
  transform: translateX(-120%);
}

/* While user is actively dragging, disable the transition so the toast
   follows the pointer 1:1. Also hint browsers to avoid scroll gestures. */
.push-toast[data-dragging='true'] {
  transition: none;
  cursor: grabbing;
  touch-action: pan-y;
  user-select: none;
}

.push-toast__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.625rem;
  background-color: color-mix(in oklch, var(--color-primary) 15%, transparent);
  color: var(--color-primary);
  flex-shrink: 0;
}

.push-toast__content {
  flex: 1;
  min-width: 0;
}

.push-toast__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.push-toast__title {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.push-toast__time {
  font-size: 0.6875rem;
  line-height: 1;
  color: color-mix(in oklch, var(--color-base-content) 55%, transparent);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.push-toast__body {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: color-mix(in oklch, var(--color-base-content) 75%, transparent);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.push-toast__close {
  position: absolute;
  top: -0.375rem;
  left: -0.375rem;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-base-content);
  color: var(--color-base-100);
  border: 2px solid var(--color-base-100);
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.8);
  transition:
    opacity 150ms ease,
    transform 150ms ease,
    background-color 150ms ease;
  box-shadow: 0 1px 3px color-mix(in oklch, oklch(0 0 0) 20%, transparent);
}

.push-toast:hover .push-toast__close,
.push-toast:focus-within .push-toast__close {
  opacity: 1;
  transform: scale(1);
}

/* On touch-primary devices, no hover is available — keep the close button
   always visible so users have an explicit way to dismiss. Swipe-to-dismiss
   still works as a secondary gesture. */
@media (hover: none) {
  .push-toast__close {
    opacity: 1;
    transform: scale(1);
  }
}

.push-toast__close:hover {
  background-color: color-mix(
    in oklch,
    var(--color-base-content) 80%,
    transparent
  );
}

.push-toast__close svg {
  width: 0.625rem;
  height: 0.625rem;
}

@media (max-width: 640px) {
  .push-toast-stack {
    left: max(0.5rem, env(safe-area-inset-left));
    right: max(0.5rem, env(safe-area-inset-right));
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .push-toast {
    transition: opacity 150ms ease-out;
    transform: translateX(0);
  }
  .push-toast[data-state='leaving'] {
    transform: translateX(0);
  }
}
