/* ==========================================================================
   Kai Design System - Reset & Base Document Styles
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: var(--app-base-font-size, 16px);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
}

body {
    margin: 0;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: 400;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Focus accessibility: crisp 2px ring with 2px offset for keyboard users */
:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[tabindex]:focus:not(:focus-visible) {
    outline: none;
}

/* Typography defaults */
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd {
    margin-top: 0;
}

p {
    margin-bottom: var(--space-3);
}

ul, ol {
    margin-top: 0;
    margin-bottom: var(--space-3);
    padding-left: 1.5rem;
}

b, strong {
    font-weight: 600;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--link-hover-color);
    text-decoration: underline;
}

hr {
    margin: var(--space-4) 0;
    color: inherit;
    border: 0;
    border-top: 1px solid var(--border-color);
    opacity: 1;
}

img, svg, video, canvas, audio, iframe, embed, object {
    display: inline-block;
    vertical-align: middle;
}

img, svg, video, canvas {
    max-width: 100%;
}

button,
input,
optgroup,
select,
textarea {
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

button,
[type="button"],
[type="reset"],
[type="submit"] {
    cursor: pointer;
}

button:disabled,
[type="button"]:disabled,
[type="reset"]:disabled,
[type="submit"]:disabled {
    cursor: not-allowed;
}

textarea {
    resize: vertical;
}

table {
    caption-side: bottom;
    border-collapse: collapse;
}

th {
    text-align: inherit;
}

code, kbd, samp, pre {
    font-family: var(--font-mono);
}

code {
    font-size: 0.875em;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    padding: 0.125em 0.35em;
    border-radius: var(--radius-xs);
    word-wrap: break-word;
}

pre {
    display: block;
    margin-top: 0;
    margin-bottom: var(--space-4);
    overflow: auto;
    font-size: var(--text-sm);
    line-height: 1.55;
    padding: var(--space-4);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

pre code {
    font-size: inherit;
    color: inherit;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    word-break: normal;
}

::selection {
    background-color: var(--accent-primary);
    color: var(--accent-contrast);
}

/* Minimalist Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-strong);
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

::-webkit-scrollbar-corner {
    background: transparent;
}
