:root {
    --max-width: 1320px;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --slate-950: #020617;
}

body:has(#lightmode:checked) {
    --slate-50: #080f31;
    --slate-100: #475472;
    --slate-200: #334155;
    --slate-300: #475569;
    --slate-400: #64748b;
    --slate-500: #94a3b8;
    --slate-600: #cbd5e1;
    --slate-700: #e2e8f0;
    --slate-800: #f1f5f9;
    --slate-900: #f8fafc;
    --slate-950: #f8fafc;
}

@supports (color: oklch(0% 0 0)) {
    :root {
        --slate-50: oklch(0.984 0.003 247.858);
        --slate-100: oklch(0.968 0.007 247.896);
        --slate-200: oklch(0.929 0.013 255.508);
        --slate-300: oklch(0.869 0.022 252.894);
        --slate-400: oklch(0.704 0.04 256.788);
        --slate-500: oklch(0.554 0.046 257.417);
        --slate-600: oklch(0.446 0.043 257.281);
        --slate-700: oklch(0.372 0.044 257.287);
        --slate-800: oklch(0.279 0.041 260.031);
        --slate-900: oklch(0.208 0.042 265.755);
        --slate-950: oklch(0.129 0.042 264.695);
    }
}

@font-face {
    font-family: "Tofu";
    font-weight: 400;
    font-display: swap;
    src: url("https://font.emtech.cc/file/original-fonts/Tofu/PawFont.woff2") format("woff2");
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: color 0.5s ease-out, background-color 0.5s ease-in-out;
}
body,
input,
button {
    font-family: "源起黑體月", "Noto Sans TC", sans-serif;
}

p {
    line-height: 150%;
}

a {
    color: #4896ff;
    text-decoration: none;
    transition: color 0.3s ease-out;
}

a:hover {
    color: #8cbeff;
}

img {
    display: block;
    max-width: 100%;
    color: transparent;
}

button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

body {
    background-color: var(--slate-900);
    color: var(--slate-100);
}

main {
    max-width: 1700px;
    margin: 0 auto;
    position: relative;
    height: 100vh;
    height: 100dvh;
}

header {
    width: 22rem;
    max-width: 100%;
    padding: 2rem 3rem;
    border-right: var(--slate-800) 1px solid;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: fixed;
    z-index: 20;
    background-color: var(--slate-900);
}

@media (min-width: 1700px) {
    header::before {
        height: 100%;
        width: calc(50vw - 850px);
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        transform: translateX(-100%);
        background-color: var(--slate-900);
    }
}

#logo {
    height: 2.8rem;
    width: auto;
}

body:has(#lightmode:checked) #logo {
    color: rgb(241, 245, 249);
    filter: brightness(0) invert(31%) sepia(19%) saturate(935%) hue-rotate(184deg) brightness(90%) contrast(83%);
}

section {
    flex: 1;
    position: relative;
    margin-left: 22rem;
}

/* hide everything */

.search-container,
.font-container,
.info-container,
section > div {
    display: none;
    transition: opacity 0.3s ease-in-out;
}

section > div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-height: 100vh;
}

.home #section-home,
.about #section-about,
.fonts #section-search,
.font .info-container {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

.fonts .search-container,
.fonts-toHome .search-container {
    display: block;
}

.fonts .search-container > * {
    animation: fadeIn 0.3s ease-in-out;
}
.font .header-links-font,
.login #section-login,
.notFound #section-404,
.font #section-font {
    display: flex;
    animation: fadeIn 0.3s ease-in-out;
}
.font .header-container,
.fonts .header-container,
.fonts-toHome #font-button,
.fonts #font-button {
    opacity: 0;
    pointer-events: none;
}

.fonts-toHome .header-container {
    opacity: 1;
    pointer-events: all;
}

.header-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: opacity 0.3s ease-in-out;
}

