/* Adaptive Math layout audit corrections
 * Version 1.0.0
 * Grid, inset, alignment, overflow, and responsive hardening
 */

/* Learning path: independent cards with true internal grid */
.ame-learning-path .ame-path-list {
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 16px !important;
  align-items: stretch !important;
}

.ame-learning-path .ame-path-item {
  box-sizing: border-box !important;
  display: grid !important;
  grid-template-columns: 44px minmax(0, 1fr) !important;
  align-items: start !important;
  gap: 18px !important;
  min-width: 0 !important;
  min-height: 170px !important;
  margin: 0 !important;
  padding: 24px !important;
  border: 1px solid var(--ame-line) !important;
  border-radius: var(--ame-radius-md) !important;
  background: var(--ame-surface) !important;
  overflow: hidden !important;
  opacity: 1;
}

.ame-learning-path .ame-path-item:last-child {
  border: 1px solid var(--ame-line) !important;
}

.ame-learning-path .ame-path-number {
  position: static !important;
  inset: auto !important;
  align-self: start !important;
  justify-self: start !important;
  box-sizing: border-box !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  margin: 0 !important;
  display: grid !important;
  place-items: center !important;
  border: 1px solid var(--ame-tint-line) !important;
  border-radius: 50% !important;
  background: var(--ame-tint) !important;
  color: var(--ame-accent) !important;
  font-size: 15px !important;
  line-height: 1 !important;
  font-weight: 800 !important;
}

.ame-learning-path .ame-path-item > div:last-child {
  min-width: 0 !important;
  align-self: start !important;
}

.ame-learning-path .ame-path-item h3 {
  margin: 0 0 8px !important;
  color: var(--ame-ink) !important;
  font-size: clamp(20px, 1.7vw, 25px) !important;
  line-height: 1.18 !important;
  overflow-wrap: anywhere;
}

.ame-learning-path .ame-path-item p {
  margin: 0 !important;
  color: var(--ame-muted) !important;
  font-size: 14px !important;
  line-height: 1.55 !important;
}

.ame-learning-path .ame-inline-actions {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  flex-wrap: wrap !important;
  margin-top: 14px !important;
}

.ame-learning-path .ame-path-item.is-mastered {
  border-color: #A9D9C9 !important;
  background: #F5FBF8 !important;
}

.ame-learning-path .ame-path-item.is-mastered .ame-path-number {
  background: var(--ame-signal) !important;
  border-color: var(--ame-signal) !important;
  color: #FFFFFF !important;
}

.ame-learning-path .ame-path-item.is-current,
.ame-learning-path .ame-path-item.is-ready {
  border-color: var(--ame-tint-line) !important;
}

.ame-learning-path .ame-path-item.is-locked {
  opacity: .68 !important;
}

/* Shared inset discipline: prevent controls and labels touching card edges */
.ame-card,
.ame-feature-card,
.ame-stat-card,
.ame-question-card,
.ame-document-card,
.ame-report-card,
.ame-result-grid > article,
.ame-panel,
.ame-auth-card,
.ame-tool-grid > a,
.ame-summary-grid > div,
.ame-course-intro,
.ame-lesson-support {
  box-sizing: border-box !important;
  min-width: 0 !important;
}

.ame-card > :first-child,
.ame-feature-card > :first-child,
.ame-stat-card > :first-child,
.ame-question-card > :first-child,
.ame-document-card > :first-child,
.ame-report-card > :first-child,
.ame-result-grid > article > :first-child {
  margin-top: 0 !important;
}

.ame-card > :last-child,
.ame-feature-card > :last-child,
.ame-stat-card > :last-child,
.ame-question-card > :last-child,
.ame-document-card > :last-child,
.ame-report-card > :last-child,
.ame-result-grid > article > :last-child {
  margin-bottom: 0 !important;
}

/* Keep badges and labels inside their own content flow */
.ame-kicker,
.ame-card-label,
.ame-status-pill,
.ame-question-count,
.ame-sheet-code,
.ame-streak {
  position: static !important;
  inset: auto !important;
  max-width: 100% !important;
}

/* Consistent internal alignment for split headers and metadata */
.ame-practice-head,
.ame-dashboard-head,
.ame-doc-hero,
.ame-result-hero,
.ame-question-meta,
.ame-cert-meta {
  box-sizing: border-box !important;
  min-width: 0 !important;
}

.ame-practice-head > *,
.ame-dashboard-head > *,
.ame-doc-hero > *,
.ame-result-hero > *,
.ame-question-meta > *,
.ame-cert-meta > * {
  min-width: 0 !important;
}

/* Prevent buttons and action rows from clipping card boundaries */
.ame-wizard-actions,
.ame-inline-actions,
.ame-practice-actions,
.ame-print-actions {
  box-sizing: border-box !important;
  max-width: 100% !important;
  flex-wrap: wrap !important;
}

.ame-btn {
  max-width: 100% !important;
  white-space: normal !important;
  text-align: center !important;
}

/* Tablet */
@media (max-width: 1024px) {
  .ame-learning-path .ame-path-list {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Mobile */
@media (max-width: 680px) {
  .ame-learning-path {
    padding: 20px !important;
  }

  .ame-learning-path .ame-path-list {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .ame-learning-path .ame-path-item {
    grid-template-columns: 40px minmax(0, 1fr) !important;
    gap: 14px !important;
    min-height: 0 !important;
    padding: 20px !important;
  }

  .ame-learning-path .ame-path-number {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
  }

  .ame-learning-path .ame-path-item h3 {
    font-size: 20px !important;
  }
}
