/* ==========================================================================
   Trang bio – chủ đề Bút & Luyện chữ
   Thiết kế ưu tiên điện thoại (mobile-first), mở rộng đẹp trên máy tính.
   ========================================================================== */

:root {
  --accent: #2b4c7e;
  --gold: #b8893b;
  --radius: 18px;
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --script: "Dancing Script", "Segoe Script", cursive;
}

/* --- 3 kiểu nền -------------------------------------------------------- */
body[data-bg="oly"] {               /* Vở ô ly: giấy kem, dòng kẻ tím */
  --bg: #fbf7ec;
  --line: rgba(150, 128, 205, .18);
  --line-strong: rgba(130, 105, 195, .32);
  --margin: rgba(224, 110, 110, .45);
  --text: #1d2742;
  --muted: #5f6680;
  --card: rgba(255, 255, 255, .86);
  --card-border: rgba(29, 39, 66, .10);
  --sheet: rgba(255, 253, 247, .72);
  --shadow: 0 1px 2px rgba(29, 39, 66, .06), 0 6px 18px -8px rgba(29, 39, 66, .22);
}
body[data-bg="kraft"] {             /* Giấy kraft nâu – cảm giác thủ công */
  --bg: #d8bd94;
  --line: rgba(90, 60, 25, .06);
  --line-strong: rgba(90, 60, 25, .10);
  --margin: transparent;
  --text: #33230f;
  --muted: #6e5434;
  --card: rgba(255, 248, 234, .9);
  --card-border: rgba(80, 50, 20, .14);
  --sheet: rgba(250, 238, 214, .55);
  --shadow: 0 1px 2px rgba(60, 35, 10, .10), 0 8px 20px -10px rgba(60, 35, 10, .45);
}
body[data-bg="ink"] {               /* Mực đêm – nền tối, chữ vàng kim */
  --bg: #111a2e;
  --line: rgba(233, 200, 118, .05);
  --line-strong: rgba(233, 200, 118, .09);
  --margin: rgba(233, 200, 118, .18);
  --text: #f4ecd8;
  --muted: #b9b3a2;
  --card: rgba(255, 255, 255, .07);
  --card-border: rgba(233, 200, 118, .22);
  --sheet: rgba(17, 26, 46, .55);
  --shadow: 0 10px 24px -12px rgba(0, 0, 0, .7);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* --- Cảnh nền ---------------------------------------------------------- */
.scene { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.paper {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-strong) 1px, transparent 1px),
    repeating-linear-gradient(to bottom, transparent 0 7px, var(--line) 7px 8px);
  background-size: 32px 32px, 32px 32px, 100% 8px;
}
.paper::after {                      /* đường lề đỏ của vở */
  content: ""; position: absolute; top: 0; bottom: 0; left: 28px;
  width: 1.5px; background: var(--margin);
}
body[data-bg="kraft"] .paper {
  background-image:
    radial-gradient(rgba(255,255,255,.18) 1px, transparent 1px),
    radial-gradient(rgba(90,60,25,.12) 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
}
body[data-bg="ink"] .paper::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% -10%, rgba(76, 112, 180, .35), transparent 60%);
}

.deco { position: absolute; user-select: none; }
.deco-pen {
  width: 46px; top: -112px; right: 4px;
  transform: rotate(32deg);
  filter: drop-shadow(8px 14px 10px rgba(0, 0, 0, .22));
  opacity: .95;
}
.deco-ink { width: 220px; opacity: .08; }
body[data-bg="ink"] .deco-ink { filter: invert(1) sepia(1) saturate(3) hue-rotate(5deg); opacity: .06; }
.deco-ink-1 { top: -70px; left: -80px; transform: rotate(-20deg); }
.deco-ink-2 { bottom: -90px; right: -70px; width: 280px; transform: rotate(40deg); }
.deco-quote {
  position: absolute; font-family: var(--script); font-weight: 700;
  color: var(--accent); opacity: .10; white-space: nowrap; display: none;
}

