:root {
    --color-brown: #3d1a1a;
    --color-cream: #f4e4bc;
    --color-dark-brown: #2a1111;
    --color-gold: #e5c07b;
    --color-spine: #1e0d0d;
    --color-ribbon: #8b1a1a;
    --color-table: #4b2b1a;

    --font-display: "Cinzel", serif;
    --font-body: "IM Fell English", serif;
}

body {
    font-family: var(--font-body);
    background-color: #322119;
}

/* If the body has a dialog that is open, lock the scroll */
body:has(dialog[open]) {
    overflow: hidden;
}

.bookshelf {
    display: flex;
    flex-wrap: wrap;
    padding: 5rem 5rem 0rem 5rem;
}

.shelf {
    width: 100%;
    min-width: 5rem;
    height: 2rem;
    margin-bottom: 2rem;
    background-color: var(--color-table);
    background-image: url(../assets/dark-wood.png);
    box-shadow:
        0 6px 12px rgba(0, 0, 0, 0.6),
        inset 0 4px 6px rgba(0, 0, 0, 0.4);
}

.book {
    width: 5rem;
    height: clamp(200px, 25vh, 300px);
    margin: 0 0.4rem;
    cursor: pointer;
    transition:
        transform 0.8s,
        box-shadow 0.8s;
}

.book:hover {
    box-shadow:
        3px 1px 3px rgba(0, 0, 0, 0.6),
        -3px -1px 3px rgba(0, 0, 0, 0.6);
    transform: scale(1.2);
}

.book__button {
    --book-width: max(5rem, 7vw);

    position: fixed;
    right: 5vw;
    bottom: 5vw;
    width: var(--book-width);
    height: calc(var(--book-width) + 2vw);
    font-size: clamp(1.2rem, 1.5vw, 1.5rem);
    color: var(--color-gold);
    background-color: var(--color-brown);
    background-image: url(../assets/dark-leather.png);
    border: 0;
    border-left: 0.5rem solid var(--color-spine);
    border-radius: 2px 0.5rem 0.5rem 2px;
    box-shadow:
        1px 1px 0 rgba(255, 255, 255, 0.6), /* Book page */
        -3px -1px 3px rgba(0, 0, 0, 0.6),
        5px 1px 3px rgba(0, 0, 0, 0.6),
        4px 3px 0 var(--color-dark-brown); /* Book back cover */
    transform: rotate(10deg);
    transition: transform 0.5s;
}

.book__button:hover {
    transform: scale(1.2);
}

.spine {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 100%;
    padding: 2rem 0.5rem;
    color: var(--color-gold);
    background-color: var(--book-color, var(--color-spine));
    background-image: url(../assets/dark-leather.png);
    box-shadow:
        inset -2px 0 4px rgba(0, 0, 0, 0.4),
        inset 2px 0 4px rgba(255, 255, 255, 0.05);
}

.spine__title {
    margin-bottom: auto;
    font-size: inherit;
    writing-mode: vertical-lr;
}

.spine__line {
    display: block;
    width: 100%;
    height: 1px;
    padding: 0;
    border: 0;
    border-top: 1px solid var(--color-gold);
}

.spine__author {
    padding: 2px 4px;
}

/* All of these content below are related to dialog */
.cover {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 310px;
    padding: 0;
    margin: 0;
    background-color: var(--color-dark-brown);
    background-image: url(../assets/dark-leather.png);
    border: 0;
    border-radius: 2px 1.2rem 1.2rem 2px;
    box-shadow:
        3px 3px var(--color-dark-brown),
        10px 10px 10px rgba(0, 0, 0, 0.3),
        0px 2px 0 var(--color-dark-brown);
    transform: translate(-50%, -50%) rotate(-1deg);
}

.cover[open] {
    animation: slideUp 1s;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100vh) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(-1deg);
    }
}

.cover::backdrop {
    background-color: var(--color-table);
    background-image: url(../assets/dark-wood.png);
}

.ribbon {
    position: absolute;
    top: 0;
    left: 30px;
    width: 15px;
    height: 100px;
    filter: drop-shadow(2px 2px 3px rgba(0, 0, 0, 0.6));
}

.ribbon--small {
    left: 2px;
    width: min(1vw, 7px);
    height: 3vw;
}

.ribbon__button {
    width: 100%;
    height: 100%;
    cursor: pointer;
    background-color: var(--color-ribbon);
    background-image: url(../assets/classy-fabric.png);
    border: 0;
    clip-path: polygon(95% 0%, 95% 85%, 50% 95%, 5% 85%, 5% 0%);
    transition: transform 0.1s ease-out;
}

