/**
 * Booktoan Pro — Sách Toán CSS
 * Mô phỏng giao diện Astro /sachtoan
 * Áp dụng cho: page-sachtoan.php và page-baitoan.php
 */

/* ================================================================
   VARIABLES
   ================================================================ */
:root {
  --st-sidebar-w:        260px;
  --st-nav-h:            56px;         /* chiều cao fixed nav */
  --st-sidebar-bg:       #ffffff;
  --st-sidebar-border:   #e5e7eb;
  --st-chapter-color:    #065f46;      /* xanh lá đậm - chương */
  --st-active-color:     #1565c0;      /* xanh blue - bài đang xem */
  --st-lesson-link:      #2563eb;      /* xanh blue - link bài học */
  --st-hero-default-bg:  #064e3b;      /* xanh đậm mặc định */

  /* Callout */
  --st-c-def-bg:     #eff6ff;   --st-c-def-border:    #3b82f6;  --st-c-def-head:  rgba(59,130,246,.12);
  --st-c-ex-bg:      #f5f3ff;   --st-c-ex-border:     #8b5cf6;  --st-c-ex-head:   rgba(139,92,246,.12);
  --st-c-sol-bg:     #f0fdf4;   --st-c-sol-border:    #10b981;  --st-c-sol-head:  rgba(16,185,129,.12);
  --st-c-method-bg:  #fff7ed;   --st-c-method-border: #f97316;  --st-c-method-head:rgba(249,115,22,.12);
  --st-c-note-bg:    #fefce8;   --st-c-note-border:   #eab308;  --st-c-note-head: rgba(234,179,8,.12);
  --st-c-warn-bg:    #fff1f2;   --st-c-warn-border:   #f43f5e;  --st-c-warn-head: rgba(244,63,94,.12);
}

/* ================================================================
   RESET cho entry khi dùng st-wrap
   ================================================================ */
.page-template-page-templates-page-sachtoan .entry,
.page-template-page-templates-page-baitoan .entry {
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
  transform: none !important;
}

.page-template-page-templates-page-sachtoan .site-inner,
.page-template-page-templates-page-baitoan .site-inner {
  padding-top: var(--st-nav-h) !important;
  max-width: 100% !important;
}

/* ================================================================
   LAYOUT: 2 CỘT
   ================================================================ */
.st-wrap {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--st-nav-h));
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.st-sidebar {
  width: var(--st-sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: var(--st-nav-h);
  height: calc(100vh - var(--st-nav-h));
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--st-sidebar-bg);
  border-right: 1px solid var(--st-sidebar-border);
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

.st-sidebar::-webkit-scrollbar        { width: 4px; }
.st-sidebar::-webkit-scrollbar-track  { background: transparent; }
.st-sidebar::-webkit-scrollbar-thumb  { background: #d1d5db; border-radius: 4px; }

/* Sidebar header */
.st-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--st-sidebar-border);
  position: sticky;
  top: 0;
  background: var(--st-sidebar-bg);
  z-index: 2;
}

.st-sidebar-book-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
  color: #111 !important;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
}

.st-sidebar-book-icon { font-size: 20px; flex-shrink: 0; }
.st-sidebar-book-name { color: #111 !important; }

/* Nav */
.st-sidebar-nav { padding: 6px 0 40px; }

.st-sidebar-section {
  border-bottom: 1px solid rgba(0,0,0,.04);
}

/* Chapter row */
.st-sidebar-chapter-row {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 4px;
}

.st-sidebar-chapter-link {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--st-chapter-color) !important;
  text-decoration: none !important;
  line-height: 1.4;
  transition: opacity 0.15s;
}

.st-sidebar-chapter-link:hover { opacity: 0.75; }
.st-sidebar-chapter-link.active { color: var(--st-active-color) !important; }

