/* Giá Cà Phê Hôm Nay — phong cách "cà phê ấm", tối giản, chữ to cho người lớn tuổi.
   Sáng mặc định, tự chuyển tối theo hệ thống. Animation tinh tế, tải nhẹ. */

:root {
  --bg: #fbf6ec;
  --surface: #ffffff;
  --ink: #2a1a0e;
  --muted: #75604c;
  --line: #ece0cd;
  --brand: #78350f;
  --gold: #b07a1e;
  --gold-soft: #f4e7cb;
  --up: #2e7d32;
  --up-bg: #e7f2e7;
  --down: #c0392b;
  --down-bg: #fbe7e3;
  --flat: #75604c;
  --flat-bg: #efe7d9;
  --warn-bg: #fdf3da;
  --warn-ink: #8a5a12;
  --warn-border: #e3b25a;
  --shadow-sm: 0 1px 2px rgba(74, 42, 16, 0.05);
  --shadow-md: 0 2px 6px rgba(74, 42, 16, 0.05), 0 14px 30px rgba(74, 42, 16, 0.08);
  --r: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c130c;
    --surface: #271a10;
    --ink: #f4eadb;
    --muted: #b9a488;
    --line: #38271a;
    --brand: #e3ad44;
    --gold: #e3ad44;
    --gold-soft: #36271a;
    --up: #6fcb7c;
    --up-bg: #1e3320;
    --down: #f08a7c;
    --down-bg: #3a211c;
    --flat: #b9a488;
    --flat-bg: #2e2013;
    --warn-bg: #33260f;
    --warn-ink: #f0cf8a;
    --warn-border: #6e561f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.25), 0 16px 34px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  position: relative;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}
/* hairline vàng đồng ở đỉnh — chi tiết tinh tế */
#app::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.7;
  z-index: 10;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: max(26px, env(safe-area-inset-top)) 22px max(26px, env(safe-area-inset-bottom));
}
.center { align-items: center; justify-content: center; text-align: center; gap: 16px; }

.muted { color: var(--muted); font-size: 1.15rem; }
.big-title { font-size: 1.7rem; font-weight: 700; margin: 0; }

/* ---------- Thương hiệu ---------- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--brand);
}
.brand-mark { width: 26px; height: 26px; display: inline-flex; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-name { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.2px; }
.brand--sm .brand-mark { width: 22px; height: 22px; }
.brand--sm .brand-name { font-size: 1.05rem; color: var(--muted); }
.brand--sm { opacity: 0.95; }

/* ---------- Màn hình giá ---------- */
#price-view { text-align: center; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.price-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.price-main > * { animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.price-main > *:nth-child(2) { animation-delay: 0.05s; }
.price-main > *:nth-child(3) { animation-delay: 0.1s; }
.price-main > *:nth-child(4) { animation-delay: 0.16s; }
.price-main > *:nth-child(5) { animation-delay: 0.22s; }

.change-province {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 11px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
}
.change-province svg { width: 17px; height: 17px; }
.change-province:hover { border-color: var(--gold); }
.change-province:active { transform: scale(0.96); }

.province-name {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 2px;
  letter-spacing: 0.2px;
}

