Files
web-alterflixhub/app/global.css
T
Bkk1234 cfb24b8138 fix(motion): คืนอนิเมชัน reveal ที่หายไป + จดข้อยกเว้นเบราว์เซอร์
สาเหตุ: hydration เขียนทับ class ของ <html> ทำให้ `fx-motion` หลุด
และอนิเมชันเดิมผูกกับคลาสนั้นอย่างเดียว → อนิเมชันหายทั้งเว็บ

- ผูก "ตัวอนิเมชัน" กับ @media (prefers-reduced-motion: no-preference)
  (สถานะซ่อนก่อน reveal ยังผูกกับ html.fx-motion เพื่อกันเนื้อหาหายเมื่อปิด JS)
- เพิ่ม <MotionBootstrap/> เติมคลาส fx-motion ซ้ำหลัง hydration + ฟังการเปลี่ยน reduced-motion
- คืน @keyframes fx-swap-in ที่หลุดไประหว่างแก้ CSS
- DESIGN.md: Motion contract สองชั้น + ตารางข้อยกเว้นต่อเบราว์เซอร์ (scrollbar/share/install/blur/ฟอนต์ไทย/ITP)
- sw VERSION v2.0.4
2026-11-14 13:18:42 +07:00

473 lines
14 KiB
CSS

