/* Axiora base components 1.0.0. Load axiora.tokens.css first.
 * CSS examples only. This file does not implement keyboard behavior, state
 * management, exercise validation, playback, audio, or graph animation.
 */
:where(.ax-ui),
:where(.ax-ui) *,
:where(.ax-ui) *::before,
:where(.ax-ui) *::after { box-sizing: border-box; }

.ax-ui {
  margin: 0;
  color: var(--ax-text);
  background: var(--ax-bg);
  font-family: var(--ax-font-body);
  font-size: var(--ax-font-size-body);
  font-weight: var(--ax-font-weight-regular);
  line-height: var(--ax-line-height-body);
}
.ax-container {
  inline-size: min(100%, var(--ax-layout-max));
  margin-inline: auto;
  padding-inline: var(--ax-layout-padding);
}
.ax-grid {
  display: grid;
  grid-template-columns: repeat(var(--ax-layout-columns), minmax(0, 1fr));
  gap: var(--ax-layout-gutter);
}
.ax-grid > * { min-inline-size: 0; }
.ax-span-full { grid-column: 1 / -1; }
.ax-stack { display: flex; flex-direction: column; gap: var(--ax-space-16); }
.ax-inline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ax-space-12); }
.ax-display, .ax-h1, .ax-h2, .ax-h3, .ax-h4 {
  margin: 0;
  color: var(--ax-text);
  font-family: var(--ax-font-body);
  font-weight: var(--ax-font-weight-bold);
  overflow-wrap: break-word;
}
.ax-display { font-size: var(--ax-font-size-display-mobile); line-height: var(--ax-line-height-display-mobile); }
.ax-h1 { font-size: var(--ax-font-size-h1-mobile); line-height: var(--ax-line-height-h1-mobile); }
.ax-h2 { font-size: var(--ax-font-size-h2-mobile); line-height: var(--ax-line-height-h2-mobile); }
.ax-h3 { font-size: var(--ax-font-size-h3); line-height: var(--ax-line-height-h3); font-weight: var(--ax-font-weight-semibold); }
.ax-h4 { font-size: var(--ax-font-size-h4); line-height: var(--ax-line-height-h4); font-weight: var(--ax-font-weight-semibold); }
.ax-body-lg { font-size: var(--ax-font-size-body-lg); line-height: var(--ax-line-height-body-lg); }
.ax-body-sm { font-size: var(--ax-font-size-body-sm); line-height: var(--ax-line-height-body-sm); }
.ax-caption { font-size: var(--ax-font-size-caption); line-height: var(--ax-line-height-caption); }
.ax-muted { color: var(--ax-text-muted); }
.ax-math { font-family: var(--ax-font-math); font-size: var(--ax-font-size-math); line-height: var(--ax-line-height-math); }
.ax-code { font-family: var(--ax-font-code); }
.ax-link { color: var(--ax-link); text-decoration: underline; text-underline-offset: var(--ax-space-4); }
.ax-link:hover { color: var(--ax-link-hover); }

/* Focus ring: 2 px + 3 px offset. Dark theme switches the ring to white.
 * Reserve room around the target; do not clip it with overflow:hidden.
 */
.ax-ui :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--ax-focus-ring-width) solid var(--ax-focus-ring-color);
  outline-offset: var(--ax-focus-ring-offset);
}

.ax-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ax-space-8);
  min-block-size: var(--ax-button-height);
  min-inline-size: var(--ax-button-height);
  padding: var(--ax-space-8) var(--ax-space-20);
  border: var(--ax-stroke-thin) solid transparent;
  border-radius: var(--ax-button-radius);
  font: inherit;
  font-size: var(--ax-font-size-body-sm);
  font-weight: var(--ax-font-weight-semibold);
  line-height: var(--ax-line-height-body-sm);
  color: var(--ax-button-primary-fg);
  background: var(--ax-button-primary-bg);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--ax-motion-feedback) var(--ax-motion-easing),
              border-color var(--ax-motion-feedback) var(--ax-motion-easing),
              color var(--ax-motion-feedback) var(--ax-motion-easing);
}
.ax-button:not(:disabled):not([aria-disabled="true"]):hover { background: var(--ax-button-primary-bg-hover); }
.ax-button:not(:disabled):not([aria-disabled="true"]):active,
.ax-button[aria-pressed="true"] { background: var(--ax-button-primary-bg-pressed); }
.ax-button--accent { color: var(--ax-button-accent-fg); background: var(--ax-button-accent-bg); }
.ax-button--accent:not(:disabled):not([aria-disabled="true"]):hover { background: var(--ax-button-accent-bg-hover); }
.ax-button--accent:not(:disabled):not([aria-disabled="true"]):active,
.ax-button--accent[aria-pressed="true"] { background: var(--ax-button-accent-bg-pressed); }
.ax-button--secondary {
  color: var(--ax-button-secondary-fg);
  background: var(--ax-button-secondary-bg);
  border-color: var(--ax-button-secondary-border);
}
.ax-button--secondary:not(:disabled):not([aria-disabled="true"]):hover,
.ax-button--secondary:not(:disabled):not([aria-disabled="true"]):active,
.ax-button--secondary[aria-pressed="true"] {
  color: var(--ax-button-secondary-fg);
  background: var(--ax-button-secondary-bg-hover);
  border-color: var(--ax-action-primary);
}
.ax-button:disabled, .ax-button[aria-disabled="true"] {
  color: var(--ax-button-disabled-fg);
  background: var(--ax-button-disabled-bg);
  border-color: var(--ax-border-subtle);
  cursor: not-allowed;
}
.ax-button[aria-busy="true"] { cursor: progress; }
.ax-button--icon { inline-size: var(--ax-button-height); padding: var(--ax-space-8); }
.ax-icon { inline-size: var(--ax-space-20); block-size: var(--ax-space-20); flex: 0 0 auto; }

