body {
    font-family: system-ui, sans-serif;
    background-color: var(--background);
    color: var(--text);

    overscroll-behavior: contain;
    font-size: 25px;
    margin: 0;
    padding: 0;
    height: 100dvh;
    width: 100dvw;
    gap: 1em
}

h1, h2, h3, h4, h5, h6 {
    margin: 0.5em 0;
    text-align: center;
}

h2 {
    margin: 0.3em 0;
}

h5 {
    padding: 0;
}

.hidden {
    display: none !important;
}

/* THEME BUTTON */

#theme-button-box {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    padding: 1em;
    appearance: none;
    aspect-ratio: 1/1;
    width: 2em;
    height: 2em;
}

#theme-button-label {
    content: url("./static/icons/dark_mode.svg");
    background-color: lightslategray;
    border-radius: 1em;
    aspect-ratio: 1/1;
    width: 100%;
    user-select: none;
    -webkit-user-select: none;
}

#theme-button-label:has(:checked) {
    content: url("./static/icons/light_mode.svg");
    filter: invert(100%);
    background-color: #349dff;
    padding: 0.2em;
}

/* MAIN LAYOUT */

#centering-box {
    height: 100%;
    display: grid;
    grid-template:
    "." 10fr
    "main" 1fr
    "." minmax(0, 1em)
    "result" auto
    "." minmax(0, 1em)
    "stats" auto
    "." 9fr / auto;
    justify-content: center;
    justify-items: center;
}

#centering-box:has(#result-box:not(.hidden)) {
    grid-template:
    "." 1.5em
    "main" auto
    "." minmax(0, 5em)
    "result" auto
    "." minmax(0, 2em)
    "stats" auto
    "." 2fr / auto;
}

.section-column {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

/* MAIN SEARCH */

#main-box {
    grid-area: main;
    display: flex;
    justify-content: end;
}

#search-box {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
}

#input-search-box {
    position: relative;
    width: 90%;
}

#input-search-box:after {
    content: url("./static/icons/search.svg");
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    height: 100%;
    padding-right: 0.45em;
    display: flex;
    justify-content: center;
    align-items: center;
    color: red;
    pointer-events: none;
    filter: var(--filter-secondary);
}

#search {
    font-family: system-ui, sans-serif;
    padding: 0.3em 0.6em;
    font-size: 0.8em;
    appearance: none;
    width: 100%;
    border: var(--secondary) solid 2px;
    border-radius: 0.5em;
    background-color: var(--background-field);
    color: var(--text-field);
}

#custom-autocomplete {
    position: absolute;
    display: flex;
    flex-direction: column;
    max-height: 15em;
    overflow-y: auto;
    box-sizing: border-box;
    top: 100%;
    left: 2%;
    width: 96%;
    border-top-width: 0;
    font-size: 0.8em;
    z-index: 10;
}

.autocomplete {
    display: flex;
    background: var(--autocomplete);
    color: var(--text-field);
    border: var(--autocomplete-border) solid 1px;
    border-bottom: none;
    text-decoration: none;
    padding: 2px;
}

.in-autocomplete {
    padding: 0.3em 0.4em;
}

.id {
    display: inline-table;
    text-align: center;
    white-space: nowrap;
    min-width: 2.8em;
    align-self: center;
}

.full-name {
    font-size: 0.8em;
    display: flex;
    align-items: center;
    padding-left: 0.5em;
    border-left: var(--autocomplete-border) dashed 1px;
    hyphens: none;
}

.autocomplete:first-child {
    border-top: none;
}

.autocomplete:last-child {
    border-bottom: var(--autocomplete-border) solid 1px;
}

.autocomplete-category > .autocomplete:last-child {
    border-bottom: var(--autocomplete-border) solid 1px;
}

.autocomplete:hover {
    cursor: pointer;
    background-color: var(--hover);
}

.autocomplete:focus {
    margin: 2px;
    padding: 0;
    outline: 2px solid var(--secondary);
}

.autocomplete-category {
    background: var(--autocomplete);
    border-right: var(--autocomplete-border) solid 1px;
    border-left: var(--autocomplete-border) solid 1px;
    color: var(--text-field);
}

.autocomplete-category:last-child {
    border-bottom: var(--autocomplete-border) solid 1px;
}

.autocomplete-category + .autocomplete-category {
    border-top: var(--autocomplete-border) double 4px;
}

.autocomplete-category-text {
    padding-bottom: 0.3em;
}

#typing-hint-box {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    height: 100%;
    width: 100%;
    justify-content: left;
    align-items: center;
    pointer-events: none;
    font-size: 0.8em;
}

#typing-hint {
    position: relative;
    margin-left: 0.7em;
    color: var(--text-hint);
}

#typing-hint-indicator {
    margin-right: 0.7em;
    text-align: center;
    display: inline-block;
    background-color: var(--text-hint);
    width: 0.05em;
    height: 1.32em;
    animation: 1.05s steps(1, end) blink infinite;
}

.stopped {
    animation: none !important;
}

