/**
 * Lesson Page Styles
 * Premium lesson experience — white canvas, step dots, glass nav, transitions
 * All styles scoped to .lesson-page to avoid affecting other pages
 */

/* ═══════════════════════════════════════
   PHASE 1: WHITE CANVAS
   ═══════════════════════════════════════ */

/* Override ice-blue background when lesson page is displayed.
   Redefine --color-background so inline styles using the variable also change. */
html:has(.lesson-page) {
  --color-background: #FFFFFF;
  background-color: var(--color-surface);
}

.lesson-page {
  --lesson-content-max-width: 680px;
  --lesson-section-gap: 48px;
  --lesson-block-gap: 24px;
  --lesson-heading-gap: 16px;

  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  padding: var(--spacing-lg) var(--spacing-md);
  max-width: 900px;
  margin: 0 auto;
  /* Bottom spacing for fixed nav bar + PWA banner */
  padding-bottom: 120px;
}

/* ═══════════════════════════════════════
   PHASE 2: LESSON PROGRESS HEADER
   ═══════════════════════════════════════ */

.lesson-progress-header {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid var(--color-border-light);
}

/* Back button — compact square */
.lesson-progress-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  transition: all var(--transition-fast);
}

.lesson-progress-back:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}

/* Center section: title + dots */
.lesson-progress-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lesson-progress-title {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  text-align: center;
}

/* Step dots container */
.lesson-progress-dots {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Individual step dot */
.lesson-progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--color-border-light);
  background-color: transparent;
  transition: all 400ms cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

/* Completed dot */
.lesson-progress-dot--completed {
  background-color: var(--color-main);
  border-color: var(--color-main);
}

/* Current dot */
.lesson-progress-dot--current {
  background-color: var(--color-main);
  border-color: var(--color-main);
  animation: dot-pulse 2s ease-in-out infinite;
}

/* Pill counter badge */
.lesson-progress-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  font-family: var(--font-family);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-muted);
  background-color: var(--color-surface-hover);
  border-radius: var(--radius-full);
  white-space: nowrap;
  min-width: 48px;
}

@keyframes dot-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(75, 96, 110, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(75, 96, 110, 0);
  }
}

/* ═══════════════════════════════════════
   PHASE 3: CONTENT TYPOGRAPHY
   ═══════════════════════════════════════ */

/* Content screen container */
.lesson-content-screen {
  display: flex;
  flex-direction: column;
  gap: var(--lesson-block-gap);
  padding: var(--spacing-lg) var(--spacing-md);
  max-width: var(--lesson-content-max-width);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* Section label — small, understated */
.lesson-section-label {
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin: 0;
}

/* Main heading */
.lesson-content-screen h2 {
  font-family: var(--font-family-heading);
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: var(--line-height-tight);
}

/* Body text */
.lesson-content-screen [data-testid="screen-content"] {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  max-width: 70ch;
}

/* Lead text (first paragraph) */
.lesson-content-screen [data-testid="screen-content"] > p:first-child {
  font-size: var(--font-size-xl);
  line-height: 1.4;
  color: var(--color-text);
}

/* Paragraph spacing */
.lesson-content-screen [data-testid="screen-content"] p {
  margin-bottom: var(--lesson-block-gap);
}

.lesson-content-screen [data-testid="screen-content"] p:last-child {
  margin-bottom: 0;
}

/* ═══ Arrow bullets ═══ */
.lesson-page .screen-content ul {
  list-style: none;
  padding-left: 28px;
}

.lesson-page .screen-content ul li {
  position: relative;
  margin-bottom: 12px;
  line-height: 1.6;
}

.lesson-page .screen-content ul li::before {
  content: '\2192';
  position: absolute;
  left: -28px;
  color: var(--color-main);
  opacity: 0.65;
  font-weight: var(--font-weight-medium);
}

/* ═══ Callout boxes (blockquotes) ═══ */
.lesson-page .screen-content blockquote {
  background: linear-gradient(135deg, rgba(75, 96, 110, 0.08), rgba(75, 96, 110, 0.04));
  border-left: 4px solid var(--color-main);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: var(--lesson-block-gap) 0;
  font-style: normal;
  color: var(--color-text);
}

.lesson-page .screen-content blockquote p {
  margin-bottom: var(--spacing-sm);
}

.lesson-page .screen-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Strong text in callouts */
.lesson-page .screen-content blockquote strong {
  color: var(--color-main);
}

/* ═══════════════════════════════════════
   PHASE 4: SCREEN TRANSITIONS
   ═══════════════════════════════════════ */

/* Screen entrance animation */
@keyframes screen-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Screen exit animation */
@keyframes screen-exit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

.screen-content {
  will-change: auto;
}

.screen-entering {
  animation: screen-enter 300ms ease-out forwards;
  will-change: transform, opacity;
}

.screen-exiting {
  animation: screen-exit 200ms ease-in forwards;
  will-change: transform, opacity;
  pointer-events: none;
}

/* Content element stagger */
.screen-entering > * {
  opacity: 0;
  animation: screen-enter 300ms ease-out forwards;
}

.screen-entering > *:nth-child(1) { animation-delay: 0ms; }
.screen-entering > *:nth-child(2) { animation-delay: 50ms; }
.screen-entering > *:nth-child(3) { animation-delay: 100ms; }
.screen-entering > *:nth-child(4) { animation-delay: 150ms; }
.screen-entering > *:nth-child(5) { animation-delay: 200ms; }
.screen-entering > *:nth-child(6) { animation-delay: 250ms; }

/* ═══════════════════════════════════════
   PHASE 5: PREMIUM NAVIGATION BAR
   ═══════════════════════════════════════ */

.screen-nav-premium {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-sm) var(--spacing-lg);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.05);
  z-index: var(--z-sticky);
}