@import url("https://fonts.googleapis.com/css2?family=Jersey+15&family=Noto+Sans+Thai:wght@400;500;600;700&display=swap");
@import "@fontsource-variable/inter";
@import "@fontsource/ibm-plex-sans-thai-looped/400.css";
@import "@fontsource/ibm-plex-sans-thai-looped/500.css";
@import "tailwindcss";
@import "@agent-native/toolkit/styles.css";
@source "./**/*.{ts,tsx}";
/* ฟอนต์เนื้อหายาว (มีหัว) — หัวข้อและ UI ยังใช้ Inter + Noto Sans Thai ตาม DESIGN.md */
@theme {
--font-content: "IBM Plex Sans Thai Looped", "Noto Sans Thai", sans-serif;
}
:root {
--background: 0 0% 100%;
--foreground: 0 0% 10%;
--card: 0 0% 100%;
--card-foreground: 0 0% 10%;
--popover: 0 0% 100%;
--popover-foreground: 0 0% 10%;
--primary: 0 0% 15%;
--primary-foreground: 0 0% 100%;
--secondary: 0 0% 95%;
--secondary-foreground: 0 0% 15%;
--muted: 0 0% 95%;
--muted-foreground: 0 0% 45%;
--accent: 0 0% 95%;
--accent-foreground: 0 0% 15%;
--destructive: 0 91% 71%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 90%;
--input: 0 0% 90%;
--ring: 0 0% 40%;
--radius: 0.5rem;
--sidebar-background: 0 0% 97%;
--sidebar-foreground: 0 0% 45%;
--sidebar-primary: 0 0% 15%;
--sidebar-primary-foreground: 0 0% 100%;
--sidebar-accent: 0 0% 95%;
--sidebar-accent-foreground: 0 0% 15%;
--sidebar-border: 0 0% 90%;
--sidebar-ring: 0 0% 40%;
--chat-sidebar-width: 17.25rem;
--chat-sidebar-content-inset: 0.5rem;
--chat-sidebar-row-padding: 0.75rem;
--chat-sidebar-title-fade: 1.25rem;
}
.chat-layout-shell {
--agent-layout-left-drawer-expanded-width: var(--chat-sidebar-width);
--agent-native-lower-surface: var(--agent-kit-nav-surface);
}
.agentkit-chat-empty-copy {
text-align: center;
}
.agentkit-chat-empty-copy h1 {
margin: 0;
color: hsl(var(--foreground));
font-size: 1.5rem;
font-weight: 600;
letter-spacing: -0.02em;
}
.agent-kit-chat-footer-stack {
inline-size: min(100%, 47rem);
margin-inline: auto;
pointer-events: auto;
}
.agent-kit-chat-footer-stack > .agentkit-composer-stack {
inline-size: 100%;
}
.agent-kit-chat-guided-question {
max-block-size: min(32rem, 58dvh);
overflow: auto;
margin-block-end: 0.5rem;
border: 1px solid var(--agentkit-border);
border-radius: var(--agentkit-radius);
background: var(--agentkit-surface);
box-shadow: var(--agentkit-elevation);
}
.chat-sidebar-history .an-chat-history__list {
padding-top: 0;
}
.chat-sidebar-history .an-chat-history__section-label {
padding: 8px
calc(var(--chat-sidebar-content-inset) + var(--chat-sidebar-row-padding))
5px;
color: hsl(var(--sidebar-foreground) / 0.66);
font-size: 11px;
font-weight: 500;
letter-spacing: 0;
text-transform: none;
}
.chat-sidebar-history.an-chat-history--rail .an-chat-history-row {
margin-inline: var(--chat-sidebar-content-inset);
border-radius: calc(var(--radius) + 2px);
}
.chat-sidebar-history.an-chat-history--rail .an-chat-history-row__button {
min-height: 34px;
padding-block: 7px;
padding-inline: var(--chat-sidebar-row-padding);
color: hsl(var(--sidebar-foreground));
}
.chat-sidebar-history.an-chat-history--rail
.an-chat-history-row--has-menu
.an-chat-history-row__button {
padding-inline-end: calc(var(--chat-sidebar-row-padding) + 1.5rem);
}
.chat-sidebar-history .an-chat-history-row__title {
flex: 1 1 auto;
color: hsl(var(--sidebar-accent-foreground));
font-size: 13px;
font-weight: 400;
text-overflow: clip;
}
.chat-sidebar-thread-title-shell {
display: flex;
min-width: 0;
align-items: center;
gap: 6px;
}
.chat-sidebar-thread-title {
display: block;
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
white-space: nowrap;
}
.chat-sidebar-thread-running {
color: hsl(var(--sidebar-foreground) / 0.72);
}
.chat-sidebar-thread-title[data-overflow="true"] {
-webkit-mask-image: linear-gradient(
to right,
hsl(var(--foreground)) 0,
hsl(var(--foreground)) calc(100% - var(--chat-sidebar-title-fade)),
hsl(var(--foreground) / 0) 100%
);
mask-image: linear-gradient(
to right,
hsl(var(--foreground)) 0,
hsl(var(--foreground)) calc(100% - var(--chat-sidebar-title-fade)),
hsl(var(--foreground) / 0) 100%
);
}
.chat-sidebar-thread-title__content {
display: block;
width: max-content;
transform: translateX(0);
}
.an-chat-history-row:hover
.chat-sidebar-thread-title[data-overflow="true"]
.chat-sidebar-thread-title__content {
animation: chat-sidebar-title-reveal
var(--chat-sidebar-title-duration, 1800ms) ease-in-out 350ms;
}
.chat-sidebar-thread-details {
border-color: hsl(var(--sidebar-border));
}
.chat-sidebar-history.an-chat-history--rail
.an-chat-history-row__menu-trigger--pinned {
pointer-events: none;
opacity: 0;
}
.chat-sidebar-history.an-chat-history--rail
.an-chat-history-row:hover
.an-chat-history-row__menu-trigger--pinned,
.chat-sidebar-history.an-chat-history--rail
.an-chat-history-row:focus-within
.an-chat-history-row__menu-trigger--pinned,
.chat-sidebar-history.an-chat-history--rail
.an-chat-history-row__menu-trigger--pinned[aria-expanded="true"] {
pointer-events: auto;
opacity: 1;
}
@keyframes chat-sidebar-title-reveal {
to {
transform: translateX(calc(-1 * var(--chat-sidebar-title-shift, 0px)));
}
}
@media (prefers-reduced-motion: reduce) {
.an-chat-history-row:hover .chat-sidebar-thread-title__content {
animation: none;
}
}
.chat-sidebar-history.an-chat-history--rail
.an-chat-history-row--active
.an-chat-history-row__button {
background: hsl(var(--sidebar-accent));
color: hsl(var(--sidebar-accent-foreground));
}
.dark {
--background: 0 0% 13%;
--foreground: 0 0% 90%;
--card: 0 0% 16.47%;
--card-foreground: 0 0% 90%;
--popover: 0 0% 15%;
--popover-foreground: 0 0% 90%;
--primary: 0 0% 75%;
--primary-foreground: 0 0% 10%;
--secondary: 0 0% 18%;
--secondary-foreground: 0 0% 90%;
--muted: 0 0% 16%;
--muted-foreground: 0 0% 60%;
--accent: 0 0% 18%;
--accent-foreground: 0 0% 90%;
--destructive: 0 84% 60%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 24%;
--input: 0 0% 24%;
--ring: 0 0% 60%;
--radius: 0.5rem;
--sidebar-background: 0 0% 10%;
--sidebar-foreground: 0 0% 60%;
--sidebar-primary: 0 0% 75%;
--sidebar-primary-foreground: 0 0% 10%;
--sidebar-accent: 0 0% 16%;
--sidebar-accent-foreground: 0 0% 90%;
--sidebar-border: 0 0% 20%;
--sidebar-ring: 0 0% 60%;
}
@layer base {
body {
@apply bg-background text-foreground;
font-family: "Inter Variable", "Inter", "Noto Sans Thai", sans-serif;
font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
}
::-webkit-scrollbar {
width: 5px;
height: 5px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: hsl(var(--muted-foreground) / 0.22);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: hsl(var(--muted-foreground) / 0.34);
}
@layer base {
/* ══ ความเท่ากันข้ามเอนจิน (Chromium / Firefox / Safari) ══════════════════
อยู่ใน @layer base เพื่อให้ utility ของ Tailwind (เช่น `text-sm`) ยังชนะได้
ทุกอย่างในบล็อกนี้มีไว้เพื่อให้ Firefox และ Safari ดู/ทำงานใกล้ Chromium ที่สุด
- `::-webkit-scrollbar` (ด้านบน) Firefox ไม่รู้จัก → ต้องมี scrollbar-width/color
- `color-scheme: dark` ทำให้ select/scrollbar/ฟอร์มเนทีฟเป็นโทนเข้มทุกเอนจิน
- `::selection` ใช้สีแบรนด์แทนสีฟ้าเริ่มต้นของ OS (คนละสีในแต่ละเอนจิน)
- `::-moz-focus-inner` กันระยะขอบภายในปุ่มที่ Firefox ใส่เอง
- Safari/iOS: ตัดไฮไลต์เทาตอนแตะ, กันข้อความพองตอนหมุนจอ, ตัดสไตล์เนทีฟของช่องค้นหา */
html {
color-scheme: dark;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
}
* {
scrollbar-width: thin;
scrollbar-color: hsl(var(--muted-foreground) / 0.22) transparent;
}
::selection {
background-color: #a92626;
color: #ffffff;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0;
}
/* iOS Safari ใส่กรอบ/มุมโค้งของตัวเองให้ช่องค้นหา — ตัดออกให้เหมือน desktop */
input[type="search"] {
-webkit-appearance: none;
appearance: none;
}
/* iOS Safari ซูมหน้าเมื่อโฟกัสช่องที่ font-size < 16px — ฟอร์มทุกตัวจึงใช้ 16px บนมือถือ
(ห้ามล็อกซูมด้วย user-scalable=no เพราะผิด WCAG 1.4.4) */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
font-size: 16px;
}
@media (min-width: 640px) {
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
font-size: inherit;
}
}
}
/* ══ Motion — อนิเมชันเล็ก ๆ ตอนโหลด/เลื่อน ═══════════════════════════════
เปิดใช้เฉพาะเมื่อผู้ใช้ไม่ได้ขอ reduced motion: สคริปต์ใน <head> (root.tsx)
ใส่คลาส .fx-motion ให้ <html> ก่อน paint → ไม่กระพริบ และถ้าปิด JS ไว้
เนื้อหาก็ยังแสดงครบเพราะไม่มีคลาสนี้ = ไม่มีอะไรถูกซ่อน
กติกา: ใช้ transform/opacity เท่านั้น (ไม่กระตุก), หน่วงไม่เกิน ~360ms */
:root {
--fx-fast: 160ms;
--fx-base: 280ms;
--fx-page: 460ms;
--fx-slow: 640ms;
--fx-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fx-rise-in {
from {
opacity: 0;
transform: translate3d(0, 28px, 0);
}
to {
opacity: 1;
transform: none;
}
}
@keyframes fx-fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes fx-pop-in {
from {
opacity: 0;
transform: scale(0.965);
}
to {
opacity: 1;
transform: none;
}
}
@keyframes fx-drop-in {
from {
opacity: 0;
transform: translate3d(0, -14px, 0);
}
to {
opacity: 1;
transform: none;
}
}
@keyframes fx-hero-zoom {
from {
opacity: 0;
transform: scale(1.06);
}
to {
opacity: 1;
transform: none;
}
}
@keyframes fx-page-in {
from {
opacity: 0;
transform: translate3d(0, 26px, 0);
}
to {
opacity: 1;
transform: none;
}
}
/* สลับภาพในแกลเลอรี (ปุ่มลูกศร) — จางเข้าเบา ๆ ไม่กระตุก */
@keyframes fx-swap-in {
from {
opacity: 0;
transform: scale(1.015);
}
to {
opacity: 1;
transform: none;
}
}
/* ══ สถานะตั้งต้น + อนิเมชัน reveal ══════════════════════════════════════
กันสองทาง:
1) เนื้อหาห้ามหายถ้าปิด JS → สถานะ "ซ่อน" ผูกกับคลาส `html.fx-motion`
(คลาสถูกใส่โดยสคริปต์ใน <head> และเสริมอีกครั้งจาก client effect)
2) อนิเมชันต้องทำงานแม้คลาสหลุด (เคยเกิดจาก hydration ลบคลาส) → ตัวอนิเมชัน
ผูกกับ `@media (prefers-reduced-motion: no-preference)` แทน
ผลคือทุกเอนจิน (Chromium / Firefox / Safari) ได้อนิเมชันเหมือนกัน และ
ผู้ใช้ที่ขอ reduced motion ได้เนื้อหานิ่งครบทันที */
html.fx-motion [data-reveal] {
opacity: 0;
}
@media (prefers-reduced-motion: no-preference) {
[data-reveal="rise"][data-revealed] {
animation: fx-rise-in var(--fx-slow) var(--fx-ease-out) var(--fx-delay, 0ms)
both;
}
[data-reveal="fade"][data-revealed] {
animation: fx-fade-in var(--fx-base) var(--fx-ease-out) var(--fx-delay, 0ms)
both;
}
[data-reveal="zoom"][data-revealed] {
animation: fx-pop-in var(--fx-slow) var(--fx-ease-out) var(--fx-delay, 0ms)
both;
}
/* อนิเมชันตอนโหลด (ไม่ผูกกับ scroll) */
.fx-page {
animation: fx-page-in var(--fx-page) var(--fx-ease-out) both;
}
.fx-swap {
animation: fx-swap-in 320ms var(--fx-ease-out) both;
}
.fx-drop {
animation: fx-drop-in var(--fx-base) var(--fx-ease-out) both;
}
.fx-hero-image {
animation: fx-hero-zoom 1400ms var(--fx-ease-out) both;
}
}
/* ทางออกสุดท้าย: ถ้าผู้ใช้ขอ reduced motion ให้ทุกอย่างนิ่งและเห็นครบ */
@media (prefers-reduced-motion: reduce) {
[data-reveal],
.fx-page,
.fx-drop,
.fx-swap,
.fx-hero-image {
animation: none !important;
opacity: 1 !important;
transform: none !important;
}
}