/* Toast + confirm system — structure + motion only.
   Atmosphere-correct COLOR comes from Tailwind gray-scale utility classes
   (.bg-white / .text-gray-900 / .text-gray-600 / .border-gray-200 / .bg-gray-100 /
   .bg-blue-600), which the atmosphere system remaps per body[data-atmosphere]
   across all 20 atmospheres (see static/css/atmospheres*.css). This file owns only
   layout, radius, depth, the refraction sheen, the semantic tone strip/icon (a thin
   fixed-hue non-text accent, safe on any atmosphere), and motion. All motion is gated
   behind html.tx-motion exactly like the boot overlay, so the motion-intensity slider's
   hard floor and OS prefers-reduced-motion both pin these to an instant presentation. */

/* ---------- Toasts ---------- */
.tx-toast-root {
  position: fixed;
  z-index: 99999;
  bottom: max(1rem, env(safe-area-inset-bottom));
  right: max(1rem, env(safe-area-inset-right));
  display: flex;
  flex-direction: column-reverse; /* newest nearest the edge, stack upward */
  align-items: flex-end;
  gap: 0.6rem;
  width: min(28rem, calc(100vw - 2rem));
  pointer-events: none;
}

@media (max-width: 560px) {
  .tx-toast-root {
    left: 0;
    right: 0;
    align-items: center;
    width: 100%;
    padding: 0 0.75rem;
  }
}

.tx-toast {
  --tone: #7c8cff;
  position: relative;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.85rem 0.95rem 0.85rem 1.05rem;
  border-radius: 1rem;
  box-shadow:
    0 18px 44px -18px var(--tx-depth-shadow-color, rgba(2, 6, 23, 0.5)),
    0 1px 0 0 rgba(255, 255, 255, 0.06) inset;
  overflow: hidden;
  pointer-events: auto;
  cursor: default;
}

/* Refraction sheen across the top edge — the premium light-catch of the boot mark. */
.tx-toast::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 38%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0.7;
  pointer-events: none;
}

/* Tone accent strip down the leading edge. */
.tx-toast::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--tone), color-mix(in srgb, var(--tone) 55%, transparent));
  box-shadow: 0 0 10px -1px var(--tone);
}

.tx-toast--success { --tone: #34d399; }
.tx-toast--error   { --tone: #fb7185; }
.tx-toast--warning { --tone: #f59e0b; }
.tx-toast--info    { --tone: #60a5fa; }

.tx-toast__icon {
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 0.05rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 18%, transparent);
}
.tx-toast__icon svg { width: 0.95rem; height: 0.95rem; display: block; }

.tx-toast__body {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  font-weight: 500;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.tx-toast__title {
  display: block;
  font-weight: 700;
  margin-bottom: 0.1rem;
}

.tx-toast__close {
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  margin: -0.15rem -0.2rem -0.15rem 0;
  display: grid;
  place-items: center;
  border-radius: 0.55rem;
  color: inherit;
  opacity: 0.5;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: opacity 0.16s ease, background-color 0.16s ease;
}
.tx-toast__close:hover { opacity: 1; background: rgba(127, 127, 127, 0.16); }
.tx-toast__close:focus-visible { outline: 2px solid var(--tx-focus, #60a5fa); outline-offset: 2px; opacity: 1; }
.tx-toast__close svg { width: 0.85rem; height: 0.85rem; }

/* Default (motion-off) presentation: instant, no movement. */
.tx-toast { opacity: 1; transform: none; }
.tx-toast.tx-toast--leaving { opacity: 0; }

/* Motion-on: spring slide-in + smooth leave, gated like the boot overlay. */
html.tx-motion .tx-toast {
  animation: tx-toast-in 0.42s var(--tx-ease-spring, cubic-bezier(0.22, 1.2, 0.36, 1)) both;
}
html.tx-motion .tx-toast.tx-toast--leaving {
  animation: tx-toast-out 0.26s ease-in both;
}

@keyframes tx-toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes tx-toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.98); }
}

/* ---------- Confirm dialog ---------- */
.tx-confirm-scrim {
  position: fixed;
  inset: 0;
  z-index: 99990;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(2, 6, 23, 0.58);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 1;
}
.tx-confirm-scrim.tx-confirm--leaving { opacity: 0; }
html.tx-motion .tx-confirm-scrim { animation: tx-fade-in 0.18s ease both; }
html.tx-motion .tx-confirm-scrim.tx-confirm--leaving { animation: tx-fade-out 0.16s ease both; }

.tx-confirm-panel {
  position: relative;
  width: min(26rem, 100%);
  border-radius: 1.25rem;
  padding: 1.4rem 1.4rem 1.25rem;
  box-shadow: 0 40px 80px -32px var(--tx-depth-shadow-color, rgba(2, 6, 23, 0.6));
  overflow: hidden;
}
.tx-confirm-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 30%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent);
  pointer-events: none;
}
html.tx-motion .tx-confirm-panel { animation: tx-pop-in 0.3s var(--tx-ease-spring, cubic-bezier(0.22, 1.2, 0.36, 1)) both; }

.tx-confirm__title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
}
.tx-confirm__msg {
  font-size: 0.92rem;
  line-height: 1.45;
  margin: 0 0 1.2rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.tx-confirm__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}
.tx-confirm__btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.16s ease, background-color 0.16s ease;
}
.tx-confirm__btn:active { transform: translateY(1px) scale(0.985); }
.tx-confirm__btn:focus-visible { outline: 2px solid var(--tx-focus, #60a5fa); outline-offset: 2px; }
.tx-confirm__btn--cancel:hover { filter: brightness(0.96); }
.tx-confirm__btn--confirm:hover { filter: brightness(1.06); }

/* Danger confirm keeps a fixed semantic-red gradient (universally readable as
   destructive); it carries no utility bg class so this rule wins cleanly. */
.tx-confirm-panel--danger .tx-confirm__btn--confirm {
  color: #fff;
  background: linear-gradient(120deg, #f43f5e, #fb7185);
}

/* ---------- Prompt input ---------- */
.tx-prompt__label {
  display: block;
  margin: 0 0 0.5rem;
}
.tx-prompt__field {
  margin: 0 0 1.2rem;
}
.tx-prompt__input {
  width: 100%;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  line-height: 1.3;
  font: inherit;
  font-weight: 500;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.tx-prompt__input::placeholder { opacity: 0.55; }
.tx-prompt__input:focus {
  outline: none;
  border-color: var(--tx-focus, #60a5fa);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tx-focus, #60a5fa) 28%, transparent);
}

@keyframes tx-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes tx-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes tx-pop-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
