/* states.css — owned by WP2, then F11 (1C): the one loader, the inline
 * notes, loading / skeleton / error / empty. EUDR: shared/LoadingOverlay.js
 * (the three dots are the platform's one loading animation, never a spinner;
 * the skeleton only on the Home's widgets), css/operator-react.css:1660-1767,
 * css/phone-kit.css:951-994 (the phone's bar, the 150 ms veil). Every colour
 * is a token (or a color-mix of one), so dark.css's token block flips it;
 * the few dark rules are marked. */

/* ═══════════════════════════ The one loader: three dots ═══════════════════════════ */

/* The rotating ring is retired (render.js spinner() now draws the dots). */
.ct-loading-dots {
  display: flex;
  gap: 8px;
}
.ct-loading-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: ct-loading-pulse 1.4s ease-in-out infinite;
}
.ct-loading-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.ct-loading-dot:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes ct-loading-pulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.1);
  }
}
@keyframes ct-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* loadingDots(): block (centred, the label under the dots), inline (on one
   line with its words: a sentence, a button), small (a button, a chip, a
   cell). */
.ct-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 28px 12px;
  text-align: center;
}
.ct-loading-label {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
}
.ct-loading--inline {
  display: inline-flex;
  flex-direction: row;
  width: auto;
  gap: 8px;
  padding: 0;
  vertical-align: middle;
}
.ct-loading--inline .ct-loading-dots {
  gap: 5px;
}
.ct-loading--inline .ct-loading-dot {
  width: 7px;
  height: 7px;
}
.ct-loading--small .ct-loading-dots,
button .ct-loading-dots,
.is-busy .ct-loading-dots {
  gap: 4px;
}
.ct-loading--small .ct-loading-dot,
button .ct-loading-dot,
.is-busy .ct-loading-dot {
  width: 6px;
  height: 6px;
}
/* In a filled button the dots take the button's ink; a secondary or quiet
   button keeps the accent. */
:is(.ct-btn-primary, .ct-questionnaire-submit, .ct-confirm-danger) .ct-loading-dot {
  background: currentColor;
}
/* busy(): the dots and the action's word ("Saving…") on one line. */
button.is-busy,
a.is-busy {
  gap: 8px;
  cursor: progress;
}
a.is-busy {
  pointer-events: none;
}
.is-busy .ct-loading-dots {
  display: inline-flex;
}
/* In a box that already places it: no room of its own. */
.ct-card-loading > .ct-loading,
.ct-sds-extracting > .ct-loading,
.ct-empty > .ct-loading {
  padding: 0;
}

/* ═══════════════════════════ Full-screen loading overlay ═══════════════════════════ */

/* loadingOverlay(): a blocking action's wait, in the action's own words. It
   holds taps at once but shows only after 150 ms (a quick action never
   flashes it). No backdrop-filter: the moving dots over a live blur
   re-blurred the whole screen on every frame (EUDR operator-react.css:1660).
   Above the drawers (4000), under the dialogs (4100). */
.ct-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 4050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(var(--storm-rgb) / 0.42);
  animation: ct-fade-in 0.2s ease 0.15s both;
  cursor: progress;
}
.ct-loading-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.ct-loading-overlay .ct-loading-dot {
  background: var(--accent-light);
}
.ct-loading-message {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--brand-white);
}
/* The phone's wait is the splash's 120×3 bar, centred over a light veil
   (EUDR phone-kit.css:963-994); its words are read out, not shown. */
.ct-loading-bar {
  display: none;
  position: relative;
  width: 120px;
  height: 3px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text) 14%, transparent);
  overflow: hidden;
}
.ct-loading-bar::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  border-radius: 2px;
  background: var(--accent);
  animation: ct-loading-slide 1.1s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes ct-loading-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}
@media (max-width: 600px) {
  .ct-loading-overlay {
    background: color-mix(in srgb, var(--ground) 60%, transparent);
  }
  .ct-loading-overlay .ct-loading-dots {
    display: none;
  }
  .ct-loading-overlay .ct-loading-bar {
    display: block;
  }
  .ct-loading-overlay .ct-loading-message {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}
/* Reduced motion slows progress, it never stops it (tokens.css zeroes every
   other animation with !important, hence the !important here). */
@media (prefers-reduced-motion: reduce) {
  .ct-loading-dot {
    animation-duration: 2.8s !important;
  }
  .ct-loading-bar::after {
    animation-duration: 3s !important;
  }
}

/* ═══════════════════════════ In-card loading veil ═══════════════════════════ */

/* Absolute veil inside a position:relative card/panel (spec-theme §6.6): the
   ground colour at 86%, pale on light and deep green on dark. Put
   loadingDots() and optional text inside. No blur under the moving dots. */
.ct-card-loading {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: inherit;
  background: color-mix(in srgb, var(--ground) 86%, transparent);
}
.ct-card-loading-text {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-muted);
}

/* ═══════════════════════════ Shimmer skeleton ═══════════════════════════ */

