/* ============================================================
 *  Topic Pages v2 — Visual upgrade overlay
 *  Polished design for deep-dive topic pages (10 exam /
 *  profession guides). All existing structure is preserved;
 *  this just layers better visuals on top.
 * ============================================================ */

/* ─── Topic page hero ──────────────────────────────────────── */
.topic-page {
  max-width: 1100px;
  margin: 0 auto;
}

.topic-hero {
  position: relative;
  padding: 100px 0 48px;
  margin-top: -70px;
  background:
    radial-gradient(ellipse at top right, rgba(45, 140, 212, 0.18) 0%, transparent 50%),
    linear-gradient(180deg, #0A2540 0%, #132F52 70%, #1A3A63 100%);
  color: #fff;
  border-radius: 0 0 28px 28px;
  overflow: hidden;
}
.topic-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center top, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center top, black 20%, transparent 70%);
  pointer-events: none;
}

.topic-hero .container {
  position: relative;
  z-index: 1;
}

.topic-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 24px;
}
.topic-breadcrumb a {
  color: rgba(255, 255, 255, 0.7);
  transition: color 0.15s ease;
}
.topic-breadcrumb a:hover { color: #fff; }
.topic-breadcrumb .sep { color: rgba(255, 255, 255, 0.3); }
.topic-breadcrumb .current { color: rgba(255, 255, 255, 0.9); }

.topic-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.back-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  order: -1;
  width: 100%;
  justify-content: flex-start;
  margin-bottom: 4px;
}
.back-home-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.fav-btn:hover {
  background: rgba(232, 168, 56, 0.15);
  border-color: rgba(232, 168, 56, 0.3);
  color: #E8A838;
}
.fav-btn.is-active {
  background: rgba(232, 168, 56, 0.2);
  border-color: rgba(232, 168, 56, 0.4);
  color: #E8A838;
}

.topic-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: linear-gradient(135deg, rgba(232, 168, 56, 0.2) 0%, rgba(245, 199, 107, 0.15) 100%);
  border: 1px solid rgba(232, 168, 56, 0.3);
  color: #F5C76B;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 100px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.topic-title {
  width: 100%;
  font-size: 42px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: #fff;
  margin: 0;
  order: 1;
}

.topic-subtitle {
  width: 100%;
  font-size: 18px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.68);
  margin: 0;
  order: 2;
  max-width: 680px;
}

/* ─── Author / meta row ────────────────────────────────────── */
.topic-author-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.topic-author {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topic-author-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1D6FB8 0%, #2D8CD4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.topic-author-info { line-height: 1.3; }
.topic-author-name {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
.topic-author-role {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
  margin-top: 2px;
}
.tas-right {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}
.tas-line {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}
.tas-line strong {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
}

/* ─── Page actions (share / print) ────────────────────────── */
.page-actions {
  display: flex;
  gap: 8px;
}
.page-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.page-action-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ─── Topic content layout ─────────────────────────────────── */
.topic-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 48px;
  align-items: start;
  padding: 48px 0;
  max-width: 1100px;
  margin: 0 auto;
}

/* ─── TOC sidebar ──────────────────────────────────────────── */
.topic-toc {
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
.toc-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-navy-700);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}
.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-list a {
  display: block;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: all 0.12s ease;
}
.toc-list a:hover {
  color: var(--color-navy-700);
  background: var(--bg-soft);
}
.toc-list a.is-active {
  color: var(--color-blue-600);
  background: var(--color-blue-50);
  border-left-color: var(--color-blue-600);
  font-weight: 600;
}
.toc-list .toc-h3 {
  padding-left: 22px;
  font-size: 12px;
}

/* ─── Content area ────────────────────────────────────────── */
.topic-content {
  min-width: 0;
}
.topic-content h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 40px;
  margin-bottom: 16px;
  letter-spacing: -0.01em;
  scroll-margin-top: 90px;
}
.topic-content h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 28px;
  margin-bottom: 12px;
  scroll-margin-top: 90px;
}
.topic-content p {
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 14px;
}
.topic-content ul,
.topic-content ol {
  color: var(--text-secondary);
  line-height: 1.7;
  padding-left: 24px;
  margin-bottom: 14px;
}
.topic-content li { margin-bottom: 6px; }

/* ─── Highlight boxes ──────────────────────────────────────── */
.highlight-box {
  display: flex;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 12px;
  background: var(--bg-soft);
  border-left: 4px solid var(--color-blue-600);
  margin: 20px 0;
}
.highlight-box .hb-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  color: var(--color-blue-600);
  margin-top: 1px;
}
.highlight-box .hb-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.highlight-box .hb-content { color: var(--text-secondary); line-height: 1.7; }

.highlight-box.warning {
  border-left-color: var(--color-amber-500);
  background: var(--color-amber-100);
}
.highlight-box.warning .hb-icon { color: var(--color-amber-600); }

.highlight-box.danger {
  border-left-color: var(--color-red-500);
  background: var(--color-red-100);
}
.highlight-box.danger .hb-icon { color: var(--color-red-600); }

