/* ==========================================================================
   Base: reset, page, typography, utilities and form fields.
   ========================================================================== */

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

html,
body {
    height: 100%;
}

html {
    background: var(--c-bg);
}

body {
    margin: 0;
    overflow: hidden;
    background: var(--c-bg);
    color: var(--c-text);
    font: 400 var(--fs-sm)/1.4 var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none;
    user-select: none;
}

h1,
h2,
h3,
p {
    margin: 0;
}

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

button {
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

input,
textarea,
[contenteditable] {
    -webkit-user-select: text;
    user-select: text;
}

a {
    color: var(--c-accent);
}

/* --------------------------------------------------------- utilities */

/* The one !important in the project: hidden must win over any display rule. */
[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Letter-spacing splits Thai vowels and tone marks from their consonants. */
:lang(th) {
    letter-spacing: 0;
}

.icon {
    flex: none;
    width: 1em;
    height: 1em;
    fill: currentColor;
}

::selection {
    background: #ffffff;
    color: #000000;
}

:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ------------------------------------------------------------- fields */

.field {
    min-width: 0;
    height: var(--h-ctl);
    padding: 0 var(--sp-5);
    border: 1px solid var(--c-line-2);
    border-radius: var(--r-chrome);
    background: var(--c-field);
    color: var(--c-text);
    font: 500 var(--fs-sm)/1 var(--font-tech);
    transition: border-color var(--t-fast) ease, box-shadow var(--t-fast) ease;
}

.field::placeholder {
    color: var(--c-text-4);
}

.field:hover {
    border-color: var(--c-line-3);
}

.field:focus {
    border-color: rgba(var(--c-accent-rgb), 0.7);
    box-shadow: 0 0 0 3px rgba(var(--c-accent-rgb), 0.14);
}

.field:focus-visible {
    outline: none;
}

.field[aria-invalid="true"] {
    border-color: var(--c-danger);
}

.field--lg {
    height: var(--h-ctl-lg);
}

.field--block {
    width: 100%;
}

textarea.field {
    height: auto;
    padding: var(--sp-4) var(--sp-5);
    line-height: 1.5;
    resize: vertical;
}

select.field {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 28px;
    background: var(--c-field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' d='M7.41 8.59 12 13.17l4.59-4.58L18 10l-6 6-6-6z'/%3E%3C/svg%3E") no-repeat right 8px center / 14px 14px;
    cursor: pointer;
}

select.field option {
    background: var(--c-panel);
    color: var(--c-text);
}

/* -------------------------------------------------------- range slider */
/* A thin, faint track so the line reads behind the thumb. */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    margin: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 1px;
    border: 0;
    background: rgba(255, 255, 255, 0.24);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    margin-top: -5.5px;
    border: 2px solid var(--c-bg);
    border-radius: 2px;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
}

input[type="range"]:hover::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.4);
}

input[type="range"]:focus-visible {
    outline-offset: 0;
}
