/* =======================================================================
   LESSON PAGE COMPONENTS
   Pairs with scripts/build_lesson.py output. Reuses tokens/components
   from the core design system — this file only adds lesson-specific
   structures.
   ======================================================================= */

/* "Ouvir" (listen) button — assets/js/listening.js, reads the text
   aloud via the browser's Web Speech API instead of a pre-recorded
   audio file. Small, circular, sits inline next to a sentence or
   above a reading passage. */
.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--color-accent);
  background: transparent;
  color: var(--color-accent);
  cursor: pointer;
  vertical-align: middle;
}
.tts-btn svg { width: 15px; height: 15px; }
.tts-btn:hover { background: var(--color-accent); color: #fff; }
.tts-btn.is-speaking { background: var(--color-accent); color: #fff; animation: tts-pulse 0.9s ease-in-out infinite; }
@keyframes tts-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.tts-btn--passage {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: 0.5em 1.1em;
  gap: 0.5em;
  font-size: var(--step--1);
  font-weight: 600;
}
.tts-btn--passage svg { width: 16px; height: 16px; }
.tts-btn--passage::after { content: "Ouvir o texto"; }
.tts-btn--passage.is-speaking::after { content: "Parar"; }

.prose {
  font-size: var(--step-0);
  color: var(--color-text);
  max-width: 68ch;
}
.prose p:not(:last-child) { margin-bottom: 1em; }
.prose strong { color: var(--color-accent); }
.prose em { color: var(--color-text-muted); }

/* Objectives */
.objectives-list, .examples-list, .summary-list, .rules-list {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  margin-top: var(--space-sm);
}
.objectives-list li, .examples-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.6em;
  font-size: var(--step--1);
}
.objectives-list svg, .examples-list__icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  margin-top: 0.15em;
  color: var(--color-success);
}
.examples-list li {
  font-size: var(--step-0);
  padding: 0.7em 0;
  border-bottom: 1px dashed var(--color-border);
}
.examples-list li:last-child { border-bottom: none; }
.examples-list span { font-style: italic; }

.rules-list {
  flex: 1;
  min-width: 240px;
  list-style: none;
  padding: 0;
}
.rules-list li {
  position: relative;
  padding-left: 1.4em;
  font-size: var(--step--1);
  color: var(--color-text);
}
.rules-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.55em;
  width: 8px; height: 8px;
  border-radius: 2px;
  background: var(--color-gold);
}

.summary-list { list-style: none; padding: 0; }
.summary-list li {
  position: relative;
  padding: 0.6em 0 0.6em 1.6em;
  border-bottom: 1px dashed var(--color-border);
  font-size: var(--step-0);
}
.summary-list li:last-child { border-bottom: none; }
.summary-list li::before {
  content: "\2192";
  position: absolute;
  left: 0;
  color: var(--color-accent);
  font-weight: 700;
}

/* Reference table */
.table-scroll { flex: 1; min-width: 260px; overflow-x: auto; }
.ref-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
  font-size: var(--step--1);
}
.ref-table caption {
  text-align: left;
  font-weight: 700;
  padding: 0.6em 0.9em;
  background: var(--color-primary-strong);
  color: var(--color-text-on-dark);
  caption-side: top;
}
.ref-table th, .ref-table td {
  padding: 0.7em 1.5em 0.7em 0;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
}
.ref-table th:first-child, .ref-table td:first-child {
  padding-left: 0.9em;
}
.ref-table th:last-child, .ref-table td:last-child {
  padding-right: 0.9em;
}
.ref-table thead th {
  background: var(--color-surface);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
}
.ref-table tbody tr:last-child td { border-bottom: none; }
.ref-table tbody tr:hover { background: var(--color-surface); }

/* Common mistakes */
.mistakes-grid {
  display: grid;
  gap: var(--space-md);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.mistake-card {
  background: var(--color-surface-raised);
  border: var(--border-hairline);
  border-left: 4px solid var(--color-danger);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.mistake-card__wrong {
  font-size: var(--step--1);
  color: var(--color-text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--color-danger);
  margin-bottom: 0.5em;
}
.mistake-card__right {
  font-size: var(--step-0);
  font-weight: 600;
  margin-bottom: 0.5em;
}
.mistake-card__why {
  font-size: var(--step--1);
  color: var(--color-text-muted);
  margin: 0;
}

/* Lesson prev/next/related nav */
.lesson-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: var(--border-hairline);
}
.lesson-nav .btn svg { transform: scaleX(-1); }
.lesson-nav .btn--accent svg { transform: none; }

/* Test Yourself page — tighter spacing per topic so 20 topics don't
   demand excessive scrolling. */
/* Rules + mistakes pairing on Test Yourself / lesson pages: give the
   (usually short) rules list a narrower, fixed-ish column and let the
   mistakes column take the rest, so its cards can wrap into two
   columns instead of stacking three full-height cards in a narrow
   half-width column — the main cause of the large empty space below
   a short rules list. */
.ty-topic { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }
.ty-split {
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: var(--space-lg);
}
.ty-split .mistakes-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-sm);
}
.ty-split .mistake-card { padding: var(--space-sm); }
.ty-split .mistake-card__wrong,
.ty-split .mistake-card__right { margin-bottom: 0.3em; }
.ty-split .rules-list { gap: 0.4em; }
@media (max-width: 860px) {
  .ty-split { grid-template-columns: 1fr; }
}
