/*
 * WoohooBook Global Foundation — V45.2 P1
 *
 * This file owns only product-wide design tokens and opt-in accessibility
 * primitives. It intentionally does not restyle existing elements in P1.
 * Shell, component and feature migrations belong to later V45.2 phases.
 */

:root {
  /* Typography */
  --wb-font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --wb-font-display: "Playfair Display", Georgia, serif;
  --wb-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* Canonical product colours. P1 definitions are passive until migrated code uses them. */
  --wb-color-primary: #6f4af6;
  --wb-color-primary-hover: #5f3ddd;
  --wb-color-primary-soft: #f1edff;
  --wb-color-primary-contrast: #ffffff;
  --wb-color-text: #211d29;
  --wb-color-text-muted: #6f6878;
  --wb-color-surface: #ffffff;
  --wb-color-surface-subtle: #faf9fc;
  --wb-color-background: #f7f5fb;
  --wb-color-border: #e5e0e9;
  --wb-color-border-strong: #d4cddd;
  --wb-color-focus: #6f4af6;
  --wb-color-success: #197347;
  --wb-color-success-soft: #edf9f2;
  --wb-color-warning: #8a4b08;
  --wb-color-warning-soft: #fff7e8;
  --wb-color-danger: #b42318;
  --wb-color-danger-soft: #fff0ef;
  --wb-color-info: #175cd3;
  --wb-color-info-soft: #eff6ff;

  /* Radius */
  --wb-radius-xs: 6px;
  --wb-radius-sm: 8px;
  --wb-radius-md: 12px;
  --wb-radius-lg: 16px;
  --wb-radius-xl: 22px;
  --wb-radius-full: 999px;

  /* Spacing tokens are values only; components own their actual spacing. */
  --wb-space-1: 4px;
  --wb-space-2: 8px;
  --wb-space-3: 12px;
  --wb-space-4: 16px;
  --wb-space-5: 20px;
  --wb-space-6: 24px;
  --wb-space-8: 32px;
  --wb-space-10: 40px;
  --wb-space-12: 48px;

  /* Elevation */
  --wb-shadow-sm: 0 2px 10px rgba(32, 24, 43, 0.06);
  --wb-shadow-md: 0 12px 34px rgba(32, 24, 43, 0.10);
  --wb-shadow-lg: 0 24px 70px rgba(32, 24, 43, 0.16);
  --wb-focus-ring: 0 0 0 3px rgba(111, 74, 246, 0.24);

  /* Motion */
  --wb-duration-fast: 120ms;
  --wb-duration-normal: 180ms;
  --wb-duration-slow: 260ms;
  --wb-ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --wb-ease-emphasized: cubic-bezier(0.2, 0, 0, 1.2);

  /* Safe-area values */
  --wb-safe-top: env(safe-area-inset-top, 0px);
  --wb-safe-right: env(safe-area-inset-right, 0px);
  --wb-safe-bottom: env(safe-area-inset-bottom, 0px);
  --wb-safe-left: env(safe-area-inset-left, 0px);

  /* Canonical stacking scale. Native top-layer elements remain outside this scale. */
  --wb-z-base: 0;
  --wb-z-raised: 10;
  --wb-z-sticky: 100;
  --wb-z-dropdown: 200;
  --wb-z-popover: 300;
  --wb-z-overlay: 400;
  --wb-z-modal: 500;
  --wb-z-toast: 600;
}

/* New shared utilities use the wb-* namespace and are opt-in during P1. */
:where(.wb-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;
}

:where(.wb-focus-ring):focus-visible {
  outline: 2px solid var(--wb-color-focus);
  outline-offset: 3px;
  box-shadow: var(--wb-focus-ring);
}

