/* =====================================================================
   style.css — Giao diện "Tiếng Anh của Phương"
   Tông màu: XANH LÁ long lanh (Phương thích xanh lá)
   Thiết kế cho người lớn tuổi: chữ to, tương phản cao, nút lớn.
   Responsive: PC (rộng, chữ rất to) + Mobile (bottom nav kiểu app).
   ===================================================================== */

:root {
  /* Bảng màu xanh lá */
  --green:       #1faa59;   /* xanh lá chính */
  --green-light: #4cd787;   /* xanh lá sáng */
  --green-dark:  #0c7a3d;   /* xanh lá đậm */
  --green-deep:  #075a2c;   /* chữ đậm */
  --grad:        linear-gradient(135deg, #19c463 0%, #0c9b4c 55%, #0c7a3d 100%);
  --gold:        #f7b733;   /* nút lưu */
  --note-yellow: #fff6c2;   /* giấy note */
  --note-line:   #f0d970;

  --bg:        #eafaf0;
  --card-bg:   #ffffff;
  --text:      #16321f;
  --muted:     #5c6f63;
  --line:      #c9e6d4;

  --fs-vi:   1.25rem;
  --fs-en:   2.2rem;
  --fs-boi:  1.9rem;
}

html[data-font="normal"] { --fs-vi: 1.4rem;  --fs-en: 1.8rem; --fs-boi: 1.5rem; }
html[data-font="large"]  { --fs-vi: 1.65rem; --fs-en: 2.2rem; --fs-boi: 1.9rem; }
html[data-font="xlarge"] { --fs-vi: 2rem;    --fs-en: 2.9rem; --fs-boi: 2.4rem; }

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 20% 0%, #d6f7e4 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--grad);
  color: #fff;
  padding: 14px 16px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 3px 14px rgba(12,122,61,0.35);
}
.topbar__title { font-size: 1.4rem; font-weight: 800; flex: 1; text-align: center; text-shadow: 0 1px 2px rgba(0,0,0,.18); }
.topbar__back, .topbar__settings {
  background: rgba(255,255,255,0.22);
  border: none; color: #fff;
  width: 44px; height: 44px; border-radius: 10px;
  font-size: 1.4rem; cursor: pointer;
}
.topbar__back { font-size: 2rem; line-height: 1; }

/* ===== Main ===== */
.main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 20px 16px 110px; }
.screen__title { font-size: 1.6rem; margin-bottom: 16px; color: var(--green-deep); }

/* ===== Trang chủ ===== */
.home__hello { font-size: 1.3rem; text-align: center; margin-bottom: 20px; color: var(--green-dark); font-weight: 600; }
.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.topic-card {
  background: var(--card-bg);
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 24px 16px; text-align: center; cursor: pointer;
  transition: transform .08s, border-color .15s, box-shadow .15s;
  min-height: 150px;
  display: flex; flex-direction: column; justify-content: center; gap: 8px;
  box-shadow: 0 2px 10px rgba(12,122,61,0.06);
}
.topic-card:active { transform: scale(.97); }
.topic-card:hover { border-color: var(--green); box-shadow: 0 6px 20px rgba(31,170,89,0.22); }
.topic-card.locked { opacity: .55; }
.topic-card__icon { font-size: 3rem; }
.topic-card__name { font-size: 1.4rem; font-weight: 800; color: var(--green-deep); }
.topic-card__desc { font-size: 1rem; color: var(--muted); }
.topic-card__badge { font-size: .9rem; color: var(--green); font-weight: 800; }
.topic-card.locked .topic-card__badge { color: var(--gold); }