/* The house skeleton (spec-theme §6.7): one shimmer keyframe, a faint tint of
   the text colour (Storm on light, near-white on dark), so it needs no dark
   rule. Bare rows get a width from JS (skeletonRows); default height 14px so
   a standalone .ct-skeleton is still visible. */
@keyframes ct-shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: 200px 0;
  }
}
.ct-skeleton {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--text) 6%, transparent) 25%,
    color-mix(in srgb, var(--text) 10%, transparent) 50%,
    color-mix(in srgb, var(--text) 6%, transparent) 75%
  );
  background-size: 400px 100%;
  animation: ct-shimmer 1.5s infinite;
}
.ct-skeleton-stat {
  height: 90px;
  border-radius: var(--radius);
}
.ct-skeleton-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* ═══════════════════════════ Error panel ═══════════════════════════ */

/* Distinct from an empty state: a failed fetch renders THIS (hazard-red, with a
   retry), never the empty CTA (spec-chemtrust §7.2). Reuses the
   .ct-extraction-error grammar (ui.css) with an icon + message + retry slot. All
   colors are tokens, so dark.css flips them automatically. */
.ct-error-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5);
  border-radius: var(--radius);
  background: var(--confirmed-tint);
  color: var(--confirmed);
  border: 1px solid var(--confirmed-edge);
}
.ct-error-panel-icon {
  flex: 0 0 auto;
  margin-top: 1px;
}
.ct-error-panel-body {
  flex: 1 1 200px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ct-error-panel-msg {
  margin: 0;
  font-weight: 700;
}
.ct-error-panel-reqid {
  margin: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  opacity: 0.85;
}
.ct-error-panel-reqid code {
  color: inherit;
}
.ct-error-panel .ct-btn-secondary {
  flex: 0 0 auto;
  align-self: center;
}

/* ═══════════════════════════ Rich empty state ═══════════════════════════ */

/* Richer than the bare .ct-empty (ui.css): stacked icon + title + hint + CTA
   slot, so a genuinely-empty list can point the user at their next action. */
.ct-empty-rich {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}
.ct-empty-icon {
  color: var(--text-subtle);
  opacity: 0.7;
}
.ct-empty-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text);
}
.ct-empty-hint {
  margin: 0;
  max-width: 46ch;
  color: var(--text-muted);
  font-size: var(--text-md);
}
.ct-empty-action {
  margin-top: var(--space-2);
}

/* ═══════════════════════════ Inline notes (feedback.js inlineNote) ═══════════════════════════ */

/* The answer where the action was (EUDR .support-error, .erp-msg--error,
   p.ph-note): no toast. The ink is the status colour 70 % into near-black
   on its 8 % tint (≥ 6.3:1); on dark the colour 62 % into white (≥ 5.7:1). */
.ct-note-slot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: var(--space-2) 0 var(--space-3);
}
.ct-note-slot[hidden],
.ct-note-slot:empty {
  display: none;
}
/* the record's foot and a flex row of actions: a line of its own */
.ct-record-foot > .ct-note-slot,
.ct-form-actions > .ct-note-slot {
  flex: 1 1 100%;
  margin: 0;
}
.ct-note {
  --note-c: var(--indeterminate);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--note-c) 30%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--note-c) 8%, var(--surface));
  color: color-mix(in srgb, var(--note-c) 70%, #1a1a1a);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.45;
  text-align: start;
  animation: ct-fade-in 0.16s ease;
}
.ct-note--error {
  --note-c: var(--confirmed);
}
.ct-note--success {
  --note-c: var(--clear);
}
.ct-note--warn {
  --note-c: var(--potential);
}
.ct-note--info {
  --note-c: var(--cyan-deep);
}
body.dark-mode .ct-note {
  background: color-mix(in srgb, var(--note-c) 12%, var(--surface));
  color: color-mix(in srgb, var(--note-c) 62%, #ffffff);
}
body.dark-mode .ct-note--info {
  --note-c: var(--accent);
}
.ct-note-icon {
  flex: none;
  margin-top: 1px;
}
.ct-note-body {
  flex: 1 1 auto;
  min-width: 0;
}
.ct-note-text {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.ct-note-ref {
  margin: 2px 0 0;
  font-size: var(--text-xs);
  font-weight: 600;
}
.ct-note-ref code {
  color: inherit;
}
.ct-note-retry {
  flex: none;
  align-self: center;
}
.ct-note-close {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: -3px -4px -3px 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.ct-note-close:hover,
.ct-note-close:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--note-c) 14%, transparent);
}
/* The page's own slot (an answer whose control is gone): under the head, and
   held in view while the page scrolls. */
.ct-note-slot--page {
  position: sticky;
  top: 0;
  z-index: 6;
  margin: 0 0 var(--space-4);
}
.ct-note-slot--page .ct-note {
  background: color-mix(in srgb, var(--note-c) 8%, #ffffff);
  box-shadow: var(--shadow-sm);
}
body.dark-mode .ct-note-slot--page .ct-note {
  background: color-mix(in srgb, var(--note-c) 12%, #163832);
}
@media (max-width: 600px) {
  .ct-note {
    font-size: 0.9375rem;
  }
}