.ribbon__button:active {
    transform: scaleY(1.15);
}

.cover__form {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 300px;
    min-height: 460px;
    padding: 3.6rem 2.8rem 2.8rem;
    border-left: 2.5rem solid var(--color-spine);
    box-shadow:
        inset 10px 0 10px -5px rgba(0, 0, 0, 0.3),
        inset 4px 0 10px -5px rgba(255, 255, 255, 0.2);
}

.cover__input {
    color: var(--color-gold);
    text-align: center;
    background-color: transparent;
    border: 0;
}

.cover__input:focus {
    outline: 0;
}

.cover__header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid color-mix(in srgb, var(--color-gold) 20%, transparent);
}

.cover__title {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0.05rem;
}

.cover__author {
    font-size: 1.8rem;
    font-style: italic;
    color: color-mix(in srgb, var(--color-gold) 80%, transparent);
}

.cover__body {
    font-size: 2.5rem;
    color: color-mix(in srgb, var(--color-gold) 50%, transparent);
    text-align: center;
    user-select: none;
}

.cover__footer {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding-top: 2.5rem;
    color: var(--color-gold);
    border-top: 1px solid color-mix(in srgb, var(--color-gold) 20%, transparent);
}

.cover__stamp {
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Hide default checkbox */
.cover__status {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
    opacity: 0;
}

/* Custom wax seal checkbox */
/* Credits to this post for the seal stamp
 * https://codepen.io/drewstaylor/pen/oNXjmgb
 */
.seal {
    position: relative;
    width: 5.5rem;
    height: 5.5rem;
    cursor: pointer;
    border: 3px dashed var(--color-ribbon);
    border-radius: 2.2rem 1.9rem 2.3rem 2rem;
    transition: all 0.3s ease;
}

.cover__status:checked + .seal {
    background: var(--color-ribbon);
    border: 0;
    box-shadow:
        0 -2px 4px rgba(0, 0, 0, 0.2) inset,
        0 3px 3px rgba(255, 255, 255, 0.3) inset,
        1px 1px 5px rgba(0, 0, 0, 0.8),
        -1px 1px 5px rgba(0, 0, 0, 0.8);
    transition: all 0.3s ease;
}

.seal__embossed {
    font-size: 1.1rem;
    color: rgba(0, 0, 0, 0.8);
    text-shadow: 0 1px 0.5px rgba(255, 255, 255, 0.2);
    opacity: 0;
    transform: rotate(-10deg);
}

.cover__status:checked + .seal .seal__embossed {
    position: absolute;
    top: 10%;
    left: 10%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80%;
    height: 80%;
    background-image: -webkit-linear-gradient(top, rgba(51, 51, 51, 0.3) 0%, rgba(51, 51, 51, 0.2) 100%);
    border-radius: 100%;
    box-shadow:
        0 -2px 2px rgba(0, 0, 0, 0.1) inset,
        0 3px 3px rgba(0, 0, 0, 0.1) inset,
        0 1px 2px rgba(0, 0, 0, 0.6) inset;
    opacity: 1;
}

.cover__status:checked + .seal:before,
.cover__status:checked + .seal:after {
    position: absolute;
    content: " ";
    background: inherit;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.8),
        0 3px 3px rgba(0, 0, 0, 0.4);
}

.cover__status:checked + .seal:after {
    top: 84%;
    left: 94%;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 1rem 0.9rem 0.95rem 0.8rem;
}

.cover__status:checked + .seal:before {
    top: 103%;
    left: 85%;
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    border-radius: 7.5px;
}

.cover__label {
    font-size: 1.4rem;
    font-style: italic;
    color: color-mix(in srgb, var(--color-gold) 80%, transparent);
}

.cover__unit {
    width: 5rem;
    text-align: right;
    border-bottom: 1px solid color-mix(in srgb, var(--color-gold) 20%, transparent);
}

/* Hide up/down arrow */
.cover__unit::-webkit-outer-spin-button,
.cover__unit::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.cover__unit[type="number"] {
    -moz-appearance: textfield;
}

.book__button,
.cover__input,
.cover__ornament,
.cover__label {
    text-shadow:
        -1px -1px rgba(0, 0, 0, 0.8),
        1px 1px color-mix(in srgb, var(--color-gold) 20%, transparent);
}