@keyframes blink {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* STATISTICS */

#stat-box {
    grid-area: stats;
}

.section-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
}

#number-stats-box {
    display: grid;
    grid-template:
    "sum . update . old" auto / 1fr minmax(0, 1em) 1fr minmax(0, 1em) 1fr;
    background: var(--primary);
    color: var(--text-light);
    padding: 0.5em;
    border-radius: 0.4em;
    align-items: start;
    justify-items: center;
}

#inst-sum-box {
    grid-area: sum;
}

#inst-update-box {
    grid-area: update;
}

#inst-old-box {
    grid-area: old;
}

.stat {
    font-size: 0.7em;
    gap: 0.2em;
    text-align: center;
}

.number-stat {
    font-size: 2em;
    font-weight: bold;
}

/* RESULT WINDOW */

#result-box {
    grid-area: result;
    color: var(--text-result);
    border: var(--secondary) double 5px;
    border-right: none;
    border-left: none;
    padding: 0.5em 0.4em;
}

#info-box {
    max-width: 1000px;
}

#info-bar {
    display: grid;
    grid-template:
    "update id badges" auto / 1fr auto 1fr;
    gap: 0.5em;
}

#instr-update-box {
    grid-area: update;
    display: flex;
    flex-direction: column;
    align-self: center;
    text-align: center;
    padding: 0 1em;
    font-size: 0.8em;
}

#instr-last-update {
    font-weight: bold;
    color: #009859;
}

#instr-new-version {
    font-weight: bold;
    color: #ff6700;
}

#instr-id {
    grid-area: id;
    padding: 0.2em;
    border: 5px solid var(--id-border);
    min-height: 1.3em;
    align-items: center;
    display: flex;
}

#instr-id:empty {
    border-color: transparent;
}

#instr-badges-box {
    grid-area: badges;
}

#open-instr-button {
    margin: 0.5em 0;
    padding: 0.2em 0.7em;
    background-color: var(--button-background);
    font-size: 1.15em;
    border-radius: 0.8em;
    font-weight: bold;
    color: var(--button-text);
    border: var(--button-border) outset 0.2em
}

#open-instr-button:active {
    border-style: inset;
}

/* BADGES */

#instr-badges-box {
    display: grid;
    align-items: center;
    justify-content: center;
    grid-auto-flow: dense;
    grid-template-columns: repeat(auto-fit, minmax(min-content, 100px));
    text-align: center;
    overflow: hidden;
    font-size: 0.7em;
}

.badge {
    border: 0.25em ridge darkgray;
    font-weight: bold;
    font-family: monospace;
    padding: 1px 2px;
    margin: 0 0.2em;
    background-color: wheat;
    border-radius: 5px;
    position: relative;
    z-index: 0;
}

#badge-newest {
    background-color: palegreen;
    border-color: green;
    color: darkgreen;
}

#badge-old {
    background-color: #ffaf98;
    border-color: orangered;
    color: darkred;
}

#badge-wcag {
    background-color: lightblue;
    border-color: cadetblue;
    color: #273c3e;
}

#badge-changes-soon {
    background-color: #ffee4f;
    border-color: #ff9d2c;
    color: #ff6200;
}


/* MOBILE COMPATIBILITY */

@media only screen and (min-width: 600px) and (max-height: 455px) {
    #stat-box {
        display: none;
    }

    #custom-autocomplete {
        max-height: 50dvh
    }
}

@media only screen and (max-width: 775px) {
    #theme-button-box {
        padding: 0.5em;
    }
}

@media only screen and (max-height: 620px) and (min-width: 600px) {
    body {
        font-size: 1.3em;
    }

    h1 {
        margin: 0.1em 0 0.3em 0;
    }

    #centering-box {
        grid-template:
        "main" auto
        "." minmax(0, 1em)
        "result" auto
        "." minmax(0, 1em)
        "stats" auto
        "." 1fr / auto;
    }

    #centering-box:has(#result-box:not(.hidden)) {
        grid-template:
        "main" auto
        "." minmax(0, 2em)
        "result" auto
        "." minmax(0, 2em)
        "stats" auto
        "." 1fr / auto;
    }
}

@media only screen and (max-width: 600px) {
    body {
        font-size: 1.3em;
    }
}

@media only screen and (max-width: 600px) and (max-height: 900px) {
    #centering-box {
        grid-template:
        "." minmax(0.8em, 1.2em)
        "main" auto
        "." minmax(0, 1em)
        "result" auto
        "." minmax(0, 1em)
        "stats" auto
        "." 1fr / auto;
    }

    #centering-box:has(#result-box:not(.hidden)) {
        grid-template:
        "." minmax(0.8em, 1.2em)
        "main" auto
        "." minmax(0, 2em)
        "result" auto
        "." 1fr
        "stats" auto / auto;
    }

    #theme-button-box {
        padding: 0.5em;
    }
}

@media only screen and (max-width: 435px) {
    #number-stats-box {
        border-radius: 0;
    }
}