/******************************************************************
 ** Theme                                                        **
 ******************************************************************/

[data-theme="dark"] .on-theme-light,
[data-theme="system"] .on-theme-light,
[data-theme="light"] .on-theme-dark,
[data-theme="system"] .on-theme-dark,
[data-theme="light"] .on-theme-system,
[data-theme="dark"] .on-theme-system {
    display: none;
}

[data-theme="system"],
[data-theme="light"] {
    color-scheme: only light;
    --color-black: #000000;
    --color-white: #ffffff;
    --color-link: #000000;
    --color-surface: #e0e0e0;
    --color-border: #888888;
    --color-font: #000000;
}

[data-theme="dark"] {
    color-scheme: only dark;
    --color-black: #ffffff;
    --color-white: #000000;
    --color-link: #ffffff;
    --color-surface: #121212;
    --color-border: #777777;
    --color-font: #ffffff;
}

@media (prefers-color-scheme: light) {

    [data-theme="system"] {
        color-scheme: only light;
        --color-black: #000000;
        --color-white: #ffffff;
        --color-link: #000000;
        --color-surface: #e0e0e0;
        --color-border: #888888;
        --color-font: #000000;
    }
}

@media (prefers-color-scheme: dark) {

    [data-theme="system"] {
        color-scheme: only dark;
        --color-black: #ffffff;
        --color-white: #000000;
        --color-link: #ffffff;
        --color-surface: #121212;
        --color-border: #777777;
        --color-font: #ffffff;
    }
}

body {
    background: var(--color-white);
    color: var(--color-font);
}

select,
input,
textarea,
button {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    color: var(--color-font);
}

button:hover {
    background: var(--color-surface);
}

/******************************************************************
 ** General                                                      **
 ******************************************************************/

code,
kbd,
pre,
samp {
    font-family: var(--ff-mono);
}

button,
select,
input,
textarea {
    padding: 0.2rem;
    border-radius: 3px;
}

select {
    padding-left: 0.6rem;
}

textarea {
    white-space: pre;
}

/* Hack to flatten pseudo-elements */
/* Targets internal wrapper when <details> is open */
details[open]::details-content {
    display: contents;
}

/******************************************************************
 ** Font                                                         **
 ******************************************************************/

/* cdnjs does not provide Roboto Mono. Serve it locally. */
@font-face {
    font-family: "Roboto Mono";
    src: url("/static/RobotoMono.woff2") format("woff2");
    font-style: normal;
    font-display: swap;
}

:root {
    --ff-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
    --ff-mono: "Roboto Mono", "SFMono-Regular", "Cascadia Mono", "Liberation Mono", Menlo, Consolas, Courier, monospace;
}

html,
body {
    font-size: 16px;
    font-family: var(--ff-sans);
    font-weight: 400;
    line-height: 1.25;
}

/* Prevent iOS using faux-bold */
h1,
h2,
h3,
h4,
h5,
h6,
strong,
b {
    font-weight: 600;
}

a {
    text-decoration: none;
}

a,
a:visited {
    color: var(--color-link);
}

a:hover,
a:focus {
    text-decoration: underline;
}

[lang="en"] * {
    word-break: break-word;
}

[lang="ko"] * {
    word-break: keep-all;
}

.ff-mono {
    font-family: var(--ff-mono);
}

/******************************************************************
 ** Layout                                                       **
 ******************************************************************/

body {
    overflow-x: hidden;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
}

.site {
    display: grid;
    gap: 1rem 2rem;
    grid-template:
        " site-header site-main  " auto
        " site-aside  site-main  " auto
        " site-footer site-main  " auto
        " .           site-main  " auto
        " site-bunny  site-bunny " auto
        / auto minmax(0, 1fr);
    max-width: 70rem;
    margin: 0 auto;
    padding: 1rem 2rem 1rem 1rem;
}

.site-header {
    grid-area: site-header;
}

.site-main {
    grid-area: site-main;
    margin-bottom: 100vh;
}

.site-bunny {
    grid-area: site-bunny;
}

.site-aside {
    grid-area: site-aside;
}

.site-footer {
    grid-area: site-footer;
}

.site-settings {
    display: flex;
    flex-flow: column nowrap;
    gap: 0.5rem;
}

/* Mobile */
@media (max-width: 767px) {
    .site {
        grid-template:
            " site-header " auto
            " site-main   " auto
            " site-aside  " auto
            " site-footer " auto
            / minmax(0, 1fr);
    }

    .site-main {
        max-width: 100%;
        margin-bottom: 0;
    }

    .site-bunny {
        display: none;
    }
}

/******************************************************************
 ** Others                                                       **
 ******************************************************************/

.semantic-only-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

/******************************************************************
 ** Site                                                         **
 ******************************************************************/

.site-logo-link {
    display: block;
    margin: -5px;
    padding: 5px;
    border: 5px solid transparent;
}

.site-logo-link:hover {
    border: 5px solid var(--color-border);
    text-decoration: none;
}

#siteTheme {
    padding: 0.25rem 0.5rem;
}

.lang-container {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 0.5rem;
}

.lang-globe {
    display: block;
    position: relative;
    width: 1rem;
    height: 1em;
}

.lang-globe>* {
    display: block;
    position: absolute;
    width: 1rem;
    height: 1em;
    line-height: 1;
    --globe-anim-duration: 16s;
    animation: lang-globe var(--globe-anim-duration) infinite;
}