@media (prefers-reduced-motion: reduce) {
  :where(.wb-motion-safe) {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Shared attention pulse for compact status indicators. The component that owns
   placement, size and colour stays responsible for those values; this utility
   only supplies the reusable ping motion. */
:where(.wb-status-ping) {
  isolation: isolate;
}

:where(.wb-status-ping)::after {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  animation: wb-status-ping 1.8s var(--wb-ease-standard) infinite;
}

@keyframes wb-status-ping {
  0% { transform: scale(.82); opacity: .48; }
  62%, 100% { transform: scale(1.85); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  :where(.wb-status-ping)::after {
    animation: none;
    opacity: 0;
  }
}

/* Shared search trigger and command-palette primitives. These are product-wide
   components and intentionally live in the global foundation rather than a
   feature stylesheet. */
:where(.wb-search-trigger) {
  display: inline-flex;
  flex: 1 1 260px;
  align-items: center;
  gap: var(--wb-space-3);
  min-width: 180px;
  max-width: 390px;
  min-height: 44px;
  padding: 0 var(--wb-space-3);
  border: 1px solid var(--wb-color-border);
  border-radius: var(--wb-radius-md);
  background: var(--wb-color-surface-subtle);
  color: var(--wb-color-text-muted);
  font: 600 13px/1 var(--wb-font-sans);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--wb-duration-fast) var(--wb-ease-standard), background var(--wb-duration-fast) var(--wb-ease-standard), box-shadow var(--wb-duration-fast) var(--wb-ease-standard);
}

:where(.wb-search-trigger:hover) {
  border-color: var(--wb-color-border-strong);
  background: var(--wb-color-surface);
  box-shadow: var(--wb-shadow-sm);
}

:where(.wb-search-trigger > svg) {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  color: var(--wb-color-text-muted);
}

:where(.wb-search-trigger > span) {
  flex: 1 1 auto;
  color: var(--wb-color-text);
}

:where(.wb-keycap) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 7px;
  border: 1px solid var(--wb-color-border);
  border-radius: var(--wb-radius-xs);
  background: var(--wb-color-surface);
  color: var(--wb-color-text-muted);
  box-shadow: 0 1px 2px rgba(32, 24, 43, 0.04);
  font: 600 10px/1 var(--wb-font-sans);
  letter-spacing: .01em;
}

:where(.wb-search-trigger--mobile) {
  display: none;
}

.modal.wb-palette {
  z-index: var(--wb-z-modal);
  place-items: start center;
  padding: max(48px, 11dvh) 16px 24px;
}


.modal__panel.wb-palette__panel {
  display: flex;
  flex-direction: column;
  width: min(680px, calc(100vw - 32px));
  max-width: 680px;
  height: auto;
  max-height: min(720px, calc(100dvh - 96px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--wb-color-border);
  border-radius: var(--wb-radius-lg);
  background: var(--wb-color-surface);
  box-shadow: var(--wb-shadow-lg);
  color: var(--wb-color-text);
  animation: wb-palette-enter var(--wb-duration-normal) var(--wb-ease-standard) both;
}

@keyframes wb-palette-enter {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

:where(.wb-palette__searchbar) {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 40px;
  align-items: center;
  gap: var(--wb-space-3);
  min-height: 64px;
  padding: 6px var(--wb-space-3) 6px var(--wb-space-5);
  border-bottom: 1px solid var(--wb-color-border);
  background: var(--wb-color-surface);
}

/* The input uses a borderless shared palette style. Restore a visible focus
   indication on its control group without reintroducing an input border. */
:where(.wb-palette__searchbar:focus-within) {
  box-shadow: inset 0 -2px 0 var(--wb-color-focus);
}

:where(.wb-palette__search-icon) {
  width: 23px;
  height: 23px;
  color: var(--wb-color-text-muted);
}

.wb-palette__searchbar input,
.wb-palette__searchbar input:focus,
.wb-palette__searchbar input:focus-visible,
#adminGlobalSearchInput,
#adminGlobalSearchInput:focus,
#adminGlobalSearchInput:focus-visible {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  margin: 0;
  padding: 0;
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  color: var(--wb-color-text);
  box-shadow: none !important;
  font: 500 16px/1.35 var(--wb-font-sans);
}

:where(.wb-palette__searchbar input::placeholder) {
  color: var(--wb-color-text-muted);
  opacity: 1;
}

:where(.wb-icon-button) {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--wb-radius-sm);
  background: transparent;
  color: var(--wb-color-text-muted);
  cursor: pointer;
  transition: background var(--wb-duration-fast) var(--wb-ease-standard), color var(--wb-duration-fast) var(--wb-ease-standard);
}

:where(.wb-icon-button:hover) {
  background: var(--wb-color-surface-subtle);
  color: var(--wb-color-text);
}

:where(.wb-icon-button svg) {
  width: 24px;
  height: 24px;
}

:where(.wb-palette__body) {
  flex: 1 1 auto;
  min-height: 210px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--wb-space-3) var(--wb-space-3) var(--wb-space-4);
  scroll-padding-block: 12px;
}

