/* feedback.css — Phase 6: alerts, toasts, spinners, skeletons, states */

/* =====================================================================
   Diff 2 — Alert foundation (semantic, token-driven, upgrades .flash)
   ===================================================================== */

/* B21 s3 (CODE-13): this sheet is the `components` cascade layer; the order is declared once, in tokens.css. */
@layer components {

[data-slot="alert"],
.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2, .5rem);
  padding: var(--space-3, .75rem) var(--space-4, 1rem);
  border-radius: var(--radius-md, 8px);
  border-inline-start: 4px solid color-mix(in srgb, var(--color-primary) 65%, var(--color-background));
  background: color-mix(in srgb, color-mix(in srgb, var(--color-primary) 65%, var(--color-background)) 10%, transparent);
  color: var(--color-foreground, inherit);
}
/* The UA's [hidden] { display: none } loses to the author `display: flex`
   above, so an alert rendered with the hidden attribute still paints —
   an empty coloured band with just its icon. Restore the attribute. */
[data-slot="alert"][hidden],
.flash[hidden] { display: none; }
[data-slot="alert"] > [data-slot="alert-icon"],
.flash > i { flex: none; margin-block-start: .1em; }
[data-slot="alert"][data-variant="success"], .flash-success {
  border-inline-start-color: var(--color-success);
  background: color-mix(in srgb, var(--color-success) 10%, transparent);
}
[data-slot="alert"][data-variant="error"], .flash-error {
  border-inline-start-color: var(--color-danger);
  background: color-mix(in srgb, var(--color-danger) 10%, transparent);
}
[data-slot="alert"][data-variant="warning"], .flash-warning {
  border-inline-start-color: var(--color-warning);
  background: color-mix(in srgb, var(--color-warning) 10%, transparent);
}
[data-slot="alert"][data-variant="info"], .flash-info {
  border-inline-start-color: color-mix(in srgb, var(--color-primary) 65%, var(--color-background));
  background: color-mix(in srgb, color-mix(in srgb, var(--color-primary) 65%, var(--color-background)) 10%, transparent);
}
[data-slot="alert-content"] { flex: 1; }
[data-slot="alert-title"] { font-weight: 600; margin-block-end: var(--space-1, .25rem); }
[data-slot="alert-description"] { color: var(--color-muted-foreground); font-size: var(--text-sm); }
[data-slot="alert-close"], .flash-close {
  background: transparent; border: 0; cursor: pointer;
  color: var(--color-muted-foreground); padding: var(--space-1);
  margin-inline-start: var(--space-2); flex: none;
}
[data-slot="alert-close"]:hover, .flash-close:hover { color: var(--color-foreground); }

/* =====================================================================
   Diff 3 — Toast viewport + toast items
   ===================================================================== */
[data-slot="toast-viewport"] {
  position: fixed;
  inset-block-start: var(--space-4, 1rem);
  inset-inline-end: var(--space-4, 1rem);
  z-index: var(--z-toast, 9500);
  display: flex; flex-direction: column; gap: var(--space-2, .5rem);
  width: min(90vw, 380px); pointer-events: none;
  --_toast-enter-x: 8px;
}
[dir="rtl"] [data-slot="toast-viewport"] { --_toast-enter-x: -8px; }
[data-slot="toast"] {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: var(--space-3, .75rem);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md, 8px);
  background: var(--color-card); color: var(--color-card-foreground);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  border-inline-start: 3px solid var(--_toast-accent, var(--toast-info));
  animation: fb-toast-in var(--dur-slow, 200ms) var(--ease-standard);
}
[data-slot="toast"][data-variant="success"] { --_toast-accent: var(--toast-success); }
[data-slot="toast"][data-variant="error"]   { --_toast-accent: var(--toast-error); }
[data-slot="toast"][data-variant="warning"] { --_toast-accent: var(--toast-warning); }
[data-slot="toast"][data-variant="info"]    { --_toast-accent: var(--toast-info); }
[data-slot="toast"][data-state="closing"]   { animation: fb-toast-out var(--dur-fast, 100ms) var(--ease-standard) forwards; }

/* Icon inherits the accent via currentColor — one rule covers all variants. */
[data-slot="toast-icon"] {
  display: inline-flex; flex: none;
  color: var(--_toast-accent, var(--toast-info));
  margin-block-start: 1px;   /* optical baseline against 14px/1.45 text */
}
[data-slot="toast-content"] { flex: 1 1 auto; min-width: 0; }
[data-slot="toast-message"] {
  font-size: var(--text-sm); line-height: 1.45; font-weight: 500;
  color: var(--color-card-foreground);
  overflow-wrap: anywhere;   /* wrap long ids/URLs — never truncate a message */
}
[data-slot="toast-description"] {
  font-size: var(--text-xs); line-height: 1.45;
  color: var(--color-muted-foreground); margin-block-start: 2px;
  overflow-wrap: anywhere;
}
[data-slot="toast-action"] {
  background: transparent; border: 0; padding: 0; cursor: pointer;
  margin-block-start: var(--space-2, .5rem);
  font-size: var(--text-xs); font-weight: 600;
  color: var(--_toast-accent, var(--toast-info));
  /* FIXUP-SHELL SHL-1 (W-K-951): a 24 px target at least (WCAG 2.2 SC 2.5.8) - the Undo was the
     word's own 31 x 14 px; the padding grows the target, the negative margin keeps the word in place */
  display: inline-flex; align-items: center;
  min-block-size: 24px; min-inline-size: 24px;
  padding-inline: var(--space-2, .5rem); margin-inline-start: calc(-1 * var(--space-2, .5rem));
  border-radius: var(--radius-sm, 6px);
}
[data-slot="toast-action"]:hover { text-decoration: underline; }
[data-slot="toast-close"] {
  background: transparent; border: 0; cursor: pointer;
  display: inline-flex; flex: none;
  color: var(--color-muted-foreground); padding: var(--space-1);
  margin-inline-start: var(--space-2);
}
[data-slot="toast-close"]:hover { color: var(--color-foreground); }
[data-slot="toast-close"]:focus-visible,
[data-slot="toast-action"]:focus-visible {
  outline: 2px solid var(--color-ring); outline-offset: 2px;
  border-radius: var(--radius-sm, 6px);
}

