/* ============================================================
   Base Styles — shared components used across all pages
   ============================================================
   Depends on: tokens.css (loaded first)
   ============================================================ */

/* ── Brand mark ── */

/* Audri swirl logomark, rendered inline via the `audri_mark` Jinja macro
   (components/ui.html). stroke="currentColor" + this token make it adapt to
   light/dark; size it by setting font-size on the element (svg is 1em square). */
.audri-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  line-height: 0;
}

.audri-mark svg {
  width: 1em;
  height: 1em;
  display: block;
}

/* ── Typography & Body ── */

body {
  font-family: var(--font-sans);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

/* Headings take the display face + tight tracking from the design uplift.
   Only family / weight / tracking are set here so per-component sizes
   (.card-title, .mode-option-title, etc.) keep their own scale. */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-snug);
}

/* Keyboard focus ring — primary outline across all interactive elements. */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Layout ── */

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px;
}

.container-narrow {
  max-width: 480px;
}

/* ── Cards ── */

.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px;
  margin-bottom: 20px;
  border: 1px solid var(--border-color-light);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card-header {
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.card-subtitle {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-color);
}

.btn-success {
  background: var(--color-success);
  color: var(--text-on-primary);
}

.btn-success:hover:not(:disabled) {
  background: var(--color-success);
  opacity: 0.9;
}

.btn-full {
  width: 100%;
}

.btn-lg {
  padding: 16px 32px;
  font-size: 1.0625rem;
}

/* ── Alerts ── */

.alert {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  font-size: 0.9375rem;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.alert-warning {
  background: var(--color-warning-bg);
  color: var(--text-primary);
  border: 1px solid var(--color-warning);
}

.alert-error {
  background: var(--color-error-bg);
  color: var(--text-primary);
  border: 1px solid var(--color-error);
}

.alert-info {
  background: var(--color-info-bg);
  color: var(--text-primary);
  border: 1px solid var(--color-info);
}

.alert-success {
  background: var(--color-success-bg);
  color: var(--text-primary);
  border: 1px solid var(--color-success);
}

/* ── Checkbox groups ── */

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.checkbox-group:hover {
  background: var(--bg-tertiary);
}

.checkbox-group:has(input:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.checkbox-group input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}

.checkbox-label {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Utility classes ── */

/* Text */
.text-muted {
  color: var(--text-secondary);
}

.text-tertiary {
  color: var(--text-tertiary);
}

.text-error {
  color: var(--color-error);
  font-weight: 600;
}

.text-primary-emphasis {
  color: var(--color-primary-dark);
}

.text-success {
  color: var(--color-success);
  font-weight: 600;
}

.text-small {
  font-size: 0.875rem;
}

.text-center {
  text-align: center;
}

.font-semibold {
  font-weight: 600;
}

/* Spacing */
.mt-0 {
  margin-top: 0;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.mt-6 {
  margin-top: 24px;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-3 {
  margin-bottom: 12px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-5 {
  margin-bottom: 20px;
}

.mb-6 {
  margin-bottom: 24px;
}

.ml-1 {
  margin-left: 4px;
}

.ml-2 {
  margin-left: 8px;
}

.mr-1 {
  margin-right: 4px;
}

.m-0 {
  margin: 0;
}

/* Display & layout */
.hidden {
  display: none;
}

.inline {
  display: inline;
}

.inline-block {
  display: inline-block;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-col-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

/* Sizing */
.p-0 {
  padding: 0;
}

.p-4 {
  padding: 20px;
}

.max-w-narrow {
  max-width: 220px;
}

.max-w-medium {
  max-width: 300px;
}

.full-col-span {
  grid-column: 1 / -1;
}

/* Dividers */
.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 24px 0;
}

/* Icon styling helpers */
.icon-success {
  color: var(--color-success);
  background: var(--color-success-bg);
}

.icon-info {
  color: var(--color-info);
  background: var(--color-info-bg);
}

/* ── Loading / HTMX indicators ── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-on-primary);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

/* ── Responsive (shared) ── */

@media (max-width: 480px) {
  .container {
    padding: 16px;
  }

  .card {
    padding: 20px;
  }
}

/* ── Additional utility classes (Phase 4, Step B2) ── */

.text-caption {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.text-detail {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.icon-inline {
  vertical-align: middle;
  margin-right: 6px;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-wrap-gap {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.code-inline {
  font-size: 0.8rem;
}

.cursor-pointer {
  cursor: pointer;
}

.spinner-sm {
  width: 16px;
  height: 16px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
  margin: 0 auto 16px;
}
