/* Redwood feedback — message banners, toasts, the empty state, the progress bar
 * and skeletons.
 *
 * Values were read out of the JET 21.0.0 Redwood theme (oj-redwood-min.css:
 * the oj-messages inline and notification rules, --oj-private-message-*,
 * --oj-progress-bar-*, --oj-animation-skeleton-*; identical at 19.0.0) and the
 * core-pack theme beside it (oraclejet-preact Theme-redwood/theme.css:
 * MessageBanner, MessageToast, ProgressBar, Skeleton), and mapped onto the
 * --rw-* names. The Cookbook describes the two message components this way:
 * a banner is "brief, moderately disruptive, semi-permanent"; a toast is
 * "short, noncritical, auto-dismissible".
 *
 * Load after redwood-tokens.css (and redwood-dark.css if you use it).
 *
 *   <div class="rw-banner rw-banner-danger" role="alert">
 *     <svg class="rw-banner-icon"/>
 *     <p class="rw-banner-summary">The invoice was not posted</p>
 *     <p class="rw-banner-detail">The period is closed. Reopen May or post to
 *       June. Reference MER-4F2A.</p>
 *   </div>
 *
 *   <div class="rw-toast-region" aria-live="polite">
 *     <div class="rw-toast" role="status"><svg class="rw-toast-icon"/>
 *       <p class="rw-toast-summary">Invoice INV-1042 posted</p></div>
 *   </div>
 *
 *   <div class="rw-progress" role="progressbar" aria-valuenow="40"
 *        aria-valuemin="0" aria-valuemax="100" style="--rw-progress: 40%"><span></span></div>
 *
 * Readings, and where each is rounded onto a token:
 *
 *   Banner     status -10 ground; a 1rem icon and a subheading-xs summary
 *              (1rem, 700) in the status -120 step; detail body-sm in
 *              neutral-190; 1rem padding, detail indented under the summary
 *              past the icon with .5rem between them. A page banner spans the
 *              page with a divider below and no radius; a section banner
 *              ("outlined") takes a 1px divider border and radius lg.
 *              Subheading-xs sets a 1.5 line height, which has no token; the
 *              body-md line height is used.
 *   Toast      a neutral-50 ground with neutral-190 ink; 1.5rem icon;
 *              summary body-md at 400; radius lg and shadow md (the legacy
 *              notification overlay); at most 37.5rem wide (150 units), and
 *              the viewport less 3rem below that; bottom centre by default.
 *              The detail is text-secondary on neutral-50 in Oracle's theme,
 *              which composites to within a few units of neutral-140, so the
 *              detail ink is neutral-140. Padding, gaps and the offset from
 *              the bottom of the window are house choices on the scale; the
 *              theme does not publish them.
 *   Progress   6px track, 3px radius; the value is neutral-190 — not brand;
 *              the track is neutral-170 at .15, rounded to --rw-bg-active
 *              (neutral-190 at .16). Indeterminate sweeps in 2s, linear.
 *   Skeleton   neutral-170 pulsing between .15 and .05 opacity, 1.5s,
 *              alternating. neutral-170 is rounded to --rw-text-primary so the
 *              pulse follows the theme; the opacities and timing are Oracle's.
 *   Empty      Oracle's no-data message is text-secondary, and that is the
 *              only reading. The layout of .rw-empty — padding, a heading-xs
 *              title, the action row — is a house arrangement of tokens, not
 *              an Oracle spec.
 *
 * What people get wrong:
 *
 *   A banner and a toast bring their own ground. Their status grounds are
 *   fixed ramp steps, so their ink is fixed too (neutral-190, status -120) and
 *   they read the same on a light or a dark page. Setting their text with
 *   --rw-text-primary would put near-white on a pastel ground in dark.
 *
 *   Errors do not go in a toast. A toast disappears; a failure the user has to
 *   act on is a banner at the top of the page or of the section it concerns.
 *   A toast confirms something that already happened.
 *
 *   Error text is written for the user, not copied from the server. Say what
 *   did not happen and what to do next, and give the short reference code that
 *   the server logged the detail under (STYLE-GUIDE §9a). Never an exception,
 *   a status dump, SQL or a driver message.
 *
 *   The progress value is near-black, not teal. Brand is not "busy".
 *
 *   A skeleton stands in for content of the same shape and size, briefly.
 *   It is not a spinner, and it does not animate for users who ask for less
 *   motion.
 *
 *   An empty state says what is missing and what makes it appear, and offers
 *   that action when the user can take it. "No data" alone is a dead end.
 *
 * (c) Oracle. Internal brand asset — see NOTICE. */

/* ── Message banner ───────────────────────────────────────────────────────── */

.rw-banner {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  column-gap: var(--rw-space-2x);
  row-gap: var(--rw-space-2x);
  padding: var(--rw-space-4x);
  padding-inline-end: var(--rw-space-2x);
  border-bottom: 1px solid var(--rw-divider);
  background: var(--rw-info-10);
  color: var(--rw-neutral-190);
  color-scheme: light;
  --rw-banner-ink: var(--rw-info-120);
  /* The banner's ground is light in every theme, so anything nested in it —
     a borderless button, a link — draws with light-theme ink. */
  --rw-text-primary: var(--rw-neutral-190);
  --rw-focus-ring: var(--rw-neutral-190);
}

.rw-banner-danger  { background: var(--rw-danger-10);  --rw-banner-ink: var(--rw-danger-120); }
.rw-banner-warning { background: var(--rw-warning-10); --rw-banner-ink: var(--rw-warning-120); }
.rw-banner-success { background: var(--rw-success-10); --rw-banner-ink: var(--rw-success-120); }
.rw-banner-info    { background: var(--rw-info-10);    --rw-banner-ink: var(--rw-info-120); }

