/* ==========================================================================
   GFIS Study Materials — shared styles for generated chapter pages
   Used by study-materials/<class>-science/chapter-*/summary.html and
   question-bank.html, plus the per-class index pages.
   Generated pages link this file, so a style tweak here updates all chapters.
   ========================================================================== */

/* ---------- Shared shell ---------- */
.sm-wrap { max-width: 900px; margin: 0 auto; }

.sm-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; justify-content: center; }
.sm-chip {
  background: var(--primary-light, #E5F3EA); color: var(--primary-dark, #0F6E32);
  font-size: .78rem; font-weight: 700; border-radius: 14px; padding: 4px 14px;
}
.sm-chip--blue { background: var(--secondary-light, #E3F1FC); color: var(--secondary-dark, #004A99); }

/* ---------- Rendered markdown content ---------- */
.sm-content { font-size: .96rem; line-height: 1.75; color: var(--text, #16202c); }
.sm-content > p:first-child > strong:only-child { font-size: 1.05rem; color: var(--primary-dark, #0F6E32); }

.sm-content h1, .sm-content h2 {
  font-size: 1.28rem; color: var(--text-dark, #1a1a2e);
  border-bottom: 2px solid var(--primary, #15873F);
  padding-bottom: 8px; margin: 34px 0 16px;
}
.sm-content h3 {
  font-size: 1.1rem; color: var(--primary-dark, #0F6E32);
  margin: 26px 0 10px; padding-left: 12px;
  border-left: 4px solid var(--primary, #15873F);
}
.sm-content h4 { font-size: .98rem; color: var(--text-dark, #1a1a2e); margin: 20px 0 8px; }
.sm-content h1:first-child, .sm-content h2:first-child, .sm-content h3:first-child { margin-top: 0; }

.sm-content p { margin: 0 0 14px; }
.sm-content ul, .sm-content ol { padding-left: 24px; margin: 0 0 16px; }
.sm-content li { margin-bottom: 8px; }
.sm-content li > ul, .sm-content li > ol { margin-top: 8px; }
.sm-content strong { color: var(--primary-dark, #0F6E32); }
.sm-content em { color: #4b5563; }
.sm-content hr { border: 0; border-top: 1px solid var(--border, #e3e7ee); margin: 28px 0; }
.sm-content blockquote {
  margin: 0 0 16px; padding: 12px 16px;
  background: var(--bg-soft, #e9f1fa);
  border-left: 4px solid var(--primary, #15873F); border-radius: 0 8px 8px 0;
}
.sm-content code {
  background: #f3f4f6; border-radius: 4px; padding: 1px 6px;
  font-size: .9em; font-family: 'Consolas', 'Menlo', monospace;
}

/* Tables scroll sideways on small screens instead of breaking the layout */
.sm-table-wrap { overflow-x: auto; border: 1px solid #e5e7eb; border-radius: 10px; margin: 0 0 20px; }
.sm-content table { width: 100%; border-collapse: collapse; font-size: .88rem; background: #fff; min-width: 520px; }
.sm-content thead th {
  background: var(--primary, #15873F); color: #fff; text-align: left;
  padding: 10px 12px; font-size: .8rem; font-weight: 700;
}
.sm-content tbody td { padding: 10px 12px; border-top: 1px solid #eef0f2; vertical-align: top; line-height: 1.55; }
.sm-content tbody tr:nth-child(even) { background: #fafbfc; }

/* ---------- Answer key (collapsed so students attempt first) ---------- */
.qb-key { margin-top: 30px; border: 2px solid var(--primary, #15873F); border-radius: 14px; overflow: hidden; background: #fff; }
.qb-key > summary {
  cursor: pointer; list-style: none; padding: 18px 22px;
  background: var(--primary, #15873F); color: #fff;
  font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: 12px; user-select: none;
}
.qb-key > summary::-webkit-details-marker { display: none; }
.qb-key > summary .arrow { transition: transform .25s; font-size: .9rem; }
.qb-key[open] > summary .arrow { transform: rotate(90deg); }
.qb-key > summary .hint { font-weight: 400; font-size: .8rem; opacity: .88; margin-left: auto; text-align: right; }
.qb-key-body { padding: 22px; }

/* ---------- Chapter page navigation ---------- */
.sm-nav { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 34px; }
.sm-foot-note { text-align: center; color: var(--text-muted, #5b6472); font-size: .84rem; margin-top: 26px; line-height: 1.7; }

/* ---------- Per-class chapter index ---------- */
.ch-intro { text-align: center; max-width: 720px; margin: 0 auto 36px; }
.ch-intro p { color: var(--text-muted, #5b6472); line-height: 1.75; font-size: 1.02rem; }

.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.ch-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04); transition: box-shadow .2s, transform .15s;
}
.ch-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.08); transform: translateY(-2px); }
.ch-card-head { display: flex; align-items: flex-start; gap: 12px; }
.ch-num {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary, #15873F); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 1.05rem;
}
.ch-card h2 { margin: 0; font-size: 1.02rem; line-height: 1.35; color: var(--text-dark, #1a1a2e); align-self: center; }
.ch-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.ch-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; border-radius: 999px; font-size: .84rem; font-weight: 700;
  background: var(--primary, #15873F); color: #fff !important;
  text-decoration: none !important; box-shadow: 0 2px 8px rgba(21,135,63,.25);
  transition: background .15s, transform .15s;
}
.ch-link:hover { background: var(--primary-dark, #0F6E32); transform: translateY(-1px); }
.ch-link--ghost {
  background: transparent; color: var(--primary, #15873F) !important;
  border: 1.5px solid var(--primary, #15873F); box-shadow: none;
}
.ch-link--ghost:hover { background: var(--primary, #15873F); color: #fff !important; }
.ch-note { text-align: center; color: var(--text-muted, #5b6472); font-size: .84rem; margin-top: 34px; line-height: 1.7; }

/* ---------- Chapter search (hub page) ---------- */
.sm-search { max-width: 720px; margin: 0 auto 40px; }
.sm-search-label {
  display: block; text-align: center; font-size: .82rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--primary-dark, #0F6E32); margin-bottom: 10px;
}
.sm-search-box { position: relative; display: flex; align-items: center; }
.sm-search-box svg {
  position: absolute; left: 16px; width: 18px; height: 18px;
  color: #9ca3af; pointer-events: none;
}
.sm-search-box input {
  width: 100%; padding: 13px 44px 13px 46px;
  border: 1.5px solid #d1d5db; border-radius: 999px;
  font-size: 1rem; font-family: inherit; outline: none; background: #fff;
  transition: border-color .2s, box-shadow .2s;
}
.sm-search-box input:focus {
  border-color: var(--primary, #15873F);
  box-shadow: 0 0 0 3px rgba(21, 135, 63, .15);
}
.sm-search-box input::-webkit-search-cancel-button { display: none; }
#smSearchClear {
  position: absolute; right: 12px; width: 28px; height: 28px;
  border: 0; border-radius: 50%; background: #e5e7eb; color: #4b5563;
  font-size: 18px; line-height: 1; cursor: pointer;
}
#smSearchClear:hover { background: #d1d5db; }
.sm-search-count {
  text-align: center; font-size: .85rem; color: var(--text-muted, #5b6472);
  margin: 12px 0 0; min-height: 1.2em;
}
.sm-results { margin-top: 18px; display: grid; gap: 12px; }
.sm-result {
  background: #fff; border: 1px solid #e5e7eb; border-left: 4px solid var(--primary, #15873F);
  border-radius: 10px; padding: 14px 18px;
}
.sm-result-meta {
  font-size: .74rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--secondary-dark, #004A99);
}
.sm-result h3 { margin: 4px 0 10px; font-size: 1.05rem; color: var(--text-dark, #1a1a2e); }
.sm-noresult {
  text-align: center; color: var(--text-muted, #5b6472);
  font-size: .9rem; line-height: 1.6; padding: 8px 0;
}
@media (max-width: 640px) {
  .sm-search-box input { font-size: 16px; }   /* 16px stops iOS zooming on focus */
}

/* ---------- Study Materials hub (all classes / subjects) ---------- */
.hub-grade { margin-bottom: 40px; }
.hub-grade-head {
  font-size: 1.25rem; color: var(--text-dark, #1a1a2e);
  border-bottom: 2px solid var(--primary, #15873F);
  padding-bottom: 8px; margin: 0 0 18px;
}
.hub-count { margin: 0; font-size: .84rem; color: var(--text-muted, #5b6472); }

@media (max-width: 640px) {
  .sm-content h1, .sm-content h2 { font-size: 1.14rem; }
  .sm-content h3 { font-size: 1.02rem; }
  .qb-key > summary { padding: 14px 16px; font-size: .95rem; }
  .qb-key > summary .hint { display: none; }
  .qb-key-body { padding: 16px; }
  .ch-grid { grid-template-columns: 1fr; }
}