@keyframes fadeInBottom {
    0% {
        opacity: 0;
        transform: translateY(1rem);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-links {
    display: flex;
    gap: 0.6rem;
    position: relative;
    width: calc(100% + 2rem);
    margin-left: -1rem;
}

.header-links > a,
.header-links > label {
    flex: 1;
    border-radius: 0.5rem;
    background: var(--slate-800);
    height: 100%;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 2.6rem;
}

.header-links img {
    width: 1.6rem;
}

.lightmodeLabel {
    cursor: pointer;
    position: relative;
}

.lightmodeLabel::before,
.lightmodeLabel::after {
    content: "";
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 1.6rem;
    height: 1.6rem;
    transition: scale 0.3s ease-in-out;
    transform-origin: top left;
    background: url("/assets/img/dark.svg") no-repeat center center / contain;
}

.lightmodeLabel::after {
    background-image: url("/assets/img/light.svg");
    scale: 0;
}

main:has(.lightmodeLabel:checked) .lightmodeLabel::after {
    scale: 1;
}

main:has(.lightmodeLabel:checked) .lightmodeLabel::before {
    scale: 0;
}

.header-links-font {
    position: absolute;
    top: 0;
    left: 0;
    display: none;
    width: 100%;
    margin-left: 0;
}

.navigation {
    font-size: 1.6rem;
}

.navigation a {
    color: var(--slate-100);
    transition: color 0.3s ease-out;
}

.navigation a:hover {
    color: #4896ff;
}

.navigation li {
    margin-bottom: 2rem;
    list-style: none;
}

nav.navigation {
    flex: 1;
    transition: opacity 0.3s ease-in-out;
    margin-top: 3rem;
}

h1 {
    margin-bottom: 2rem;
    font-size: 2rem;
}

#section-404,
#section-login {
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 100%;
}

#section-404 h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

#section-404 a:last-child {
    display: block;
    margin-top: 0.5rem;
}

#section-login h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}
#section-login p {
    font-size: 1.2rem;
}

.btn {
    padding: 1.2rem 2.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.3rem;
    color: var(--slate-100);
    background-color: var(--slate-700);
    border-radius: 1rem;
    margin-top: 2rem;
    transition: background-color 0.3s ease-out;
}

a.btn:hover {
    color: var(--slate-100);
    background-color: var(--slate-600);
}

a.btn:active {
    color: var(--slate-100);
    background-color: var(--slate-500);
}

#section-about {
    padding: 10rem 3rem 3rem;
}

#section-about p {
    max-width: 40rem;
    margin-bottom: 1rem;
}

#section-about {
    background: linear-gradient(rgba(15, 23, 42, 0.8), rgba(15, 23, 42, 0.8)), url("/assets/img/logo/emfont-logo-light.svg") no-repeat right bottom;
    background-size: 80%;
}

body:has(#lightmode:checked) #section-about {
    background: linear-gradient(rgba(241, 245, 249, 0.8), rgba(241, 245, 249, 0.8)), url("/assets/img/logo/emfont-logo-dark.svg") no-repeat right bottom / 80%;
}

.credits {
    display: flex;
    max-width: 50rem;
    margin-top: 5rem;
    text-align: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2rem;
}
.credits h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.buy-me-a-coffee {
    flex: 0 0 100%;
    margin-top: 1rem;
}
.buy-me-a-coffee img {
    margin: auto;
}
.contributors,
.sponsors {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.contributors > div {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 2rem;
    flex: 1;
}

.contributors img {
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1rem;
}

.ncse {
    width: 185px;
}

.contributors a {
    color: var(--slate-100);
}

.sponsors img,
.sponsors svg {
    margin: auto;
    margin-bottom: 2rem;
    width: 211px;
}

.sponsors a {
    color: #f1f5f9;
}
body:has(#lightmode:checked) .sponsors a {
    color: #000;
}

#section-home {
    color: var(--slate-700);
    height: 100%;
    line-height: 1;
    white-space: nowrap;
}

body:has(#lightmode:checked) #section-home {
    color: var(--slate-600);
}

body:has(#lightmode:checked) #section-home > div:nth-child(2n) {
    color: var(--slate-700);
}

body:has(.home) {
    overflow: hidden;
}

#section-home > div:nth-child(2n) {
    color: var(--slate-800);
}

#section-home > div {
    animation: marquee 20s linear infinite;
    --innerWidth: 100vw;
}

