/* ============================================================
   Shared subject hub and topic-list styling.
   ============================================================ */

/* ── Subject hub shell ───────────────────────────────────── */
body.subject-shell {
  margin: 0;
  width: auto;
  max-width: none;
  padding-top: 70px;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(180deg, #dde8ff 0%, #f1f5f9 300px, #f1f5f9 100%);
  color: #1e293b;
  transition: background-color 0.3s, color 0.3s;
}

body.topic-list {
  width: auto !important;
  max-width: none !important;
  margin: 0 !important;
}

body.dark-mode.subject-shell {
  background: linear-gradient(180deg, #0e1a2e 0%, #0f1117 280px, #0f1117 100%);
  color: #e8edf5;
}

/* Hub page title */
body.subject-shell main h1 {
  font-size: clamp(28px, 2.8vw, 40px);
  font-weight: 800;
  color: #18398a;
  margin: 0 0 6px;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

body.dark-mode.subject-shell main h1 {
  color: #93c5fd;
}

/* ── Main content wrapper ────────────────────────────────── */
body.topic-list main,
body.subject-shell main {
  width: min(1180px, calc(100% - 48px));
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 0 52px;
}

body.topic-list main {
  background: transparent !important;
}

body.dark-mode.topic-list main {
  background: transparent !important;
}

/* ── Topic list headings ─────────────────────────────────── */
body.topic-list main h1,
body.topic-list main h2 {
  color: #18398a;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

body.topic-list main h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 2.6vw, 38px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

body.topic-list main > p {
  margin: 0 0 6px;
  color: #18398a;
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 700;
  line-height: 1.15;
}

/* Section sub-heading — clean left-border style */
body.topic-list main h2 {
  display: block !important;
  font-size: clamp(17px, 1.6vw, 22px) !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  padding: 10px 16px !important;
  margin: 0 0 14px !important;
  background: #eff6ff !important;
  border-left: 4px solid #18398a !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-radius: 0 8px 8px 0 !important;
  box-shadow: none !important;
  transform: none !important;
  color: #18398a !important;
  width: auto !important;
  max-width: 100% !important;
}

/* ── Topic list items ────────────────────────────────────── */
body.topic-list main ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: block;   /* block, not flex — prevents auto-margin shrinkage on li */
}

body.topic-list main li {
  /* reset inline-style overrides that stagger widths */
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 0 8px !important;
  padding: 0 !important;
  box-sizing: border-box !important;

  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #18398a;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-left-color 0.2s;
  position: relative;
  overflow: hidden;
}

body.topic-list main li::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(37, 99, 235, 0.07) 0%, transparent 55%);
  opacity: 0;
  transition: opacity 0.22s;
  pointer-events: none;
  z-index: 0;
}

body.topic-list main li:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(24, 57, 138, 0.13);
  border-left-color: #2563eb;
}

body.topic-list main li:hover::before {
  opacity: 1;
}

body.topic-list main li a {
  display: block;
  padding: 13px 18px;
  text-decoration: none;
  color: #18398a;
  font-weight: 600;
  font-size: clamp(14px, 1vw, 16px);
  line-height: 1.35;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  transition: color 0.15s;
  position: relative;
  z-index: 1;
}

body.topic-list main li a:hover {
  color: #2563eb;
  text-decoration: none;
}

/* ── Subject cards grid (hub pages) ─────────────────────── */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 24px 0;
}

.subject-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: box-shadow 0.22s, transform 0.22s, border-color 0.22s;
  position: relative;
  overflow: hidden;
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #18398a 0%, #2563eb 100%);
}

.subject-card:hover {
  transform: translateY(-7px);
  box-shadow: 0 18px 40px rgba(24, 57, 138, 0.20);
  border-color: #c0d0f5;
}

.subject-card img {
  max-width: 100%;
  border-radius: 8px;
}

.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #18398a 0%, #1d4699 100%);
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  margin-top: auto;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
  box-shadow: 0 3px 10px rgba(24, 57, 138, 0.30);
}

.card-btn:hover {
  background: linear-gradient(135deg, #0e2a6d 0%, #18398a 100%);
  text-decoration: none;
  color: #fff;
  box-shadow: 0 6px 20px rgba(24, 57, 138, 0.42);
  transform: translateY(-1px);
}

/* ── Fun fact callout ────────────────────────────────────── */
.fun-fact {
  background-color: #eff6ff;
  margin: 24px 0;
  padding: 14px 18px;
  border-left: 4px solid #2563eb;
  border-radius: 0 8px 8px 0;
  font-size: 15px;
  color: #1e3a8a;
  line-height: 1.65;
}

/* ── Dark mode ───────────────────────────────────────────── */
body.dark-mode.topic-list main h1,
body.dark-mode.topic-list main h2 {
  color: #93c5fd !important;
}

body.dark-mode.topic-list main h2 {
  background: #1e2d4a !important;
  border-left-color: #60a5fa !important;
  color: #93c5fd !important;
}

body.dark-mode.topic-list main li {
  background-color: #1a1f2e !important;
  border-color: #2b3650 !important;
  border-left-color: #3b82f6 !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22) !important;
}

body.dark-mode.topic-list main li:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32) !important;
  border-left-color: #60a5fa !important;
}

body.dark-mode.topic-list main li a {
  color: #93c5fd;
}

body.dark-mode.topic-list main li a:hover {
  color: #bfdbfe;
}

body.dark-mode .subject-card {
  background-color: #1a1f2e;
  border-color: #2b3650;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  color: #e8edf5;
}

body.dark-mode .subject-card::before {
  background: linear-gradient(90deg, #3b63cc 0%, #4d7ef7 100%);
}

body.dark-mode .subject-card:hover {
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.48);
  border-color: #3a4e7a;
}

body.dark-mode .card-btn {
  background-color: #2548b0;
  color: #fff;
}

body.dark-mode .card-btn:hover {
  background-color: #1e3a8a;
}

body.dark-mode .fun-fact {
  background-color: #1a2540;
  border-left-color: #60a5fa;
  color: #93c5fd;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  body.topic-list main,
  body.subject-shell main {
    width: calc(100% - 24px);
    padding: 20px 0 32px;
  }

  body.topic-list main h2 {
    padding: 9px 14px;
    margin: 24px 0 12px;
    font-size: 16px;
  }

  body.topic-list main li a {
    padding: 12px 14px;
    font-size: 14px;
  }

  .subject-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    padding: 16px 0;
  }
}