.highlight-box.success {
  border-left-color: var(--color-green-500);
  background: var(--color-green-100);
}
.highlight-box.success .hb-icon { color: var(--color-green-600); }

/* ─── Info cards ───────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: all 0.2s ease;
}
.info-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.info-card-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--color-blue-600);
}
.info-card .stat-num {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-gold-600);
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.info-card h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.info-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0;
  line-height: 1.5;
}

/* ─── Comparison tables ────────────────────────────────────── */
.topic-table-wrapper {
  margin: 24px 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xs);
}
.topic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.topic-table th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text-primary);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-default);
}
.topic-table td {
  padding: 12px 16px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
.topic-table tr:last-child td { border-bottom: none; }
.topic-table tr:hover td { background: var(--bg-card-hover); }

/* ─── FAQ ──────────────────────────────────────────────────── */
.topic-faq-item {
  border: 1px solid var(--border-default);
  border-radius: 10px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: all 0.15s ease;
  background: var(--bg-card);
}
.topic-faq-item:hover {
  border-color: var(--border-strong);
}
.topic-faq-q {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease;
}
.topic-faq-q:hover { background: var(--bg-soft); }
.faq-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.topic-faq-item.is-open .faq-icon { transform: rotate(180deg); }
.topic-faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.topic-faq-a p {
  padding: 0 20px 16px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.topic-faq-item.is-open .topic-faq-a {
  max-height: 600px;
}

/* ─── Bottom section ───────────────────────────────────────── */
.topic-bottom-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border-default);
}

.official-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 24px;
  background: var(--bg-soft);
  border-radius: 14px;
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
}
.official-link-card h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.official-link-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}
.btn-official {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--color-navy-700);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn-official:hover {
  background: var(--color-navy-700);
  border-color: var(--color-navy-700);
  color: #fff;
}

.vocab-game-promo {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: linear-gradient(135deg, rgba(29, 111, 184, 0.08) 0%, rgba(45, 140, 212, 0.04) 100%);
  border: 1px solid var(--color-blue-100);
  border-radius: 14px;
  margin-bottom: 24px;
}
.vocab-game-promo__icon {
  font-size: 36px;
  flex-shrink: 0;
}
.vocab-game-promo__content { flex: 1; min-width: 0; }
.vocab-game-promo__content h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
}
.vocab-game-promo__content p {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}
.vocab-game-promo__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--color-navy-700);
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.vocab-game-promo__btn:hover {
  background: var(--color-navy-600);
  transform: translateY(-1px);
  box-shadow: var(--shadow-blue);
  color: #fff;
}

/* ─── Related topics ───────────────────────────────────────── */
.related-topics h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 16px;
}
.related-topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.related-topic-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.related-topic-card:hover {
  border-color: var(--color-blue-300);
  background: var(--color-blue-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.related-topic-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-blue-600), var(--color-blue-400));
  color: #fff;
  border-radius: 8px;
  flex-shrink: 0;
}
.related-topic-card h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 2px;
}
.related-topic-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

/* ─── Dark mode ────────────────────────────────────────────── */
html[data-theme="dark"] .topic-hero {
  background:
    radial-gradient(ellipse at top right, rgba(45, 140, 212, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, #051830 0%, #0A2540 70%, #132F52 100%);
}
html[data-theme="dark"] .back-home-btn,
html[data-theme="dark"] .fav-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}
html[data-theme="dark"] .topic-toc {
  background: var(--bg-card);
  border-color: var(--border-default);
}
html[data-theme="dark"] .info-card {
  background: var(--bg-card);
  border-color: var(--border-default);
}
html[data-theme="dark"] .official-link-card {
  background: var(--bg-soft);
  border-color: var(--border-subtle);
}
html[data-theme="dark"] .vocab-game-promo {
  background: rgba(29, 111, 184, 0.06);
  border-color: rgba(29, 111, 184, 0.2);
}

/* ─── Mobile ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .topic-layout {
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 32px 0;
  }
  .topic-toc {
    position: static;
    max-height: none;
    order: -1;
  }
  .toc-list {
    display: none;
  }
  .topic-toc.is-expanded .toc-list {
    display: flex;
  }
}
@media (max-width: 768px) {
  .topic-hero { padding: 80px 0 32px; border-radius: 0 0 20px 20px; }
  .topic-title { font-size: 30px; }
  .topic-subtitle { font-size: 15px; }
  .topic-content h2 { font-size: 22px; }
  .topic-content h3 { font-size: 18px; }
  .vocab-game-promo {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }
  .vocab-game-promo__btn { align-self: stretch; justify-content: center; }
  .official-link-card { flex-direction: column; align-items: flex-start; }
}

/* Print styles */
@media print {
  .topic-toc, .back-home-btn, .fav-btn, .page-actions, .topic-bottom-section {
    display: none !important;
  }
  .topic-layout { display: block; }
  .topic-hero { background: #fff !important; color: #000 !important; padding: 0; }
  .topic-hero * { color: #000 !important; }
}
