/* Learning-platform UI primitives (sim / practice / hubs). Load only on those routes + /_components/. Tokens from site theme. */

.wh-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.wh-demo-section {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}

.wh-demo-section h2 {
  margin: 0 0 0.75rem;
  font-size: var(--fs-h3);
}

.wh-demo-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .wh-demo-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* —— Segmented (radiogroup) —— */
.wh-segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md, 18px);
}

.wh-segmented [role="radio"] {
  appearance: none;
  margin: 0;
  min-height: 44px;
  min-width: 44px;
  padding: 0.45rem 0.9rem;
  border: 0;
  border-radius: var(--r-sm, 12px);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.wh-segmented [role="radio"][aria-checked="true"] {
  background: var(--bg-1);
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

/* —— Tabs (wh-tabs mirrors calc-tabs ink underline) —— */
.wh-tabs [role="tablist"] {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.35rem;
  margin-bottom: 0.75rem;
}

.wh-tabs [role="tab"] {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  border-radius: 0.55rem;
  padding: 0.45rem 0.8rem 0.55rem;
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  cursor: pointer;
}

.wh-tabs [role="tab"]::after {
  content: "";
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 0.35rem;
  height: 1.5px;
  border-radius: 1px;
  background: var(--accent);
  transform: scaleX(0) rotate(-1.4deg);
  transform-origin: left center;
  transition: transform 200ms var(--ease-out);
}

.wh-tabs [role="tab"][aria-selected="true"],
.wh-tabs [role="tab"].is-active {
  color: var(--text);
}

.wh-tabs [role="tab"][aria-selected="true"]::after,
.wh-tabs [role="tab"].is-active::after {
  transform: scaleX(1) rotate(-1.4deg);
}

.wh-tabs [role="tabpanel"] {
  padding: 0.25rem 0;
}

/* —— Filter chips —— */
.wh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wh-chip {
  min-height: 44px;
  padding: 0.4rem 0.95rem;
  border-radius: var(--r-pill, 999px);
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.wh-chip[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-1));
}

/* —— Search shell —— */
.wh-search {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 28rem;
}

.wh-search-row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md, 18px);
  padding: 0.25rem 0.35rem 0.25rem 0.75rem;
}

.wh-search input {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
}

.wh-search-clear {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: var(--r-sm, 12px);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}

.wh-search-clear[hidden] {
  display: none;
}

/* —— Feedback (never colour-only) —— */
.wh-feedback {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border-radius: var(--r-md, 18px);
  border: 1px solid var(--line-2);
  background: var(--bg-1);
}

.wh-feedback__icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.1rem;
}

.wh-feedback__body {
  min-width: 0;
}

.wh-feedback__label {
  margin: 0;
  font-weight: 700;
}

.wh-feedback__text {
  margin: 0.25rem 0 0;
  color: var(--text-dim);
}

.wh-feedback[data-state="correct"] {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line-2));
  background: color-mix(in srgb, var(--ok) 12%, var(--bg-1));
}

.wh-feedback[data-state="incorrect"] {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-1));
}

.wh-feedback[data-state="hint"] {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line-2));
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-1));
}

.wh-feedback[data-state="correct"] .wh-feedback__icon {
  color: var(--ok);
}

.wh-feedback[data-state="incorrect"] .wh-feedback__icon,
.wh-feedback[data-state="hint"] .wh-feedback__icon {
  color: var(--accent);
}

.wh-feedback[data-state="hint"] .wh-feedback__icon {
  color: var(--warn);
}

.wh-feedback[data-state="neutral"] .wh-feedback__icon {
  color: var(--text-dim);
}

/* —— Progress —— */
.wh-progress {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-height: 44px;
}

.wh-progress__label {
  color: var(--text-mute);
  font-weight: 500;
  font-size: var(--fs-small);
}

/* —— Empty / loading / error —— */
.wh-state {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-start;
  padding: 1.1rem 1.15rem;
  border-radius: var(--r-md, 18px);
  border: 1px dashed var(--line-2);
  background: var(--bg-1);
  color: var(--text-dim);
}

.wh-state[data-state="error"] {
  border-style: solid;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line-2));
}

.wh-state__title {
  margin: 0;
  font-weight: 700;
  color: var(--text);
}

.wh-state__text {
  margin: 0;
}

.wh-state__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.45;
}

@media (prefers-reduced-motion: no-preference) {
  .wh-state[data-state="loading"] .wh-state__dot {
    animation: wh-pulse 1.2s var(--ease-in-out) infinite;
  }
}

@keyframes wh-pulse {
  50% {
    opacity: 1;
  }
}

/* —— Breadcrumb (wh- prefix; mirrors site crumbs) —— */
.wh-breadcrumb {
  font-size: var(--fs-small);
  color: var(--text-dim);
}

.wh-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 0;
}

.wh-breadcrumb li {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.wh-breadcrumb li:not(:last-child)::after {
  content: "/";
  margin: 0 0.55rem;
  color: var(--text-mute);
}

.wh-breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-dim);
  text-decoration: none;
}

.wh-breadcrumb a:hover {
  color: var(--text);
  text-decoration: underline;
}

.wh-breadcrumb [aria-current="page"] {
  color: var(--text-dim);
}

/* —— Topic card —— */
.wh-topic-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.15rem 1.2rem;
  background: var(--bg-1);
  border: 1px solid var(--line-2);
  border-radius: 24px;
  text-decoration: none;
  color: inherit;
  min-height: 7.5rem;
}

.wh-topic-card h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.wh-topic-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: var(--fs-small);
}

.wh-type {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 0.15rem 0.5rem;
  border-radius: var(--r-pill, 999px);
  font-size: 0.78rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-1));
  color: var(--accent);
}

@media (hover: hover) {
  .wh-topic-card:hover,
  .wh-topic-card:focus-visible {
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-1));
  }
}

/* —— Next steps —— */
.wh-next-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wh-next-steps__title {
  margin: 0;
  font-weight: 700;
}

.wh-next-steps__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.wh-next-steps__list a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.95rem;
  border-radius: var(--r-pill, 999px);
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.wh-next-steps__list a:hover,
.wh-next-steps__list a:focus-visible {
  border-color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .wh-tabs [role="tab"]::after,
  .wh-segmented [role="radio"],
  .wh-chip,
  .wh-next-steps__list a {
    transition: none;
  }

  .wh-state[data-state="loading"] .wh-state__dot {
    animation: none;
    opacity: 1;
  }
}