/* Toggle arrow button — reset tất cả global button overrides từ modern-effects.css */
.st-wrap .st-sidebar-toggle,
.st-wrap .st-sidebar-toggle:focus,
.st-wrap .st-sidebar-toggle:hover,
.st-wrap .st-sidebar-toggle:active {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px !important;
  height: 24px !important;
  padding: 0 !important;
  background: transparent !important;
  background-image: none !important;
  border: none !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  cursor: pointer;
  color: #9ca3af !important;
  transform: none !important;
  flex-shrink: 0;
  font-size: inherit !important;
  font-weight: inherit !important;
  letter-spacing: 0 !important;
  text-transform: none !important;
  opacity: 1 !important;
  transition: color 0.15s, background 0.15s !important;
  line-height: 1 !important;
}
.st-wrap .st-sidebar-toggle:hover {
  color: #374151 !important;
  background: #f3f4f6 !important;
}

.st-sidebar-toggle svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
  pointer-events: none;
}

.st-sidebar-section.is-open .st-sidebar-toggle svg {
  transform: rotate(180deg);
}

/* Lessons list */
.st-sidebar-lessons {
  display: none;
  list-style: none !important;
  margin: 0 !important;
  padding: 2px 8px 8px 24px !important;
}

.st-sidebar-lessons.is-visible { display: block; }

.st-sidebar-lesson-item {
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.st-sidebar-lesson-item a {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: #374151 !important;
  text-decoration: none !important;
  border-radius: 6px;
  line-height: 1.4;
  transition: background 0.12s, color 0.12s;
}

.st-sidebar-lesson-item a::before {
  content: '•';
  color: #d1d5db;
  flex-shrink: 0;
  font-size: 10px;
  margin-top: 2px;
}

.st-sidebar-lesson-item a:hover {
  background: #f0fdf4;
  color: #065f46 !important;
}
.st-sidebar-lesson-item a:hover::before { color: #10b981; }

.st-sidebar-lesson-item.active > a {
  background: #eff6ff;
  color: var(--st-active-color) !important;
  font-weight: 600;
}
.st-sidebar-lesson-item.active > a::before { color: var(--st-active-color); }

/* ================================================================
   MAIN CONTENT AREA
   ================================================================ */
.st-main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

/* ================================================================
   HERO SECTION
   ================================================================ */
.st-hero {
  background-color: var(--st-hero-default-bg);
  padding: 48px 40px 56px;
  overflow: hidden;
  position: relative;
}

.st-hero-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  max-width: 900px;
}

.st-hero-content { flex: 1; }

.st-hero-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.6);
  margin: 0 0 10px;
}

.st-hero-title {
  font-size: clamp(28px, 5vw, 52px) !important;
  font-weight: 800 !important;
  color: #fff !important;
  margin: 0 0 16px !important;
  line-height: 1.1 !important;
  letter-spacing: -0.025em !important;
}

.st-hero-desc {
  font-size: 15px;
  color: rgba(255,255,255,.75);
  line-height: 1.7;
  margin: 0 0 24px;
  max-width: 520px;
}

.st-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.st-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 9999px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.st-hero-deco {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  opacity: 0.7;
}
.st-hero-deco svg { width: 100%; height: 100%; }

/* ================================================================
   SECTION WRAPPER
   ================================================================ */
.st-section { padding: 36px 40px; }

.st-section-heading {
  font-size: 20px !important;
  font-weight: 700 !important;
  color: #111 !important;
  margin: 0 0 24px !important;
  padding-bottom: 12px;
  border-bottom: 2px solid #e5e7eb;
}

/* ================================================================
   CHAPTER GRID & CARDS
   ================================================================ */
.st-chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.st-chapter-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px 22px;
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
}

.st-chapter-card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,.1);
  transform: translateY(-3px);
}

.st-chapter-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.st-chapter-card__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--st-chapter-color);
}

.st-chapter-card__emoji { font-size: 18px; }

.st-chapter-card__title {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: #111 !important;
  margin: 0 0 8px !important;
  line-height: 1.4 !important;
}

.st-chapter-card__title a {
  color: #111 !important;
  text-decoration: none !important;
}
.st-chapter-card__title a:hover { color: var(--st-chapter-color) !important; }

.st-chapter-card__desc {
  font-size: 12.5px;
  color: #6b7280;
  margin: 0 0 12px;
  line-height: 1.5;
}

.st-chapter-card__lessons {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border-top: 1px solid #f0f0f0;
  padding-top: 10px !important;
}

.st-chapter-card__lessons li {
  border: none !important;
  padding: 2px 0 !important;
  margin: 0 !important;
}

