/* =========================================================
   Study Guide page styles for the full USCIS textbook content
   ========================================================= */

/* ---------- Search ---------- */
.guide-search-section {
  padding: 28px 0 4px;
}

.guide-search-wrap {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
}

.guide-search-input {
  width: 100%;
  padding: 16px 22px;
  font-size: 1.05rem;
  border-radius: 999px;
  border: 2px solid var(--navy);
  background: var(--paper);
  box-shadow: var(--shadow);
  font-family: var(--sans);
}

.guide-search-input:focus {
  outline: none;
  box-shadow: var(--shadow-lg);
}

.guide-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  z-index: 60;
}

.guide-search-results.show {
  display: block;
}

.gsr-item {
  display: block;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.gsr-item:last-child {
  border-bottom: none;
}

.gsr-item:hover {
  background: var(--parchment);
}

.gsr-chapter {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 3px;
}

.gsr-snippet {
  display: block;
  font-size: .92rem;
  color: var(--ink);
  line-height: 1.45;
}

.gsr-snippet mark {
  background: rgba(176, 141, 63, .35);
  color: var(--ink);
  border-radius: 3px;
  padding: 0 2px;
}

.gsr-empty {
  padding: 16px 20px;
  font-size: .9rem;
  color: var(--ink-soft);
}

/* ---------- Chapter TOC grid ---------- */
.toc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media(max-width:860px) {
  .toc-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.toc-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}

.toc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.toc-card .toc-num {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--gold);
  font-size: .85rem;
  flex: none;
}

.toc-card .toc-icon {
  flex: none;
  color: var(--navy);
}

.toc-card .toc-icon .icon-svg {
  width: 22px;
  height: 22px;
}

.toc-card-appendix .toc-icon {
  color: var(--red);
}

.toc-card .toc-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.toc-card-appendix {
  border-color: var(--red);
  background: rgba(213, 43, 30, .04);
}

/* ---------- Chapter sections ---------- */
.chapter-section {
  padding: 56px 0;
  border-top: 1px solid var(--line);
}

.chapter-section:nth-of-type(odd) {
  background: var(--paper);
}

.chapter-head {
  max-width: 760px;
  margin: 0 auto 24px;
}

.chapter-head h2 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  color: var(--navy);
  margin-top: 10px;
}

.chapter-hero {
  width: 100%;
  max-width: 900px;
  display: block;
  margin: 0 auto 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  aspect-ratio: 612/166;
  object-fit: cover;
}

.chapter-body {
  max-width: 760px;
  margin: 0 auto;
}

.chapter-body h3 {
  font-size: 1.15rem;
  color: var(--navy);
  margin: 32px 0 10px;
}

.chapter-body h3.h3-section {
  font-size: .95rem;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: .02em;
  font-style: normal;
}

.chapter-body h3.h3-sub {
  font-size: 1.1rem;
  color: var(--navy);
  font-style: italic;
}

.example-label {
  font-size: .85rem;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-bottom: 8px !important;
}

.note-box {
  border: 2px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin: 16px 0;
}

.note-box p {
  font-weight: 700;
  font-style: italic;
  color: var(--ink);
  margin: 0;
}

.chapter-body p {
  margin-bottom: 16px;
}

.chapter-body strong {
  color: var(--ink);
}

.learn-box {
  background: rgba(11, 61, 145, .05);
  border: 1.5px solid rgba(11, 61, 145, .18);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 28px;
}

.learn-title {
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 10px !important;
}

.learn-list {
  margin: 0;
  padding-left: 22px;
}

.learn-list li {
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.body-list {
  margin: 0 0 16px;
  padding-left: 22px;
}

.body-list li {
  margin-bottom: 8px;
  color: var(--ink-soft);
  line-height: 1.55;
}

.chapter-body figure {
  margin: 24px 0;
}

.chapter-body figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  display: block;
}

.chapter-body figcaption {
  font-size: .8rem;
  color: var(--ink-soft);
  margin-top: 8px;
  font-style: italic;
}

/* a figure shown at its true PDF size rather than stretched to fill the column */
.fig-solo {
  margin: 24px auto;
}

.fig-solo figure {
  margin: 0;
}

@media(max-width:640px) {
  .fig-solo {
    width: 100% !important;
  }
}

/* multiple images side by side column widths mirror each image's actual PDF width */
.img-row {
  display: grid;
  gap: 16px;
  margin: 24px 0;
  align-items: start;
}

@media(max-width:620px) {
  .img-row {
    grid-template-columns: 1fr !important;
  }
}

.img-row figure {
  margin: 0;
}

