/* ============================================================
   Health Guide — disease-details.css
   Dedicated skin for pages/disease-details.html
   Depends on: css/design-system.css (hg-* tokens)
   Load order: design-system.css > site.css > disease-details.css
   RTL / Arabic-first (Cairo + Tajawal)
   ============================================================ */

/* ---------- 0. Page container ---------- */
main.main-content {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  padding: clamp(1rem, 3vw, 2rem);
  padding-bottom: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  animation: dd-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes dd-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 1. Show / hide logic (paired with inline JS) ---------- */
.disease-detail,
.error-message {
  display: none;
}

.disease-detail.active,
.error-message.active {
  display: block;
  animation: dd-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ---------- 2. Error state ---------- */
.error-message {
  background: var(--hg-card, #fff);
  border: 1px solid var(--hg-line-soft, #eef3f9);
  border-radius: var(--hg-r-lg, 22px);
  box-shadow: var(--hg-shadow-md, 0 10px 30px rgba(15,23,42,0.08));
  text-align: center;
  padding: clamp(2rem, 5vw, 3.5rem) clamp(1.25rem, 4vw, 2.5rem);
}

.error-message i.fa-exclamation-triangle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  font-size: 1.9rem;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 12px 30px rgba(239, 68, 68, 0.28);
  margin-bottom: 1.1rem;
}

.error-message h2 {
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  margin-bottom: 0.6rem;
}

.error-message p {
  max-width: 52ch;
  margin: 0 auto 1.5rem;
}

/* ---------- 3. Disease hero header ---------- */
.disease-detail {
  min-width: 0;
}

.disease-header {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  padding: clamp(1.75rem, 4vw, 2.75rem) clamp(1.25rem, 4vw, 2.25rem);
  color: #fff;
  background:
    radial-gradient(520px 220px at 88% -40px, rgba(255, 255, 255, 0.22), transparent 60%),
    radial-gradient(420px 200px at 8% 115%, rgba(45, 212, 191, 0.38), transparent 60%),
    linear-gradient(120deg, #1d4ed8 0%, #1e40af 52%, #0d9488 100%);
  box-shadow: 0 24px 60px rgba(29, 78, 216, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.22);
  text-align: center;
  margin-bottom: 1.5rem;
}

/* soft medical watermark */
.disease-header::after {
  content: "\f21e";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  left: -18px;
  bottom: -42px;
  font-size: 10rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.1);
  pointer-events: none;
  transform: rotate(-12deg);
}

.disease-header h1 {
  color: #fff !important;
  font-size: clamp(1.6rem, 4.5vw, 2.5rem);
  font-weight: 800;
  margin: 0.9rem 0 0.5rem;
  text-wrap: balance;
}

.disease-header p {
  color: rgba(255, 255, 255, 0.9) !important;
  font-size: clamp(0.98rem, 2.4vw, 1.12rem);
  max-width: 62ch;
  margin: 0 auto;
  line-height: 1.8;
}

.disease-category {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.32);
  padding: 0.38rem 1rem;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.disease-category::before {
  content: "\f02b";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.72rem;
  opacity: 0.9;
}

/* ---------- 4. Content grid (2x2: الأعراض بجانب الأسباب، الوقاية بجانب العلاج) ---------- */
.disease-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}

/* المقدمة (الأولى) والمصادر (الأخيرة) بعرض كامل */
.disease-content > .content-section:first-child,
.disease-content > .sources-section {
  grid-column: 1 / -1;
}

.content-section,
.sources-section {
  background: var(--hg-card, #fff);
  border: 1px solid var(--hg-line-soft, #eef3f9);
  border-radius: var(--hg-r-lg, 22px);
  box-shadow: var(--hg-shadow-sm, 0 4px 14px rgba(15,23,42,0.06));
  padding: clamp(1.15rem, 3vw, 1.75rem);
  transition: transform 0.28s cubic-bezier(0.22,1,0.36,1),
    box-shadow 0.28s cubic-bezier(0.22,1,0.36,1),
    border-color 0.28s;
}

.content-section:hover,
.sources-section:hover {
  transform: translateY(-4px);
  box-shadow: var(--hg-shadow-md, 0 10px 30px rgba(15,23,42,0.08));
  border-color: rgba(37, 99, 235, 0.22);
}

/* Section title with icon medallion */
.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  font-weight: 800;
  margin-bottom: 1rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--hg-line-soft, #eef3f9);
}

.section-title i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 13px;
  font-size: 1.05rem;
  color: #fff !important;
  background: linear-gradient(135deg, var(--hg-primary, #2563eb), var(--hg-teal, #0d9488));
  box-shadow: var(--hg-shadow-brand, 0 12px 30px rgba(37,99,235,0.28));
}

/* Color-code section icons by type (same blue→teal family) */
.content-section:has(.fa-stethoscope) .section-title i {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
}
.content-section:has(.fa-virus) .section-title i {
  background: linear-gradient(135deg, #0f766e, #14b8a6);
}
.content-section:has(.fa-shield-alt) .section-title i {
  background: linear-gradient(135deg, #0d9488, #2563eb);
}
.content-section:has(.fa-pills) .section-title i {
  background: linear-gradient(135deg, #1d4ed8, #0d9488);
}
.sources-section .section-title i {
  background: linear-gradient(135deg, #0b2a4a, #2563eb);
}

.section-content p {
  color: var(--hg-body, #334155) !important;
  font-size: 1.02rem;
  line-height: 1.9;
}

.section-content p:last-child {
  margin-bottom: 0;
}

/* ---------- 5. Medical lists ---------- */
.section-content ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.section-content ul li {
  position: relative;
  background: var(--hg-bg, #f4f8fc);
  border: 1px solid var(--hg-line-soft, #eef3f9);
  border-radius: 13px;
  padding: 0.7rem 1rem 0.7rem 1rem;
  padding-right: 2.9rem;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--hg-ink, #0f172a);
  line-height: 1.75;
  transition: border-color 0.25s, background 0.25s, transform 0.25s cubic-bezier(0.22,1,0.36,1);
}

[dir="rtl"] .section-content ul li {
  padding-right: 2.9rem;
  padding-left: 1rem;
}

.section-content ul li::before {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: 50%;
  right: 0.85rem;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 0.72rem;
  color: #fff;
  background: linear-gradient(135deg, var(--hg-primary, #2563eb), var(--hg-teal, #0d9488));
}

.section-content ul li:hover {
  background: #fff;
  border-color: rgba(37, 99, 235, 0.3);
  transform: translateX(-4px);
}

/* Treatment lists use pill icon instead of check */
.content-section:has(.fa-pills) ul li::before {
  content: "\f484";
}

/* ---------- 6. Sources ---------- */
.sources-section {
  border-style: dashed;
  background:
    radial-gradient(400px 160px at 90% 0%, rgba(37,99,235,0.07), transparent 60%),
    var(--hg-card, #fff);
}

.sources-section .section-content {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--hg-primary-dark, #1d4ed8) !important;
  background: rgba(37, 99, 235, 0.08);
  border: 1.5px solid rgba(37, 99, 235, 0.16);
  padding: 0.65rem 1.15rem;
  border-radius: 14px;
  transition: all 0.28s cubic-bezier(0.22,1,0.36,1);
}

.source-link i {
  font-size: 0.82rem;
  opacity: 0.8;
}

.source-link:hover {
  background: linear-gradient(135deg, var(--hg-primary, #2563eb), var(--hg-teal, #0d9488));
  border-color: transparent;
  color: #fff !important;
  transform: translateY(-2px);
  box-shadow: var(--hg-shadow-brand, 0 12px 30px rgba(37,99,235,0.28));
}

/* ---------- 7. Navigation buttons ---------- */
.navigation-buttons {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 0.4rem;
  padding-top: 0.4rem;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 50px;
  padding: 0.85rem 1.9rem;
  border-radius: 16px;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none !important;
  cursor: pointer;
  border: 0;
  transition: transform 0.28s cubic-bezier(0.22,1,0.36,1),
    box-shadow 0.28s, filter 0.28s;
}

.nav-btn.back {
  background: linear-gradient(135deg, var(--hg-primary, #2563eb) 0%, var(--hg-teal, #0d9488) 100%);
  color: #fff !important;
  box-shadow: var(--hg-shadow-brand, 0 12px 30px rgba(37,99,235,0.28));
}

.nav-btn.back:hover {
  transform: translateY(-3px);
  box-shadow: var(--hg-shadow-lg, 0 24px 60px rgba(15,23,42,0.14));
  filter: saturate(1.08);
  color: #fff !important;
}

.nav-btn.back:active {
  transform: translateY(-1px) scale(0.99);
}

/* RTL: arrow points right (back in RTL) — keep icon from jumping */
.nav-btn.back i {
  transition: transform 0.28s cubic-bezier(0.22,1,0.36,1);
}
.nav-btn.back:hover i {
  transform: translateX(4px);
}

/* ---------- 8. Inline-legacy overrides (page has some inline styles) ---------- */
.disease-detail .stats-container {
  border-radius: 18px !important;
  border: 1px solid var(--hg-line-soft, #eef3f9) !important;
}

.disease-detail a.source-link[style] {
  display: inline-flex !important;
  border-radius: 14px !important;
}

/* ---------- 9. Responsive ---------- */
@media (max-width: 768px) {
  .disease-content {
    grid-template-columns: 1fr;
  }
  main.main-content {
    padding: 0.9rem 0.85rem 6.5rem;
  }

  .disease-header {
    border-radius: 20px;
    margin-bottom: 1rem;
  }

  .disease-header::after {
    font-size: 7rem;
  }

  .content-section,
  .sources-section {
    border-radius: 18px;
    padding: 1.1rem;
  }

  .section-title {
    font-size: 1.08rem;
  }

  .section-title i {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
  }

  .section-content ul li {
    font-size: 0.94rem;
  }

  .sources-section .section-content {
    flex-direction: column;
    align-items: stretch;
  }

  .source-link {
    justify-content: center;
    width: 100%;
  }

  .navigation-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .disease-category {
    font-size: 0.76rem;
  }
  .section-content ul li {
    padding-right: 2.6rem;
  }
}

/* ---------- 10. Accessibility / print ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  .content-section,
  .sources-section {
    border-width: 2px;
  }
  .section-content ul li {
    border-width: 1.5px;
  }
}

@media print {
  .disease-header {
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #000;
    box-shadow: none;
  }
  .disease-header h1,
  .disease-header p {
    color: #000 !important;
  }
  .disease-header::after,
  .disease-category::before {
    display: none;
  }
  .disease-category {
    background: #fff;
    color: #000;
    border: 1px solid #000;
  }
  .content-section,
  .sources-section {
    box-shadow: none;
    break-inside: avoid;
    border: 1px solid #ccc;
  }
  .navigation-buttons,
  .mobile-nav {
    display: none !important;
  }
  .disease-detail {
    display: block !important;
  }
  .disease-detail:not(.active) {
    display: none !important;
  }
  a[href]::after {
    content: " [" attr(href) "]";
    font-size: 0.75em;
    color: #444;
  }
}
