/* responsive.css — chỉnh giao diện cho điện thoại & máy tính bảng.
 * Các trang dùng style viết thẳng trong thẻ (inline), nên ở đây phải chọn theo nội dung
 * thuộc tính style và dùng !important để ghi đè.
 * shortcut: chọn theo chuỗi style inline — nếu sửa style trong HTML thì kiểm tra lại các bộ chọn ở đây. */

html, body { overflow-x: clip; }
img, svg, video { max-width: 100%; }

/* ---------- Máy tính bảng (≤ 900px) ---------- */
@media (max-width: 900px) {
  h1 { font-size: clamp(34px, 6.5vw, 48px) !important; }
  h2[style*="font-size: 4"] { font-size: clamp(30px, 5vw, 38px) !important; }
  [style*="padding: 88px 24px"] { padding-top: 64px !important; padding-bottom: 64px !important; }
}

/* ---------- Điện thoại (≤ 640px) ---------- */
@media (max-width: 640px) {
  /* Lề hai bên 16px cho mọi khung nội dung */
  [style*="margin: 0 auto; padding"] { padding-left: 16px !important; padding-right: 16px !important; }
  [style*="padding: 88px 24px"] { padding-top: 52px !important; padding-bottom: 52px !important; }
  [style*="padding: 72px 24px 88px"], [style*="padding: 64px 24px 80px"] { padding-top: 36px !important; padding-bottom: 52px !important; gap: 32px !important; }

  /* Chữ tiêu đề */
  h1 { font-size: clamp(30px, 8.6vw, 38px) !important; line-height: 1.28 !important; }
  h2[style*="font-size: 4"], h2[style*="font-size: 3"] { font-size: clamp(26px, 7.4vw, 32px) !important; line-height: 1.3 !important; }
  h2[style*="font-size: 28px"] { font-size: 23px !important; }
  p[style*="font-size: 22px"] { font-size: 18px !important; }
  p[style*="font-size: 18px"], p[style*="font-size: 17px"] { font-size: 16px !important; }

  /* Thanh đầu trang: logo + nút trên một hàng, menu thành một hàng vuốt ngang */
  header > div { gap: 10px 12px !important; padding-top: 12px !important; padding-bottom: 0 !important; flex-wrap: wrap !important; }
  header > div > a:first-child { gap: 10px !important; }
  header > div > a:first-child img { width: 50px !important; height: 40px !important; }
  header > div > a:first-child span[style*="font-size: 22px"] { font-size: 18px !important; }
  header > div > a:first-child span[style*="font-size: 12px"] { font-size: 10px !important; letter-spacing: 1.5px !important; }
  header > div > button, header > div > a:last-child { min-height: 40px !important; padding: 0 12px !important; font-size: 14px !important; }
  header > div > *:not(nav) { margin-bottom: 12px; }
  header nav {
    order: 3; width: calc(100% + 32px); margin: 0 -16px; padding: 0 16px;
    flex-wrap: nowrap !important; gap: 0 22px !important; overflow-x: auto;
    border-top: 1px solid #3B2A22; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  header nav::-webkit-scrollbar { display: none; }
  header nav a { white-space: nowrap; padding: 12px 0 !important; font-size: 14px; }

  /* Nút bấm ở hero co theo màn hình */
  #top a[style*="min-height: 52px"] { flex: 1 1 100%; justify-content: center; }
  #top img { max-width: 320px !important; }

  /* Sản phẩm: 2 cột thay vì 1 cột dài */
  #san-pham [style*="minmax(260px"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }
  #san-pham article > div[style*="padding: 20px"] { padding: 12px !important; gap: 6px !important; }
  #san-pham article > div[style*="padding: 12px 20px 0"] { padding: 10px 12px 0 !important; }
  #san-pham article [style*="grid-template-columns: repeat(5"] { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  #san-pham article p[style*="letter-spacing: 2px"] { font-size: 10px !important; letter-spacing: 1px !important; }
  #san-pham article h3 { font-size: 16px !important; line-height: 1.3 !important; }
  #san-pham article p[style*="font-size: 14px"] { font-size: 13px !important; line-height: 1.5 !important; }
  #san-pham article button[style*="min-height: 36px"] { padding: 0 9px !important; font-size: 12px !important; }
  #san-pham article [style*="justify-content: space-between"] { flex-direction: column; align-items: stretch !important; gap: 8px !important; }
  #san-pham article [style*="justify-content: space-between"] > span { font-size: 15px !important; }
  #san-pham article [style*="justify-content: space-between"] > button,
  #san-pham article [style*="justify-content: space-between"] > a { justify-content: center; width: 100%; }
  #san-pham [role="group"] button[style*="padding: 0 20px"] { padding: 0 14px !important; font-size: 13px !important; min-height: 40px !important; }

  /* Lưới có cột tối thiểu rộng hơn màn hình */
  [style*="minmax(340px"], [style*="minmax(270px"], [style*="minmax(280px"] { grid-template-columns: minmax(0, 1fr) !important; }
  [style*="minmax(200px"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 24px 16px !important; }
  [style*="minmax(220px"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 18px 14px !important; }

  /* Hàng số liệu (2007 / 80 năm / Ninh Bình) không còn tràn chữ */
  p[style*="white-space: nowrap"][style*="font-size: 30px"] { font-size: 21px !important; white-space: normal !important; }
  p[style*="font-size: 44px"][style*="line-height: 1.3"] { font-size: 36px !important; }

  /* Form & hộp thoại bớt lề */
  form[style*="padding: 32px"] { padding: 20px 16px !important; }
  [role="dialog"] > div[style*="padding: 24px 28px"] { padding: 20px 16px !important; }
  [role="dialog"][style*="padding: 32px 28px"] { padding: 24px 18px !important; }
  [role="dialog"] h2 { font-size: 22px !important; }
  [role="dialog"] p[style*="font-size: 30px"] { font-size: 24px !important; }

  /* Nút liên hệ nổi: chỉ còn icon tròn, nhỏ hơn, không che chữ */
  .an-float > span:first-child { display: none !important; }
  .an-float > span:last-child { width: 48px !important; height: 48px !important; }
  .an-float svg { width: 22px; height: 22px; }
  .an-float .an-ico[style*="font-size: 16px"] { font-size: 13px !important; }
  div[style*="position: fixed; right: 20px"] { right: 12px !important; bottom: 16px !important; gap: 12px !important; }
}