/* Previous button — ghost style */
.screen-nav-prev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  min-height: 48px;
  padding: var(--spacing-sm) var(--spacing-lg);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-muted);
  background-color: transparent;
  border: none;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.screen-nav-prev:hover {
  color: var(--color-text);
  background-color: var(--color-surface-hover);
  text-decoration: none;
}

/* Next button — premium filled */
.screen-nav-next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  min-height: 48px;
  padding: 12px 24px;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-inverse);
  background-color: var(--color-main);
  border: none;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(75, 96, 110, 0.25);
  transition: all 150ms ease-out;
}

.screen-nav-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(75, 96, 110, 0.35);
  text-decoration: none;
  color: var(--color-text-inverse);
}

.screen-nav-next:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(75, 96, 110, 0.2);
}

/* Disabled next button */
.screen-nav-next--disabled {
  background-color: var(--color-border-light);
  color: var(--color-text-inverse);
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7;
}

.screen-nav-next--disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Placeholder for empty button space */
.screen-nav-placeholder {
  min-width: 48px;
  min-height: 48px;
}

/* ═══════════════════════════════════════
   PHASE 6: COMPACT FEEDBACK WIDGET
   ═══════════════════════════════════════ */

.feedback-compact-trigger {
  position: fixed;
  bottom: 72px;
  right: var(--spacing-md);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  color: var(--color-text-muted);
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: var(--font-weight-bold);
  line-height: 1;
  padding: 0;
}

.feedback-compact-trigger:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-border);
  color: var(--color-text);
  box-shadow: var(--shadow-md);
}

/* Compact popover */
.feedback-compact-popover {
  position: fixed;
  bottom: 118px;
  right: var(--spacing-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  padding: var(--spacing-xs) 0;
  min-width: 180px;
}

.feedback-compact-popover-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: transparent;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--transition-fast);
}

.feedback-compact-popover-item:hover {
  background-color: var(--color-surface-hover);
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 768px) {
  .lesson-content-screen h2 {
    font-size: var(--font-size-2xl);
  }

  .lesson-content-screen [data-testid="screen-content"] > p:first-child {
    font-size: var(--font-size-lg);
  }

  .lesson-progress-header {
    gap: var(--spacing-sm);
  }

  .lesson-progress-title {
    font-size: var(--font-size-xs);
  }

  .lesson-progress-dot {
    width: 8px;
    height: 8px;
  }

  .lesson-progress-dots {
    gap: 6px;
  }

  .screen-nav-premium {
    padding: var(--spacing-sm) var(--spacing-md);
  }
}

@media (max-width: 480px) {
  .lesson-page {
    padding: var(--spacing-md) var(--spacing-sm);
    padding-bottom: 100px;
  }

  .lesson-content-screen {
    padding: var(--spacing-md) var(--spacing-sm);
  }
}

/* ═══════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .lesson-progress-dot--current {
    animation: none;
  }

  .screen-entering,
  .screen-exiting {
    animation: none;
  }

  .screen-entering > * {
    animation: none;
    opacity: 1;
  }

  .screen-nav-next:hover {
    transform: none;
  }

  .screen-nav-next:active {
    transform: none;
  }
}