/* Slides in from the viewport edge; RTL flips via --_toast-enter-x. */
@keyframes fb-toast-in  { from { opacity: 0; transform: translateX(var(--_toast-enter-x, 8px)); } to { opacity: 1; transform: none; } }
@keyframes fb-toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(var(--_toast-enter-x, 8px)); } }
@media (prefers-reduced-motion: reduce) {
  [data-slot="toast"], [data-slot="toast"][data-state="closing"] { animation: none; }
}

/* =====================================================================
   Diff 4 — Spinner variants (consolidation target)
   ===================================================================== */
[data-slot="spinner"] {
  display: inline-block; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 18%, transparent);
  border-block-start-color: currentColor;
  inline-size: var(--icon-md, 16px); block-size: var(--icon-md, 16px);
  animation: fb-spin var(--dur-spin, 800ms) linear infinite;
}
[data-slot="spinner"][data-size="sm"] { inline-size: var(--icon-sm, 14px); block-size: var(--icon-sm, 14px); }
[data-slot="spinner"][data-size="lg"] { inline-size: 80px; block-size: 80px; border-width: 4px; }
@keyframes fb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [data-slot="spinner"] { animation-duration: 1.5s; } }

/* =====================================================================
   Diff 5 — Skeleton (re-export Phase-5 pulse, single source)
   ===================================================================== */
[data-slot="skeleton"], .skel {
  position: relative; overflow: hidden;
  background: var(--color-muted);
  border-radius: var(--radius-sm, 4px);
}

/* Visually-hidden but screen-reader-announced (page has no global .sr-only) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
[data-slot="skeleton"]::after, .skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent,
      color-mix(in srgb, var(--color-foreground) 8%, transparent), transparent);
  animation: fb-shimmer 1.4s var(--ease-standard, cubic-bezier(.4,0,.2,1)) infinite;
}
[dir="rtl"] [data-slot="skeleton"]::after,
[dir="rtl"] .skel::after { animation-direction: reverse; }
@keyframes fb-shimmer { to { transform: translateX(100%); } }
@keyframes fb-skeleton { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) {
  [data-slot="skeleton"]::after, .skel::after { animation: none; }
  [data-slot="skeleton"], .skel { animation: none; }
}

/* Crossfade utility used by skeletonCycle.hide() → no abrupt skeleton→content swap */
.skel-fade-out { animation: fb-fade-out var(--dur-base) var(--ease-standard) forwards; }
.skel-fade-in  { animation: fb-fade-in  var(--dur-base) var(--ease-standard); }
@keyframes fb-fade-out { to { opacity: 0; } }
@keyframes fb-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .skel-fade-out, .skel-fade-in { animation: none; }
}

/* =====================================================================
   Diff 6 — [data-state] visibility + empty-state slots
   ===================================================================== */
[data-state="loading"] [data-show="ready"],
[data-state="loading"] [data-show="empty"],
[data-state="empty"]   [data-show="ready"] { display: none; }
[data-slot="empty-state"], .empty-state { text-align: center; padding: var(--space-8, 3rem) var(--space-4, 1rem); }
[data-slot="empty-title"] { font-size: var(--text-lg); font-weight: 600; margin-block: var(--space-2) var(--space-1); }
[data-slot="empty-actions"] { display: flex; gap: var(--space-3, 1rem); justify-content: center; margin-block-start: var(--space-4); flex-wrap: wrap; }

/* =====================================================================
   Diff 7 — Alert dark-mode parity
   ===================================================================== */
.dark-mode [data-slot="toast"] { background: var(--color-card); color: var(--color-card-foreground); border-color: var(--color-border); }
.dark-mode [data-slot="alert"], .dark-mode .flash { color: var(--color-foreground); }
/* No dark override for the spinner. Both the track and the arc are derived
   from currentColor, so the primitive is already theme-agnostic. The rule
   that stood here restated the track colour verbatim — but as the
   `border-color` SHORTHAND, which also overwrote the
   `border-block-start-color: currentColor` longhand above that forms the
   arc. The result was a uniform ring, which is pixel-identical at every
   frame of the rotation and read as a static spinner. */

/* =====================================================================
   Diff 11 — Legacy .notification* compat bridge removed. No template or JS
   emits these classes after Diff 2.3 (showNotification forwarder) lands.
   script.js L390's fallback branch is the only remaining consumer and is
   unreachable whenever feedback.js is loaded (per-template now). If you
   choose to delete that fallback body too, this block can be re-purged
   with grep. Currently empty so the diff stays a pure removal.
   ===================================================================== */

} /* end @layer components */
