/* Brand source: brand_design/02_color_palette_panel.png and 03_typography_panel.png.
   Bamboo green #3B524F; preferred logo background #F9F5EC.
   Local system stacks avoid sending visitor data to a third-party font host.
   Existing layout, spacing, sizing and interaction states are preserved. */

:root {
  --brand: #3b524f;
  --brand-deep: #2e403d;
  --brand-ink: #22312f;
  --brand-soft: #6e8580;

  /* Dominant background pixel in brand_design/16_logo_horizontal.png.
     User preference: a single logo-colored surface across the website. */
  --logo-background: #f9f5ec;
  --cream: var(--logo-background);
  --cream-deep: var(--logo-background);
  --surface: var(--logo-background);
  --bg-color: var(--logo-background);

  --text-primary: var(--brand-ink);
  --text-secondary: #566a66;
  --primary-color: var(--brand);
  --primary-hover: var(--brand-deep);
  --on-brand: var(--cream);
  --on-brand-muted: #b3c3bc;
  --border-color: #e4d8c4;
  --border-strong: #768682;
  --danger: #9c3b2a;
  --success: var(--brand);
  --white: #ffffff;
  --black: #000000;

  /* --- Chữ — dùng font hệ thống cục bộ, không phát sinh request bên thứ ba. */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Arial, Helvetica, sans-serif;
  --font-heading: var(--font-sans);
  --font-body: var(--font-sans);
  --font-display: var(--font-sans);

  /* --- Thang chữ --------------------------------------------------------- */
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.25rem;
  --text-4xl: 3rem;

  /* --- Khoảng cách (thang 4px) ------------------------------------------ */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  /* --- Hình khối ---------------------------------------------------------
     Bo góc 12–24px theo hướng hữu cơ của bộ nhận diện (lá, giọt nước, gợn
     nước) — không có góc vuông sắc ở đâu ngoài đường kẻ.                   */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* Đổ bóng lấy màu từ mực xanh chứ không phải đen — bóng đen trên nền kem
     ngả xám và trông bẩn. */
  --shadow-sm: 0 2px 8px rgba(34, 49, 47, 0.06);
  --shadow: 0 10px 30px rgba(34, 49, 47, 0.08);
  --shadow-lg: 0 20px 50px rgba(34, 49, 47, 0.12);

  /* --- Chuyển động ------------------------------------------------------- */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-fast: 150ms;
  --dur: 220ms;
  --dur-slow: 380ms;

  /* --- Lớp chồng --------------------------------------------------------- */
  --z-base: 0;
  --z-sticky: 100;
  --z-floating: 900;
  --z-header: 1000;
  --z-overlay: 1100;

  --container: 1200px;
  --measure: 68ch;         /* Bề rộng đọc thoải mái cho đoạn văn dài */

  /* Một ảnh phủ nền; viewport bỏ viền mẫu, giữ nguyên pixel họa tiết gốc. */
  --leaf-pattern: url("../brand/pattern-light-background.svg");
  --leaf-pattern-size: cover;
}

/* --------------------------------------------------------------------------
   Reset
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Keep anchored and keyboard-focused controls clear of the sticky header and
     the floating contact actions. */
  scroll-padding-top: 96px;
  scroll-padding-bottom: 120px;
}

body {
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Nội dung phải cao ít nhất bằng một phần khung nhìn, nếu không footer sẽ trôi
   lên giữa trang trên những trang ngắn (đăng nhập, thư viện rỗng). */
main {
  display: block;
  min-height: 40vh;
}

img,
picture,
video,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--brand);
  text-wrap: balance;
}

p, li {
  text-wrap: pretty;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font-heading);
  font-size: inherit;
  color: inherit;
}

input,
select,
textarea {
  font-family: var(--font-heading);
  font-size: inherit;
  color: inherit;
}

/* URL, mã lớp, tên tệp do biên tập viên nhập có thể dài hơn cả cột — cho phép
   xuống dòng ở bất kỳ đâu thay vì đẩy ngang cả trang. */