@media (prefers-reduced-motion: reduce) {
    #section-home > div {
        animation: fadeIn 3s linear infinite alternate;
    }
    #section-home > .emfont-GenYoMinTC-min {
        animation-delay: -2s;
    }
    #section-home > .emfont-jfOpenHuninn-min {
        animation-delay: -1s;
    }
    #section-home > .emfont-MantouSans-min {
        animation-delay: -2s;
    }
    #section-home > .emfont-ChenYuLuoYan-min {
        animation-delay: -1.5s;
    }
    #section-home > .emfont-ChillBitmap16px-min {
        animation-delay: -2.5s;
    }
    #section-home > div:nth-child(2n) {
        color: unset;
    }
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(var(--innerWidth));
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0.2;
    }
    100% {
        opacity: 1;
    }
}

.emfont-GenYoGothicTC-min {
    font-family: "源樣黑體丹", "微軟正黑體";
    font-size: 20vh;
}
.emfont-GenYoMinTC-min {
    font-family: "源樣明體丹", "新細明體", "PMingLiU";
    font-size: 15vh;
}
.emfont-jfOpenHuninn-min {
    font-family: "jf open 粉圓 2.1", "微軟正黑體";
    font-size: 17vh;
}
.emfont-MantouSans-min {
    font-family: "饅頭黑體", "新細明體", "PMingLiU";
    font-size: 19vh;
}
.emfont-ChenYuLuoYan-min {
    font-family: "辰宇落雁體 2.0", "微軟正黑體";
    font-size: 18vh;
}
.emfont-ChillBitmap16px-min {
    font-family: "寒蝉点阵体", "新細明體", "PMingLiU";
    font-size: 15vh;
}

.search-container,
.info-container {
    position: absolute;
    top: 7.8rem;
    left: 3rem;
    width: calc(100% - 6rem);
    height: calc(100% - 13.5rem);
    overflow: auto;
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    scrollbar-width: none; /* Firefox */
}

.search-container::-webkit-scrollbar .info-container::-webkit-scrollbar {
    display: none; /* Safari and Chrome */
}
.font h1 {
    margin-bottom: 0.6rem;
    width: fit-content;
}

.info-container h1 + p {
    margin-bottom: 1.3rem;
    width: fit-content;
}

.fonts .header-links::before {
    content: "";
    display: block;
    height: 1rem;
    width: 100%;
    background: linear-gradient(to top, var(--slate-900) 0%, var(--slate-900) 50%, transparent 100%);
    position: absolute;
    top: -2rem;
    left: 0;
    pointer-events: none;
}

.fontPage-container .navigation {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}

.search-container a.navigation {
    color: #43e7f3;
}

.navigation img {
    width: 0.6875rem;
    margin-right: 0.5rem;
    transition: all 0.3s ease-out;
}

.navigation:hover img {
    transform: translateX(0.3rem);
}

.font .navigation img {
    filter: brightness(0%) invert(55%) sepia(46%) saturate(3414%) hue-rotate(194deg) brightness(100%) contrast(101%);
}

.fonts .search-container > .navigation {
    animation: unset;
}

.fonts .fontPage-container .navigation img {
    animation: navigationFadeIn 0.3s ease-in-out;
}

.fonts-toHome .fontPage-container .navigation {
    margin-left: -1.1875rem;
    transition: margin-left 0.3s ease-in-out;
    opacity: 1;
}

.fonts-toHome .search-container > *,
.fonts-toFont .search-container {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}
.fonts-toFont .search-container {
    display: block;
}

@keyframes navigationFadeIn {
    0% {
        opacity: 0;
        margin-left: -1.1875rem;
    }
    100% {
        opacity: 1;
        margin-left: 0;
    }
}

.search-container input[type="text"] {
    background: url("/assets/img/search.svg") no-repeat 0.5rem center, var(--slate-700);
    background-size: 1.2rem;
    padding: 0.4rem 0.875rem 0.4rem 2.3rem;
}

::placeholder {
    color: var(--slate-500);
}

input,
textarea,
select {
    padding: 0.4rem;
    width: 100%;
    border-radius: 1rem;
    background-color: var(--slate-700);
    color: var(--slate-100);
    font-size: 1.2rem;
    border: none;
    outline: none;
    transition: background-color 0.3s ease-out;
    margin-bottom: 1.5rem;
    cursor: pointer;
}

textarea {
    padding: 0.875rem;
    resize: vertical;
}

