/* ========================================================================
   LESSONS CAROUSEL
   A premium infinite scroll carousel for articles/lessons
   Matches the warm glassmorphic design language of the portfolio
   ======================================================================== */

/* --- Section Container --- */
.lessons-section {
  padding: 6rem 0 8rem;
  overflow: hidden;
  position: relative;
}

/* --- Section Header --- */
.lessons-header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 4rem;
  padding: 0 1.5rem;
}

.lessons-header .section-header-image {
  width: 80px;
  height: 80px;
  margin-bottom: 1.5rem;
}

.lessons-header h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
  margin-bottom: 1rem;
  color: var(--color-text, #2a2a30);
}

.lessons-header h2 .title-italic {
  font-style: italic;
  font-weight: 300;
  color: var(--color-muted, #6b6b6b);
}

:root[data-theme="dark"] .lessons-header h2 .title-italic {
  color: rgba(255, 255, 255, 0.4);
}

.lessons-header p {
  font-size: 1.125rem;
  color: var(--color-muted, #5a5a64);
  line-height: 1.6;
}

.lessons-header .start-here-highlight {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--color-muted);
}

.lessons-header .start-here-link {
  color: var(--accent, #d4923f);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.3s ease;
}

@media (hover: hover) {
  .lessons-header .start-here-link:hover {
    color: var(--palette-sun-brown-dark, #5a3214);
  }
}

/* --- Carousel Wrapper --- */
.lessons-carousel-wrapper {
  position: relative;
  width: 100%;
  padding: 1.5rem 0 3rem;
}

/* Gradient Fade Edges */
.lessons-carousel-wrapper::before,
.lessons-carousel-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 200px;
  pointer-events: none;
  z-index: 10;
}

.lessons-carousel-wrapper::before {
  left: 0;
  background: linear-gradient(90deg,
    var(--lessons-fade-color, rgba(232, 240, 230, 1)) 0%,
    var(--lessons-fade-color, rgba(232, 240, 230, 0.8)) 40%,
    transparent 100%
  );
}

.lessons-carousel-wrapper::after {
  right: 0;
  background: linear-gradient(270deg,
    var(--lessons-fade-color, rgba(232, 240, 230, 1)) 0%,
    var(--lessons-fade-color, rgba(232, 240, 230, 0.8)) 40%,
    transparent 100%
  );
}

/* --- The Carousel Track --- */
.lessons-track {
  display: flex;
  gap: 32px;
  width: max-content;
  animation: lessons-scroll 45s linear infinite;
  padding: 1rem 0;
}

@media (hover: hover) {
  .lessons-track:hover {
    animation-play-state: paused;
  }
}

@keyframes lessons-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .lessons-track {
    animation: none;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 1rem 2rem;
  }

  .lesson-card {
    scroll-snap-align: start;
  }
}

/* --- Individual Lesson Card --- */
.lesson-card {
  flex: 0 0 380px;
  display: flex;
  flex-direction: column;
  border-radius: 28px;
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  position: relative;
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92) 0%, rgba(252, 252, 253, 0.88) 100%) padding-box,
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.03)) border-box;
  background-clip: padding-box, border-box;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow:
    0 8px 32px rgba(139, 111, 71, 0.08),
    0 4px 16px rgba(139, 111, 71, 0.04),
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -1px 0 rgba(0, 0, 0, 0.03);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light from top effect */
.lesson-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background:
    radial-gradient(
      ellipse 80% 100% at center top,
      rgba(255, 255, 255, 0.5) 0%,
      rgba(255, 255, 255, 0.2) 35%,
      transparent 60%
    );
  pointer-events: none;
  border-radius: 28px 28px 0 0;
  z-index: 0;
}

@media (hover: hover) {
  .lesson-card:hover {
    box-shadow:
      0 20px 60px rgba(139, 111, 71, 0.15),
      0 8px 24px rgba(139, 111, 71, 0.08),
      inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
  }
}

/* Remove all underlines from card children */
.lesson-card,
@media (hover: hover) {
  .lesson-card:hover,
  .lesson-card *,
  .lesson-card:hover * {
    text-decoration: none !important;
  }
}

