/* ============================================================
   Lesson Cards — WCAG 2.1 AA compliant layout
   ============================================================ */

/* Disable animations for users who prefer reduced motion (SC 2.3.3) */
@media (prefers-reduced-motion: reduce) {
  .lesson-card__inner,
  .lc-btn,
  .lesson-card__actions .lc-btn::before,
  .lesson-card__word-badge {
    transition: none !important;
    animation: none !important;
  }
}

/* ── Grid ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1rem 0;
}

@media (max-width: 767.98px) {
  .cards-grid { grid-template-columns: 1fr; }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1200px) {
  .cards-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1400px) {
  .cards-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Card shell ── */
.lesson-card {
  margin: 0;
  /* <article> resets */
}

.lesson-card__inner {
  background: var(--bg-primary);
  border: 1px solid #c8cdd2;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  padding: 1.25rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

/* Decorative top stripe */
.lesson-card__inner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--gradient-primary);
  border-radius: 12px 12px 0 0;
}

.lesson-card__inner:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* ── Card header ── */
.lesson-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px dashed #c8cdd2;
}

/* SC 1.3.1 – heading hierarchy: h3 inside article */
.lesson-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading); /* #1E262F — 16.4:1 on white ✓ */
  margin: 0;
  line-height: 1.3;
}

/* Badge: white on #3d6e0e ≈ 7.1:1 ✓ (SC 1.4.3) */
.lesson-card__badge {
  display: inline-flex;
  align-items: baseline;
  flex-shrink: 0;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #3d6e0e;
  padding: 0.2rem 0.55rem;
  border-radius: 10px;
  line-height: 1.4;
  white-space: nowrap;
}

.lesson-card__badge-count {
  font-variant-numeric: tabular-nums;
}

.lesson-card__badge-label {
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  opacity: 0.95;
}

/* ── Words as badges (no scroll; wrap) ── */
.lesson-card__words-wrapper {
  flex: 1;
  margin-bottom: 1rem;
  min-height: 0;
}

.lesson-card__words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.45rem;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  margin: 0;
}

/* SC 1.4.3 — heading color on neutral chip: >10:1 on #f0f2f5 (AA ✓) */
.lesson-card__word-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.42rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-heading, #1e262f);
  background: #f0f2f5;
  border: 1px solid #d2d8e0;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.lesson-card__word-badge:hover {
  color: var(--text-heading, #1e262f);
  background: #e4e8ee;
  border-color: #c2cad4;
}

/* ── Actions footer ── */
.lesson-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

/* ── Buttons / links (SC 2.5.5 – min 44 × 44 px touch target) ── */
.lc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  /* SC 2.4.7 / 2.4.11 – visible focus indicator */
  outline-offset: 2px;
}

.lc-btn:focus-visible {
  outline: 3px solid #005fcc;
  outline-offset: 2px;
}

.lc-btn--full { width: 100%; }

/* Card actions: same palette + behavior as .tab-btn (app.css) */
.lesson-card__actions .lc-btn {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  color: #fff !important;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.lesson-card__actions .lc-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 0;
}

.lesson-card__actions .lc-btn:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  color: #fff !important;
  text-decoration: none;
}

.lesson-card__actions .lc-btn:hover::before {
  opacity: 1;
}

.lesson-card__actions .lc-btn > i,
.lesson-card__actions .lc-btn > span {
  position: relative;
  z-index: 1;
}

.lesson-card__actions .lc-btn--tab-success {
  background: var(--gradient-secondary);
}

.lesson-card__actions .lc-btn--tab-success::before {
  background: linear-gradient(135deg, #68ae36 0%, var(--primary-cactus) 100%);
}

.lesson-card__actions .lc-btn--tab-info {
  background: var(--gradient-accent);
}

.lesson-card__actions .lc-btn--tab-info::before {
  background: linear-gradient(135deg, #3da799 0%, var(--accent-turquoise) 100%);
}

.lesson-card__actions .lc-btn--tab-primary {
  background: var(--gradient-primary);
}

.lesson-card__actions .lc-btn--tab-primary::before {
  background: linear-gradient(135deg, #ff5722 0%, #e64a19 100%);
}

/* ── Ad card variant ── */
.lesson-card--ad .lesson-card__inner {
  border-style: dashed;
  border-color: #e2c4a6;
  background: #fff9f4;
}

.lesson-card--ad .lesson-card__header {
  border-bottom-color: #e0c0a0;
}

.lesson-card__words-wrapper--ad {
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: visible;
  max-height: none;
}

/* #495057 on white ≈ 7.7:1 ✓ */
.lesson-card__ad-text {
  color: #495057;
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

/* #b34500 on white ≈ 5.4:1 ✓ (large/bold text — threshold 3:1 ✓) */
.lesson-card__ad-cta {
  font-weight: 700;
  color: #b34500;
  font-size: 1rem;
  margin: 0;
}

/* ── Loading / error states ── */
.cards-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 0.75rem;
}
