/* Wordly Wise homework helpers - shared stylesheet.
   Scoped to /ww-helpers/. Each helper keeps its own :root palette inline.
   Component rules below reference var(--rust), var(--gold), var(--card-accent), etc.
   so each helper's local palette resolves into the shared component styles. */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 17px;
  line-height: 1.65;
}

.wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

/* ─── Top utility bar (back link + language toggle) ─── */
.ww-utility-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: var(--parchment-dark);
  border-bottom: 1px solid var(--rule);
}

.ww-back {
  color: var(--navy);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: bold;
  letter-spacing: 0.02em;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.ww-back:hover { background: rgba(14, 49, 72, 0.08); }

.lang-group {
  display: flex;
  background: rgba(14, 49, 72, 0.08);
  border: 1px solid var(--rule);
  border-radius: 99px;
  padding: 3px;
  gap: 2px;
}

.lang-btn {
  background: transparent;
  border: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: Georgia, serif;
}

.lang-btn:hover { color: var(--ink); }

.lang-btn.active {
  background: var(--navy);
  color: var(--parchment);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* ─── Language toggle visibility ─── */
.en-alt {
  display: block;
  font-style: italic;
  font-size: 0.92em;
  color: var(--ink-soft);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--rule);
}

body.mode-es .en-alt { display: none; }
body.mode-en .es-main { display: none; }
body.mode-en .en-alt {
  display: block;
  font-style: normal;
  color: inherit;
  font-size: 1em;
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

/* Inline contexts: when the visible language span sits next to inline siblings (label-tag,
   number, link text), keep it inline so the layout doesn't break onto multiple lines.
   These rules only fire when the body mode actually wants the span visible - they never
   override the mode-es/mode-en hide rules above. */
body.mode-en .question .en-alt,
body.mode-en .hw-name .en-alt,
body.mode-en a .en-alt,
body.mode-en h2.section-head .en-alt,
body.mode-en .meaning .en-alt,
body.mode-en .example .en-alt,
body.mode-en .your-turn .en-alt,
body.mode-en .hint .en-alt,
body.mode-en .where .en-alt,
body.mode-en .answer .en-alt,
body.mode-en .reasoning .en-alt,
body.mode-en td .en-alt,
body.mode-en th .en-alt,
body.mode-es .question .es-main,
body.mode-es .hw-name .es-main,
body.mode-es a .es-main,
body.mode-es h2.section-head .es-main,
body.mode-es .meaning .es-main,
body.mode-es .example .es-main,
body.mode-es .your-turn .es-main,
body.mode-es .hint .es-main,
body.mode-es .where .es-main,
body.mode-es .answer .es-main,
body.mode-es .reasoning .es-main,
body.mode-es td .es-main,
body.mode-es th .es-main,
body.mode-both .question .es-main, body.mode-both .question .en-alt,
body.mode-both .hw-name .es-main, body.mode-both .hw-name .en-alt,
body.mode-both a .es-main, body.mode-both a .en-alt,
body.mode-both h2.section-head .es-main, body.mode-both h2.section-head .en-alt,
body.mode-both .meaning .es-main, body.mode-both .meaning .en-alt,
body.mode-both .example .es-main, body.mode-both .example .en-alt,
body.mode-both .your-turn .es-main, body.mode-both .your-turn .en-alt,
body.mode-both .hint .es-main, body.mode-both .hint .en-alt,
body.mode-both .where .es-main, body.mode-both .where .en-alt,
body.mode-both .answer .es-main, body.mode-both .answer .en-alt,
body.mode-both .reasoning .es-main, body.mode-both .reasoning .en-alt,
body.mode-both td .es-main, body.mode-both td .en-alt,
body.mode-both th .es-main, body.mode-both th .en-alt {
  display: inline;
  font-style: inherit;
  color: inherit;
  font-size: inherit;
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
/* In mode-both, the en-alt becomes a styled secondary annotation after the es-main */
body.mode-both .question .en-alt,
body.mode-both .hw-name .en-alt,
body.mode-both a .en-alt,
body.mode-both h2.section-head .en-alt,
body.mode-both .meaning .en-alt,
body.mode-both .example .en-alt,
body.mode-both .your-turn .en-alt,
body.mode-both .hint .en-alt,
body.mode-both .where .en-alt,
body.mode-both .answer .en-alt,
body.mode-both .reasoning .en-alt,
body.mode-both td .en-alt,
body.mode-both th .en-alt {
  font-style: italic;
  color: var(--ink-soft);
}
body.mode-both .question .en-alt::before,
body.mode-both .hw-name .en-alt::before,
body.mode-both a .en-alt::before,
body.mode-both h2.section-head .en-alt::before,
body.mode-both .meaning .en-alt::before,
body.mode-both .example .en-alt::before,
body.mode-both .your-turn .en-alt::before,
body.mode-both .hint .en-alt::before,
body.mode-both .where .en-alt::before,
body.mode-both .answer .en-alt::before,
body.mode-both .reasoning .en-alt::before,
body.mode-both td .en-alt::before,
body.mode-both th .en-alt::before {
  content: " - ";
  color: var(--rule);
  font-style: normal;
}

/* ─── Title block ─── */
header.title {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
  border-bottom: 2px solid var(--gold);
  margin-bottom: 2rem;
  position: relative;
}

header.title h1 {
  font-family: "Trajan Pro", "Cinzel", Georgia, serif;
  font-size: 2.1rem;
  color: var(--navy);
  margin: 0.25rem 0;
  letter-spacing: 0.04em;
}

header.title .lesson-label {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 0.78rem;
  color: var(--rust);
  font-weight: bold;
}

header.title .subtitle {
  font-style: italic;
  color: var(--ink-soft);
  margin-top: 0.5rem;
  font-size: 1.05rem;
}

/* ─── Lesson tabs (one section per tab) ─── */
nav.lesson-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  background: var(--parchment);
  z-index: 5;
  padding-top: 1rem;
}
.lesson-tab {
  background: var(--parchment-dark);
  border: 1px solid var(--rule);
  border-radius: 99px;
  padding: 0.45rem 1rem;
  font: inherit;
  font-family: Georgia, serif;
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.lesson-tab:hover {
  background: var(--gold-soft);
  color: var(--ink);
  border-color: var(--gold);
}
.lesson-tab.active {
  background: var(--navy);
  color: var(--parchment);
  border-color: var(--navy);
}
section.lesson-pane { display: none; }
section.lesson-pane.active { display: block; }

/* ─── TOC navigation (legacy - used by interactive-readings nav.passage-nav etc.) ─── */
nav.toc {
  background: var(--parchment-dark);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  margin-bottom: 2.5rem;
}

nav.toc h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--rust);
}

nav.toc ol {
  margin: 0;
  padding-left: 1.4rem;
  columns: 2;
  column-gap: 1.5rem;
}

nav.toc a {
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px dotted var(--gold);
}

nav.toc a:hover { color: var(--rust); }

/* ─── Sections and headers ─── */
section { margin-bottom: 3rem; }

h2.section-head {
  font-family: Georgia, serif;
  color: var(--navy);
  font-size: 1.55rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.4rem;
  margin-bottom: 0.5rem;
}

h2.section-head .label {
  background: var(--navy);
  color: var(--parchment);
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  vertical-align: middle;
  margin-right: 0.5rem;
}

.intro {
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: 1.5rem;
}

/* ─── Vocabulary reference cards ─── */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.vocab-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--card-accent);
  padding: 0.7rem 0.9rem;
  border-radius: 2px;
  font-size: 0.92rem;
}

