/*
 * SPDX-FileCopyrightText: 2026 Andyou <andyou@animagram.jp>
 * SPDX-License-Identifier: Apache-2.0
 */

@layer css.reset {

    /*
        Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property
        - The "symbol *" part is to solve Firefox SVG sprite bug
        - The "html" element is excluded, otherwise a bug in Chrome breaks the CSS hyphens property (https://github.com/elad2412/the-new-css-reset/issues/36)
    */
    :where(:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)) {
        all: unset;
        display: revert;
    }

    /* Preferred box-sizing value */
    *,
    *::before,
    *::after,
    ::backdrop, /* per tailwind-preflight.css:7-16 */
    ::file-selector-button { /* per tailwind-preflight.css:7-16 */
        box-sizing: border-box;
    }

    /* Fix mobile Safari increase font-size on landscape mode */
    html, :host { /* per tailwind-preflight.css:28-51 */
        -moz-text-size-adjust: none;
        -webkit-text-size-adjust: none;
        text-size-adjust: none;
        line-height: var(--md-line-height); /* per tailwind-preflight.css:28-51 */
        tab-size: 4; /* per tailwind-preflight.css:28-51 */
        text-spacing-trim: trim-start; /* per kiso.css:30 */
        text-autospace: normal; /* per kiso.css:33 */
        line-break: strict; /* per kiso.css:36 */
        overflow-wrap: anywhere; /* per kiso.css:39 */
        -webkit-tap-highlight-color: transparent; /* per kiso.css:55 */
    }

    html:focus-within { /* per modern-reset.css */
        scroll-behavior: smooth;
    }
    @media (prefers-reduced-motion: reduce) {
        html:focus-within {
            scroll-behavior: auto;
        }
    }

    @media screen {
        body {
            min-block-size: 100dvb; /* per kiso.css:63 */
        }
    }

    /* Revert Modal native behavior */
    :where(dialog:modal) {
        all: revert;
        box-sizing: border-box;
        scrollbar-gutter: stable;
    }

    :where(html) {
        scrollbar-gutter: stable;
    }
    :where(html):has(:modal) {
        overflow: hidden;
    }

    :where(dialog, [popover]) { /* per kiso.css:483-493 */
        overscroll-behavior-block: contain;
    }

    :is(h1, h2, h3, h4, h5, h6, p, caption):lang(en) { /* per kiso.css:74, 118, 311 */
        text-wrap: pretty;
    }

    hr { /* per tailwind-preflight.css:53-63 */
        border-block-start-width: 1px;
        border-block-start-style: solid;
        height: 0;
    }

    /* Firefox: solve issue where nested ordered lists continue numbering from parent (https://bugzilla.mozilla.org/show_bug.cgi?id=1881517) */
    ol {
        counter-reset: revert;
    }

    /* Remove list styles (bullets/numbers). */
    ol, ul, menu, summary {
        list-style: none;
    }

    /* preformatted text - use only for this feature */
    pre {
        all: revert;
        box-sizing: border-box;
    }

    b, strong { /* per tailwind-preflight.css:98-105 */
        font-weight: bolder;
    }

    em:lang(ja) { /* per kiso.css:171 */
        font-weight: bolder;
    }

    cite, i, dfn, em { /* per kiso.css:174 */
        font-style: italic;
    }
    :where(cite, i, dfn, em):where(:lang(ja), :lang(zh), :lang(ko)) { /* per kiso.css:176 */
        font-style: normal;
    }

    small { /* per tailwind-preflight.css:134-140, but "smaller" not "80%" */
        font-size: smaller;
    }

    sub, sup { /* per tailwind-preflight.css:142-160 */
        font-size: 0.75em;
        line-height: 0;
        position: relative;
        vertical-align: baseline;
    }
    sub { /* per tailwind-preflight.css:142-160 */
        bottom: -0.25em;
    }
    sup { /* per tailwind-preflight.css:142-160 */
        top: -0.5em;
    }

    time { /* per kiso.css:220 */
        text-autospace: no-autospace;
    }

    /* Reapply the pointer cursor for anchor tags */
    a, button {
        cursor: revert;
    }

    a { /* per modern-reset.css */
        text-decoration-skip-ink: auto;
    }

    /* For images to not be able to exceed their container */
    img, svg, picture, video, audio, canvas, model, iframe, embed, object { /* per kiso.css:276-282 */
        max-inline-size: 100%;
        vertical-align: bottom;
    }

    img, svg, picture, video, canvas, model, iframe, embed, object { /* per kiso.css:284-291 */
        display: inline flow-root;
        block-size: auto;
    }

    iframe { /* per kiso.css:294-296 */
        border: unset;
    }

    /* removes spacing between cells in tables */
    table {
        border-collapse: collapse;
        text-indent: 0; /* per tailwind-preflight.css:162-172 */
        border-color: inherit; /* per tailwind-preflight.css:162-172 */
    }

    /* Safari - solving issue when using user-select:none on the <body> text input doesn't working */
    input, textarea {
        -webkit-user-select: auto;
    }

    input[type="search"] { /* per kiso.css:348-351 */
        appearance: textfield;
    }

    input[type="number"] {
        appearance: textfield;
    }
    
    @supports (-webkit-touch-callout: none) { /* per kiso.css:353-358 */
        input[type="search"] {
            background-color: Canvas;
        }
    }

    input:is([type="tel"], [type="url"], [type="email"], [type="number"]):not(:placeholder-shown) { /* per kiso.css:360-374 */
        direction: ltr;
    }

    /* revert the 'white-space' property for textarea elements on Safari */
    textarea {
        white-space: revert;
        resize: block; /* per kiso.css:381 */
    }

    input:not([type="button"], [type="submit"], [type="reset"]), textarea, [contenteditable] { /* per kiso.css:384-391 */
        text-autospace: no-autospace;
    }

    ::file-selector-button { /* per tailwind-preflight.css:236-257 */
        color: inherit;
        font: inherit;
        font-feature-settings: inherit;
        font-variation-settings: inherit;
        letter-spacing: inherit;
        background-color: unset; /* per kiso.css:393-400 */
    }

    :where(
        button,
        input:is([type="button"], [type="submit"], [type="reset"]),
        [role="tab"],
        [role="button"],
        [role="option"]
    ),
    ::file-selector-button { /* per kiso.css:402-416 */
        touch-action: manipulation;
    }

    fieldset { /* per kiso.css:438-450 */
        min-inline-size: 0;
    }

    /* minimum style to allow to style meter element */
    meter {
        -webkit-appearance: revert;
        appearance: revert;
    }

    ::-webkit-search-decoration { /* per tailwind-preflight.css:311-317 */
        -webkit-appearance: none;
    }

    /* reset default text opacity of input placeholder. */
    ::placeholder { /* per tailwind-preflight.css:283-289 */
        opacity: 1;
    }

    :-moz-ui-invalid { /* per tailwind-preflight.css:365-371 */
        box-shadow: none;
    }

    ::-webkit-inner-spin-button,
    ::-webkit-outer-spin-button { /* per tailwind-preflight.css:383-390 */
        height: auto;
        appearance: none;
        margin: 0;
    }

    /* revert for bug in Chromium browsers
       - fix for the content editable attribute will work properly.
       - webkit-user-select: auto; added for Safari in case of using user-select:none on wrapper element*/
    :where([contenteditable]:not([contenteditable="false"])) {
        -moz-user-modify: read-write;
        -webkit-user-modify: read-write;
        overflow-wrap: break-word;
        -webkit-line-break: after-white-space;
        -webkit-user-select: auto;
    }

    /* apply back the draggable feature - exist only in Chromium and Safari */
    :where([draggable="true"]) {
        -webkit-user-drag: element;
    }

    /* fix the feature of 'hidden' attribute.
       display:revert; revert to element instead of attribute */
    :where([hidden]):where(:not([hidden="until-found"])) { /* per tailwind-preflight.css:392-398 */
        display: none !important;
    }
}
