/* =========================================================
   BLOG LIFECODE — KHUSUS BLOG (TAK USIK HEADER/NAV/FOOTER)
   Reka ikut gaya index.html + stylespage.css
   Device sasaran:
   - iPhone SE (~375x667)
   - iPhone 16 Pro (tinggi notch / safe area)
   - iPad 11" (~834–1194)
   - Laptop (≥1280)
   - Monitor besar (≥1536)
   ========================================================= */

/* ---- Variabel KHUSUS blog (jangan ubah --header-h dari stylespage.css) ---- */
:root {
  --content-gap: 16px; /* jarak antara kolum */
  --text-max: 90ch; /* lebar bacaan selesa */
  --sidebar-w: 28%; /* 25%–30% ikut citarasa */
  /* colors */
  --brand: #1565c0;
  --brand-dark: #0d47a1;
  --ink: #1a1a1a;
  --meta: #555;
  --card: #f9f9f9;
  --muted: #f0f0f0;
}

/* ---- Tajuk/Hero Blog ---- */
.blog-title {
  width: 100%;
  position: relative;
  background-color: #1565c0;
  min-height: svh;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 4px rgba(0, 0, 0, 0.2);
  padding: 24px;
}
.blog-title h1 {
  color: #fff;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  font-size: clamp(1.6rem, 2vw + 1rem, 2.2rem);
  line-height: 1.25;
}

/* ---- Zon 2-kolum: artikel + sidebar ---- */
section:not(.blog-title) {
  display: flex;
  align-items: flex-start;
  gap: var(--content-gap);
  margin: 12px 20px 24px;
}