.rich-text-content a,
.postExcerpt,
.courseDesc {
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Tiêu điểm bàn phím
   Một vòng tiêu điểm duy nhất cho toàn site. Dùng `:focus-visible` nên chuột
   không thấy vòng này, còn bàn phím thì luôn thấy.
   -------------------------------------------------------------------------- */

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

/* Accessible name for compact controls without changing the visual layout. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Trên nền xanh đậm thì vòng xanh biến mất — đổi sang kem. */
.on-dark :focus-visible {
  outline-color: var(--cream);
}

/* --------------------------------------------------------------------------
   Bỏ qua điều hướng
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: var(--space-4);
  z-index: var(--z-overlay);
  transform: translateY(-250%);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: var(--on-brand);
  font-weight: 600;
  transition: transform var(--dur) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Bố cục
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

@media (min-width: 768px) {
  .container { padding: 0 var(--space-6); }
}

.section {
  padding: var(--space-9) 0;
}

/* Legacy section class uses the same logo background. */
.bg-light {
  background-color: var(--cream-deep);
}

.text-center {
  text-align: center;
}

/* Nền hoạ tiết lá, rất nhạt. Đặt ở lớp giả để hoạ tiết mờ đi mà chữ bên trên
   vẫn giữ nguyên độ tương phản. */
.leaf-bg {
  position: relative;
  isolation: isolate;
}

.leaf-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: var(--leaf-pattern);
  background-size: var(--leaf-pattern-size);
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.05;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Tiêu đề mục
   -------------------------------------------------------------------------- */

.section-title {
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.25rem);
  text-align: center;
  margin-bottom: var(--space-6);
  color: var(--brand);
}

/* Nét gạch dưới tiêu đề — nhắc lại nét mảnh của gợn nước trong logo. */
.section-title::after {
  content: '';
  display: block;
  width: 56px;
  height: 2px;
  margin: var(--space-4) auto 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, transparent, var(--brand-soft), transparent);
}

.text-center .section-title,
.headerSection .section-title {
  margin-bottom: var(--space-4);
}

/* Phụ đề dùng cùng hệ chữ không chân để tiếng Việt hiển thị nhất quán. */
.subtitle {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-style: italic;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 60ch;
  margin: var(--space-4) auto 0;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Nút
   Cao tối thiểu 48px ở mọi kích thước màn hình — vừa đạt ngưỡng chạm của
   Material (48dp) vừa vượt ngưỡng 44pt của Apple.
   -------------------------------------------------------------------------- */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-pill);
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
  transition:
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.btn-primary {
  background-color: var(--brand);
  color: var(--on-brand);
  border: 1.5px solid var(--brand);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--brand-deep);
  border-color: var(--brand-deep);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0) scale(0.985);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}

.btn-secondary:hover {
  background-color: var(--brand);
  color: var(--on-brand);
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0) scale(0.985);
}

/* Nút trên nền xanh đậm: đảo màu để vẫn đạt tương phản. */
.on-dark .btn-primary {
  background-color: var(--cream);
  border-color: var(--cream);
  color: var(--brand-deep);
}

.on-dark .btn-primary:hover {
  background-color: var(--white);
  border-color: var(--white);
}

.on-dark .btn-secondary {
  color: var(--cream);
  border-color: rgba(248, 239, 224, 0.55);
}

.on-dark .btn-secondary:hover {
  background-color: var(--cream);
  color: var(--brand-deep);
  border-color: var(--cream);
}

/* Trạng thái vô hiệu: mờ đi, đổi con trỏ, và không còn hiệu ứng di chuột —
   một nút trông bấm được mà không làm gì là lỗi giao diện. */
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-primary[aria-disabled='true'],
.btn-secondary[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary:disabled:hover {
  background-color: var(--brand);
  border-color: var(--brand);
  transform: none;
  box-shadow: none;
}

.btn-secondary:disabled:hover {
  background-color: transparent;
  color: var(--brand);
  transform: none;
}

.fullWidthBtn {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Biểu mẫu — mặc định dùng chung cho mọi form trên site
   -------------------------------------------------------------------------- */

.formGroup {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.formGroup label {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--brand);
}

.formGroup input,
.formGroup select,
.formGroup textarea {
  /* 16px là ngưỡng iOS Safari ngừng tự phóng to khi người dùng chạm vào ô. */
  font-size: var(--text-base);
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text-primary);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.formGroup textarea {
  min-height: 120px;
  resize: vertical;
}

.formGroup input::placeholder,
.formGroup textarea::placeholder {
  color: var(--text-secondary);
  opacity: 1;
}

.formGroup input:hover,
.formGroup select:hover,
.formGroup textarea:hover {
  border-color: var(--brand-soft);
}

.formGroup input:focus,
.formGroup select:focus,
.formGroup textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 82, 79, 0.18);
}