@media (min-width: 900px) {
  .deco-pen { width: 120px; top: 6vh; right: max(4vw, calc(50% - 560px)); transform: rotate(28deg); }
  .deco-ink { width: 340px; opacity: .10; }
  .deco-ink-1 { top: auto; bottom: 6vh; left: max(2vw, calc(50% - 600px)); }
  .deco-ink-2 { bottom: auto; top: 58vh; right: max(-60px, calc(50% - 620px)); }
  .deco-quote { display: block; }
  .deco-quote-1 { font-size: 64px; top: 16vh; left: max(2vw, calc(50% - 600px)); transform: rotate(-10deg); }
  .deco-quote-2 { font-size: 34px; bottom: 12vh; right: max(2vw, calc(50% - 600px)); transform: rotate(-6deg); }
}

/* --- Khung nội dung ---------------------------------------------------- */
.page {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px; margin: 0 auto;
  padding: calc(36px + env(safe-area-inset-top)) 18px calc(32px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) {
  .page {
    margin: 40px auto; padding: 44px 36px 32px;
    background: var(--sheet);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .35);
  }
}

/* --- Hồ sơ -------------------------------------------------------------- */
.profile { text-align: center; }
.avatar-wrap {
  width: 112px; height: 112px; margin: 0 auto 14px; padding: 4px; border-radius: 50%;
  background: conic-gradient(from 210deg, var(--gold), #f6e2a8, var(--accent), var(--gold));
  box-shadow: var(--shadow);
}
.avatar { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid var(--bg); background: var(--bg); }
.name {
  margin: 0; font-family: var(--script); font-weight: 700;
  font-size: clamp(32px, 9vw, 42px); line-height: 1.15; color: var(--accent);
  display: inline-flex; align-items: center; gap: 6px;
}
body[data-bg="ink"] .name { color: #f1d488; }
.verified { width: 22px; height: 22px; color: #3d9bf0; flex: none; }
.swash { display: block; width: 150px; height: 16px; margin: 0 auto 4px; color: var(--gold); }
.handle { margin: 0 0 8px; font-weight: 600; color: var(--muted); font-size: 15px; }
.bio { margin: 0 auto 16px; max-width: 420px; white-space: pre-line; font-size: 15px; }

.socials { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.social {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  background: var(--card); border: 1px solid var(--card-border); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none;
  transition: transform .18s ease, background .18s ease, color .18s ease;
}
.social svg { width: 21px; height: 21px; }
.social:hover, .social:focus-visible { transform: translateY(-3px); background: var(--accent); color: #fff; }

/* --- Mã QR (hiển thị trực tiếp dưới tên TikTok) ------------------------- */
.qr-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin: 4px 0 16px; }
.qr-card {
  margin: 0; width: 200px; max-width: calc(50% - 6px); padding: 12px 12px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.qr-row .qr-card:only-child { width: 230px; max-width: 100%; }
.qr-label { font-weight: 700; font-size: 14.5px; color: var(--accent); line-height: 1.3; }
body[data-bg="ink"] .qr-label { color: #f1d488; }
.qr-img { width: 100%; padding: 8px; border: 0; border-radius: 12px; background: #fff; cursor: zoom-in; }
.qr-img img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.qr-note { margin: 0; font-size: 13px; color: var(--muted); white-space: pre-line; line-height: 1.4; }

/* --- Khối nội dung ------------------------------------------------------ */
.block { margin-top: 30px; }
.block-title {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 14px; font-family: var(--script); font-weight: 700; font-size: 28px; color: var(--accent);
}
body[data-bg="ink"] .block-title { color: #f1d488; }
.block-title::before, .block-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }

/* --- Nút liên kết ------------------------------------------------------- */
.links { display: grid; gap: 12px; }
.link {
  position: relative; display: flex; align-items: center; gap: 14px;
  min-height: 64px; padding: 12px 16px 12px 12px;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none; overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.link:hover, .link:focus-visible { transform: translateY(-2px); border-color: var(--accent); }
.link:active { transform: scale(.985); }
.link-icon {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 12px; font-size: 22px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.link-text { flex: 1; min-width: 0; text-align: left; }
.link-title { display: block; font-weight: 600; font-size: 15.5px; line-height: 1.3; }
.link-sub { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.link-arrow { flex: none; width: 18px; height: 18px; opacity: .45; }
.link.highlight { background: var(--accent); color: #fff; border-color: transparent; }
.link.highlight .link-sub { color: rgba(255, 255, 255, .82); }
.link.highlight .link-icon { background: rgba(255, 255, 255, .18); }
.link.highlight .link-arrow { opacity: .8; }
.link.highlight::after {             /* ánh sáng lướt qua nút nổi bật */
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-20deg); animation: shine 3.6s ease-in-out infinite;
}
@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }

/* --- Sản phẩm ----------------------------------------------------------- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -18px 14px; padding: 2px 18px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 16px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--card-border); font-size: 14px; font-weight: 500;
}
.chip[aria-selected="true"] { background: var(--accent); color: #fff; border-color: transparent; }

.products { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.product {
  display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform .18s ease, border-color .18s ease;
}
.product:hover, .product:focus-visible { transform: translateY(-3px); border-color: var(--accent); }
.product-img { position: relative; aspect-ratio: 1; background: color-mix(in srgb, var(--accent) 8%, #fff); }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.badge {
  position: absolute; top: 8px; left: 8px; padding: 3px 9px; border-radius: 999px;
  background: #d9483b; color: #fff; font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
}
.product-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-name {
  font-size: 14px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.price { margin-top: auto; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.price-now { font-weight: 700; color: #d9483b; font-size: 15px; }
body[data-bg="ink"] .price-now { color: #ff8a7a; }
.price-old { font-size: 12.5px; color: var(--muted); text-decoration: line-through; }

@media (min-width: 640px) {
  .chips { margin: 0 0 14px; padding: 2px 0; }
}

/* --- Thư viện ảnh ------------------------------------------------------- */
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.shot {
  position: relative; padding: 0; border: 0; cursor: zoom-in; border-radius: 12px; overflow: hidden;
  aspect-ratio: 4 / 5; background: var(--card); box-shadow: var(--shadow);
}
.shot img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s ease; }
.shot:hover img { transform: scale(1.05); }

/* --- Chân trang --------------------------------------------------------- */
.footer { margin-top: 36px; text-align: center; font-size: 13px; color: var(--muted); }

/* --- Nút chia sẻ -------------------------------------------------------- */
.share-btn {
  position: fixed; z-index: 5; top: calc(14px + env(safe-area-inset-top)); left: 14px;
  width: 42px; height: 42px; display: grid; place-items: center; cursor: pointer;
  border-radius: 50%; border: 1px solid var(--card-border);
  background: var(--card); box-shadow: var(--shadow);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.share-btn svg { width: 19px; height: 19px; }

/* --- Hộp xem chi tiết (bottom sheet trên điện thoại) -------------------- */
.modal {
  width: 100%; max-width: 520px; max-height: 92dvh; padding: 0; border: 0;
  margin: auto auto 0; border-radius: 22px 22px 0 0;
  background: var(--bg); color: var(--text); overflow: auto;
}
.modal::backdrop { background: rgba(10, 15, 30, .55); backdrop-filter: blur(3px); }
.modal[open] { animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 640px) {
  .modal { margin: auto; border-radius: 22px; }
}
.modal.is-photo { background: transparent; max-width: min(92vw, 720px); border-radius: 14px; overflow: visible; margin: auto; }
.modal.is-photo .modal-close { top: -14px; right: -6px; }
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 2; width: 38px; height: 38px; cursor: pointer;
  border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; font-size: 24px; line-height: 1;
}
.modal-body img.full { width: 100%; max-height: 82dvh; object-fit: contain; border-radius: 14px; }
.modal-caption { color: #fff; text-align: center; margin: 10px 0 0; font-size: 14px; }
.detail-img { aspect-ratio: 1; background: #fff; }
.detail-img img { width: 100%; height: 100%; object-fit: cover; }
.detail { padding: 18px 20px calc(22px + env(safe-area-inset-bottom)); }
.detail h3 { margin: 0 0 6px; font-size: 19px; line-height: 1.35; }
.detail .price { margin: 0 0 12px; }
.detail .price-now { font-size: 20px; }
.detail p { margin: 0 0 18px; white-space: pre-line; color: var(--muted); font-size: 14.5px; }
.buy {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px;
  border-radius: 14px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600;
}

/* --- Thông báo nhỏ ------------------------------------------------------ */
.toast {
  position: fixed; z-index: 10; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 10px 18px; border-radius: 999px; background: #1d2742; color: #fff; font-size: 14px;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Hiệu ứng xuất hiện ------------------------------------------------- */
.reveal { animation: rise .55s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
