@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@500;700;800&display=swap');

/* ==============================
   IIKANZI EDU - Home UI Styles
   Clean code: gom biến, chia section,
   giữ nguyên giao diện đã chốt
================================ */

:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --text: #121826;
  --muted: #6f7d95;
  --line: #e4e8f0;
  --primary-soft: #edf1ff;
  --hero-bg: linear-gradient(140deg, #5f6ef8 0%, #7f59ec 60%, #955adf 100%);

  /* Base chiều cao ảnh bìa (không tính vùng tai mèo) */
  --hero-base-height: 200px;
  /* Tự lấy chiều cao tai mèo theo từng máy iPhone */
  --safe-top: max(env(safe-area-inset-top, 0px), constant(safe-area-inset-top, 0px));
  /* Tổng chiều cao render hero: base + tai mèo */
  --hero-height: calc(var(--hero-base-height) + var(--safe-top));

  --space-page-x: 12px;
  --space-level-top: 10px;
  --space-title-to-grid: 21px;
  --space-grid-col: 16px;
  --space-grid-row: 16px;

  --tile-height: 119px;
  --tile-radius: 16px;
  --tile-shadow: 0 2px 4px rgba(21, 31, 56, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Nunito', 'Avenir Next', Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 2026-04-21: visually-hidden — ẩn visual nhưng screen reader vẫn đọc.
   Dùng cho H1 SEO, skip-to-content link, aria description. */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 2026-04-21: fix layout vỡ khi lang=my — font Noto Sans Myanmar + line-height rộng hơn
   vì ký tự Myanmar có dấu trên-dưới cao hơn Latin ~30%. */
html[lang="my"],
html[lang="my"] body {
  font-family: 'Noto Sans Myanmar', 'Nunito', 'Avenir Next', Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.35;
}

/* ===== Hero ===== */
.hero-art {
  position: relative;
  width: 100%;
  height: var(--hero-height);
  /* Kéo hero phủ lên vùng tai mèo nhưng giữ nguyên mép dưới như cũ */
  margin-top: calc(-1 * var(--safe-top));
  overflow: hidden;
  border-radius: 0;
  background: var(--hero-bg);
}

/* 2026-04-21: profile icon overlay góc dưới-phải hero — Material hiking SVG.
   Không nền, không viền — chỉ icon trắng với drop-shadow để nổi trên gradient. */
.hero-profile-link {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Giữ touch target ≥ 36×36 (Material/Apple guideline) */
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.92);
  transition: transform 0.1s, color 0.15s;
}
.hero-profile-link:hover { transform: scale(1.1); }
.hero-profile-link:active { transform: scale(0.95); }
.hero-profile-icon {
  font-size: 26px;
  line-height: 1;
  display: block;
  /* Drop-shadow để emoji nổi trên gradient hero */
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.hero-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

/* ===== Level strip ===== */
.level-section {
  padding: var(--space-level-top) var(--space-page-x) 0;
}

.level-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.level-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 13px;
  padding: 8px 4px 7px;
  text-align: center;
  line-height: 1.12;
}

.level-chip .lv {
  font-size: 15px;
  font-weight: 700;
  color: #2360b3;
}

.level-chip .meta {
  margin-top: 3px;
  font-size: 9.5px;
  color: var(--muted);
}

.level-chip.active {
  background: var(--primary-soft);
  border-color: #bfd0ff;
}

.level-chip.is-locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.level-chip.is-locked .lv,
.level-chip.is-locked .meta {
  color: #78839a;
}

/* ===== Main content ===== */
.main-content {
  padding: 14px var(--space-page-x) 16px;
}

.main-content h2 {
  margin: 0 0 var(--space-title-to-grid);
  font-size: 32px;
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.2px;
}

/* ===== Module grid ===== */
.module-grid {
  width: 100%;
  margin-top: 0;
  padding-inline: 4px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-grid-col);
  row-gap: var(--space-grid-row);
}

.module-tile {
  width: 100%;
  /* 2026-04-21: min-height thay vì height fix — cho phép tile nở ra khi text dài
     (tiếng Myanmar có ký tự rộng hơn + wrap 2 dòng). */
  min-height: var(--tile-height);
  padding: 10px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  background: #fff;
  border: 1px solid #e7eaf2;
  border-radius: var(--tile-radius);
  box-shadow: var(--tile-shadow);

  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.module-tile:active {
  transform: scale(0.99);
}

.module-tile:focus-visible {
  outline: 2px solid #88a1ff;
  outline-offset: 1px;
}

/* Nút thứ 5 nằm cột trái theo yêu cầu đã chốt */
.module-grid .module-tile:last-child {
  grid-column: 1 / 2;
  width: 100%;
  justify-self: stretch;
}

.module-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  /* 2026-04-21: ngăn icon bị đẩy khỏi viewport khi text MY dài */
  min-width: 0;
}

.icon {
  /* 2026-04-20: 22 → 26 → 33px theo yêu cầu (+~27% so với 26) */
  font-size: 33px;
  line-height: 1;
  /* 2026-04-21: ngăn icon co lại/biến mất khi text chiếm hết space */
  flex-shrink: 0;
}

