/* ============================================================
   SPA Page View System
   ============================================================ */
.app-viewport {
  position: relative;
}
.page-view {
  display: none;
  animation: pageFadeIn 0.35s ease;
}
.page-view.active {
  display: block;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Topic Page Layout
   ============================================================ */
.topic-page {
  background: var(--bg-primary);
  min-height: calc(100vh - 68px);
  padding-top: 32px;
  padding-bottom: 64px;
}
.topic-container {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 48px;
  align-items: start;
}
.topic-content {
  min-width: 0;
}

/* Breadcrumb */
.topic-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.topic-breadcrumb a {
  color: var(--aussie-blue);
  transition: color 0.2s ease;
  text-decoration: none;
}
.topic-breadcrumb a:hover {
  color: var(--navy);
  text-decoration: underline;
}
.topic-breadcrumb .sep {
  color: var(--border-strong);
}
.topic-breadcrumb .current {
  color: var(--text-secondary);
  font-weight: 500;
}

/* Topic Hero Header */
.topic-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, var(--aussie-blue) 100%);
  border-radius: 20px;
  padding: 48px 48px 44px;
  color: #fff;
  margin-bottom: 36px;
  position: relative;
  overflow: hidden;
}
.topic-header::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(212,175,55,0.18) 0%, transparent 70%);
  border-radius: 50%;
}
.topic-header::after {
  content: '';
  position: absolute;
  bottom: -100px;
  right: 60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.06) 0%, transparent 70%);
  border-radius: 50%;
}
.topic-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(212,175,55,0.2);
  color: var(--gold-light);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
}
.topic-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}
.topic-subtitle {
  font-size: 15px;
  line-height: 1.7;
  color: rgba(255,255,255,0.75);
  max-width: 600px;
  position: relative;
  z-index: 1;
}
.topic-meta {
  display: flex;
  gap: 24px;
  margin-top: 24px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.topic-meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}
.topic-meta-item strong {
  color: #fff;
  font-weight: 600;
}
.back-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 20px;
}
.back-home-btn:hover {
  background: rgba(255,255,255,0.22);
  transform: translateX(-2px);
}

/* ============================================================
   Sidebar TOC (Table of Contents)
   ============================================================ */
.topic-toc {
  position: sticky;
  top: 92px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}
.toc-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-left: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.toc-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--gold);
  border-radius: 2px;
}
.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-list > li > a {
  display: block;
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.4;
  font-weight: 500;
  border-left: 2px solid transparent;
}
.toc-list > li > a:hover {
  color: var(--navy);
  background: var(--bg-soft);
}
.toc-list > li > a.active {
  color: var(--aussie-blue);
  background: rgba(29,111,184,0.06);
  border-left-color: var(--gold);
  font-weight: 600;
}
.toc-sub-list {
  list-style: none;
  margin: 2px 0 2px 14px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toc-sub-list a {
  display: block;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.15s ease;
}
.toc-sub-list a:hover {
  color: var(--text-secondary);
  background: var(--bg-soft);
}
.toc-sub-list a.active {
  color: var(--aussie-blue);
  font-weight: 600;
}

/* ============================================================
   Topic Content Typography
   ============================================================ */
.topic-section {
  margin-bottom: 40px;
  scroll-margin-top: 90px;
}
.topic-section h2 {
  font-family: 'Noto Serif SC', serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gold);
  display: flex;
  align-items: center;
  gap: 10px;
}
.topic-section h2::before {
  content: '';
  width: 5px;
  height: 24px;
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: 3px;
  flex-shrink: 0;
}
.topic-section h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin: 28px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topic-section h3::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  flex-shrink: 0;
}
.topic-section h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 20px 0 10px;
}
.topic-section p {
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.topic-section ul,
.topic-section ol {
  margin: 10px 0 16px;
  padding-left: 20px;
  font-size: 14.5px;
  line-height: 1.8;
  color: var(--text-secondary);
}
.topic-section ul li,
.topic-section ol li {
  margin-bottom: 6px;
}
.topic-section ul li::marker {
  color: var(--gold);
}
.topic-section strong {
  color: var(--navy);
  font-weight: 600;
}

/* Info Cards */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
}
.info-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  transition: all 0.2s ease;
}
.info-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 12px rgba(10,37,64,0.06);
  transform: translateY(-2px);
}
.info-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--aussie-blue), var(--aussie-blue-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.info-card h5 {
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}
.info-card p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}
.info-card .stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
  margin-bottom: 4px;
}
.info-card .stat-num .unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

