:root {
  --bg: #f7f8fb;
  --bg-alt: #eef0f6;
  --surface: #ffffff;
  --text: #1a1d29;
  --text-muted: #5b6172;
  --border: #e2e4ec;
  --accent: #2f6feb;
  --accent-soft: #e8f0fe;
  --success: #1a9c6b;
  --highlight-bg: #fff8e8;
  --highlight-border: #f0c869;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.06), 0 4px 12px rgba(20, 24, 40, 0.05);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #12141c;
  --bg-alt: #171a24;
  --surface: #1b1e2a;
  --text: #e9eaf2;
  --text-muted: #a2a7ba;
  --border: #2b2f3d;
  --accent: #6d9bff;
  --accent-soft: #202944;
  --success: #3fd39a;
  --highlight-bg: #2a2410;
  --highlight-border: #7a5c15;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12141c;
    --bg-alt: #171a24;
    --surface: #1b1e2a;
    --text: #e9eaf2;
    --text-muted: #a2a7ba;
    --border: #2b2f3d;
    --accent: #6d9bff;
    --accent-soft: #202944;
    --success: #3fd39a;
    --highlight-bg: #2a2410;
    --highlight-border: #7a5c15;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

/* Cỡ chữ gốc: nhỏ gọn trên điện thoại, tăng dần trên màn hình lớn hơn */
html { font-size: 16px; }
@media (min-width: 641px) {
  html { font-size: 17.5px; }
}
@media (min-width: 1024px) {
  html { font-size: 18.5px; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  /* Chừa khoảng cho thanh điều hướng cố định ở đáy màn hình điện thoại */
  padding-bottom: 0;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Thanh tiến độ cuộn trang, nổi cố định trên cùng mọi lúc */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 40;
  background: transparent;
  pointer-events: none;
}
.scroll-progress__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  box-shadow: 0 0 8px rgba(47, 111, 235, 0.5);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.05rem;
  margin-right: auto;
}
.brand__icon { font-size: 1.2rem; }
.nav {
  display: flex;
  align-items: center;
  column-gap: 20px;
}
.nav__item {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  cursor: pointer;
}
.nav__item:hover { color: var(--accent); }
.nav__item[aria-current="page"] { color: var(--accent); }

/* Dropdown "Kiến thức" gom các trang hướng dẫn lại cho menu gọn hơn */
.nav-dropdown { position: relative; }
.nav-dropdown > summary.nav__item {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.nav-dropdown > summary.nav__item::-webkit-details-marker { display: none; }
.nav-dropdown[open] > summary.nav__item { color: var(--accent); }
.nav-dropdown__caret { font-size: 0.65rem; transition: transform 0.15s ease; }
.nav-dropdown[open] .nav-dropdown__caret { transform: rotate(180deg); }

.nav-dropdown__menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: grid;
  gap: 2px;
  min-width: 220px;
  z-index: 50;
}
.nav-dropdown__menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
}
.nav-dropdown__menu a:hover,
.nav-dropdown__menu a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-alt);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.05rem;
  flex-shrink: 0;
}

/* Hero */
.hero {
  padding: 48px 0 36px;
  background: linear-gradient(180deg, var(--accent-soft), var(--bg) 70%);
}
.hero h1 {
  font-size: clamp(1.6rem, 3.2vw, 2.4rem);
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.hero__lead {
  color: var(--text-muted);
  max-width: 720px;
  font-size: 1.02rem;
}
.hero__lead a { color: var(--accent); font-weight: 600; }
.hero__lead + .hero__lead { margin-top: -6px; }
.hero__progress { max-width: 520px; margin-top: 22px; }
.progress-bar {
  height: 10px;
  border-radius: 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: var(--success);
  transition: width 0.25s ease;
}
.hero__progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.hero--sub { padding: 40px 0 32px; }

.hero__hint {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 10px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  text-decoration: underline;
  padding: 0;
}

/* Sections */
.section { padding: 44px 0; }
.section--alt { background: var(--bg-alt); }
.section__title {
  font-size: 1.5rem;
  margin: 0 0 6px;
}
.section__desc {
  color: var(--text-muted);
  margin: 0 0 24px;
}

/* Roadmap */
.phase {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.phase--highlight {
  border-color: var(--highlight-border);
  background: var(--highlight-bg);
}
.phase__header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
}
.phase__tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}
.phase__title { margin: 4px 0 6px; font-size: 1.15rem; }
.phase__note { margin: 0; color: var(--text-muted); font-size: 0.9rem; max-width: 640px; }
.phase__chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-top: 6px;
}
.phase__header[aria-expanded="false"] .phase__chevron { transform: rotate(-90deg); }

.phase__body {
  padding: 0 20px 20px;
  display: grid;
  gap: 18px;
}
.phase__body.is-collapsed { display: none; }

.topic {
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.topic:first-child { border-top: none; padding-top: 0; }
.topic__name { margin: 0 0 4px; font-size: 1rem; }
.topic__why {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.topic__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.92rem;
  cursor: pointer;
}
.check input { margin-top: 4px; accent-color: var(--accent); }

.ask-ai-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  padding: 2px 4px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85em;
  line-height: 1;
  opacity: 0.55;
  vertical-align: -2px;
}
.ask-ai-icon:hover {
  opacity: 1;
  background: var(--accent-soft);
}