/* ---- Artikel (kiri) ---- */
.info {
  flex: 1 1 auto;
  min-width: 0; /* elak overflow pada flex item */
  background: #f9f9f9;
  padding: clamp(16px, 1.5vw + 8px, 24px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  max-width: 100%;
}
.info .post-content {
  max-width: var(--text-max);
}

/* Tajuk pos + meta */
.post-title,
.info > h4 {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  font-size: clamp(2rem, 2vw + 1.2rem, 2.8rem);
  line-height: 1.25;
  font-weight: 800;
  margin: 0 0 0.75rem 0;
}
.info > p {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: clamp(0.98rem, 0.25vw + 0.9rem, 1.05rem);
  color: #555;
  margin: 0 0 0.25rem 0;
}
.info > p + p {
  margin-bottom: 0.9rem;
}

/* Kandungan artikel */
.post-content p {
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: clamp(1.05rem, 1.2vw + 0.6rem, 1.25rem);
  line-height: 1.85;
  letter-spacing: 0.01em;
  margin: 0 0 1rem 0;
  color: #1a1a1a;
}
.post-content h2 {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  font-size: clamp(1.4rem, 1.2vw + 1rem, 1.75rem);
  margin: 1.2rem 0 0.6rem;
  color: #0b2072;
}
.post-content h3 {
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  font-size: clamp(1.2rem, 1vw + 0.8rem, 1.4rem);
  margin: 1rem 0 0.4rem;
  color: #0b2072;
}
.post-content strong {
  font-weight: 700;
}

/* Gaya “Daftar istilah” */
.post-content p strong {
  display: block;
  margin-left: 20px; /* “ketengah” sedikit seperti permintaan */
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.post-content ul {
  margin-left: 40px;
  padding-left: 0;
}
.post-content ul li {
  margin-bottom: 0.4rem;
}

/* Gambar dalam artikel */
.blog-image {
  text-align: center;
  margin: 1rem 0;
}
.blog-image img {
  max-width: 300px;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* ----DAFTAR ISTILAH -lebih kecil dari teks cerita -- */
.glossary {
  margin: 0.25rem 0 1rem 28px;
  padding-left: 0;
}

/* Lebih kecil daripada post-content p (=1.05 - 1.25rem) */
.glossary li {
  font-size: clamp(0.92rem, 0.3vw + 0.82rem, 1.02rem);
  line-height: 1.6;
  color: #0b2072;
}

.glossary li + li {
  margin-top: 0.35rem;
}

.glossary li strong {
  font-size: 1em;
  font-weight: 650;
}

@media (max-width: 390px) {
  .glossary {
    margin-left: 22px;
  }
  .glossary {
    font-size: 0.9rem;
    line-height: 1.55;
  }
}

/* ---- Sidebar (kanan) ---- */
aside {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  max-width: 30%;
  min-width: 25%;
  background: #f0f0f0;
  padding: clamp(14px, 1.4vw + 6px, 20px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  align-self: stretch;
}
aside ul {
  margin: 0;
  padding: 0;
}
aside li {
  list-style: none;
}
aside a {
  display: block;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: #1565c0;
  text-decoration: none; /* buang underline */
  margin-bottom: 0.6rem;
  transition: color 0.3s ease, transform 0.2s ease;
}
aside a:hover {
  color: #0d47a1;
  transform: translateX(3px);
}

/* =========================================================
   RESPONSIF — susun ikut breakpoints stylepage.css & keperluan blog
   (Header fixed & padding-top ditentukan dalam stylespage.css)
   ========================================================= */

/* ≥1536px — Monitor besar: longgarkan grid & tambah max-width kandungan */
@media (min-width: 1536px) {
  :root {
    --content-gap: 20px;
  }
  section:not(.blog-title) {
    margin: 16px auto 28px;
    max-width: 1400px;
  }
  .info .post-content {
    max-width: 95ch;
  }
  aside {
    max-width: 28%;
  }
}

/* 1280px–1535px — Laptop biasa/monitor sederhana */
@media (min-width: 1280px) and (max-width: 1535px) {
  section:not(.blog-title) {
    margin: 14px auto 24px;
    max-width: 1200px;
  }
}

/* ≤1280px — Laptop kecil / iPad bersauh: rapatkan sedikit gap */
@media (max-width: 1280px) {
  :root {
    --content-gap: 14px;
  }
}

/* ≤1024px — iPad 11": kekalkan 2 kolum, tapi beri ruang tepi lebih kecil */
@media (max-width: 1024px) {
  section:not(.blog-title) {
    margin: 10px 16px 20px;
    gap: var(--content-gap);
  }
  .post-content p {
    line-height: 1.9;
  }
}

/* ≤860px — Tablet menegak / telefon besar: stack jadi 1 kolum */
@media (max-width: 860px) {
  section:not(.blog-title) {
    flex-direction: column;
  }
  aside {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    order: -1; /* sidebar selepas artikel */
  }
  .info {
    order: 2;
  }
}

/* ≤640px — Telefon umum (termasuk iPhone 16 Pro dalam mod biasa) */
@media (max-width: 640px) {
  .blog-title {
    min-height: 24svh;
    margin: 0 0 10px;
    padding: 18px;
  }
  .post-content p {
    font-size: clamp(1rem, 1.2vw + 0.92rem, 1.18rem);
    line-height: 1.9;
  }
  /* elak kandungan tertindih header fixed (nilai --header-h datang dari stylespage.css) */
  body {
    padding-top: var(--header-h);
  } /* rujuk stylespage.css untuk min-height header */
}

/* ≤390px — iPhone SE: ketatkan tipografi & padding */
@media (max-width: 390px) {
  section:not(.blog-title) {
    margin: 8px 12px 18px;
  }
  .info,
  aside {
    padding: 14px;
    border-radius: 10px;
  }
  .post-title,
  .info > h4 {
    font-size: clamp(1.5rem, 3.8vw + 0.8rem, 1.8rem);
  }
  aside a {
    font-size: 1.05rem;
  }
}

/* Ketinggian kecil (telefon ber-“Dynamic Island”/home indicator) */
@media (max-height: 740px) {
  .blog-title {
    min-height: 22svh;
    padding: 16px;
  }
}

/* Intro ringkas di bawah tajuk "Kisah Perubatan" */
/* Intro teks di bawah tajuk besar */
.blog-title-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.page-intro {
  max-width: 70ch;
  margin-top: 0.75rem;
  font-size: clamp(1rem, 0.4vw + 0.98rem, 1.15rem);
  line-height: 1.7;
  color: #f0f4ff; /* putih kebiruan untuk kontras atas latar biru */
  text-align: center;
  font-style: italic;
}

/* kecilkan margin pada skrin kecil */
@media (max-width: 640px) {
  .page-intro {
    margin-bottom: 1rem;
  }
}

/* =========================
   6) BACK-TO-TOP BUTTON
   ========================= */
#backToTop {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 4000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 0;
  border-radius: 20px;
  font-size: 1rem;
  cursor: pointer;
  background-color: var(--brand);
  color: #fff;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}
#backToTop.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
#backToTop:hover {
  background-color: var(--brand-dark);
  transform: translateY(0) scale(1.05);
}
@media (max-width: 480px) {
  #backToTop {
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    right: 16px;
    font-size: 0.95rem;
    padding: 8px 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  #backToTop {
    transition: none;
  }
}