:where(.wb-palette__results) {
  display: grid;
  gap: var(--wb-space-2);
}

:where(.wb-result-group) {
  display: grid;
  gap: var(--wb-space-1);
}

:where(.wb-result-group + .wb-result-group) {
  margin-top: var(--wb-space-3);
  padding-top: var(--wb-space-3);
  border-top: 1px solid var(--wb-color-border);
}

:where(.wb-result-group__title) {
  margin: 0;
  padding: 6px var(--wb-space-2);
  color: var(--wb-color-text-muted);
  font: 700 11px/1.3 var(--wb-font-sans);
  letter-spacing: .035em;
  text-transform: uppercase;
}

:where(.wb-list-row) {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 20px;
  align-items: center;
  gap: var(--wb-space-3);
  width: 100%;
  min-height: 58px;
  padding: 9px var(--wb-space-3);
  border: 1px solid transparent;
  border-radius: var(--wb-radius-md);
  background: transparent;
  color: var(--wb-color-text);
  text-align: left;
  cursor: pointer;
  transition: background var(--wb-duration-fast) var(--wb-ease-standard), border-color var(--wb-duration-fast) var(--wb-ease-standard);
}

/* Question guidance uses the same palette row; only its explanatory copy wraps. */
:where(.wb-list-row--guided) {
  align-items: start;
  border-color: var(--wb-color-border);
  background: var(--wb-color-surface-subtle);
  padding-block: var(--wb-space-3);
}
:where(.wb-list-row--guided .wb-list-row__copy small) {
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
}
:where(.wb-list-row__copy .wb-list-row__help) {
  color: var(--wb-color-text);
  font-size: 12px;
  line-height: 1.5;
}

:where(.wb-list-row:hover),
:where(.wb-list-row.is-active) {
  border-color: var(--wb-color-border-strong);
  background: var(--wb-color-primary-soft);
}

:where(.wb-list-row:focus-visible) {
  outline: 2px solid var(--wb-color-focus);
  outline-offset: 1px;
}

:where(.wb-list-row__icon),
:where(.wb-list-row__arrow) {
  width: 22px;
  height: 22px;
  color: var(--wb-color-text-muted);
}

:where(.wb-list-row__arrow) {
  width: 19px;
  height: 19px;
  justify-self: end;
  opacity: .68;
  transition: transform var(--wb-duration-fast) var(--wb-ease-standard), opacity var(--wb-duration-fast) var(--wb-ease-standard);
}

:where(.wb-list-row:hover .wb-list-row__arrow),
:where(.wb-list-row.is-active .wb-list-row__arrow) {
  transform: translateX(2px);
  opacity: 1;
}

:where(.wb-list-row__copy) {
  display: grid;
  min-width: 0;
  gap: 3px;
}