select {
    -moz-appearance: none; /* Firefox */
    -webkit-appearance: none; /* Safari and Chrome */
    appearance: none;
    background: url("/assets/img/barr.svg") no-repeat 0.7rem 52%, var(--slate-700);
    background-size: 0.8rem;
    padding: 0.4rem 0.875rem 0.4rem 2.1rem;
}

input[type="checkbox"],
input[type="radio"] {
    display: none;
}

h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.8rem;
}

.search-container label,
.font-tags > a {
    padding: 0.5rem 0.75rem;
    background-color: var(--slate-600);
    display: block;
    border-radius: 0.875rem;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.1s ease-out;
    color: var(--slate-100);
}

.font-tags > a:hover {
    background-color: var(--slate-500);
}

label:has(input[type="checkbox"]:checked),
label:has(input[type="radio"]:checked) {
    background-color: var(--slate-400);
}

.language,
.category,
.tags,
.font-tags {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

#lang-other + label {
    flex-grow: 1;
}

#section-search {
    padding: 2rem 3rem 2rem 2rem;
}

.fonts #section-search:has(.no-result) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.╯°□°╯ {
    font-size: 3rem;
}

.no-result {
    font-size: 1.5rem;
    line-height: 2;
    text-align: center;
}

.font-item {
    border-bottom: 1px solid var(--slate-800);
    padding-block: 1.5rem;
    padding-left: 1rem;
    display: block;
    color: var(--slate-100);
    transition: background 0.3s ease-out;
    position: relative;
    animation: fadeInBottom 0.3s ease-in-out;
}

#section-search .font-item:last-child {
    border-bottom: none;
}

a.font-item:hover {
    color: var(--slate-100);
    background: var(--slate-800);
    cursor: pointer;
}

.font-preview {
    font-size: 3rem;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    transition: color 0.3s ease-out;
    font-family: serif;
    color: transparent;
    font-family: Tofu;
}

body:has(#lightmode:checked) .font-preview {
    color: #000 !important;
}

body:has(#lightmode:checked) .font-preview[style="color: rgb(112, 37, 37);"] {
    color: rgb(112, 37, 37) !important;
}

.font-item:has(.font-preview:focus)::after {
    display: none;
}
.font-preview:focus {
    outline: auto 2px var(--slate-500);
    white-space: unset;
    overflow: unset;
}

.font-item:after {
    content: "";
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    width: 2em;
    height: 100%;
    background: linear-gradient(to left, var(--slate-900) 0%, transparent 100%);
}

.font-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 2;
}

.font-item h3 {
    font-size: 1.1rem;
    font-weight: 500;
}

.weight {
    color: var(--slate-400);
    font-weight: 500;
}

.T {
    font-weight: 100;
}

.EL {
    font-weight: 200;
}

.L {
    font-weight: 300;
}

.N {
    font-weight: 350;
}

.R {
    font-weight: 400;
}

.M {
    font-weight: 500;
}

.SM {
    font-weight: 600;
}

.B {
    font-weight: 700;
}

.EB {
    font-weight: 800;
}

.H {
    font-weight: 900;
}

.font-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.font-class {
    color: var(--slate-400);
    --background: var(--slate-700);
    background-color: var(--background);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    flex: 1;
    overflow: hidden;
    border-radius: 5rem;
    cursor: pointer;
    transition: background-color 0.3s ease-out;
}

.font-class:hover {
    --background: var(--slate-600);
}

.font-class div {
    flex-shrink: 1;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}
.font-class div:first-child:after {
    content: "";
    display: block;
    position: absolute;
    top: 0;
    right: 0;
    width: 2em;
    height: 100%;
    background: linear-gradient(to left, var(--background) 0%, transparent 100%);
}

.font-actions a,
#copyClass {
    flex-shrink: 0;
}
.font-actions img {
    height: 1.3rem;
    width: 1.3rem;
    object-fit: contain;
}

#copyClass {
    width: 0.75rem;
    height: 0.9375rem;
    background: url("/assets/img/copy.svg") no-repeat center center / contain;
    color: transparent;
}

.font-tags,
.font p {
    margin-bottom: 1.2rem;
}

.font .font-description {
    margin-bottom: 0.8rem;
}

