/* Toán học — giao diện cho học sinh từ lớp 6: màu tươi, bo tròn, chữ to */

:root {
  --bg: #f5f3ff;
  --surface: #ffffff;
  --surface-2: #ede9fe;
  --ink: #1e1b3a;
  --ink-2: #4b4870;
  --muted: #6f6b91;
  --line: #e0dcf5;
  --primary: #6d4aff;
  --primary-dark: #5636e0;
  --accent: #0f9d8a;
  --warm: #ffb703;
  --warm-soft: #fff4cc;
  --pink: #d6336c;
  --shadow: 0 6px 0 rgba(30, 27, 58, 0.08), 0 14px 30px -12px rgba(109, 74, 255, 0.25);
  --radius: 18px;
  --radius-sm: 12px;
  --font-head: "Baloo 2", "Be Vietnam Pro", system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, Menlo, monospace;
  --max: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17152b;
    --surface: #221f3d;
    --surface-2: #2c2850;
    --ink: #f3f1ff;
    --ink-2: #d2cfee;
    --muted: #a7a3cc;
    --line: #3a3664;
    --primary: #a592ff;
    --primary-dark: #8c75ff;
    --accent: #3fd0b8;
    --warm: #ffc933;
    --warm-soft: rgba(255, 201, 51, 0.14);
    --pink: #ff7aa2;
    --shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 14px 30px -12px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --bg: #17152b;
  --surface: #221f3d;
  --surface-2: #2c2850;
  --ink: #f3f1ff;
  --ink-2: #d2cfee;
  --muted: #a7a3cc;
  --line: #3a3664;
  --primary: #a592ff;
  --primary-dark: #8c75ff;
  --accent: #3fd0b8;
  --warm: #ffc933;
  --warm-soft: rgba(255, 201, 51, 0.14);
  --pink: #ff7aa2;
  --shadow: 0 6px 0 rgba(0, 0, 0, 0.25), 0 14px 30px -12px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-main {
  flex: 1 0 auto;
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid var(--warm);
  outline-offset: 3px;
  border-radius: 6px;
}

.wrapper {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 720px) {
  .wrapper {
    padding: 0 28px;
  }
}

/* ---------- Header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--line);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.site-brand:hover {
  text-decoration: none;
}

.site-brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  color: #fff;
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 0 rgba(109, 74, 255, 0.25);
}

.site-brand-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.01em;
}

.site-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.site-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.site-nav a {
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 0.98rem;
  font-weight: 700;
}

.site-nav a:hover {
  background: var(--surface-2);
  color: var(--primary);
  text-decoration: none;
}

.site-lang-switch {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--warm-soft);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.site-lang-switch:hover {
  background: var(--warm);
  color: #1e1b3a;
  text-decoration: none;
}

/* ---------- Hero ---------- */
.hero {
  padding: 48px 0 40px;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 183, 3, 0.35) 0 60px, transparent 61px),
    radial-gradient(circle at 92% 80%, rgba(15, 157, 138, 0.25) 0 80px, transparent 81px),
    linear-gradient(160deg, var(--surface-2), var(--bg) 70%);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 40px;
  align-items: center;
}

@media (max-width: 820px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}

