/* ==========================================================================
   DTL Accounting — Base
   Load order: tokens.css -> reset.css -> typography.css -> base.css
   Thiết lập nền tảng: document, container, focus, motion, selection,
   và các utility class dùng chung toàn site (không thuộc riêng component nào).
   ========================================================================== */

/* 1. Document */
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    overflow-x: hidden; /* an toàn cuối cùng — không component nào được phép gây horizontal overflow */
}

/* 2. Container — dùng chung toàn site theo foundations/design_system.md */
.container {
    width: min(100% - (var(--container-padding-inline) * 2), var(--container-max-width));
    margin-inline: auto;
}

/* 3. Section spacing — theo Spacing Scale, tránh margin/padding tự phát cho từng section */
.section {
    padding-block: var(--space-12);
}

@media (min-width: 768px) {
    .section {
        padding-block: var(--space-16);
    }
}

@media (min-width: 1024px) {
    .section {
        padding-block: var(--space-20);
    }
}

.section--alt {
    background-color: var(--color-surface-alt);
}

.section--tinted {
    background-color: var(--color-surface-tinted);
}

/* 4. Focus state — áp dụng toàn cục qua :focus-visible.
   KHÔNG được xóa outline ở đâu khác trong codebase mà không có thay thế
   tương đương (bắt buộc theo foundations/accessibility.md mục 3). */
:focus-visible {
    outline: var(--focus-ring-width) var(--focus-ring-style) var(--color-focus-ring);
    outline-offset: var(--focus-ring-offset);
}

[aria-invalid="true"]:focus-visible {
    outline-color: var(--color-focus-ring-error);
}

/* 5. Text selection — dùng brand tint thay vì mặc định trình duyệt */
::selection {
    background-color: var(--navy-200);
    color: var(--color-text-primary);
}

/* 6. Skip link — điều hướng bàn phím bỏ qua navigation, ẩn cho tới khi được focus */
.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    z-index: 100;
    padding: var(--space-2) var(--space-4);
    background-color: var(--color-surface);
    color: var(--color-text-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: top 0.15s ease;
}

.skip-link:focus-visible {
    top: var(--space-4);
}

/* 7. Visually hidden — dùng cho text chỉ dành cho screen reader
   (VD: label ẩn, icon accessible name theo accessibility.md mục 7) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 8. Icon trang trí — ẩn khỏi assistive tech, không thay thế label quan trọng */
.icon-decorative {
    pointer-events: none;
}

/* 9. Motion — tôn trọng prefers-reduced-motion trên toàn site
   (bắt buộc theo foundations/design_system.md mục 9 và accessibility.md mục 6) */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* 10. Disabled state — dùng chung cho button/input, không giảm contrast
   xuống mức khó đọc (theo components/form.md mục 3) */
[disabled],
[aria-disabled="true"] {
    cursor: not-allowed;
}