/* Item 20: standalone page for each topic (dist/topics/<id>/) and the topics index. */
.topic-page .brand,
.topic-page .main-nav a { color: inherit; text-decoration: none; }
.topic-page .main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .86rem;
  font-weight: 600;
  transition: background .18s ease;
}
.topic-page .main-nav a:hover { background: rgba(255, 255, 255, .08); }

.topic { padding-block: 48px 70px; }
.topic-head { max-width: 900px; margin-block-end: 32px; }
.topic-head h1 {
  margin: 10px 0 8px;
  color: var(--ink);
  font-family: "Noto Kufi Arabic", sans-serif;
  font-size: clamp(1.45rem, 3.2vw, 2.15rem);
  line-height: 1.7;
}
.topic-subtitle { margin: 0 0 14px; color: var(--ink-soft); font-size: 1.02rem; }
.topic-open {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px;
  background: #fff;
  color: var(--teal-dark);
  font-weight: 600;
  text-decoration: none;
}
.topic-open:hover { border-color: var(--teal-dark); }

.topic-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-block-end: 38px;
}
.topic-gallery figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.topic-gallery a {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: var(--paper-2);
}
/* Small pictures are not stretched to fill the frame (item 16). */
.topic-gallery img { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.topic-gallery figcaption { padding: 8px 12px 10px; color: var(--ink-soft); font-size: .82rem; line-height: 1.7; }

.topic-text { max-width: 860px; margin-block-end: 34px; }
.topic-text h2 {
  margin: 28px 0 10px;
  color: var(--teal-dark);
  font-size: 1.15rem;
  line-height: 1.8;
}
.topic-text p { margin: 0 0 12px; font-size: 1rem; line-height: 2.05; }

.topic-related h2 { font-size: 1.05rem; margin: 0 0 10px; }
.topic-related ul,
.topics-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.topic-related ul { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); margin-block-end: 28px; }
.topic-related a,
.topics-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transition: border-color .18s ease, transform .18s ease;
}
.topic-related a:hover,
.topics-list a:hover { border-color: var(--teal); transform: translateY(-1px); }

.topics-group { margin: 30px 0 12px; color: var(--teal-dark); font-size: 1.1rem; }
.topics-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.topics-list__media {
  width: 76px;
  aspect-ratio: 4 / 3;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--paper-2);
}
.topics-list__media img { width: auto; height: auto; max-width: 100%; max-height: 100%; }

@media (max-width: 760px) {
  .topic { padding-block: 30px 60px; }
  .topic-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .topic-gallery figcaption { font-size: .74rem; padding: 6px 8px 8px; }
  .topic-text p { font-size: .95rem; }
  .topics-list { grid-template-columns: 1fr; }
}

/* 3 Nov 2026: section headings by kind (medical errors red, complications and correct treatment blue). */
.topic-text h2.heading--error { color: #c62828; }
.topic-text h2.heading--complication,
.topic-text h2.heading--treatment { color: #00548c; }
