/* Shared notification surface: Documents-style frosted cards, owned by the renderer. */
.tn-notifications,
[data-tn-flash-seeds] {
  --tn-notification-surface: rgba(239, 240, 240, 0.88);
  --tn-notification-border: #cbd5e1;
  --tn-notification-text: #111827;
  --tn-notification-muted: #475569;
  --tn-notification-hover: rgba(15, 23, 42, 0.07);
  --tn-notification-focus: #2d6a72;
  color: var(--tn-notification-text);
  font-family: inherit;
  text-align: start;
}

.tn-notifications {
  position: fixed;
  z-index: 10120;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(37px, env(safe-area-inset-bottom, 0px));
  width: min(420px, calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  max-height: calc(100vh - 74px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 74px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  pointer-events: none;
}

.tn-notifications:empty,
.tn-notifications[hidden],
[data-tn-flash-seeds][hidden] {
  display: none;
}

/* Native Fomantic display rules must not show a second copy after adoption.
   Only nodes already represented in the shared host receive this marker. */
[data-tn-notification-source][hidden] {
  display: none !important;
}

.tn-notifications:focus-visible {
  outline: 2px solid var(--tn-notification-focus);
  outline-offset: 2px;
}

/* Progressive enhancement: server flashes stay in page flow before import. */
[data-tn-flash-seeds] {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-block: 16px;
}

.tn-notification {
  --tn-notification-accent: #2563eb;
  --tn-notification-accent-bg: rgba(37, 99, 235, 0.1);
  display: flex;
  align-items: flex-start;
  flex: 0 0 auto;
  gap: 12px;
  min-width: 0;
  min-height: 56px;
  padding: 12px 14px;
  box-sizing: border-box;
  border: 1px solid var(--tn-notification-border);
  border-radius: 8px;
  background: var(--tn-notification-surface);
  color: var(--tn-notification-text);
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.12), 0 4px 6px -4px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
  animation: tn-notification-enter 160ms ease-out;
}

.tn-notification[data-variant="error"] {
  --tn-notification-accent: #b91c1c;
  --tn-notification-accent-bg: rgba(185, 28, 28, 0.1);
}

.tn-notification[data-variant="warning"] {
  --tn-notification-accent: #a16207;
  --tn-notification-accent-bg: rgba(161, 98, 7, 0.1);
}

.tn-notification[data-variant="success"] {
  --tn-notification-accent: #15803d;
  --tn-notification-accent-bg: rgba(21, 128, 61, 0.1);
}

.tn-notification-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--tn-notification-accent-bg);
  color: var(--tn-notification-accent);
}

.tn-notification-icon svg {
  width: 18px;
  height: 18px;
}

.tn-notification-body {
  flex: 1;
  min-width: 0;
  padding-block: 3px;
  overflow-wrap: anywhere;
}

.tn-notification-title {
  color: var(--tn-notification-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.tn-notification-description {
  margin-block-start: 4px;
  color: var(--tn-notification-muted);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.tn-notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-block-start: 8px;
}

.tn-notification-action,
.tn-notification-close {
  flex-shrink: 0;
  min-height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--tn-notification-text);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.tn-notification-action {
  padding: 4px 8px;
  border: 1px solid var(--tn-notification-border);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  text-decoration: none;
}

.tn-notification-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-inline-start: auto;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.tn-notification-action:hover,
.tn-notification-close:hover {
  background: var(--tn-notification-hover);
  color: var(--tn-notification-text);
}

.tn-notification-action:focus-visible,
.tn-notification-close:focus-visible,
.tn-notification a:focus-visible {
  outline: 2px solid var(--tn-notification-focus);
  outline-offset: 2px;
}

.tn-notification-action:disabled {
  opacity: 0.6;
  cursor: wait;
}

html.tn-chrome-dark .tn-notifications,
html.tn-chrome-dark [data-tn-flash-seeds] {
  --tn-notification-surface: rgba(30, 41, 59, 0.9);
  --tn-notification-border: rgba(148, 163, 184, 0.35);
  --tn-notification-text: #f8fafc;
  --tn-notification-muted: #cbd5e1;
  --tn-notification-hover: rgba(255, 255, 255, 0.08);
  --tn-notification-focus: #8fb9be;
}

html.tn-chrome-dark .tn-notification { --tn-notification-accent: #93c5fd; }
html.tn-chrome-dark .tn-notification[data-variant="error"] { --tn-notification-accent: #fca5a5; }
html.tn-chrome-dark .tn-notification[data-variant="warning"] { --tn-notification-accent: #fcd34d; }
html.tn-chrome-dark .tn-notification[data-variant="success"] { --tn-notification-accent: #86efac; }

@media (max-width: 639.98px) {
  .tn-notifications {
    right: max(12px, env(safe-area-inset-right, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    width: auto;
    max-width: 420px;
    margin-inline-start: auto;
  }
}

@keyframes tn-notification-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .tn-notification { animation: none; }
}