/* Highlight / Alert Boxes */
.highlight-box {
  border-radius: 12px;
  padding: 18px 20px;
  margin: 16px 0 20px;
  font-size: 14px;
  line-height: 1.7;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.highlight-box .hb-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  margin-top: 2px;
}
.highlight-box .hb-content {
  flex: 1;
  min-width: 0;
}
.highlight-box .hb-title {
  font-weight: 700;
  margin-bottom: 4px;
  font-size: 14.5px;
}
.highlight-box.info {
  background: rgba(29,111,184,0.06);
  border: 1px solid rgba(29,111,184,0.15);
  color: var(--navy);
}
.highlight-box.info .hb-icon {
  background: var(--aussie-blue);
  color: #fff;
}
.highlight-box.warning {
  background: rgba(212,175,55,0.08);
  border: 1px solid rgba(212,175,55,0.25);
  color: var(--navy);
}
.highlight-box.warning .hb-icon {
  background: var(--gold);
  color: #fff;
}
.highlight-box.danger {
  background: rgba(220,53,69,0.06);
  border: 1px solid rgba(220,53,69,0.15);
  color: var(--navy);
}
.highlight-box.danger .hb-icon {
  background: #dc3545;
  color: #fff;
}
.highlight-box.success {
  background: rgba(31,138,91,0.06);
  border: 1px solid rgba(31,138,91,0.15);
  color: var(--navy);
}
.highlight-box.success .hb-icon {
  background: var(--success);
  color: #fff;
}

/* Comparison Tables */
.topic-table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.topic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: #fff;
}
.topic-table th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}
.topic-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  line-height: 1.5;
}
.topic-table tr:last-child td {
  border-bottom: none;
}
.topic-table tr:nth-child(even) td {
  background: var(--bg-soft);
}
.topic-table td.emphasis {
  color: var(--navy);
  font-weight: 600;
}
.topic-table td.gold {
  color: var(--gold-dark);
  font-weight: 600;
}

/* Score badge */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 2px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--navy);
}

/* FAQ blocks in topic page */
.topic-faq-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.topic-faq-item:hover {
  border-color: var(--border-strong);
}
.topic-faq-q {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topic-faq-q .faq-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.topic-faq-item.open .topic-faq-q .faq-icon {
  background: var(--aussie-blue);
  color: #fff;
  transform: rotate(180deg);
}
.topic-faq-a {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 18px;
}
.topic-faq-item.open .topic-faq-a {
  max-height: 500px;
  padding: 0 18px 16px;
}
.topic-faq-a p {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-secondary);
  margin: 0;
}

/* Bottom: official link + related topics */
.topic-bottom-section {
  margin-top: 48px;
  padding-top: 36px;
  border-top: 1px solid var(--border);
}
.official-link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  border-radius: 14px;
  padding: 24px 28px;
  color: #fff;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.official-link-card h4 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0 0 4px;
}
.official-link-card p {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  margin: 0;
}
.official-link-card .btn-official {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--gold);
  color: var(--navy);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.official-link-card .btn-official:hover {
  background: var(--gold-light);
  transform: translateX(2px);
}

.related-topics h3 {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
}
.related-topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.related-topic-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.related-topic-card:hover {
  border-color: var(--gold);
  box-shadow: 0 4px 16px rgba(212,175,55,0.12);
  transform: translateY(-2px);
}
.related-topic-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.related-topic-card h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 4px;
}
.related-topic-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ============================================================
   Nav Dropdown Menus
   ============================================================ */
.nav-links > li {
  position: relative;
}
.nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(10,37,64,0.12);
  padding: 8px;
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.18s ease;
  z-index: 200;
}
.nav-links > li:hover .nav-dropdown,
.nav-links > li:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.nav-dropdown a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.nav-dropdown a:hover {
  color: var(--navy);
  background: var(--bg-soft);
}
.nav-dropdown a .dd-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--bg-soft);
  color: var(--aussie-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
}
.nav-dropdown a:hover .dd-icon {
  background: rgba(29,111,184,0.1);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .topic-container {
    grid-template-columns: 1fr;
  }
  .topic-toc {
    display: none;
  }
  .topic-header {
    padding: 36px 28px;
  }
  .topic-title {
    font-size: 28px;
  }
}

@media (max-width: 640px) {
  .topic-page {
    padding-top: 20px;
  }
  .topic-header {
    padding: 28px 20px;
    border-radius: 14px;
  }
  .topic-title {
    font-size: 22px;
  }
  .topic-subtitle {
    font-size: 13.5px;
  }
  .topic-section h2 {
    font-size: 20px;
  }
  .topic-section h3 {
    font-size: 16px;
  }
  .info-grid {
    grid-template-columns: 1fr;
  }
  .topic-meta {
    gap: 14px;
  }
}

/* ============================================================
   SPA Page View Transitions
   ============================================================ */
#homeView.page-view {
  display: block;
}

#homeView.page-view.active {
  animation: fadeInPage 0.35s ease;
}

.topic-pages-root {
  animation: fadeInPage 0.35s ease;
}

@keyframes fadeInPage {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Official link pill inside topic detail - "view guide" variant */
.official-link-pill[data-topic-link] {
  background: var(--gold-light);
  color: var(--gold-dark);
  border-color: transparent;
}
.official-link-pill[data-topic-link]:hover {
  background: var(--gold);
  color: var(--navy);
}