.ax-field { display: grid; gap: var(--ax-space-8); }
.ax-label { font-size: var(--ax-font-size-body-sm); line-height: var(--ax-line-height-body-sm); font-weight: var(--ax-font-weight-semibold); }
.ax-input {
  display: block;
  inline-size: 100%;
  min-block-size: var(--ax-input-height);
  padding: var(--ax-space-8) var(--ax-space-12);
  color: var(--ax-input-fg);
  background: var(--ax-input-bg);
  border: var(--ax-stroke-thin) solid var(--ax-input-border);
  border-radius: var(--ax-input-radius);
  font: inherit;
  font-size: var(--ax-font-size-body);
  line-height: var(--ax-line-height-body);
  transition: border-color var(--ax-motion-feedback) var(--ax-motion-easing);
}
.ax-input::placeholder { color: var(--ax-input-placeholder); opacity: 1; }
.ax-input:not(:disabled):not([aria-invalid="true"]):hover { border-color: var(--ax-input-border-hover); }
.ax-input[aria-invalid="true"] { border-color: var(--ax-input-border-invalid); }
.ax-input:disabled { color: var(--ax-disabled-text); background: var(--ax-disabled-bg); cursor: not-allowed; }
textarea.ax-input { min-block-size: calc(var(--ax-input-height) * 3); resize: vertical; }
.ax-help, .ax-error { margin: 0; font-size: var(--ax-font-size-body-sm); line-height: var(--ax-line-height-body-sm); }
.ax-help { color: var(--ax-text-muted); }
.ax-error { color: var(--ax-status-error); }

.ax-card {
  padding: var(--ax-space-24);
  color: var(--ax-card-fg);
  background: var(--ax-card-bg);
  border: var(--ax-stroke-thin) solid var(--ax-card-border);
  border-radius: var(--ax-card-radius);
  box-shadow: var(--ax-card-shadow);
}
/* A decorative card border may be subtle. Interactive cards need a real
 * link/button and the stronger border, plus a focus indicator.
 */
.ax-card--interactive { border-color: var(--ax-border); }
.ax-card__heading { margin: 0 0 var(--ax-space-8); font-size: var(--ax-font-size-h4); line-height: var(--ax-line-height-h4); font-weight: var(--ax-font-weight-semibold); }
.ax-card__body { margin: 0; }
.ax-dialog {
  max-inline-size: min(100%, var(--ax-dialog-max));
  padding: var(--ax-space-32);
  color: var(--ax-text);
  background: var(--ax-surface-raised);
  border: var(--ax-stroke-thin) solid var(--ax-border);
  border-radius: var(--ax-layout-radius-dialog);
  box-shadow: var(--ax-elevation-dialog);
}

.ax-tabs {
  display: flex;
  gap: var(--ax-space-4);
  overflow-x: auto;
  padding: var(--ax-space-8);
  border-block-end: var(--ax-stroke-thin) solid var(--ax-border-subtle);
}
.ax-tab {
  position: relative;
  flex: 0 0 auto;
  min-block-size: var(--ax-tab-height);
  padding: var(--ax-space-8) var(--ax-space-16);
  border: var(--ax-stroke-thin) solid transparent;
  border-block-end: var(--ax-stroke-selected) solid transparent;
  border-radius: var(--ax-radius-control) var(--ax-radius-control) 0 0;
  color: var(--ax-tab-fg);
  background: var(--ax-tab-bg);
  font: inherit;
  font-weight: var(--ax-font-weight-semibold);
  cursor: pointer;
  transition: background-color var(--ax-motion-feedback) var(--ax-motion-easing);
}
.ax-tab:hover { background: var(--ax-surface-soft); }
.ax-tab[aria-selected="true"] {
  color: var(--ax-tab-selected-fg);
  background: var(--ax-tab-selected-bg);
  border-block-end-color: var(--ax-tab-indicator);
}
.ax-tab:disabled, .ax-tab[aria-disabled="true"] { color: var(--ax-disabled-text); background: var(--ax-disabled-bg); cursor: not-allowed; }
.ax-panel { padding-block: var(--ax-space-24); }
.ax-panel[hidden] { display: none; }

