/* ===== Sửa lỗi tràn ngang & chữ trên mobile ===== */
html, body { max-width: 100%; overflow-x: hidden; }
img, video, svg { max-width: 100%; }
h1, h2, h3, h4, p, a, span, button { overflow-wrap: break-word; }

/* ===== Font tiêu đề: FC Lilita One (bản Việt hóa của Lilita One, giấy phép SIL OFL 1.1; xem fonts/README.md) ===== */
@font-face {
    font-family: 'FC Lilita One';
    src: url('../fonts/FC-Lilita-One-Regular.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
/* Nunito (Google Fonts, SIL OFL) tự lưu, font biến thiên 400-800, chia theo bộ ký tự */
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 400 800; font-display: swap;
    src: url('../fonts/Nunito-vietnamese.woff2') format('woff2');
    unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 400 800; font-display: swap;
    src: url('../fonts/Nunito-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 400 800; font-display: swap;
    src: url('../fonts/Nunito-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
.font-title { font-synthesis: none; }

/* Chữ quanh avatar quay chậm (1 vòng ~40s), tắt khi bật "giảm chuyển động" */
.hero-ring-spin { transform-origin: 100px 100px; animation: heroRingSpin 40s linear infinite; }
@keyframes heroRingSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .hero-ring-spin { animation: none; } }   /* font chỉ có 1 độ đậm: không giả lập chữ in đậm */
.font-mono { font-weight: 700; }        /* nhãn nhỏ dùng Nunito đậm; font-normal / font-semibold... vẫn ghi đè được */

/* ===== Nền: gradient xanh-tím-hồng + chấm bi halftone (phong cách NTE) ===== */
.bg-pop-gradient { background: linear-gradient(155deg, #1E5FC0 0%, #624BC3 48%, #E640BD 100%); }
.bg-halftone-dark {
    background-image: radial-gradient(rgba(10, 10, 40, .28) 2.2px, transparent 2.4px);
    background-size: 18px 18px;
    -webkit-mask-image: linear-gradient(200deg, #000 0%, transparent 60%);
    mask-image: linear-gradient(200deg, #000 0%, transparent 60%);
}
.bg-halftone-light {
    background-image: radial-gradient(rgba(255, 255, 255, .22) 2px, transparent 2.2px);
    background-size: 18px 18px;
    background-position: 9px 9px;
    -webkit-mask-image: linear-gradient(20deg, #000 0%, transparent 50%);
    mask-image: linear-gradient(20deg, #000 0%, transparent 50%);
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #100E30; }
::-webkit-scrollbar-thumb {
    background: #2A2570;
    border-radius: 4px;
    border: 2px solid #100E30;
}
::-webkit-scrollbar-thumb:hover { background: #FE367C; }


/* Viền focus cho người dùng bàn phím (chỉ hiện khi điều hướng bằng phím, không hiện khi bấm chuột) */
a:focus-visible, button:focus-visible, input:focus-visible, [role="button"]:focus-visible {
  outline: 2px solid #FE367C;
  outline-offset: 2px;
}
.gear-item-card:focus-visible { outline-color: #FE367C; }
#messengerChatBox:focus { outline: none; }

/* ===== Mây nền: trôi ngang chậm (có nhấp nhô nhẹ), nằm sau nội dung ===== */
.bg-cloud { position: absolute; left: 0; max-width: none; overflow: visible; opacity: .92;
    animation: cloudDrift var(--cloud-dur) linear infinite; animation-delay: var(--cloud-delay); will-change: transform; }
.bg-cloud-1 { top: 9%;  width: 230px; --cloud-dur: 120s; --cloud-delay: -35s; }
.bg-cloud-2 { top: 62%; width: 170px; --cloud-dur: 170s; --cloud-delay: -120s; }
.bg-cloud-3 { top: 28%; width: 140px; --cloud-dur: 150s; --cloud-delay: -95s; }
.bg-cloud-4 { top: 46%; width: 190px; --cloud-dur: 200s; --cloud-delay: -45s; }
.bg-cloud-5 { top: 82%; width: 130px; --cloud-dur: 135s; --cloud-delay: -15s; }
@media (min-width: 640px) {
    .bg-cloud-1 { width: 400px; }
    .bg-cloud-2 { width: 300px; }
    .bg-cloud-3 { width: 230px; }
    .bg-cloud-4 { width: 320px; }
    .bg-cloud-5 { width: 210px; }
}
@keyframes cloudDrift {
    0%   { transform: translate(-120%, 0); }
    25%  { transform: translate(calc(25vw - 90%), -10px); }
    50%  { transform: translate(calc(50vw - 60%), 6px); }
    75%  { transform: translate(calc(75vw - 30%), -8px); }
    100% { transform: translate(calc(100vw + 20%), 0); }
}
@media (prefers-reduced-motion: reduce) {
    .bg-cloud { animation: none !important; transform: translateX(8vw); }
    .bg-cloud-2 { transform: translateX(55vw); }
    .bg-cloud-3 { transform: translateX(72vw); }
    .bg-cloud-4 { transform: translateX(28vw); }
    .bg-cloud-5 { transform: translateX(84vw); }
}

/* ===== Giảm chuyển động: tôn trọng cài đặt "Reduce motion" của hệ điều hành =====
   Tắt hiệu ứng trang trí lặp vô hạn (ping, pulse) và chuyển động khi hover,
   nhưng giữ nguyên nội dung và trạng thái (chữ, màu, vị trí). */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

/* ===== Vùng an toàn (tai thỏ, thanh cử chỉ) cho nút cố định ở đáy =====
   Cần viewport-fit=cover trong thẻ meta viewport. Trên máy không có vùng an toàn, env() = 0 nên giá trị giữ như cũ. */
body {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}
#chatWidget {
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  right: calc(1.5rem + env(safe-area-inset-right, 0px));
}

/* ===== Phong cách NTE: viên thuốc menu + chữ tiêu đề có viền đen ===== */
.nav-pill {
    display: block;
    background: #F0E3D9;
    color: #1A1A1A;
    border: 2px solid #1A1A1A;
    border-radius: 999px;
    padding: 7px 18px;
    font-weight: 800;
    font-size: 14px;
    text-align: center;
    transition: background-color .15s;
}
.nav-pill:hover { background: #FE367C; }
.title-outline {
    text-shadow: 4px 4px 0 #1A1A1A, -2px -2px 0 #1A1A1A, 2px -2px 0 #1A1A1A, -2px 2px 0 #1A1A1A;
}

/* ===== Menu: mỗi nút một màu theo theme ===== */
.nav-pill--pink   { background: #FE367C; }
.nav-pill--yellow { background: #FFE08A; }
.nav-pill--cafe   { background: #FF8A3D; }
.nav-pill--mint   { background: #5BE3A0; }
.nav-pill--pink:hover, .nav-pill--yellow:hover, .nav-pill--cafe:hover, .nav-pill--mint:hover { background: #F0E3D9; }

/* ===== Nhãn "NTE Creator" lật như đồng hồ lật (js/main.js đổi màu giữa lúc lật) ===== */
.flip-tag { color: #1A1A1A; will-change: transform; }
.flip-tag--cream  { background: #F0E3D9; }
.flip-tag--mint   { background: #5BE3A0; }
.flip-tag--cafe   { background: #FF8A3D; }
.flip-tag--out { animation: flipOut .22s ease-in forwards; }
.flip-tag--in  { animation: flipIn .26s ease-out forwards; }
@keyframes flipOut { from { transform: perspective(300px) rotateX(0); } to { transform: perspective(300px) rotateX(-90deg); } }
@keyframes flipIn  { from { transform: perspective(300px) rotateX(90deg); } to { transform: perspective(300px) rotateX(0); } }

/* ===== Nút "Gửi cốc Cafe": rung nhẹ ngắn, lặp lại sau vài giây (dùng thuộc tính `rotate` để không đè lên hiệu ứng nhấc khi rê chuột) ===== */
.cafe-shake { animation: cafeShake 4.5s ease-in-out infinite; transform-origin: 50% 60%; }
.cafe-shake:hover, .cafe-shake:focus-visible { animation: none; }
@keyframes cafeShake {
  0%, 14%, 100% { rotate: 0deg; }
  2%  { rotate: -2.2deg; }
  4%  { rotate: 2.2deg; }
  6%  { rotate: -1.6deg; }
  8%  { rotate: 1.6deg; }
  10% { rotate: -0.8deg; }
  12% { rotate: 0.8deg; }
}

/* ===== Thanh liên kết nhanh dọc bên trái: chỉ hiện khi màn hình đủ rộng (nằm ngoài cột nội dung 1180px)
   và chỉ khi phần giới thiệu (#hero) đã cuộn khỏi màn hình (js/main.js bỏ/ thêm .is-hidden). Rê chuột/focus thì hiện tên nền tảng. ===== */
.side-dock { display: none; }
@media (min-width: 1380px) {
  .side-dock {
    display: flex; flex-direction: column; gap: 14px;
    position: fixed; z-index: 20; top: 50%; transform: translateY(-50%);
    left: max(16px, calc(50% - 590px - 190px));   /* chừa chỗ cho nhãn tên (khoảng 115px) bên phải nút mà không chạm khung nội dung */
    transition: opacity .25s ease, transform .25s ease;
  }
  .side-dock.is-hidden { opacity: 0; transform: translate(-12px, -50%); pointer-events: none; }
  .side-dock a { position: relative; }
  .side-dock a::after {
    content: attr(data-label); position: absolute; left: calc(100% + 12px); top: 50%;
    transform: translate(-6px, -50%); white-space: nowrap; pointer-events: none; opacity: 0;
    background: #9C8AF2; color: #1A1A1A; border: 2px solid #1A1A1A; border-radius: 999px;
    padding: 3px 12px; font-size: 13px; font-weight: 800; line-height: 1.4;
    box-shadow: 3px 3px 6px rgba(26, 26, 26, .35); transition: opacity .15s ease, transform .15s ease;
  }
  .side-dock a:hover::after, .side-dock a:focus-visible::after { opacity: 1; transform: translate(0, -50%); }
}
/* Dưới ~1564px không còn đủ chỗ cho nhãn tên bên ngoài khung nội dung nên ẩn nhãn (nút vẫn có aria-label) */
@media (min-width: 1380px) and (max-width: 1563px) {
  .side-dock a::after { display: none; }
}
@media (min-width: 1380px) {
  .side-dock-mug { transform: translateX(1px); }   /* biểu tượng cốc có quai bên phải nên nhìn lệch trái: dịch nhẹ cho thẳng tâm */
}

/* ===== Nút chọn ngôn ngữ: viên thuốc kem (quả cầu + VI/EN/中文 + mũi tên), bấm mở danh sách ===== */
.lang-switch { position: relative; flex: none; }
.lang-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; padding: 0;
    background: #9C8AF2; color: #1A1A1A; border: 2px solid #1A1A1A; border-radius: 999px;
    box-shadow: 3px 3px 8px rgba(26, 26, 26, .35); cursor: pointer;
    font: 800 15px/1 Nunito, "Microsoft YaHei", "PingFang SC", sans-serif; transition: background-color .15s ease;
}
.lang-btn:hover { background: #F0E3D9; }
.lang-btn:focus-visible, .lang-menu button:focus-visible { outline: 3px solid #624BC3; outline-offset: 2px; }
.lang-btn .fa-globe { font-size: 22px; }
.lang-menu {
    position: absolute; right: 0; top: calc(100% + 10px); z-index: 40; min-width: 100%; margin: 0; padding: 6px; list-style: none;
    background: #F0E3D9; border: 2px solid #1A1A1A; border-radius: 22px; box-shadow: 5px 5px 8px rgba(26, 26, 26, .35);
}
.lang-menu[hidden] { display: none; }
.lang-menu button {
    display: block; width: 100%; padding: 9px 16px; border: 0; border-radius: 999px; text-align: center; white-space: nowrap;
    background: transparent; color: #1A1A1A; cursor: pointer;
    font: 800 15px/1 Nunito, "Microsoft YaHei", "PingFang SC", sans-serif;
}
.lang-menu button:hover { background: rgba(254, 54, 124, .3); }
.lang-menu button[aria-selected="true"] { background: #FE367C; }
/* Điện thoại: chọn ngôn ngữ nằm trong menu 3 gạch (#navLang), cùng kiểu viên thuốc, ngôn ngữ đang chọn tô hồng */
.nav-lang { display: flex; align-items: center; gap: 6px; }
.nav-lang .fa-globe { flex: none; width: 30px; text-align: center; font-size: 20px; color: #1A1A1A; }
.nav-lang button {
    flex: 1; min-width: 0; height: 36px; border: 2px solid #1A1A1A; border-radius: 999px; background: #9C8AF2; color: #1A1A1A; cursor: pointer;
    font: 800 14px/1 Nunito, "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}
.nav-lang button:hover { background: #F0E3D9; }
.nav-lang button[aria-pressed="true"] { background: #FE367C; }
.nav-lang button:focus-visible { outline: 3px solid #624BC3; outline-offset: 2px; }

/* Chữ Hán: font Noto Sans SC (nạp từ Google Fonts khi chọn 中文, js/i18n.js). Latin và tiếng Việt vẫn dùng FC Lilita One / Nunito (có đủ dấu), chỉ chữ Hán mới rơi sang Noto Sans SC */
html[lang="zh-CN"] body { font-family: Nunito, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif; }
html[lang="zh-CN"] .font-title { font-family: "FC Lilita One", Nunito, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; font-weight: 800; letter-spacing: .02em; }

/* Ảnh panorama góc setup (index.html #setup + js/popups.js) */
/* Khung xem trước: ảnh cắt object-cover và tự lia ngang qua lại; ai tắt hiệu ứng chuyển động thì đứng yên ở giữa ảnh */
.pano-pan { object-fit: cover; object-position: 0% 50%; animation: pano-pan 28s ease-in-out infinite alternate; }
@keyframes pano-pan { to { object-position: 100% 50%; } }
@media (prefers-reduced-motion: reduce) { .pano-pan { animation: none; object-position: 50% 50%; } }
.pano-badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 2px solid #1A1A1A; border-radius: 999px;
    background: #F0E3D9; color: #1A1A1A; font: 800 11px/1 Nunito, sans-serif; box-shadow: 2px 2px 6px rgba(26, 26, 26, .35);
}
/* Modal: khung cao cố định, ảnh giữ tỉ lệ và cuộn ngang. .is-fit = thu cả ảnh vào khung (nút "Toàn cảnh") */
.pano-viewer {
    height: min(62vh, 560px); overflow-x: auto; overflow-y: hidden; cursor: grab;
    overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: #FE367C transparent;
}
@media (max-width: 640px) { .pano-viewer { height: min(55vh, 340px); } }   /* điện thoại dọc: khung thấp lại để ảnh không bị phóng quá to */
.pano-viewer img { display: block; height: 100%; width: auto; max-width: none; user-select: none; -webkit-user-drag: none; }
.pano-viewer.is-dragging { cursor: grabbing; }
.pano-viewer.is-fit { height: auto; max-height: 72vh; overflow: hidden; cursor: default; display: flex; align-items: center; justify-content: center; }
.pano-viewer.is-fit img { width: 100%; height: auto; max-height: 72vh; object-fit: contain; }
.pano-viewer:focus-visible { outline: 3px solid #624BC3; outline-offset: 2px; }
.pano-ctrl {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 2px solid #1A1A1A; color: #1A1A1A;
    background: #F0E3D9; cursor: pointer; box-shadow: 2px 2px 4px rgba(26, 26, 26, .35); transition: transform .15s, background-color .15s;
}
.pano-ctrl:hover { background: #FFE08A; transform: scale(1.08); }
.pano-ctrl:active { transform: scale(.95); }
.pano-ctrl:focus-visible { outline: 3px solid #624BC3; outline-offset: 2px; }
.pano-ctrl--pill { height: 36px; padding: 0 14px; border-radius: 999px; font: 800 13px/1 Nunito, sans-serif; }
.pano-ctrl--pill[aria-pressed="true"] { background: #FE367C; }
.pano-ctrl--side { position: absolute; top: 50%; margin-top: -20px; width: 40px; height: 40px; border-radius: 999px; }
.pano-ctrl--left { left: 10px; }
.pano-ctrl--right { right: 10px; }
.pano-ctrl--side[hidden] { display: none; }