/* ===== Thẻ học câu ===== */
.learn__progress { text-align: center; font-size: 1.1rem; color: var(--green-dark); margin-bottom: 8px; font-weight: 800; }
.card {
  background: var(--card-bg);
  border: 2px solid var(--line);
  border-radius: 22px;
  padding: 30px 22px;
  box-shadow: 0 6px 22px rgba(12,122,61,0.12);
  text-align: center;
  display: flex; flex-direction: column;
  position: relative;
}
/* Thứ tự mobile: nội dung → ảnh → ghi chú (ghi chú dưới cùng) */
.card__main   { order: 1; }
.card__visual { order: 2; }
.card__note   { order: 3; }
/* Ảnh/emoji: mobile nằm DƯỚI nội dung (đặt sau .card__main trong HTML) */
.card__visual { margin-top: 18px; min-height: 80px; display: flex; align-items: center; justify-content: center; }
.card__visual .emoji { font-size: 5rem; line-height: 1; }
.card__visual img {
  max-width: 100%; max-height: 220px; border-radius: 16px;
  border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(12,122,61,0.15); object-fit: cover;
}
@media (min-width: 768px) {
  /* PC: GHI CHÚ treo cột trái | nội dung giữa | ẢNH phải — gọn trong 1 màn hình */
  .card { display: flex; flex-direction: row; align-items: center; gap: 22px; }
  /* GHI CHÚ ra HẲN NGOÀI thẻ, treo tuyệt đối bên trái — KHÔNG chiếm chỗ, nút không xê dịch */
  .card__note   { position: absolute; top: 0; right: 100%; margin-right: 16px;
                  width: 210px; max-height: 100%; overflow: auto;
                  flex-direction: column; align-items: flex-start; gap: 8px; }
  .card__main   { order: 1; flex: 1 1 0; min-width: 0; }
  .card__visual { order: 2; flex: 0 0 230px; margin: 0; }
  .card__visual .emoji { font-size: 6rem; }
  .card__visual img { max-height: 220px; }
  .btn { min-height: 52px; padding: 12px 16px; }
  .arrow { min-height: 52px; padding: 12px; }
  .voice-pick button { min-height: 46px; }
}
.card__vi  { font-size: var(--fs-vi);  color: var(--green-deep); font-weight: 700; margin-bottom: 8px; line-height: 1.25; }
.card__en  { font-size: var(--fs-en);  font-weight: 800; color: var(--green-deep); line-height: 1.2; }
.card__boi {
  font-size: var(--fs-boi); color: var(--green-dark); font-weight: 800;
  margin-top: 10px;
  background: linear-gradient(180deg, #e8fbef, #d4f6e0);
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--line);
}
.card__boi::before { content: "📢 "; }

.card__actions { display: flex; gap: 12px; margin-top: 10px; justify-content: center; flex-wrap: wrap; }

