/* =========================================================
   ControlIO — Feedback Primitives
   Handle: wb-feedback · depends on wb-tokens · Step 3 Pass C

   Notices, badges, loading/skeleton, empty states, error states.

   Principle running through all of it: never signal by colour
   alone. Every variant carries an icon glyph and a text label
   as well as a hue, so it survives greyscale, low vision and
   colour-blindness.
   ========================================================= */

/* ---------------------------------------------------------
   NOTICE
   Inline and page-level. Toasts are in overlays.css.
   --------------------------------------------------------- */

.wbc-notice{
  --_tone: var(--muted);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--_tone) 35%, var(--border));
  border-inline-start: 4px solid var(--_tone);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--_tone) 7%, var(--surface));
  color: var(--text);
  font-size: var(--text-sm);
  line-height: var(--leading-base);
}

.wbc-notice::before{
  content: attr(data-icon);
  flex: none;
  display: grid;
  place-items: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  background: var(--_tone);
  color: var(--surface);
  font-weight: 800;
  font-size: .85em;
  line-height: 1;
}

.wbc-notice__body{ flex: 1 1 auto; min-width: 0; }
.wbc-notice__title{ font-weight: 700; margin: 0 0 var(--space-1); }
.wbc-notice__body > :last-child{ margin-bottom: 0; }
.wbc-notice__dismiss{ flex: none; margin-inline-start: auto; }

.wbc-notice--info{ --_tone: var(--status-info); }
.wbc-notice--success{ --_tone: var(--status-success); }
.wbc-notice--warning{ --_tone: var(--status-warning); }
.wbc-notice--error{ --_tone: var(--status-error); }

/* Page-level notices sit above content and get more presence. */
.wbc-notice--page{
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-base);
  box-shadow: var(--elevation-raised);
}

/* ---------------------------------------------------------
   BADGE / CHIP
   --------------------------------------------------------- */

.wbc-badge{
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: .2em .6em;
  border-radius: var(--radius-pill);
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.wbc-badge--neutral{ background: var(--chip-bg); color: var(--text); }
.wbc-badge--success{ background: var(--status-success); color: #fff; }
.wbc-badge--warning{ background: var(--status-warning); color: #fff; }
.wbc-badge--danger{ background: var(--status-error); color: #fff; }
.wbc-badge--outline{
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ----- Stock state -----
   Presentation only. The underlying availability logic stays with
   WooCommerce and the pricing/stock system. */
.wbc-stock{
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
}
.wbc-stock::before{
  content: "";
  width: .55em;
  height: .55em;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.wbc-stock--in{ color: var(--status-success); }
.wbc-stock--low{ color: var(--status-warning); }
.wbc-stock--order,
.wbc-stock--backorder{ color: var(--status-info); }
.wbc-stock--out{ color: var(--muted); }
.wbc-stock--discontinued{ color: var(--muted); text-decoration: line-through; }

/* ---------------------------------------------------------
   LOADING
   Skeletons where geometry is predictable, spinner where it is
   not. Both reserve space so nothing shifts (brief 3.39).
   --------------------------------------------------------- */

.wbc-skeleton{
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--text) 6%, var(--surface)) 25%,
    color-mix(in srgb, var(--text) 11%, var(--surface)) 37%,
    color-mix(in srgb, var(--text) 6%, var(--surface)) 63%
  );
  background-size: 400% 100%;
  animation: wbc-shimmer 1.4s ease-in-out infinite;
}
.wbc-skeleton--text{ height: 1em; margin-block: .25em; }
.wbc-skeleton--title{ height: 1.5em; width: 60%; }
.wbc-skeleton--media{ aspect-ratio: 1 / 1; width: 100%; border-radius: var(--radius-md); }
.wbc-skeleton--button{ height: var(--control-height-md); border-radius: var(--radius-pill); }

@keyframes wbc-shimmer{
  from{ background-position: 100% 0 }
  to{ background-position: 0 0 }
}

/* A shimmer is decoration. With reduced motion, hold a flat tone — it still
   reads as "not content yet" without the movement. */
@media (prefers-reduced-motion: reduce){
  .wbc-skeleton{
    animation: none;
    background: color-mix(in srgb, var(--text) 8%, var(--surface));
  }
}

.wbc-spinner{
  display: inline-block;
  width: 1.25em;
  height: 1.25em;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: wbc-spin 700ms linear infinite;
}
@media (prefers-reduced-motion: reduce){
  .wbc-spinner{ animation: none; opacity: .6; }
}

/* Anything replaced by a loading state must keep its footprint. */
.wbc-loading-region{ position: relative; min-height: var(--control-height-lg); }
.wbc-loading-region[aria-busy="true"]{ pointer-events: none; }

/* ---------------------------------------------------------
   EMPTY STATE
   Must say what happened AND what to do next (brief 3.40).
   --------------------------------------------------------- */

.wbc-empty{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text);
}
.wbc-empty__icon{
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
}
.wbc-empty__title{
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  line-height: var(--leading-snug);
}
.wbc-empty__body{
  margin: 0;
  max-width: 42ch;             /* readable measure, not full width */
  color: var(--muted);
  line-height: var(--leading-base);
}
.wbc-empty__actions{
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  margin-top: var(--space-2);
}

/* ---------------------------------------------------------
   ERROR STATE
   Same shape as empty, different tone. Customer-facing copy
   must never carry PHP/REST internals — those go to the log.
   --------------------------------------------------------- */

.wbc-errorstate{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}
.wbc-errorstate__icon{
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--status-error) 12%, var(--surface));
  color: var(--status-error);
  font-size: var(--text-xl);
  font-weight: 800;
}
.wbc-errorstate__title{
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
}
.wbc-errorstate__body{
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  line-height: var(--leading-base);
}
/* Technical detail is opt-in and collapsed by default: useful in a support
   conversation, noise for everyone else. */
.wbc-errorstate__detail{
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--muted);
}
.wbc-errorstate__detail pre{
  margin: var(--space-2) 0 0;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  text-align: left;
  overflow-x: auto;
  font-size: var(--text-xs);
}

/* ---------------------------------------------------------
   VISUALLY HIDDEN
   For accessible names and live-region text that must exist
   for assistive technology but not be seen.
   --------------------------------------------------------- */

.wbc-sr-only{
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
/* Skip links and similar must become visible when focused. */
.wbc-sr-only--focusable:focus,
.wbc-sr-only--focusable:focus-visible{
  position: static !important;
  width: auto; height: auto;
  margin: 0; overflow: visible;
  clip: auto; clip-path: none;
  white-space: normal;
}