.ax-range {
  display: block;
  inline-size: 100%;
  min-inline-size: var(--ax-space-80);
  block-size: var(--ax-range-height);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--ax-radius-control);
  background: transparent;
  accent-color: var(--ax-range-thumb-color);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
.ax-range::-webkit-slider-runnable-track {
  block-size: var(--ax-range-track-size);
  border-radius: var(--ax-radius-pill);
  background: var(--ax-range-track-color);
}
.ax-range::-webkit-slider-thumb {
  inline-size: var(--ax-range-thumb-size);
  block-size: var(--ax-range-thumb-size);
  margin-block-start: calc((var(--ax-range-track-size) - var(--ax-range-thumb-size)) / 2);
  border: var(--ax-stroke-focus) solid var(--ax-range-thumb-border);
  border-radius: var(--ax-radius-pill);
  background: var(--ax-range-thumb-color);
  box-shadow: 0 0 0 var(--ax-stroke-thin) var(--ax-range-thumb-outline);
  appearance: none;
  -webkit-appearance: none;
}
.ax-range::-moz-range-track {
  block-size: var(--ax-range-track-size);
  border: 0;
  border-radius: var(--ax-radius-pill);
  background: var(--ax-range-track-color);
}
.ax-range::-moz-range-thumb {
  inline-size: var(--ax-range-thumb-size);
  block-size: var(--ax-range-thumb-size);
  border: var(--ax-stroke-focus) solid var(--ax-range-thumb-border);
  border-radius: var(--ax-radius-pill);
  background: var(--ax-range-thumb-color);
  box-shadow: 0 0 0 var(--ax-stroke-thin) var(--ax-range-thumb-outline);
}
.ax-range:disabled { cursor: not-allowed; }
.ax-range:disabled::-webkit-slider-thumb { background: var(--ax-disabled-text); }
.ax-range:disabled::-moz-range-thumb { background: var(--ax-disabled-text); }
.ax-range-value { color: var(--ax-text); font-weight: var(--ax-font-weight-semibold); font-variant-numeric: tabular-nums; }

/* Status messages always include an icon and explicit language in markup. */
.ax-notice {
  display: flex;
  align-items: flex-start;
  gap: var(--ax-space-12);
  padding: var(--ax-space-16);
  border: var(--ax-stroke-thin) solid currentColor;
  border-radius: var(--ax-radius-control);
}
.ax-notice--success { color: var(--ax-notice-success-fg); background: var(--ax-notice-success-bg); }
.ax-notice--error { color: var(--ax-notice-error-fg); background: var(--ax-notice-error-bg); }
.ax-notice--warning { color: var(--ax-notice-warning-fg); background: var(--ax-notice-warning-bg); }
.ax-notice--info { color: var(--ax-notice-info-fg); background: var(--ax-notice-info-bg); }
.ax-notice p { margin: 0; }
.ax-notice__title { font-weight: var(--ax-font-weight-bold); }
.ax-lab-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ax-space-12); }

@media (min-width: 768px) {
  .ax-display { font-size: var(--ax-font-size-display); line-height: var(--ax-line-height-display); }
  .ax-h1 { font-size: var(--ax-font-size-h1); line-height: var(--ax-line-height-h1); }
  .ax-h2 { font-size: var(--ax-font-size-h2); line-height: var(--ax-line-height-h2); }
}
@media (prefers-reduced-motion: reduce) {
  .ax-ui { scroll-behavior: auto; }
  .ax-ui *, .ax-ui *::before, .ax-ui *::after {
    animation: none !important;
    transition-duration: 0ms !important;
    scroll-behavior: auto !important;
  }
}
/* High contrast: preserve system colors and explicit borders. */
@media (forced-colors: active) {
  .ax-button, .ax-input, .ax-tab, .ax-card--interactive { border-color: ButtonText; }
  .ax-tab[aria-selected="true"] { border-block-end-color: Highlight; }
  .ax-ui :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline-color: Highlight; }
  .ax-range { appearance: auto; -webkit-appearance: auto; }
}