/* Do not let the more specific form rule suppress the global keyboard ring. */
.formGroup input:focus-visible,
.formGroup select:focus-visible,
.formGroup textarea:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.formGroup select {
  appearance: none;
  /* Mũi tên vẽ bằng SVG nội tuyến để giữ đúng màu thương hiệu ở mọi trình duyệt. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%233b524f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  padding-right: var(--space-7);
}

.formRow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.consentField {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  align-items: start;
  margin: var(--space-4) 0;
}

.consentField input {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--brand);
}

.consentField label {
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--text-primary);
}

.consentField a {
  font-weight: 600;
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.consentField small {
  grid-column: 2;
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (max-width: 640px) {
  .formRow { grid-template-columns: 1fr; gap: 0; }
}

/* Thông báo kết quả gửi form. `[data-lead-message]` và `[data-trial-message]`
   đã là vùng aria-live sẵn trong markup; ở đây chỉ lo phần nhìn. */
[data-lead-message],
[data-trial-message] {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  background-color: rgba(59, 82, 79, 0.08);
  font-size: var(--text-sm);
}

[role='alert'] {
  margin-top: var(--space-3);
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Phân trang
   -------------------------------------------------------------------------- */

.c-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-7);
}

.paginationLink {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--brand);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease);
}

.paginationLink:not(.disabled):hover {
  background-color: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.paginationLink.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.paginationStatus {
  font-family: var(--font-display);
  color: var(--text-secondary);
  /* Số trang đổi độ rộng khi sang trang 10 làm cả hàng nhích. Chữ số đều bề
     ngang thì không. */
  font-variant-numeric: tabular-nums;
}

@media (max-width: 520px) {
  .c-pagination { gap: var(--space-2); }
  .paginationStatus { font-size: var(--text-sm); }
  .paginationLink { padding: var(--space-2) var(--space-3); }
}

/* --------------------------------------------------------------------------
   Nội dung rich text (Lexical) render ra website.
   Mọi rule đều bọc trong .rich-text-content để không đụng tới list/typography
   của các component khác (checkList, crossList, navbar...).
   -------------------------------------------------------------------------- */

.rich-text-content {
  font-size: var(--text-lg);
  line-height: 1.8;
  color: var(--text-primary);
  max-width: var(--measure);
}

.rich-text-content > * + * {
  margin-top: 1.15em;
}

.rich-text-content h1,
.rich-text-content h2,
.rich-text-content h3,
.rich-text-content h4,
.rich-text-content h5,
.rich-text-content h6 {
  line-height: 1.35;
  margin-top: 2em;
  margin-bottom: 0.6em;
  color: var(--brand);
}

.rich-text-content h1 { font-size: var(--text-2xl); }
.rich-text-content h2 { font-size: var(--text-xl); }
.rich-text-content h3 { font-size: 1.25rem; }
.rich-text-content h4 { font-size: var(--text-lg); }

.rich-text-content > :first-child {
  margin-top: 0;
}

.rich-text-content ul,
.rich-text-content ol {
  padding-left: 1.5rem;
}

.rich-text-content ul { list-style: disc; }
.rich-text-content ol { list-style: decimal; }

.rich-text-content li + li {
  margin-top: 0.4em;
}

.rich-text-content li::marker {
  color: var(--brand-soft);
}

/* Checklist của Lexical dùng ul[class] riêng, không hiện dấu chấm. */
.rich-text-content ul.check-list,
.rich-text-content ul[role="list"] {
  list-style: none;
  padding-left: 0;
}

.rich-text-content a {
  color: var(--brand);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.rich-text-content a:hover {
  color: var(--primary-hover);
  text-decoration-thickness: 2px;
}

.rich-text-content strong { font-weight: 600; }

.rich-text-content blockquote {
  padding: var(--space-2) 0 var(--space-2) var(--space-5);
  border-left: 3px solid var(--brand-soft);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.0625em;
}

.rich-text-content code {
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  background: rgba(59, 82, 79, 0.09);
  font-size: 0.9em;
}

.rich-text-content hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 2em 0;
}

.rich-text-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}

.rich-text-content table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.rich-text-content th,
.rich-text-content td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-color);
  text-align: left;
}

.rich-text-content th {
  background: rgba(59, 82, 79, 0.06);
  font-weight: 600;
  color: var(--brand);
}

/* --------------------------------------------------------------------------
   Điểm dừng
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  .section {
    padding: var(--space-7) 0;
  }

  .rich-text-content {
    font-size: var(--text-base);
  }
}

/* --------------------------------------------------------------------------
   Giảm chuyển động
   Người bật tuỳ chọn này ở hệ điều hành thường bị chóng mặt vì chuyển động.
   Tắt hẳn thay vì rút ngắn.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