@keyframes lang-globe {
    0% {
        opacity: 1.0;
    }

    23% {
        opacity: 1.0;
    }

    24% {
        opacity: 0.5;
    }

    25% {
        opacity: 0.0;
    }

    98% {
        opacity: 0.0;
    }

    99% {
        opacity: 0.5;
    }

    100% {
        opacity: 1.0;
    }
}

.lang-globe>:nth-child(1) {
    animation-delay: calc(var(--globe-anim-duration) / 4 * -4);
}

.lang-globe>:nth-child(2) {
    animation-delay: calc(var(--globe-anim-duration) / 4 * -3);
}

.lang-globe>:nth-child(3) {
    animation-delay: calc(var(--globe-anim-duration) / 4 * -2);
}

.lang-globe>:nth-child(4) {
    animation-delay: calc(var(--globe-anim-duration) / 4 * -1);
}

.site-bunny {
    font-size: 12px;
    text-align: center;
}

/******************************************************************
 ** Group                                                        **
 ******************************************************************/

.cards {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.card-link {
    display: contents;
    text-decoration: none;
}

.card {
    display: flex;
    flex-flow: column nowrap;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--color-surface);
    border: 5px solid transparent;
}

.card:hover {
    border: 5px solid var(--color-border);
}

/******************************************************************
 ** Detail                                                       **
 ******************************************************************/

.detail-form {
    display: grid;
    align-items: stretch;
    grid-template-columns: 1fr 1fr;
    grid-gap: 1rem;
}

.detail-row {
    display: contents;
}

.detail-left {
    display: flex;
    flex-flow: column nowrap;
    justify-content: center;
    align-items: flex-end;
    grid-column: 1;
    padding: 0.1rem 1rem 0.1rem 0;
    border-right: 1px solid var(--color-black);
}

.detail-label {
    text-align: end;
}

.detail-right {
    display: flex;
    flex-flow: column nowrap;
    justify-content: center;
    align-items: flex-start;
    grid-column: 2;
    padding: 0.1rem 1rem 0.1rem 0;
}

.detail-both {
    display: flex;
    flex-flow: column nowrap;
    grid-column: 1 / -1;
}

summary.detail-both {
    display: revert;
}

.detail-both>* {
    align-self: center;
}

.detail-both .detail-label {
    width: fit-content;
    margin-bottom: 0.5rem;
    padding: 0 0.5rem 0.1rem 0.5rem;
    border-bottom: 1px solid var(--color-black);
}

.detail-advanced {
    display: contents;
}

.detail-advanced>summary {
    cursor: pointer;
    text-align: center;
}

.detail-generate-button {
    display: inline-block;
    max-width: auto;
    margin: 0 auto;
    padding: 0.5rem 1rem;
}

.detail-form input,
.detail-form textarea {
    font-family: var(--ff-mono);
    font-weight: 500;
}

.detail-form li label {
    transition: font-weight 0.2s ease-in-out;
    font-weight: 250;
}

.detail-form li label:has(>:checked) {
    font-weight: 500;
}

.detail-helptext {
    margin: 0.2rem 0 0 0;
    font-size: 0.8rem;
    font-weight: 250;
}

.detail-helptext:first-child {
    margin-top: 0;
}

.detail-output {
    display: block;
    overflow-x: auto;
    max-width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--color-black);
}

.detail-output pre {
    margin: 0;
    font-family: var(--ff-mono);
}

.detail-output-error {
    color: red;
}

@media (max-width: 424px) {

    body {
        padding-right: 0;
    }

    .site-logo-link {
        text-align: center;
    }

    .site-main h2 {
        text-align: center;
    }

    .detail-form {
        display: flex;
        flex-flow: column nowrap;
        grid-gap: 2rem;
    }

    .detail-row {
        display: flex;
        flex-flow: column nowrap;
        gap: 0.3rem;
    }

    .detail-left,
    .detail-right,
    .detail-both {
        text-align: left;
    }

    .detail-left {
        align-items: flex-start;
        padding: 0;
        border-right: none;
    }

    .detail-right {
        padding: 0;
    }

    .detail-label {
        padding: 0.1rem 0.2rem;
        background: var(--color-black);
        font-weight: 500;
        color: var(--color-white);
        text-align: start;
    }

    .detail-both>* {
        align-self: start;
    }
}

.site-nav .site-nav-item-home {
    margin-bottom: 1rem;
}

.site-nav .site-nav-link-current {
    padding: 0 0.2rem;
    background: var(--color-black);
    font-weight: 600;
    color: var(--color-white);
    text-align: start;
}

/******************************************************************
 ** Print                                                        **
 ******************************************************************/

@media print {

    :root {
        color-scheme: only light;
        --color-black: #000000;
        --color-white: #ffffff;
        --color-link: #000000;
        --color-surface: #e0e0e0;
        --color-border: #888888;
        --color-font: #000000;
    }

    body {
        padding: 0;
    }

    textarea {
        line-break: anywhere;
        max-width: 100%;
        white-space: normal;
    }

    .site {
        display: flex;
        flex-flow: column nowrap;
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .site-header * {
        display: inline-block;
    }

    .site-aside {
        column-count: 3;
        font-size: calc(100vw / 20 / 3);
    }

    .site-bunny {
        display: none;
    }

    .site-main {
        margin-bottom: 0;
    }
}