/* --- Card Image Area --- */
.lesson-card-image {
  position: relative;
  height: 200px;
  overflow: hidden;
  background: linear-gradient(135deg, var(--card-gradient-1, #f0e6d6) 0%, var(--card-gradient-2, #e8d9c5) 100%);
}

.lesson-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease-out;
}

@media (hover: hover) {
  .lesson-card:hover .lesson-card-image img {
    transform: scale(1.08);
  }
}

/* Gradient overlay for text readability */
.lesson-card-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top,
    rgba(0, 0, 0, 0.4) 0%,
    rgba(0, 0, 0, 0.1) 30%,
    transparent 60%
  );
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

@media (hover: hover) {
  .lesson-card:hover .lesson-card-image::after {
    opacity: 0.4;
  }
}

/* Featured Badge */
.lesson-featured-badge {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(250, 250, 252, 0.9)) padding-box,
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.03)) border-box;
  background-clip: padding-box, border-box;
  border-radius: 999px;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lesson-featured-badge svg {
  width: 12px;
  height: 12px;
  color: var(--accent, #d4923f);
  fill: var(--accent, #d4923f);
}

.lesson-featured-badge span {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent, #d4923f);
}

/* --- Card Content Area --- */
.lesson-card-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  padding: 1.75rem;
}

/* Meta line (category + read time) */
.lesson-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.lesson-category {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-category-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--category-color, #d4923f);
}

.lesson-category-text {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted, #5a5a64);
}

.lesson-read-time {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-muted, #888);
}

.lesson-read-time svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

/* Title */
.lesson-title {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.75rem;
  color: var(--color-text, #2a2a30);
  transition: text-decoration 0.3s ease;
}


/* Description */
.lesson-description {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-muted, #5a5a64);
  margin-bottom: 1.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Bottom action area */
.lesson-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px dashed rgba(139, 111, 71, 0.2);
}

.lesson-action-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text, #2a2a30);
}

.lesson-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(139, 111, 71, 0.08);
  border: 1px solid rgba(139, 111, 71, 0.15);
  border-radius: var(--radius-pill);
}

.lesson-action-icon svg {
  width: 16px;
  height: 16px;
  color: var(--color-text, #2a2a30);
}

/* --- Category Color Variants --- */
.lesson-card[data-category="ux-writing"] .lesson-category-dot {
  background: #3b82f6; /* Blue */
}

.lesson-card[data-category="growth"] .lesson-category-dot {
  background: #f97316; /* Orange */
}

.lesson-card[data-category="case-study"] .lesson-category-dot {
  background: #8b5cf6; /* Purple */
}

.lesson-card[data-category="gamification"] .lesson-category-dot {
  background: #ec4899; /* Rose */
}

.lesson-card[data-category="conversion"] .lesson-category-dot {
  background: #10b981; /* Emerald */
}

/* --- Footer Link --- */
.lessons-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding: 0 1.5rem;
}

.lessons-view-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text, #2a2a30);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid var(--color-text, #2a2a30);
  transition: all var(--duration-slow) var(--ease-smooth);
}