/* Section level: a bordered, rounded banner inside a card or region. */
.rw-banner-section {
  border: 1px solid var(--rw-divider);
  border-radius: var(--rw-radius-lg);
}

.rw-banner-icon {
  grid-column: 1;
  grid-row: 1;
  width: var(--rw-space-4x);
  height: var(--rw-space-4x);
  font-size: var(--rw-space-4x);
  /* Centres the 1rem icon on the first line of the summary. */
  margin-block-start: calc((var(--rw-body-md-size) * var(--rw-body-md-lh) - var(--rw-space-4x)) / 2);
  color: var(--rw-banner-ink);
}

.rw-banner-summary {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  color: var(--rw-banner-ink);
  font-size: var(--rw-body-md-size);
  line-height: var(--rw-body-md-lh);
  font-weight: 700;
}

.rw-banner-detail {
  grid-column: 2;
  margin: 0;
  font-size: var(--rw-body-sm-size);
  line-height: var(--rw-body-sm-lh);
}

/* A close button or an action sits in the end column of the first row. */
.rw-banner-close {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: start;
  margin-block: calc(-1 * var(--rw-space-2x));
}

/* ── Toast ────────────────────────────────────────────────────────────────── */

.rw-toast-region {
  position: fixed;
  inset-inline: 0;
  inset-block-end: var(--rw-space-6x);
  z-index: 2000; /* --oj-core-z-index-messages */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rw-space-1x);
  pointer-events: none;
}

.rw-toast {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: var(--rw-space-3x);
  width: max-content;
  max-width: min(37.5rem, calc(100vw - var(--rw-space-12x)));
  padding: var(--rw-space-3x) var(--rw-space-4x);
  border-radius: var(--rw-radius-lg);
  background: var(--rw-neutral-50);
  box-shadow: var(--rw-shadow-md);
  color: var(--rw-neutral-190);
  color-scheme: light;
  pointer-events: auto;
  --rw-text-primary: var(--rw-neutral-190);
  --rw-focus-ring: var(--rw-neutral-190);
}

.rw-toast-icon {
  width: var(--rw-space-6x);
  height: var(--rw-space-6x);
  font-size: var(--rw-space-6x);
}

.rw-toast-summary {
  margin: 0;
  font-size: var(--rw-body-md-size);
  line-height: var(--rw-body-md-lh);
  font-weight: 400;
}

.rw-toast-detail {
  grid-column: 2;
  margin: var(--rw-space-1x) 0 0;
  color: var(--rw-neutral-140);
  font-size: var(--rw-body-sm-size);
  line-height: var(--rw-body-sm-lh);
}

/* ── Empty state ──────────────────────────────────────────────────────────── */

.rw-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--rw-space-2x);
  padding: var(--rw-space-8x) var(--rw-space-4x);
  color: var(--rw-text-secondary);
  font-size: var(--rw-body-md-size);
  line-height: var(--rw-body-md-lh);
  text-align: center;
}

.rw-empty > :is(h2, h3, h4, .rw-empty-title) {
  margin: 0;
  color: var(--rw-text-primary);
  font-size: var(--rw-heading-xs-size);
  line-height: var(--rw-heading-xs-lh);
  font-weight: var(--rw-heading-weight);
}

.rw-empty > p { margin: 0; }

.rw-empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--rw-space-2x);
  margin-top: var(--rw-space-2x);
}

/* Inline: one line of text-secondary where a table or list would be. */
.rw-empty-inline {
  display: block;
  padding: var(--rw-space-3x) var(--rw-space-4x);
  text-align: start;
}

/* ── Progress bar ─────────────────────────────────────────────────────────── */

.rw-progress {
  position: relative;
  overflow: hidden;
  height: 6px;
  border-radius: 3px;
  background: var(--rw-bg-active);
}

.rw-progress > span {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--rw-progress, 0%);
  border-radius: inherit;
  background: var(--rw-text-primary);
}

/* Across the top edge of a region that is loading: square, full width. */
.rw-progress-edge { border-radius: 0; }

.rw-progress-indeterminate > span {
  width: auto;
  animation: rw-progress-sweep 2s linear infinite;
}

@keyframes rw-progress-sweep {
  0%   { left: -35%; right: 100%; }
  60%  { left: 100%; right: -90%; }
  100% { left: 100%; right: -90%; }
}

[dir="rtl"] .rw-progress-indeterminate > span { animation-name: rw-progress-sweep-rtl; }

@keyframes rw-progress-sweep-rtl {
  0%   { left: 100%; right: -35%; }
  60%  { left: -90%; right: 100%; }
  100% { left: -90%; right: 100%; }
}

/* ── Skeleton ─────────────────────────────────────────────────────────────── */

.rw-skeleton {
  display: block;
  min-height: var(--rw-body-md-size);
  border-radius: var(--rw-radius-md);
  background: var(--rw-text-primary);
  opacity: .15;
  animation: rw-skeleton 1.5s infinite alternate;
}

@keyframes rw-skeleton {
  from { opacity: .15; }
  to   { opacity: .05; }
}

@media (prefers-reduced-motion: reduce) {
  .rw-skeleton { animation: none; }
  .rw-progress-indeterminate > span { animation: none; inset-inline: 0; }
}

/* ── Windows high contrast ────────────────────────────────────────────────── */

@media (forced-colors: active) {
  .rw-banner, .rw-toast { border: 1px solid CanvasText; }
  .rw-banner-icon, .rw-banner-summary { color: CanvasText; }
  .rw-progress { border: 1px solid CanvasText; }
  .rw-progress > span { background: Highlight; }
  .rw-skeleton { border: 1px solid GrayText; }
}