.price-big {
  font-size: clamp(4.2rem, 23vw, 7.2rem);
  font-weight: 800;
  line-height: 0.98;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.unit {
  font-size: 1.4rem;
  color: var(--muted);
  margin: 2px 0 16px;
  letter-spacing: 0.5px;
}

.change-line {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 9px 24px 9px 10px;
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: pop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.16s;
}
@media (prefers-color-scheme: dark) {
  .change-line { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
}
.change-line.up   { color: var(--up);   background: var(--up-bg); }
.change-line.down { color: var(--down); background: var(--down-bg); }
.change-line.flat { color: var(--flat); background: var(--flat-bg); }
/* vòng sáng accent toả ra một lần khi pill xuất hiện */
.change-line::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 currentColor;
  opacity: 0;
  pointer-events: none;
  animation: ringOut 1s ease-out 0.45s 1;
}
/* chip mũi tên tròn — điểm nhấn có cấu trúc */
.arrow-badge {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  animation: badgeIn 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.28s both;
}
.arrow-badge svg { width: 21px; height: 21px; }
.change-line.up   .arrow-badge { background: var(--up); }
.change-line.down .arrow-badge { background: var(--down); }
.change-line.flat .arrow-badge { background: var(--flat); }
.change-line.up   .arrow-badge svg { color: var(--up-bg); }
.change-line.down .arrow-badge svg { color: var(--down-bg); }
.change-line.flat .arrow-badge svg { color: var(--flat-bg); }
/* khối chữ 2 tầng: số nổi bật + phụ chú nhỏ, nhạt */
.change-text {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.12;
  text-align: left;
}
.change-main {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.change-main .delta-amt { font-variant-numeric: tabular-nums; }
.change-sub {
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0.68;
  margin-top: 2px;
  white-space: nowrap;
}

.status-line {
  display: inline-flex;
  justify-content: center;
  margin: 22px 0 0;
}
/* chip trạng thái gọn một dòng */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 0.98rem;
  white-space: nowrap;
}
.status-label { color: var(--ink); font-weight: 600; }
.status-divider { width: 1px; height: 14px; background: var(--line); flex-shrink: 0; }
.status-date { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
/* chấm trạng thái theo độ tươi: xanh=hôm nay (nhịp sống), vàng=phiên gần nhất, đỏ=quá cũ */
.status-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.status-dot.fresh  { background: var(--up); }
.status-dot.recent { background: var(--gold); }
.status-dot.stale  { background: var(--down); }
.status-dot.fresh::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--up);
  animation: ping 2.6s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.stale-warning {
  margin-top: 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  background: var(--warn-bg);
  color: var(--warn-ink);
  border: 1.5px solid var(--warn-border);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  max-width: 380px;
}
.stale-warning svg { width: 22px; height: 22px; flex-shrink: 0; margin-top: 1px; }

.source {
  margin-top: auto;
  padding-top: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 1rem;
  color: var(--muted);
}
.source b { color: var(--ink); font-weight: 600; }
.source-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.source-link {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.source-link:hover { color: var(--gold); border-bottom-color: var(--gold); }
.source-link:active { color: var(--gold); }

/* ---------- Màn hình chọn tỉnh ---------- */
#picker { gap: 0; }
.brand { animation: fadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both; }
.picker-title {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 22px 0 22px;
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.05s;
}

.province-buttons { display: flex; flex-direction: column; gap: 14px; }

.province-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  padding: 20px 22px;
  font-family: inherit;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.1s, box-shadow 0.2s;
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* dải vàng đồng bên trái mỗi thẻ */
.province-btn::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--gold);
  opacity: 0;
  transition: opacity 0.2s;
}
.province-btn:hover { border-color: var(--gold); box-shadow: var(--shadow-md); }
.province-btn:hover::before { opacity: 1; }
.province-btn:active { transform: scale(0.985); }
.province-btn:nth-child(1) { animation-delay: 0.06s; }
.province-btn:nth-child(2) { animation-delay: 0.12s; }
.province-btn:nth-child(3) { animation-delay: 0.18s; }
.province-btn:nth-child(4) { animation-delay: 0.24s; }
.province-btn:nth-child(5) { animation-delay: 0.3s; }
.province-btn .pb-price {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ---------- Nút chung ---------- */
.btn-primary {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: var(--brand);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0));
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 16px 26px;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: filter 0.2s, transform 0.12s, box-shadow 0.2s;
}
@media (prefers-color-scheme: dark) { .btn-primary { color: #1c130c; } }
/* ánh sáng quét ngang một lần khi nút xuất hiện */
.btn-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 45%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-18deg);
  animation: sheen 1.1s ease-out 0.5s 1;
  pointer-events: none;
}
.btn-primary svg { width: 20px; height: 20px; transform-origin: 50% 5px; }
.btn-primary:hover { filter: brightness(1.06); box-shadow: var(--shadow-md); }
.btn-primary:hover svg { animation: bellRing 0.7s ease-in-out; }
.btn-primary:active { transform: scale(0.98); }
/* chuông rung nhẹ một lần khi nút báo giá hiện ra */
.notif-area .btn-primary svg { animation: bellRing 0.9s ease-in-out 0.75s 1; }

/* ---------- Vùng thông báo ---------- */
.notif-area { margin-top: 22px; width: 100%; max-width: 360px; }
.notif-area .btn-primary { width: 100%; }
.notif-on {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--up); font-size: 1.2rem; font-weight: 700;
}
.notif-on svg { width: 22px; height: 22px; flex-shrink: 0; }
.notif-on-text { display: inline-flex; flex-direction: column; align-items: flex-start; line-height: 1.2; text-align: left; }
.notif-on-main { font-size: 1.2rem; font-weight: 700; }
.notif-on-sub { font-size: 0.9rem; font-weight: 500; opacity: 0.75; }
.notif-hint {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 1.05rem;
  line-height: 1.45;
  color: var(--muted);
  box-shadow: var(--shadow-sm);
  text-align: justify;
}
.notif-hint b { color: var(--ink); }

/* ---------- Mẹo cài đặt ---------- */
.install-tip {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  max-width: 536px; margin: 0 auto;
  background: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  font-size: 1.02rem; line-height: 1.35;
  box-shadow: var(--shadow-md);
  z-index: 20;
  animation: slideUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.4s;
}
.install-tip b { color: var(--gold); }
.install-tip button {
  margin-left: auto; background: transparent; border: none;
  color: var(--bg); font-size: 1.2rem; cursor: pointer; flex-shrink: 0; opacity: 0.7;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}

/* ---------- Keyframes ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(0.9); } 60% { transform: scale(1.03); } 100% { opacity: 1; transform: scale(1); } }
@keyframes badgeIn { 0% { opacity: 0; transform: scale(0.4); } 100% { opacity: 1; transform: scale(1); } }
@keyframes ringOut { 0% { box-shadow: 0 0 0 0 currentColor; opacity: 0.22; } 100% { box-shadow: 0 0 0 14px currentColor; opacity: 0; } }
@keyframes ping { 0% { transform: scale(1); opacity: 0.55; } 70%, 100% { transform: scale(2.6); opacity: 0; } }
@keyframes sheen { 0% { left: -60%; } 100% { left: 130%; } }
@keyframes bellRing {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(13deg); }
  30% { transform: rotate(-11deg); }
  45% { transform: rotate(8deg); }
  60% { transform: rotate(-5deg); }
  75% { transform: rotate(3deg); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tôn trọng "giảm chuyển động" ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Focus rõ ràng cho bàn phím ---------- */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