.st-chapter-card__lessons li a {
  font-size: 13px;
  color: var(--st-lesson-link) !important;
  text-decoration: none !important;
  display: block;
  padding: 2px 0;
  line-height: 1.5;
}
.st-chapter-card__lessons li a:hover { text-decoration: underline !important; }

/* ================================================================
   LESSON PAGE
   ================================================================ */
.st-lesson {
  max-width: 820px;
  padding: 32px 40px 80px;
}

/* Breadcrumb */
.st-breadcrumb { margin-bottom: 20px; }

.st-bc-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  gap: 0;
  font-size: 13px;
  color: #9ca3af;
}
.st-bc-list li {
  display: flex;
  align-items: center;
  border: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.st-bc-list li + li::before { content: ' › '; margin: 0 5px; color: #d1d5db; }
.st-bc-list a { color: #6b7280 !important; text-decoration: none !important; }
.st-bc-list a:hover { color: var(--st-chapter-color) !important; }
.st-bc-list li:last-child { color: #374151; font-weight: 500; }

/* Lesson header */
.st-lesson-header {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e5e7eb;
}

.st-lesson-title {
  font-size: clamp(22px, 4vw, 34px) !important;
  font-weight: 800 !important;
  color: #111 !important;
  line-height: 1.2 !important;
  margin: 0 0 10px !important;
}

.st-lesson-meta { display: flex; align-items: center; gap: 10px; }

.st-lesson-meta__chapter a {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--st-chapter-color) !important;
  text-decoration: none !important;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 9999px;
  padding: 3px 12px;
}
.st-lesson-meta__chapter a:hover { background: #dcfce7; }

/* Lesson content (MathJax render từ Genesis) */
.st-lesson-content {
  font-family: 'STIX Two Text', 'Times New Roman', Georgia, serif !important;
  font-size: 17px;
  line-height: 1.9;
  color: #111;
}

.st-lesson-content h2 {
  font-family: 'Be Vietnam Pro', sans-serif !important;
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 700;
  color: #111 !important;
  margin: 44px 0 16px;
  padding-left: 14px;
  border-left: 4px solid var(--st-active-color);
}

.st-lesson-content h3 {
  font-family: 'Be Vietnam Pro', sans-serif !important;
  font-size: clamp(15px, 2.5vw, 18px);
  font-weight: 600;
  color: #1e3a5f !important;
  background: #f0f9ff;
  padding: 10px 16px;
  border-radius: 8px;
  border-left: 3px solid #38bdf8;
  margin: 32px 0 14px;
}

.st-lesson-content p { margin-bottom: 20px; }

/* MathJax override — không co chữ */
.st-lesson-content mjx-container { font-size: 1.05em !important; }

/* ================================================================
   CALLOUT BOXES
   ================================================================ */
.st-callout {
  border-radius: 10px;
  margin: 24px 0;
  border: 1px solid transparent;
  overflow: hidden;
}

.st-callout__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: default;
}

.st-callout__icon  { font-size: 16px; flex-shrink: 0; }
.st-callout__title { flex: 1; }
.st-callout__arrow { font-size: 10px; color: #6b7280; transition: transform 0.2s; }
details.st-callout[open] .st-callout__arrow { transform: rotate(90deg); }

.st-callout__body {
  padding: 14px 20px 18px;
  font-size: 16px;
  line-height: 1.8;
}
.st-callout__body > *:last-child { margin-bottom: 0 !important; }

/* Định nghĩa */
.st-callout--def { background: var(--st-c-def-bg); border-color: var(--st-c-def-border); }
.st-callout--def .st-callout__head { background: var(--st-c-def-head); color: #1e40af; }

/* Ví dụ */
.st-callout--ex { background: var(--st-c-ex-bg); border-color: var(--st-c-ex-border); }
.st-callout--ex .st-callout__head { background: var(--st-c-ex-head); color: #5b21b6; }

/* Lời giải (details/summary) */
.st-callout--sol { background: var(--st-c-sol-bg); border-color: var(--st-c-sol-border); }
.st-callout--sol > summary.st-callout__head {
  cursor: pointer;
  background: var(--st-c-sol-head);
  color: #065f46;
  list-style: none;
  user-select: none;
}
.st-callout--sol > summary::-webkit-details-marker { display: none; }

/* Phương pháp */
.st-callout--method { background: var(--st-c-method-bg); border-color: var(--st-c-method-border); }
.st-callout--method .st-callout__head { background: var(--st-c-method-head); color: #9a3412; }

/* Nhận xét */
.st-callout--note { background: var(--st-c-note-bg); border-color: var(--st-c-note-border); }
.st-callout--note .st-callout__head { background: var(--st-c-note-head); color: #854d0e; }

/* Chú ý */
.st-callout--warn { background: var(--st-c-warn-bg); border-color: var(--st-c-warn-border); }
.st-callout--warn .st-callout__head { background: var(--st-c-warn-head); color: #9f1239; }

/* ================================================================
   BÀI TRƯỚC / SAU NAVIGATION
   ================================================================ */
.st-lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.st-lesson-nav__btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  text-decoration: none !important;
  color: #111 !important;
  background: #fff;
  flex: 1;
  max-width: 45%;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.st-lesson-nav__btn:hover {
  border-color: var(--st-active-color);
  box-shadow: 0 4px 16px rgba(21,101,192,.12);
  transform: translateY(-1px);
  color: var(--st-active-color) !important;
}

.st-lesson-nav__btn--next { justify-content: flex-end; text-align: right; }

.st-lesson-nav__arrow {
  font-size: 18px;
  color: var(--st-active-color);
  flex-shrink: 0;
}

.st-lesson-nav__text {
  display: flex;
  flex-direction: column;
}

.st-lesson-nav__text small {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

/* ================================================================
   FAB + OVERLAY (MOBILE)
   Reset HOÀN TOÀN khỏi global button styles của modern-effects.css
   ================================================================ */
#st-fab,
#st-fab:link,
#st-fab:visited,
#st-fab:hover,
#st-fab:focus,
#st-fab:active {
  /* Ẩn mặc định - chỉ hiện trên mobile qua media query */
  display: none;
  /* Layout */
  position: fixed !important;
  bottom: 24px !important;
  right: 20px !important;
  z-index: 1001 !important;
  align-items: center !important;
  gap: 8px !important;
  /* Màu sắc */
  background: linear-gradient(135deg, #1565c0 0%, #1976d2 100%) !important;
  background-image: linear-gradient(135deg, #1565c0 0%, #1976d2 100%) !important;
  color: #fff !important;
  /* Form */
  border: none !important;
  border-radius: 9999px !important;
  padding: 12px 20px !important;
  /* Typography */
  font-family: 'Be Vietnam Pro', sans-serif !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em !important;
  text-transform: none !important;
  white-space: nowrap !important;
  /* Shadow & interaction */
  box-shadow: 0 4px 20px rgba(21,101,192,.4) !important;
  cursor: pointer !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
  transform: none !important;
  opacity: 1 !important;
  text-decoration: none !important;
}

#st-fab:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 28px rgba(21,101,192,.5) !important;
}

.st-fab__icon { font-size: 16px; pointer-events: none; }
.st-fab__text { pointer-events: none; }

.st-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.st-overlay.is-visible { display: block; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1024px) {
  :root { --st-sidebar-w: 220px; }
  .st-hero       { padding: 36px 28px 44px; }
  .st-section    { padding: 28px 28px; }
  .st-lesson     { padding: 24px 28px 60px; }
}

@media (max-width: 840px) {
  /* Sidebar ẩn sang trái, toggle bằng .is-open */
  .st-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }

  .st-sidebar.is-open { transform: translateX(0); }

  .st-main {
    width: 100%;
  }

  /* Hiển thị FAB trên mobile */
  #st-fab { display: flex !important; }

  .st-hero        { padding: 32px 20px 40px; }
  .st-section     { padding: 24px 20px; }
  .st-lesson      { padding: 20px 20px 60px; }

  .st-chapter-grid { grid-template-columns: 1fr; }

  .st-hero-deco   { display: none; }
  .st-hero-inner  { flex-direction: column; gap: 0; }

  .st-lesson-nav { flex-direction: column; }
  .st-lesson-nav__btn { max-width: 100%; }
}

@media (max-width: 480px) {
  .st-hero-title { font-size: 26px !important; }
  .st-lesson-title { font-size: 22px !important; }
}