/* FAQ */
.faq-search {
  width: 100%;
  max-width: 480px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 20px;
}
.faq-list { display: grid; gap: 10px; }
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
}
.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--accent);
  transition: transform 0.15s ease;
}
.faq-item[open] summary::before { transform: rotate(90deg); }
.faq-item p {
  margin: 10px 0 8px;
  color: var(--text-muted);
  font-size: 0.92rem;
}
.faq-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-size: 0.72rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 999px;
}
.faq-empty { color: var(--text-muted); }

.ai-callout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 20px;
}
.ai-callout__text h3 { margin: 0 0 4px; font-size: 1rem; }
.ai-callout__text p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }
.ai-callout__button {
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.ai-callout__button:hover { opacity: 0.9; }

@media (max-width: 640px) {
  .ai-callout { flex-direction: column; align-items: stretch; text-align: center; }
  .ai-callout__button { text-align: center; }
}

/* API Testing guide */
.process-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.process-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.process-step h3 { margin: 0 0 6px; font-size: 0.98rem; color: var(--accent); }
.process-step p { margin: 0; color: var(--text-muted); font-size: 0.88rem; }

.quick-checklist {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.quick-checklist li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.92rem;
}

/* Test Case & Bug Report guide */
.field-table {
  display: grid;
  gap: 10px;
}
.field-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  align-items: start;
}
.field-row__name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
}
.field-row__desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.compare-grid { display: grid; gap: 16px; }
.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.compare-card__aspect { margin: 0 0 10px; font-size: 1rem; }
.compare-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.compare-box {
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}
.compare-box--bad { border-left: 3px solid #e5484d; }
.compare-box--good { border-left: 3px solid var(--success); }
.compare-box__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.compare-box p { margin: 0; font-size: 0.88rem; }
.compare-card__note {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
  font-style: italic;
}

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; gap: 4px; }
  .compare-row { grid-template-columns: 1fr; }
}

/* Interview Q&A bank */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.chip--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.exercise-instruction {
  margin: 10px 0 10px;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.exercise-hints { margin-top: 0; }

/* Glossary (Từ điển A-Z) */
.alpha-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0 22px;
  position: sticky;
  top: calc(64px + env(safe-area-inset-top));
  background: var(--bg);
  padding: 8px 0;
  z-index: 10;
}
.alpha-jump__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-soft);
}
.alpha-jump__link--empty {
  color: var(--text-muted);
  background: var(--bg-alt);
  opacity: 0.5;
}
.alpha-jump__link:hover:not(.alpha-jump__link--empty) {
  background: var(--accent);
  color: #fff;
}

.glossary-group {
  scroll-margin-top: 110px;
  margin-bottom: 26px;
}
.glossary-group__letter {
  font-size: 1.4rem;
  color: var(--accent);
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
  margin: 0 0 14px;
}
.glossary-group__terms {
  display: grid;
  gap: 12px;
}
.glossary-term {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
}
.glossary-term h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}
.glossary-term p {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Resources */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.resource-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.resource-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.resource-card h3 { margin: 0 0 6px; font-size: 1rem; }
.resource-card p { margin: 0; color: var(--text-muted); font-size: 0.86rem; }

/* Footer */
.site-footer {
  padding: 28px 0 40px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ===== Responsive cho điện thoại (iPhone SE/mini/standard/Pro Max...) ===== */
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }

  /* Nav chuyển thành thanh tab cố định ở đáy màn hình, dễ bấm bằng ngón cái. */
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    column-gap: 2px;
  }
  .nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    min-height: 48px;
    font-size: 0.72rem;
    text-align: center;
    border-radius: 10px;
  }
  .nav__item:active,
  .nav__item:hover {
    background: var(--accent-soft);
    color: var(--accent);
  }
  .nav-dropdown__caret { display: none; }

  /* Dropdown mở lên trên vì nav nằm cố định ở đáy màn hình */
  .nav-dropdown__menu {
    top: auto;
    bottom: calc(100% + 10px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
  }

  /* Chừa chỗ cho thanh tab cố định để không che nội dung/footer */
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  .hero { padding: 28px 0 24px; }
  .section { padding: 32px 0; }

  .site-header__inner { padding: 12px 16px; }

  /* Input tối thiểu 16px để iOS Safari không tự zoom khi focus */
  .faq-search { font-size: 16px; padding: 12px 14px; }

  /* Tap target rộng rãi hơn cho checklist và các mục có thể bấm */
  .phase__header { padding: 16px; }
  .topic__items { gap: 10px; }
  .check { min-height: 44px; font-size: 0.95rem; }
  .check input {
    width: 20px;
    height: 20px;
    margin-top: 0;
    flex-shrink: 0;
  }
  .faq-item { padding: 14px 16px; }
  .faq-item summary { min-height: 24px; }
  .resource-card { padding: 14px 16px; }
}

@media (max-width: 400px) {
  .wrap { padding: 0 14px; }
  .hero__lead { font-size: 0.95rem; }
  .nav__item { font-size: 0.68rem; }
}