/* Hàng chọn giọng: Nữ 1 / Nữ 2 / Nam 1 / Nam 2 */
.voice-pick { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.voice-pick button {
  flex: 1 1 calc(50% - 8px); min-height: 52px; padding: 10px 8px;
  border: 2px solid var(--line); background: #fff; color: var(--green-dark);
  border-radius: 12px; font-size: 1.1rem; font-weight: 700; cursor: pointer;
}
.voice-pick button.active { background: var(--green); color: #fff; border-color: var(--green); }
@media (min-width: 768px) { .voice-pick button { flex: 1 1 0; } }

.btn {
  border: none; border-radius: 14px;
  font-size: 1.25rem; font-weight: 800;
  padding: 16px 18px; min-height: 60px; min-width: 130px;
  cursor: pointer; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s, filter .15s; flex: 1;
}
.btn:active { transform: scale(.95); }
.btn--listen { background: var(--grad); box-shadow: 0 4px 12px rgba(31,170,89,0.35); }
.btn--male   { background: #2e7d8f; }              /* xanh ngọc cho giọng nam */
.btn--listen.speaking, .btn--male.speaking { animation: pulse .6s infinite alternate; }
.btn--save { background: var(--gold); color: #4a3500; }
.btn--save.saved { background: var(--green); color: #fff; }
.btn--note { background: #fff; color: var(--green-dark); border: 2px solid var(--green); }
.btn--del  { background: #e25555; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.4); } }

/* ===== Ghi chú hiện trên thẻ ===== */
.card__note {
  margin-top: 18px;
  background: var(--note-yellow);
  border: 1px solid var(--note-line);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: left;
  font-size: 1.2rem;
  color: #6a5400;
  box-shadow: 0 3px 8px rgba(180,150,0,0.18);
  display: flex; align-items: center; gap: 10px; cursor: pointer;
}
.card__note::before { content: "📒"; font-size: 1.4rem; }
.card__note .note-edit { margin-left: auto; font-size: .95rem; color: var(--green-dark); font-weight: 700; }

/* ===== Mũi tên ===== */
.nav-arrows { display: flex; gap: 14px; margin-top: 12px; }
.arrow {
  flex: 1; background: #fff; border: 2px solid var(--green);
  color: var(--green-dark); font-size: 1.3rem; font-weight: 800;
  padding: 18px; min-height: 64px; border-radius: 14px; cursor: pointer;
}
.arrow:active { transform: scale(.96); }
.arrow:disabled { opacity: .4; cursor: default; }

/* ===== Đã lưu ===== */
.saved-list { display: flex; flex-direction: column; gap: 12px; }
.saved-item { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 16px; display: flex; align-items: center; gap: 10px; }
.saved-item__text { flex: 1; }
.saved-item__en  { font-size: 1.4rem; font-weight: 800; color: var(--green-deep); }
.saved-item__boi { font-size: 1.2rem; color: var(--green-dark); margin-top: 4px; }
.saved-item__listen, .saved-item__male {
  color: #fff; border: none; border-radius: 12px;
  width: 54px; height: 54px; font-size: 1.4rem; cursor: pointer; flex-shrink: 0;
}
.saved-item__listen { background: var(--green); }
.saved-item__male   { background: #2e7d8f; }

.empty-note { color: var(--muted); font-size: 1.15rem; text-align: center; padding: 30px 10px; line-height: 1.5; }

/* ===== Cài đặt ===== */
.setting-row { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; }
.setting-row > label { display: block; font-size: 1.2rem; font-weight: 800; margin-bottom: 12px; color: var(--green-deep); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 14px; min-height: 54px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-size: 1.1rem; cursor: pointer; }
.seg button.active { background: var(--green); color: #fff; border-color: var(--green); }
.setting-note { color: var(--muted); font-size: 1.05rem; line-height: 1.6; margin-top: 10px; }

/* ===== Bottom nav ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 2px solid var(--line);
  display: flex; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -3px 14px rgba(12,122,61,0.10);
}
.bottom-nav__item {
  flex: 1; background: none; border: none; cursor: pointer;
  padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); min-height: 60px;
}
.bottom-nav__item .bn-icon { font-size: 1.5rem; }
.bottom-nav__item .bn-label { font-size: .8rem; }
.bottom-nav__item.active { color: var(--green); font-weight: 800; }

/* ===== Overlay giấy note ===== */
.note-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(12,40,24,0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.note-overlay[hidden] { display: none !important; }
.card__note[hidden]   { display: none !important; }
.note-pad {
  position: relative;
  width: 100%; max-width: 460px;
  background: var(--note-yellow);
  background-image: repeating-linear-gradient(transparent, transparent 37px, var(--note-line) 38px);
  border-radius: 14px; padding: 26px 22px 20px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.35); transform: rotate(-1deg);
}
.note-pad__pin { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; background: var(--green); border-radius: 50%; box-shadow: 0 2px 5px rgba(0,0,0,.3); }
.note-pad__head { font-size: 1.35rem; font-weight: 800; color: #6a5400; margin-bottom: 6px; }
.note-pad__en   { font-size: 1.15rem; font-weight: 700; color: var(--green-deep); margin-bottom: 12px; }
.note-pad textarea {
  width: 100%; border: 2px solid var(--note-line); border-radius: 10px;
  background: rgba(255,255,255,0.7); padding: 12px; font-size: 1.25rem;
  font-family: inherit; color: #4a3a00; resize: vertical;
}
.note-pad__actions { display: flex; gap: 10px; margin-top: 16px; }
.note-pad__actions .btn { flex: 1; min-width: 0; font-size: 1.1rem; padding: 14px 10px; min-height: 56px; }
.note-pad__actions .arrow { flex: 1; padding: 14px 10px; min-height: 56px; }

/* ===== PC ===== */
@media (min-width: 768px) {
  :root { --fs-en: 2.4rem; --fs-boi: 2rem; --fs-vi: 1.6rem; }
  .main { padding-top: 10px; padding-bottom: 88px; }
  .topic-grid { grid-template-columns: repeat(3, 1fr); gap: 22px; }
  .card { padding: 24px 32px; }
  .topbar__title { font-size: 1.6rem; }
  .bottom-nav { max-width: 900px; margin: 0 auto; border-radius: 16px 16px 0 0; }
}
