@view-transition {
    navigation: auto;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    overflow-y: scroll;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
    font-style: italic;
}

p {
    margin-bottom: 1rem;
}

/* utility styles */

.wrapper {
    max-width: 800px;
    margin-inline: auto;
    padding-inline: 0.5rem;
}

/* header styles */

.header {
    display: flex;
    justify-content: end;
    align-items: center;
    height: 4rem;
    padding-inline: 0.5rem;
    max-width: 800px;
    margin-inline: auto;
}
.header-nav-list {
    list-style: none;
    display: flex;
    gap: 1rem;
}

.header-nav-item > a {
    text-decoration: none;
    color: inherit;
}

.header-nav-item > a:hover {
    color: rgb(37, 37, 254);
}

.header-nav-item > a:active {
    color: rgb(1, 1, 191);
}

/* form styles */

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.input-group > label {
    font-weight: 600;
}

.input-group > input, textarea {
    padding: 0.5rem;
    border-radius: 0.25rem;
}

.input-group > select {
    padding: 0.5rem;
    border-radius: 0.25rem;
}

form > .btn-primary {
    cursor: pointer;
    padding: 0.5rem;
    background: none;
    background-color: rgb(85, 85, 85);
    color: white;
    text-transform: uppercase;
    font-weight: 500;
    border: 1px solid gray;
    border-radius: 0.25rem;
}

form > .btn-primary:not(:disabled):hover {
    background-color: rgb(137, 136, 136);
}

form > .btn-primary:not(:disabled):active {
    transform: scale(0.98);
    background-color: rgb(52, 52, 52);
}

form > .btn-primary:disabled {
    opacity: 50%;
    cursor: not-allowed;
}

/* auth form */

.auth-form__input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.auth-form__label {
    font-weight: 600;
}

.auth-form__input {
    padding: 0.25rem;
}

/* articles styles */

.article-item {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid black;
    display: grid;
}

/* reader styles */

.reader {
    padding-block: 48px 96px;
    max-width: 65ch;
    margin-inline: auto;
}

.reader__title {
    font-size: 2.0rem;
    line-height: 1.8;
    margin-bottom: 1rem;
}

.reader__paragraph {
    font-size: 2rem;
    line-height: 1.8;
}

ruby {
    padding-inline: 0.125rem;
    ruby-position: under;
    cursor: pointer;
}

ruby.selected {
    text-decoration: underline;
    text-underline-offset: 0.25rem;
    text-decoration-color: rgba(7, 82, 243, 1);
}

rt {
    user-select: none;
}

.controls {
    z-index: 10000;
    height: 48px;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: end;
}

.btn {
    cursor: pointer;
    border: none;
    background-color: white;
    color: black;
    padding-block: 0.25rem;
    padding-inline: 0.5rem;
    border-radius: 0.25rem;
    transition: 
        background-color 200ms ease-in,
        color 200ms ease-in;
}

.btn:hover {
    background-color: rgba(205, 204, 204, 1);
}

.btn:active {
    background-color: rgba(132, 130, 130, 1);
}

.btn.checked {
    background-color: rgba(7, 82, 243, 1);
    color: white;
}

.btn.checked:hover{
    background-color: rgba(52, 116, 253, 1);
}

.btn.checked:active{
    background-color: rgba(11, 56, 153, 1);
}

.pinyin {
    transition: opacity 200ms ease-in;
}

.pinyin.hide {
    opacity: 0;
}

.speed-controls {
    button {
        cursor: pointer;
        padding-block: 0.125rem;
        padding-inline: 0.5rem;
        background: none;
        border: 1px solid black;
        border-radius: 0.25rem;
    }

    button:hover {
        background-color: rgba(76, 146, 238, 1);
    }

    button.active {
        background-color: rgba(20, 95, 235, 1);
        border-color: rgba(20, 95, 235, 1);
        color: rgb(255, 255, 255);
    }
}

/* translate widget styles */

.translate-widget {
    height: 3rem;
    width: 500px;
    display: none;
    background-color: white;
    border: 1px solid black;
    padding-inline: 0.5rem;
    border-radius: 0.25rem;
    position: absolute;
    top: -3.25rem;
    right: 0.25rem;
    text-wrap: wrap;

    p {
        height: 24px;
        margin-bottom: 0;
    }

    form {
        display: none;
    }

    button {
        cursor: pointer;
        position: absolute;
        bottom: -2rem;
        right: 0;
        padding-inline: 0.5rem;
        padding-block: 0.25rem;
    }
}

.translate-widget.show {
    display: block;
}

@media screen and (max-width: 550px) {
    .translate-widget.show {
        border: none;
        border-top: 1px solid black;
        border-radius: 0rem;
        width: 100%;
        right: 0rem;
        top: -3rem;
    }
}


/* Hide pause icon by default */
#pause-play-button [data-audio-icon="pause"] { display: none; }
#pause-play-button [data-audio-icon="play"]  { display: block; }

/* When button is playing, flip the visibility */
#pause-play-button[data-audio-state="playing"] [data-audio-icon="pause"]  { display: block; }
#pause-play-button[data-audio-state="playing"] [data-audio-icon="play"]  { display: none; }

#pause-play-button[data-audio-state="playing"] {
    transform: scale(95%);
    box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    background-color: hsl(231 100 65);
    color: white;
}

/* vocabulary styles */
.common-words {
    list-style-type: none;
}

body.hide-pinyin rt {
    opacity: 0;
    visibility: hidden;
}

.common-words > li {
    margin-bottom: 1rem;
    opacity: 1;
    transition: opacity 0.2s ease-out;
}

.common-words .card {
    border: 1px solid black;
    padding: 1rem;
    border-radius: 0.5rem;
    min-height: 100px;
    display: grid;
    place-content: center;
    cursor: pointer;
}

.common-words > li.htmx-swapping {
    opacity: 0;
}

.common-words > li.htmx-added {
    opacity: 0;
}

.common-words .card > p {
    margin-bottom: 0;
    font-size: 2rem;
}

ruby {
    font-size: 2rem;
}

rt {
    margin-top: 0.25rem;
    opacity: 1;
    visibility: visible;
    text-align: center;
    font-size: 1rem;
    transition: 
        opacity 0.2s ease-in,
        visibility 0.2s ease-in
    ;
}

.pinyin-toggle {
    position: fixed;
    bottom: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    aspect-ratio: 1;
    border-radius: 100%;
}