/* =============================================================================
   SÓNG — nền tảng: reset, chữ, phần tử cơ bản
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

/*  Ai bật "giảm chuyển động" trong hệ điều hành thường là vì chuyển động làm
    họ chóng mặt hoặc buồn nôn — với một số người đây là vấn đề sức khoẻ thật,
    không phải sở thích. Tắt gần hết, chỉ chừa lại một nhịp rất ngắn để giao
    diện không nhảy giật cục.                                                 */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    /*  Chừa chỗ cho thanh phát cố định dưới cùng, cộng vùng an toàn của điện
        thoại có khấc. Thiếu dòng này thì bài cuối danh sách bị thanh phát che. */
    padding-bottom: calc(var(--h-player) + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 860px) {
    body {
        padding-bottom: calc(var(--h-player-m) + var(--h-tabbar) + env(safe-area-inset-bottom, 0px));
    }
}

h1, h2, h3, h4 {
    margin: 0 0 var(--s-3);
    line-height: var(--lh-tight);
    font-weight: 700;
    letter-spacing: -.02em;
    text-wrap: balance;      /* tránh dòng cuối trơ trọi một chữ */
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--s-4); }

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}
a:hover { color: var(--brand-soft); }

/*  Viền tiêu điểm chỉ hiện khi điều hướng bằng bàn phím (:focus-visible), chứ
    không hiện khi bấm chuột. Xoá hẳn outline là cắt đường đi của người dùng
    bàn phím — họ sẽ không biết mình đang đứng ở đâu.                         */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--brand-soft);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

img, video { max-width: 100%; height: auto; display: block; }

button, input, select, textarea {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}
button:disabled { cursor: not-allowed; opacity: .5; }

ul, ol { margin: 0; padding: 0; list-style: none; }

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: var(--s-6) 0;
}

::selection {
    background: var(--brand);
    color: var(--text-on-brand);
}

/* ---- Thanh cuộn -------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: var(--r-full);
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---- Tiện ích ----------------------------------------------------------- */

/*  Chữ chỉ dành cho trình đọc màn hình. Không dùng display:none — cái đó ẩn
    khỏi cả trình đọc màn hình, tức là làm hỏng đúng thứ đang muốn phục vụ.  */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/*  Link "tới nội dung chính" — ẩn cho tới khi người dùng bàn phím nhấn Tab
    lần đầu. Giúp họ bỏ qua cả menu để vào thẳng nội dung.                   */
.skip-link {
    position: absolute;
    top: -100px; left: var(--s-4);
    z-index: var(--z-toast);
    background: var(--brand);
    color: var(--text-on-brand);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r);
    font-weight: 600;
    transition: top var(--t) var(--ease);
}
.skip-link:focus { top: var(--s-4); }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*  Cắt sau N dòng. -webkit-line-clamp vẫn là cách duy nhất chạy ở mọi nơi;
    line-clamp chuẩn hoá còn chưa đủ phổ biến để bỏ tiền tố.                 */
.clamp-2, .clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.clamp-2 { -webkit-line-clamp: 2; }
.clamp-3 { -webkit-line-clamp: 3; }

.num { font-variant-numeric: tabular-nums; }

/* Chữ tô màu thương hiệu. background-clip:text cần cả bản có tiền tố cho Safari. */
.grad-text {
    background: var(--brand-grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