.font p {
    color: var(--slate-400);
}

.font-coverage label {
    display: block;
    margin-bottom: 0.5rem;
}

.coverage-bar {
    width: 100%;
    height: 1rem;
    border-radius: 0.5rem;
    background-color: var(--slate-700);
    margin-bottom: 1rem;
    background: linear-gradient(to right, var(--slate-500) 0%, var(--slate-500) var(--percent), var(--slate-700) var(--percent), var(--slate-700) 100%);
}

#section-font {
    flex-direction: column;
    justify-content: space-between;
}

#section-font h2 {
    font-size: 1.5rem;
}

.first-time {
    background-color: var(--slate-600);
    margin: 2rem;
    padding: 2rem;
}

.first-time p {
    color: var(--slate-200);
    margin-bottom: 0;
}

footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 2rem;
    gap: 2rem;
}

.font footer p {
    margin-bottom: 0;
    max-width: 35rem;
}

.footer-logo {
    width: 5rem;
}

.footer-zeabur {
    margin-left: auto;
}

.footer-zeabur img {
    width: 14rem;
}

#bulletin {
    display: none;
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    width: 19rem;
    max-width: calc(100% - 2rem);
    padding: 2rem 2rem;
    z-index: 999;
    background-color: var(--slate-800);
    border: 1px solid var(--slate-700);
}
#closeBulletin {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1rem;
    height: 1rem;
    background: url("/assets/img/x.svg") no-repeat center center / contain;
    cursor: pointer;
}

@media (max-width: 50rem) {
    header {
        transform: translateX(-100%);
        height: 100vh;
        padding: 2rem 1.5rem;
        border-right: none;
        transition: transform 0.3s ease-in-out;
        position: fixed;
        max-width: calc(100% - 3rem);
    }

    .home header {
        transform: translateX(0%);
        background-color: transparent;
        left: 0;
    }

    #mobileToggle:checked ~ header {
        transform: translateX(0%);
    }
    section {
        margin-left: 0;
    }

    .mobile-nav {
        display: block;
        position: absolute;
        top: 50%;
        left: 100%;
        z-index: 10;
        transform: translate(0%, -50%);
        background-color: var(--slate-500);
        width: 1.5rem;
        height: 3rem;
        border-radius: 0 0.3rem 0.3rem 0;
        cursor: pointer;
    }
    .home .mobile-nav {
        display: none;
    }

    .mobile-nav::after {
        content: "";
        display: block;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(270deg);
        width: 1.5rem;
        height: 1.5rem;
        background: url("/assets/img/barr.svg") no-repeat center center / contain;
        transition: transform 0.3s ease-in-out;
    }
    #mobileToggle:checked ~ header .mobile-nav::after {
        transform: translate(-50%, -50%) rotate(90deg);
    }

    header::after {
        content: "";
        position: absolute;
        top: 0;
        left: 100%;
        width: 100vw;
        height: 100%;
        background-color: var(--slate-900);
        z-index: -1;
        transition: opacity 0.3s ease-in-out;
        opacity: 0;
        pointer-events: none;
    }
    #mobileToggle:checked ~ header::after {
        opacity: 0.8;
    }

    body:has(#mobileToggle:checked) {
        overflow: hidden;
    }
}

.language {
    color: var(--slate-400);
}

.section-font-container:has(.no-result) {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
}
.section-font-container {
    padding: 2rem 3rem 2rem 2rem;
}

.loading .weight,
.loading .font-preview,
.loading h1,
.loading .tag,
.loading p,
.loading .font-actions img {
    animation: loading 1s linear infinite alternate;
    color: transparent;
    background-color: var(--slate-800);
    border-radius: 0.5rem;
}
.loading .font-class {
    color: transparent;
}
.loading .font-preview {
    height: 3rem;
}

.loading .font-description {
    display: inline;
}

@keyframes loading {
    to {
        background-color: var(--slate-700);
    }
}

/* Accessible helpers */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    z-index: 1000;
}

.skip-link:focus {
    left: 16px;
    top: 16px;
    width: auto;
    height: auto;
    overflow: visible;
    border-radius: 4px;
}

/* Ensure keyboard focus is visible */
a:focus,
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}