.vocab-card .word {
  font-weight: bold;
  color: var(--rust);
  font-size: 1rem;
  display: block;
}

.vocab-card .pos {
  color: var(--ink-soft);
  font-style: italic;
  font-size: 0.78rem;
}

.vocab-card .def {
  margin-top: 0.25rem;
  color: var(--ink);
}

/* ─── Prompt blocks ─── */
.prompt {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.1rem 1.3rem;
  margin: 1rem 0 1.4rem;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.prompt .number {
  display: inline-block;
  background: var(--rust);
  color: var(--parchment);
  width: 1.7rem;
  height: 1.7rem;
  line-height: 1.7rem;
  text-align: center;
  border-radius: 50%;
  font-weight: bold;
  font-size: 0.85rem;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.prompt .question {
  font-weight: bold;
  color: var(--navy);
  font-size: 1.05rem;
  display: inline;
}

.prompt .question b {
  color: var(--rust);
}

.prompt .meaning,
.prompt .example,
.prompt .your-turn,
.prompt .hint,
.prompt .where,
.prompt .answer,
.prompt .reasoning {
  margin-top: 0.7rem;
  padding-left: 0.4rem;
}

/* ─── Tag pills ─── */
.label-tag {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.1rem 0.5rem;
  border-radius: 2px;
  font-weight: bold;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.tag-meaning { background: var(--gold-soft); color: #6b5520; }
.tag-example { background: #d8e8e0; color: #2a5a4a; }
.tag-yours   { background: #f4dada; color: var(--rust); }
.tag-hint    { background: #d8e2ec; color: var(--navy); }
.tag-where   { background: #ede2c8; color: #7a5a2a; }
.tag-answer  { background: #d8e8d8; color: #2d5a2d; }
.tag-why     { background: #e2dcec; color: #4a3a6a; }

/* ─── Example fill highlight ─── */
.example em.fill {
  background: linear-gradient(transparent 70%, var(--gold-soft) 70%);
  font-style: normal;
  padding: 0 2px;
}

/* ─── Tip boxes ─── */
.tip-box {
  background: var(--parchment-dark);
  border-left: 4px solid var(--navy);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  border-radius: 2px;
}

.tip-box h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--navy);
}

/* ─── Synonym / antonym tables ─── */
table.synant {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.95rem;
}

table.synant th {
  background: var(--navy);
  color: var(--parchment);
  text-align: left;
  padding: 0.5rem 0.7rem;
  font-weight: normal;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

table.synant td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--rule);
  background: #fff;
}

table.synant td.pair {
  color: var(--rust);
  font-weight: bold;
}

table.synant td.tag {
  text-align: center;
  width: 3rem;
}

table.synant td.tag.S {
  background: #d8e8d8;
  color: #2d5a2d;
  font-weight: bold;
}

table.synant td.tag.A {
  background: #f4dada;
  color: var(--rust);
  font-weight: bold;
}

/* ─── Answer-letter chips ─── */
.answer-letters {
  font-family: "Courier New", monospace;
  font-weight: bold;
  color: var(--rust);
  background: var(--gold-soft);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  letter-spacing: 0.1em;
}

/* ─── Closing flourish ─── */
.flourish {
  text-align: center;
  color: var(--card-accent);
  font-size: 1.5rem;
  margin: 3rem 0 1rem;
  letter-spacing: 1rem;
}

.closing-note {
  text-align: center;
  color: var(--ink-soft);
  font-style: italic;
  font-size: 0.95rem;
  max-width: 520px;
  margin: 0 auto;
}

/* ─── Mobile ─── */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .wrap { padding: 1rem 0.85rem 3rem; }
  nav.toc ol { columns: 1; }
  header.title h1 { font-size: 1.6rem; }
  .vocab-grid { grid-template-columns: 1fr; }
  table.synant { font-size: 0.85rem; }
  table.synant td { padding: 0.4rem 0.5rem; }
  .ww-utility-bar { padding: 0.55rem 0.85rem; flex-wrap: wrap; gap: 0.5rem; }
  .lang-btn { padding: 0.3rem 0.6rem; font-size: 0.72rem; }
}

/* ─── Interactive widgets (reveal gates, student textareas, click-classify) ─── */
.is-hidden { display: none; }

.reveal-btn {
  display: inline-block;
  background: var(--parchment-dark);
  border: 1px solid var(--gold);
  color: var(--ink);
  padding: 0.45rem 0.95rem;
  font-family: Georgia, serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  margin-top: 0.7rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.reveal-btn:hover {
  background: var(--gold-soft);
  border-color: var(--rust);
}

.student-answer-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0.8rem 0 0.3rem;
  font-weight: bold;
}

.student-answer {
  display: block;
  width: 100%;
  min-height: 4.5rem;
  padding: 0.6rem 0.75rem;
  border: 1px dashed var(--rule);
  background: #fffdf8;
  font-family: Georgia, serif;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink);
  border-radius: 3px;
  resize: vertical;
  box-sizing: border-box;
}
.student-answer:focus {
  outline: none;
  border-color: var(--card-accent);
  border-style: solid;
}

/* 17D click-classify (S/A buttons replacing the prebuilt tag cell) */
table.synant td.sa-cell {
  text-align: center;
  padding: 0.3rem 0.4rem;
  white-space: nowrap;
}
.sa-btn {
  background: #fff;
  border: 1px solid var(--rule);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--ink-soft);
  margin: 0 0.1rem;
  border-radius: 3px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sa-btn:hover:not(.correct):not(.wrong) {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--ink);
}
.sa-btn.correct {
  background: #d8e8d8;
  color: #2d5a2d;
  border-color: #2d5a2d;
}
.sa-btn.wrong {
  background: #f4dada;
  color: var(--rust);
  border-color: var(--rust);
}
table.synant td.why-mute .why-inner { visibility: hidden; }

/* Vocab tracker - words used in any student-answer get highlighted */
.vocab-card .word.vw-tracked {
  background: var(--gold-soft);
  padding: 0 4px;
  border-radius: 2px;
}

/* ─── Print ─── */
@media print {
  body { background: white; font-size: 12pt; }
  .ww-utility-bar { display: none; }
  nav.toc { display: none; }
  .prompt, .tip-box { break-inside: avoid; }
  section { break-inside: avoid-page; }
  .reveal-btn { display: none; }
  .is-hidden { display: block !important; }
  table.synant td.why-mute .why-inner { visibility: visible; }
}