@media (hover: hover) {
  .lessons-view-all:hover {
    gap: 12px;
    border-bottom-color: var(--accent, #d4923f);
    color: var(--accent, #d4923f);
  }
}

.lessons-view-all svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
}

@media (hover: hover) {
  .lessons-view-all:hover svg {
    transform: translateX(2px);
  }
}

/* ========================================================================
   THEME VARIANTS
   ======================================================================== */

/* Mint theme (default for insights) */
[data-theme="mint"] .lessons-carousel-wrapper::before {
  background: linear-gradient(90deg,
    rgba(232, 240, 230, 1) 0%,
    rgba(232, 240, 230, 0.8) 40%,
    transparent 100%
  );
}

[data-theme="mint"] .lessons-carousel-wrapper::after {
  background: linear-gradient(270deg,
    rgba(232, 240, 230, 1) 0%,
    rgba(232, 240, 230, 0.8) 40%,
    transparent 100%
  );
}

/* Cream theme */
[data-theme="cream"] .lessons-carousel-wrapper::before {
  background: linear-gradient(90deg,
    rgba(255, 248, 240, 1) 0%,
    rgba(255, 248, 240, 0.8) 40%,
    transparent 100%
  );
}

[data-theme="cream"] .lessons-carousel-wrapper::after {
  background: linear-gradient(270deg,
    rgba(255, 248, 240, 1) 0%,
    rgba(255, 248, 240, 0.8) 40%,
    transparent 100%
  );
}

/* Butter theme */
[data-theme="butter"] .lessons-carousel-wrapper::before {
  background: linear-gradient(90deg,
    rgba(245, 230, 211, 1) 0%,
    rgba(245, 230, 211, 0.8) 40%,
    transparent 100%
  );
}

[data-theme="butter"] .lessons-carousel-wrapper::after {
  background: linear-gradient(270deg,
    rgba(245, 230, 211, 1) 0%,
    rgba(245, 230, 211, 0.8) 40%,
    transparent 100%
  );
}

/* ========================================================================
   DARK MODE
   ======================================================================== */

:root[data-theme="dark"] .lesson-card {
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(15, 20, 35, 0.85), rgba(8, 12, 20, 0.9)) padding-box,
    linear-gradient(180deg, rgba(140, 182, 255, 0.3), rgba(140, 182, 255, 0.08)) border-box;
  background-clip: padding-box, border-box;
  box-shadow:
    0 8px 32px rgba(0, 15, 40, 0.4),
    0 4px 16px rgba(0, 15, 40, 0.3),
    inset 0 2px 0 rgba(140, 182, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

:root[data-theme="dark"] .lesson-card::before {
  background:
    radial-gradient(
      ellipse 80% 100% at center top,
      rgba(140, 182, 255, 0.15) 0%,
      rgba(140, 182, 255, 0.05) 35%,
      transparent 60%
    );
}

@media (hover: hover) {
  :root[data-theme="dark"] .lesson-card:hover {
    border-color: rgba(100, 150, 255, 0.2);
    box-shadow:
      0 20px 60px rgba(0, 15, 40, 0.5),
      0 8px 24px rgba(0, 15, 40, 0.4),
      inset 0 1px 0 rgba(100, 150, 255, 0.1);
  }
}

:root[data-theme="dark"] .lesson-title {
  color: rgba(255, 255, 255, 0.95);
}

:root[data-theme="dark"] .lesson-description {
  color: rgba(255, 255, 255, 0.6);
}

:root[data-theme="dark"] .lesson-category-text {
  color: rgba(255, 255, 255, 0.65);
}

:root[data-theme="dark"] .lesson-read-time {
  color: rgba(255, 255, 255, 0.6);
}

:root[data-theme="dark"] .lesson-action {
  border-top-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .lesson-action-text {
  color: rgba(255, 255, 255, 0.9);
}

:root[data-theme="dark"] .lesson-action-icon {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

:root[data-theme="dark"] .lesson-action-icon svg {
  color: rgba(255, 255, 255, 0.9);
}

:root[data-theme="dark"] .lesson-featured-badge {
  border: 2px solid transparent;
  background:
    linear-gradient(180deg, rgba(15, 20, 35, 0.9), rgba(10, 14, 25, 0.95)) padding-box,
    linear-gradient(180deg, rgba(140, 182, 255, 0.3), rgba(140, 182, 255, 0.1)) border-box;
  background-clip: padding-box, border-box;
  box-shadow:
    0 4px 12px rgba(0, 15, 40, 0.3),
    inset 0 1px 0 rgba(140, 182, 255, 0.1);
}

:root[data-theme="dark"] .lesson-featured-badge svg {
  color: rgba(140, 182, 255, 0.9);
  fill: rgba(140, 182, 255, 0.9);
}

:root[data-theme="dark"] .lesson-featured-badge span {
  color: rgba(196, 215, 255, 0.95);
}

:root[data-theme="dark"] .lessons-carousel-wrapper::before {
  background: linear-gradient(90deg,
    rgba(5, 5, 7, 0.95) 0%,
    rgba(5, 5, 7, 0.6) 40%,
    transparent 100%
  );
}

:root[data-theme="dark"] .lessons-carousel-wrapper::after {
  background: linear-gradient(270deg,
    rgba(5, 5, 7, 0.95) 0%,
    rgba(5, 5, 7, 0.6) 40%,
    transparent 100%
  );
}

:root[data-theme="dark"] .lessons-header h2 {
  color: rgba(255, 255, 255, 0.95);
}

:root[data-theme="dark"] .lessons-header p {
  color: rgba(255, 255, 255, 0.6);
}

:root[data-theme="dark"] .lessons-view-all {
  color: rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.9);
}

@media (hover: hover) {
  :root[data-theme="dark"] .lessons-view-all:hover {
    color: var(--accent, #c4d7ff);
    border-bottom-color: var(--accent, #c4d7ff);
  }
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */

@media (max-width: 1024px) {
  .lessons-carousel-wrapper::before,
  .lessons-carousel-wrapper::after {
    width: 120px;
  }

  .lesson-card {
    flex: 0 0 340px;
  }
}

@media (max-width: 768px) {
  .lessons-section {
    padding: 4rem 0 5rem;
  }

  .lessons-header {
    margin-bottom: 2.5rem;
  }

  .lessons-header h2 {
    font-size: 1.75rem;
  }

  .lessons-header p {
    font-size: 1rem;
  }

  .lessons-footer {
    margin-top: 1.25rem;
  }

  .lessons-view-all {
    font-size: 0.85rem;
  }

  .lessons-carousel-wrapper {
    padding: 1rem 0 2rem;
  }

  .lessons-carousel-wrapper::before,
  .lessons-carousel-wrapper::after {
    width: 60px;
  }

  .lessons-track {
    gap: 20px;
    animation-duration: 35s;
  }

  .lesson-card {
    flex: 0 0 300px;
  }

  .lesson-card-image {
    height: 160px;
  }

  .lesson-card-content {
    padding: 1.25rem;
  }

  .lesson-title {
    font-size: 1.15rem;
  }

  .lesson-description {
    font-size: 0.85rem;
    margin-bottom: 1rem;
  }
}

@media (max-width: 480px) {
  .lessons-carousel-wrapper::before,
  .lessons-carousel-wrapper::after {
    width: 40px;
  }

  .lesson-card {
    flex: 0 0 280px;
  }

  .lesson-card-image {
    height: 140px;
  }

  .lesson-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ========================================================================
   PERFORMANCE & ACCESSIBILITY
   ======================================================================== */

/* GPU acceleration for smooth animations */
.lessons-track,
.lesson-card,
.lesson-card-image img {
  will-change: transform;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Focus states for accessibility */
.lesson-card:focus {
  outline: 2px solid var(--accent, #d4923f);
  outline-offset: 4px;
}

.lesson-card:focus-visible {
  outline: 2px solid var(--accent, #d4923f);
  outline-offset: 4px;
}

/* Touch device optimizations - make carousel swipeable */
@media (hover: none) and (pointer: coarse) {
  .lessons-carousel-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .lessons-carousel-wrapper::-webkit-scrollbar {
    display: none;
  }

  .lessons-track {
    animation: none;
    padding-left: 24px;
    padding-right: 24px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  .lesson-card {
    scroll-snap-align: center;
    flex: 0 0 85vw;
    max-width: 380px;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }

  /* Disable hover transforms on touch */
  @media (hover: hover) {
    .lesson-card:hover {
      transform: none;
      box-shadow:
        0 8px 32px rgba(139, 111, 71, 0.08),
        0 4px 16px rgba(139, 111, 71, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    }
  }

  @media (hover: hover) {
    .lesson-card:hover .lesson-card-image img {
      transform: none;
    }
  }

  /* Hide edge fades on touch - scrollbar provides context */
  .lessons-carousel-wrapper::before,
  .lessons-carousel-wrapper::after {
    display: none;
  }
}