.hero-eyebrow {
  display: inline-block;
  margin: 0 0 16px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.hero-title {
  margin: 0 0 16px;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.08;
}

.hero-lede {
  margin: 0 0 26px;
  max-width: 560px;
  color: var(--ink-2);
  font-size: 1.12rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.btn {
  display: inline-block;
  padding: 13px 24px;
  border-radius: 14px;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.05rem;
  border: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(2px);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 5px 0 var(--primary-dark);
}

.btn-primary:hover {
  color: #fff;
}

.btn-ghost {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--line);
}

.btn-ghost:hover {
  color: var(--ink);
}

/* Thẻ công thức nổi bật trên trang chủ */
.chalkboard {
  margin: 0;
  padding: 28px 22px 20px;
  background: linear-gradient(145deg, var(--primary), #9b5cff 55%, var(--pink));
  color: #fff;
  border-radius: 28px;
  box-shadow: 0 10px 0 rgba(86, 54, 224, 0.35), 0 26px 40px -18px rgba(109, 74, 255, 0.6);
  transform: rotate(-2deg);
}

.chalkboard-math {
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  text-align: center;
  padding: 16px 0 10px;
  color: #fff;
}

.chalkboard figcaption {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  opacity: 0.92;
  margin-top: 6px;
}

@media (max-width: 820px) {
  .chalkboard {
    transform: none;
  }
}

/* ---------- Sections ---------- */
.section {
  padding: 44px 0 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 800;
}

.section-link {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 2px solid var(--line);
  font-size: 0.95rem;
  white-space: nowrap;
}

.section-link:hover {
  border-color: var(--primary);
  text-decoration: none;
}

/* ---------- Thẻ chủ đề ---------- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}

.topic-card {
  --c: var(--primary);
  display: flex;
  flex-direction: column;
  padding: 20px 20px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--line);
  box-shadow: 0 6px 0 var(--line);
  color: var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.topic-card:hover {
  text-decoration: none;
  border-color: var(--c);
  transform: translateY(-3px);
  box-shadow: 0 9px 0 var(--c);
}

.topic-symbol {
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  height: 52px;
  padding: 0 12px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: var(--c);
  color: #fff;
  font-family: var(--font-head);
  font-size: 1.35rem;
  font-weight: 800;
}

.topic-name {
  margin: 0 0 6px;
  font-family: var(--font-head);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
}

.topic-desc {
  margin: 0 0 14px;
  font-size: 0.97rem;
  color: var(--ink-2);
  flex: 1;
}

.topic-count {
  display: inline-block;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 700;
}

/* ---------- Danh sách bài học ---------- */
.notebook-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.notebook-item a {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.notebook-item a:hover {
  text-decoration: none;
  border-color: var(--primary);
  transform: translateX(4px);
}

.notebook-date {
  display: inline-grid;
  place-items: center;
  min-width: 96px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--warm-soft);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.notebook-title {
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}

@media (max-width: 560px) {
  .notebook-item a {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .notebook-date {
    justify-self: start;
  }
}

/* ---------- Trang phụ: bài viết, chủ đề ---------- */
.page {
  padding-top: 44px;
  padding-bottom: 40px;
}

.page-title {
  margin: 0 0 8px;
  font-family: var(--font-head);
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.page-lede {
  color: var(--ink-2);
  font-size: 1.1rem;
  margin: 0 0 26px;
}

.topic-block {
  padding: 26px 24px 22px;
  margin-bottom: 22px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--line);
  scroll-margin-top: 20px;
}

.topic-block-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}

.topic-block-symbol {
  display: inline-grid;
  place-items: center;
  min-width: 56px;
  height: 48px;
  padding: 0 10px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-head);
  font-size: 1.2rem;
  font-weight: 800;
}

.topic-block-title {
  margin: 0;
  font-family: var(--font-head);
  font-size: 1.85rem;
  font-weight: 800;
}

.topic-block-desc {
  margin: 0 0 16px;
  color: var(--ink-2);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.archive-year-title {
  margin: 30px 0 12px;
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

.archive-year:first-child .archive-year-title {
  margin-top: 0;
}

/* ---------- Bài học ---------- */
.post {
  padding-top: 44px;
  padding-bottom: 28px;
  max-width: 760px;
}

.post-header {
  margin-bottom: 26px;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
}

.post-tag {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.post-tag:hover {
  text-decoration: none;
  color: #fff;
  filter: brightness(1.08);
}

.post-title {
  margin: 0;
  font-family: var(--font-head);
  font-size: clamp(2.1rem, 4.6vw, 2.9rem);
  font-weight: 800;
  line-height: 1.12;
}

.post-content {
  font-size: 1.08rem;
  line-height: 1.8;
}

.post-content h2 {
  margin: 2em 0 0.5em;
  font-family: var(--font-head);
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--primary);
}

.post-content h3 {
  margin: 1.6em 0 0.4em;
  font-family: var(--font-head);
  font-size: 1.45rem;
  font-weight: 700;
}

.post-content p {
  margin: 0 0 1.1em;
}

.post-content ul,
.post-content ol {
  padding-left: 1.4em;
  margin: 0 0 1.2em;
}

.post-content li {
  margin-bottom: 0.45em;
}

.post-content strong {
  color: var(--ink);
  font-weight: 800;
}

/* Hộp ghi nhớ / thử sức */
.note {
  margin: 1.6em 0;
  padding: 18px 22px;
  background: var(--warm-soft);
  border-radius: var(--radius-sm);
  border: 2px solid var(--warm);
  font-size: 1.02rem;
}

.note-label {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--warm);
  color: #1e1b3a;
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 800;
}

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

.note-try {
  background: rgba(15, 157, 138, 0.1);
  border-color: var(--accent);
}

.note-try .note-label {
  background: var(--accent);
  color: #fff;
}

/* Khối công thức */
.math-block {
  margin: 1.4em 0;
  padding: 16px 12px;
  text-align: center;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 1.15rem;
}

.katex-display {
  margin: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--surface-2);
  border-radius: 6px;
}

.post-content pre {
  overflow-x: auto;
  padding: 16px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
}

.post-content pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.post-back {
  margin-top: 36px;
  padding-top: 20px;
  border-top: 2px dashed var(--line);
  font-size: 1rem;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 56px;
  background: var(--surface);
  border-top: 3px solid var(--line);
  padding: 22px 0 28px;
  font-size: 0.95rem;
  color: var(--muted);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
}

.site-footer p {
  margin: 0;
}

/* ---------- Điện thoại ---------- */
@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .site-header-right {
    width: 100%;
    justify-content: space-between;
  }

  .site-nav a {
    padding: 6px 10px;
    font-size: 0.92rem;
  }

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

  .topic-block {
    padding: 20px 16px;
  }

  .post-content {
    font-size: 1.04rem;
  }
}