:where(.wb-list-row__copy strong) {
  overflow: hidden;
  color: var(--wb-color-text);
  font: 650 13px/1.35 var(--wb-font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

:where(.wb-list-row__copy small) {
  overflow: hidden;
  color: var(--wb-color-text-muted);
  font: 450 11.5px/1.4 var(--wb-font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}

:where(.wb-palette__footer) {
  flex: 0 0 auto;
  padding: 10px var(--wb-space-5);
  border-top: 1px solid var(--wb-color-border);
  background: var(--wb-color-surface-subtle);
  color: var(--wb-color-text-muted);
  font: 500 10.5px/1.3 var(--wb-font-sans);
  text-align: center;
}

:where(.wb-empty-state) {
  display: grid;
  justify-items: center;
  gap: var(--wb-space-2);
  padding: 44px 22px;
  color: var(--wb-color-text-muted);
  text-align: center;
}

:where(.wb-empty-state > svg) {
  width: 32px;
  height: 32px;
  margin-bottom: var(--wb-space-1);
  opacity: .62;
}

:where(.wb-empty-state strong) {
  color: var(--wb-color-text);
  font: 650 14px/1.4 var(--wb-font-sans);
}

:where(.wb-empty-state p) {
  max-width: 460px;
  margin: 0;
  font: 450 12px/1.55 var(--wb-font-sans);
}


/* Keep immediately actionable local results visible while server search is pending. */
:where(.wb-palette__status) {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--wb-space-2);
  padding: var(--wb-space-3) var(--wb-space-2);
  color: var(--wb-color-text-muted);
  font: 500 12px/1.5 var(--wb-font-sans);
}
:where(.wb-palette__status.is-error) {
  border-top: 1px solid var(--wb-color-border);
}
:where(.wb-palette__status .secondary-btn) {
  min-height: 36px;
}

:where(.wb-skeleton-list) {
  display: grid;
  gap: var(--wb-space-2);
  padding: var(--wb-space-1) 0;
}

:where(.wb-skeleton-row) {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: var(--wb-space-3);
  min-height: 58px;
  padding: 10px var(--wb-space-3);
  border-radius: var(--wb-radius-md);
  background: var(--wb-color-surface-subtle);
}

:where(.wb-skeleton-row__icon),
:where(.wb-skeleton-row__line) {
  display: block;
  border-radius: var(--wb-radius-xs);
  background: linear-gradient(100deg, var(--wb-color-border) 25%, var(--wb-color-surface-subtle) 38%, var(--wb-color-border) 55%);
  background-size: 220% 100%;
  animation: wb-skeleton-shimmer 1.4s ease-in-out infinite;
}

:where(.wb-skeleton-row__icon) { width: 22px; height: 22px; }
:where(.wb-skeleton-row__copy) { display: grid; gap: 8px; }
:where(.wb-skeleton-row__line) { width: min(56%, 270px); height: 10px; }
:where(.wb-skeleton-row__line:last-child) { width: min(76%, 360px); height: 8px; }

@keyframes wb-skeleton-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (max-width: 760px) {
  :where(.wb-search-trigger--mobile) { display: inline-grid; }

  .modal.wb-palette {
    place-items: stretch;
    padding: 0;
    /* Respect the visible viewport while the on-screen keyboard is open. */
    top: var(--wb-command-visible-top, 0px);
    bottom: auto;
    height: var(--wb-command-visible-height, 100dvh);
  }

  .modal__panel.wb-palette__panel {
    width: 100%;
    max-width: none;
    height: var(--wb-command-visible-height, 100dvh);
    max-height: var(--wb-command-visible-height, 100dvh);
    border: 0;
    border-radius: 0;
    padding-top: var(--wb-safe-top);
    padding-bottom: var(--wb-safe-bottom);
  }

  :where(.wb-palette__searchbar) {
    position: sticky;
    top: 0;
    z-index: var(--wb-z-raised);
    min-height: 64px;
    padding-right: max(var(--wb-space-3), var(--wb-safe-right));
    padding-left: max(var(--wb-space-4), var(--wb-safe-left));
  }

  :where(.wb-palette__body) {
    min-height: 0;
    padding-right: max(var(--wb-space-3), var(--wb-safe-right));
    padding-left: max(var(--wb-space-3), var(--wb-safe-left));
  }

  :where(.wb-list-row),
  :where(.wb-skeleton-row) {
    min-height: 56px;
  }

  :where(.wb-palette__footer) { display: none; }
  :where(.wb-keycap) { display: none; }
  :where(.wb-list-row__copy strong, .wb-list-row__copy small) {
    overflow-wrap: anywhere;
    white-space: normal;
    text-overflow: clip;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal__panel.wb-palette__panel,
  :where(.wb-skeleton-row__icon),
  :where(.wb-skeleton-row__line) {
    animation: none;
  }

  :where(.wb-list-row__arrow) { transition: none; }
}

:where(.wb-search-trigger--mobile) {
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--wb-radius-sm);
  background: transparent;
  color: var(--wb-color-text);
  cursor: pointer;
}

:where(.wb-search-trigger--mobile > svg) {
  width: 22px;
  height: 22px;
}

/* Command Center introduction: the existing search trigger, not a new navigation component. */
:where(.wb-search-trigger[data-wb-discovery="active"], .wb-search-trigger--mobile[data-wb-discovery="active"]) {
  background: var(--wb-color-primary-soft);
  color: var(--wb-color-text);
  box-shadow: var(--wb-focus-ring);
  outline-offset: 2px;
  animation: wb-command-discovery-notice 650ms var(--wb-ease-standard) both;
}
:where(.wb-search-trigger[data-wb-discovery="active"]:hover, .wb-search-trigger--mobile[data-wb-discovery="active"]:hover) {
  background: var(--wb-color-primary-soft);
  border-color: var(--wb-color-focus);
}
@keyframes wb-command-discovery-notice {
  from { box-shadow: 0 0 0 0 rgba(111,74,246,.04); }
  to { box-shadow: var(--wb-focus-ring); }
}
.wb-command-discovery__tip {
  position: fixed;
  z-index: var(--wb-z-popover);
  box-sizing: border-box;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  border: 1px solid var(--wb-color-border);
  border-radius: var(--wb-radius-lg);
  background: var(--wb-color-surface);
  color: var(--wb-color-text);
  box-shadow: var(--wb-shadow-md);
  padding: var(--wb-space-4);
  font: 400 13px/1.55 var(--wb-font-sans);
  opacity: 0;
  transform: translateY(5px);
  transition: opacity var(--wb-duration-normal) var(--wb-ease-standard), transform var(--wb-duration-normal) var(--wb-ease-standard);
}
.wb-command-discovery__tip.is-visible { opacity: 1; transform: translateY(0); }
.wb-command-discovery__heading { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--wb-space-3); }
.wb-command-discovery__heading strong { font-size: 14px; line-height: 1.45; font-weight: 750; }
.wb-command-discovery__close {
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -6px -6px 0 0;
  border: 0;
  border-radius: var(--wb-radius-sm);
  background: transparent;
  color: var(--wb-color-text-muted);
  cursor: pointer;
  font: 20px/1 var(--wb-font-sans);
}
.wb-command-discovery__close svg { width: 18px; height: 18px; }
.wb-command-discovery__close:hover { background: var(--wb-color-surface-subtle); }
.wb-command-discovery__tip p { margin: var(--wb-space-2) 0 var(--wb-space-4); color: var(--wb-color-text-muted); }
.wb-command-discovery__footer { display: flex; align-items: center; justify-content: space-between; gap: var(--wb-space-3); }
.wb-command-discovery__footer > span { font: 600 12px/1.4 var(--wb-font-sans); color: var(--wb-color-text-muted); }
.wb-command-discovery__footer .primary-btn { min-height: 44px; padding-inline: var(--wb-space-4); border: 1px solid var(--wb-color-primary); border-radius: var(--wb-radius-sm); background: var(--wb-color-primary); color: var(--wb-color-primary-contrast); font-weight: 650; cursor: pointer; }
.wb-command-discovery__footer .primary-btn:hover { background: var(--wb-color-primary-hover); }
@media (prefers-reduced-motion: reduce) {
  :where(.wb-search-trigger[data-wb-discovery="active"], .wb-search-trigger--mobile[data-wb-discovery="active"]) { animation: none; }
  .wb-command-discovery__tip { transition: none; transform: none; }
}

/* Command Center onboarding: concise helper inside existing empty results. */
:where(.wb-palette-guide) { padding: var(--wb-space-4); border-bottom: 1px solid var(--wb-color-border); }
:where(.wb-palette-guide > strong) { display: block; font: 750 14px/1.45 var(--wb-font-sans); color: var(--wb-color-text); }
:where(.wb-palette-guide > p) { margin: var(--wb-space-2) 0 var(--wb-space-3); color: var(--wb-color-text-muted); font: 400 13px/1.55 var(--wb-font-sans); }
:where(.wb-palette-guide__examples) { display: flex; flex-wrap: wrap; gap: var(--wb-space-2); }
:where(.wb-palette-guide__example) { border: 1px solid var(--wb-color-border); border-radius: var(--wb-radius-sm); background: var(--wb-color-surface); color: var(--wb-color-text); padding: var(--wb-space-2) var(--wb-space-3); min-height: 44px; display: inline-flex; align-items: center; font: 600 12px/1.45 var(--wb-font-sans); cursor: pointer; text-align: left; }
:where(.wb-palette-guide__example:hover, .wb-palette-guide__example:focus-visible) { border-color: var(--wb-color-primary); color: var(--wb-color-primary); }

/* Command Center P4: maintain visible focus for the discovery close control. */
.wb-command-discovery__close:focus-visible {
  outline: 2px solid var(--wb-color-focus);
  outline-offset: 2px;
}