.fig-note {
  font-size: .85rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* image on one side, text on the other mirrors the PDF's two-column layout;
   the figure's width is set inline per-instance to match its actual PDF size */
.side-by-side {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  margin: 24px 0;
}

.side-by-side figure {
  margin: 0;
}

.side-by-side .side-text {
  flex: 1 1 auto;
  min-width: 0;
}

.side-by-side .side-text p:last-child {
  margin-bottom: 0;
}

.side-by-side.side-right {
  flex-direction: row-reverse;
}

.side-by-side .side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media(max-width:640px) {

  .side-by-side,
  .side-by-side.side-right {
    flex-direction: column;
  }

  .side-by-side figure {
    flex: none !important;
    max-width: 100% !important;
    width: 100%;
    margin: 0 auto;
  }

  .side-by-side .side-stack {
    flex: none !important;
    max-width: 100% !important;
    width: 100%;
    margin: 0 auto;
  }

  .side-by-side .side-stack figure {
    max-width: 100% !important;
  }
}

/* ---------- Sidebar callout box (e.g. Voting Rights Timeline) ---------- */
.timeline-box {
  border-top: 3px solid var(--red);
  border-bottom: 3px solid var(--red);
  padding: 16px 0;
  margin: 24px 0;
}

.timeline-stars {
  color: var(--navy);
  font-size: .8rem;
  letter-spacing: 3px;
  margin: 0 0 14px;
  line-height: 1;
}

.timeline-box>.timeline-stars:last-child {
  margin: 14px 0 0;
}

.timeline-title {
  color: var(--navy) !important;
  margin: 0 0 10px !important;
}

.timeline-box p {
  color: var(--navy);
  font-weight: 700;
}

.timeline-list {
  margin: 0 0 16px;
  padding-left: 20px;
}

.timeline-list li {
  color: var(--navy);
  font-weight: 700;
  margin-bottom: 8px;
}

/* ---------- PDF download ---------- */
.download-section {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(11, 61, 145, .62), rgba(10, 24, 48, .72)),
    url("images/cta-bg.webp") center/cover no-repeat;
  border-top: 3px solid var(--gold);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, .08);
}

.download-section .container {
  position: relative;
  z-index: 1;
}

.download-section .chip {
  background: rgba(255, 255, 255, .12);
  color: #f2c879;
  border-color: rgba(255, 255, 255, .3);
}

.download-section h2 {
  color: #fff;
}

.download-section p {
  color: #c7d3ee;
}

.download-section .btn-primary {
  box-shadow: 0 12px 28px rgba(0, 0, 0, .28);
}

.back-to-top {
  display: inline-block;
  margin-top: 20px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--navy);
}

.back-to-top:hover {
  color: var(--red);
}

/* ---------- Floating "back to top" button ---------- */
.to-top-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 70;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s, visibility .2s, background .15s;
}

.to-top-btn.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.to-top-btn:hover {
  background: var(--red);
}

.to-top-btn .icon-svg {
  width: 22px;
  height: 22px;
}

@media(max-width:640px) {
  .to-top-btn {
    right: 16px;
    bottom: 16px;
    width: 42px;
    height: 42px;
  }
}

/* ---------- Appendix Q&A ---------- */
.qa-grid {
  max-width: 820px;
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.qa-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  scroll-margin-top: 90px;
}

.qa-num {
  font-family: var(--serif);
  color: var(--gold);
  font-weight: 700;
  font-size: .85rem;
}

.qa-text {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
  flex: 1;
}

.qa-text-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 6px;
}

.qa-text-row .voice-btn {
  margin-top: 2px;
}

.qa-answer {
  display: none;
  font-size: .94rem;
  color: var(--ink-soft);
  background: var(--parchment);
  border-radius: 10px;
  padding: 8px 16px;
  margin-top: 8px;
}

.qa-answer.show {
  display: block;
}

.qa-answer ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.qa-answer li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}

.qa-card .reveal-btn {
  font-size: .82rem;
  font-weight: 600;
  color: var(--navy);
  background: none;
  border: none;
  padding: 0;
}

h3[id],
.qa-card {
  scroll-margin-top: 90px;
}

/* ---------- Shared voice / translate controls (appendix + elsewhere) ---------- */
.q-btnrow {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 4px;
}

.translate-btn {
  font-size: .82rem;
  font-weight: 600;
  color: var(--navy);
  background: none;
  border: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.translate-btn .icon-svg {
  width: 14px;
  height: 14px;
}

.translation-box {
  display: none;
  margin-top: 12px;
  background: rgba(11, 61, 145, .05);
  border: 1px dashed rgba(11, 61, 145, .3);
  border-radius: 10px;
  padding: 12px 16px;
}

.translation-box.show {
  display: block;
}

.translation-box ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.translation-box li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}

.tr-label {
  font-size: .7rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.tr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
}

.tr-row span,
.translation-box li span,
.qa-answer li span {
  font-size: .92rem;
  color: var(--ink);
}

.voice-btn {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  transition: background .15s, color .15s;
}

.voice-btn .icon-svg {
  width: 14px;
  height: 14px;
}

.voice-btn:hover {
  background: var(--navy);
  color: #fff;
}

.voice-btn.speaking {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.voice-toggle-btn {
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--gold);
  background: var(--gold);
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  box-shadow: 0 3px 10px rgba(176, 141, 63, .35);
  margin-top: 16px;
}

.voice-toggle-btn:hover {
  background: #9a7935;
  border-color: #9a7935;
}

.voice-toggle-btn.open {
  background: var(--red);
  border-color: var(--red);
  box-shadow: 0 3px 10px rgba(213, 43, 30, .35);
}

.voice-settings-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  width: 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  text-align: left;
}

.voice-settings-panel.show {
  display: block;
}

.voice-settings-panel label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
}

.voice-settings-panel select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  font-size: .85rem;
  font-family: var(--sans);
  color: var(--ink);
}

.voice-settings-note {
  font-size: .75rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.4;
}