.module-name {
  font-size: 15px;
  line-height: 1.15;
  font-weight: 700;
  /* 2026-04-21: cho phép wrap 2 dòng + hyphenate cho từ dài (MY/EN) */
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.module-meta {
  margin-top: 1px;
  font-size: 10.5px;
  color: #65748f;
  max-width: 100%;
  word-break: break-word;
}

/* 2026-04-21: text MY dài hơn 30-50% — giảm font nhẹ + tăng line-height để vừa tile */
html[lang="my"] .module-name {
  font-size: 13.5px;
  line-height: 1.3;
}
html[lang="my"] .module-meta {
  font-size: 10px;
  line-height: 1.35;
}

/* ===== Error UI ===== */
.ui-error {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.4;
}

/* ===== Mobile small ===== */
@media (max-width: 390px) {
  .main-content h2 {
    font-size: 28px;
  }

  .module-name {
    font-size: 14px;
  }

  .module-meta {
    font-size: 10px;
  }

  .module-tile {
    /* 2026-04-21: đổi height fix → min-height cho phép nở ra khi MY wrap */
    min-height: 110px;
  }

  .module-grid .module-tile:last-child {
    width: 100%;
  }

  /* 2026-04-21: MY trên màn nhỏ — giảm font + giảm icon nhẹ để giữ 1 hàng tile gọn */
  html[lang="my"] .module-name {
    font-size: 12.5px;
  }
  html[lang="my"] .module-meta {
    font-size: 9.5px;
  }
  html[lang="my"] .icon {
    font-size: 28px;
  }
}

/* ===== Auth UI ===== */
.top-bar {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Language switcher (pill cam) — bên trái Login */
.lang-wrap { position: relative; }
.lang-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s, transform 0.15s;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lang-btn:active { transform: scale(0.96); }
.lang-btn .lang-flag { font-size: 18px; line-height: 1; }
.lang-btn .lang-code { font-size: 10px; }
.lang-btn .lang-caret { font-size: 9px; opacity: 0.7; }
.lang-btn[aria-expanded="true"] .lang-caret { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: max-content;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(47,55,82,0.18);
  padding: 3px;
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.lang-menu[hidden] { display: none; }

.lang-option {
  appearance: none;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #2d3a5b;
  font-size: 13px;
  text-align: left;
  width: 100%;
  white-space: nowrap;
}
.lang-option:hover { background: #fef2ec; }
.lang-option.is-active { background: #ffe8da; color: #d95a2a; font-weight: 700; }
.lang-option .lang-flag { font-size: 16px; line-height: 1; }
.lang-option-code {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  background: rgba(217,90,42,0.12);
  color: #d95a2a;
  border-radius: 4px;
}
.lang-option-label { flex: 1; }

.auth-btn[hidden] { display: none !important; }
.auth-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s;
}

.auth-btn:hover { background: rgba(255, 255, 255, 0.18); }
.auth-btn:disabled { opacity: 0.6; cursor: wait; }
.auth-btn.is-user { color: #b9ffd4; }
.auth-btn .auth-icon { font-size: 14px; line-height: 1; }

/* Modal */
.auth-modal[hidden] { display: none; }
.auth-modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 20, 40, 0.55);
  backdrop-filter: blur(4px);
}
.auth-modal-panel {
  position: relative;
  width: 100%; max-width: 380px;
  background: #fff;
  border-radius: 18px;
  padding: 24px 22px 22px;
  box-shadow: 0 20px 60px rgba(15, 20, 40, 0.25);
}
.auth-modal-close {
  position: absolute; top: 10px; right: 12px;
  background: transparent; border: 0;
  font-size: 18px; color: #9aa3b8; cursor: pointer;
  padding: 4px 8px;
}
.auth-modal-title {
  margin: 0 0 6px;
  font-size: 20px; font-weight: 700;
}
.auth-modal-sub {
  margin: 0 0 18px;
  font-size: 13px; color: #6f7d95;
  line-height: 1.4;
}

.auth-google-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px; border: 1px solid #dadce0; border-radius: 10px;
  background: #fff;
  font-size: 14px; font-weight: 600; color: #3c4043;
  cursor: pointer;
}
.auth-google-btn:hover { background: #f6f8ff; }
.auth-google-btn:disabled { opacity: 0.5; cursor: wait; }
.auth-google-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ea4335, #fbbc05, #34a853, #4285f4);
  color: #fff;
  font-size: 12px; font-weight: 900;
}

.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0;
  color: #9aa3b8; font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: #e5e9f2;
}

.auth-email-form {
  display: flex; flex-direction: column; gap: 8px;
}
.auth-email-form input {
  padding: 10px 12px;
  border: 1px solid #e5e9f2;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.auth-email-form input:focus {
  outline: 2px solid #6f79f6;
  outline-offset: -1px;
  border-color: #6f79f6;
}
.auth-email-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 4px;
}
.auth-email-actions button {
  padding: 10px; border-radius: 8px;
  border: 1px solid #e5e9f2;
  background: #fff;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
}
.auth-email-actions button.is-primary {
  background: #6f79f6; color: #fff; border-color: #6f79f6;
}
.auth-email-actions button:hover { filter: brightness(1.05); }

.auth-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  background: #fdf5f5;
  color: #8f2b2c;
  border: 1px solid #e6c0c0;
  border-radius: 8px;
  font-size: 13px;
}
.auth-note {
  margin: 14px 0 0;
  font-size: 12px;
  color: #9aa3b8;
  text-align: center;
}

/* ===== Legal footer (Privacy · Terms · Contact) 2026-04-21 ===== */
.legal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  padding: 20px 16px 24px;
  margin-top: 20px;
  font-size: 12.5px;
  color: #7a849b;
  border-top: 1px solid #e7eaf2;
}
.legal-footer a {
  color: #4f6ef7;
  text-decoration: none;
  font-weight: 600;
}
.legal-footer a:hover { text-decoration: underline; }
.legal-footer span { color: #c1c8d5; }

/* 2026-04-21: Profile link — cùng hàng với các link legal, có icon */
.footer-profile-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.footer-profile-icon { font-size: 14px; }

