:root {
    --primary-color: 85, 0, 0;
    --green: rgb(38, 176, 38);
    --text-color: #5b5b5b;
}

* {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    color: var(--text-color);
}

body {
    display: flex;
    align-items: center;
    flex-direction: column;

    background-color: #f2f2f2;
}

button:hover {
    cursor: pointer;
}

select, input[type="number"] {
    background-color: white;
    border: 1px solid rgb(195, 195, 195);
    border-radius: 5px;
    padding: 0.5rem;
    margin: 0;
    width: 128px;
    font-family: inherit;
    font-size: inherit;
    cursor: inherit;
    line-height: inherit;
    outline: none;
}

select:focus, select:focus-visible {
    border: 1px solid rgb(var(--primary-color), 0.8);
}

.main-container {
    display: flex;
    flex-direction: column;

    width: 60vw;
    height: 100vh;
}

.logo-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;

    margin: 40px 0;
    font-weight: bold;
}

.logo {
    width: 64px;
}

.site-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: rgb(var(--primary-color), 1);
}

.options-container {
    display: flex;
    gap: 1rem;
    
    margin-top: 0;
    margin-bottom: 32px;
}

#filter-options {
    margin-right: auto;
}

.display-mode-buttons-container {
    display: flex;
    align-items: center;
    border: 1px solid rgb(195, 195, 195);
    border-radius: 5px;
    background-color: white;
}

.display-mode-buttons-container > button {
    background-color: transparent;
    border: none;
    height: 100%;
    aspect-ratio: 1;
}

.button-divider {
    background-color: rgb(195, 195, 195);
    width: 1px;
    height: 70%;
}

#card-view, #list-view {
    background-size: 60%;
    background-repeat: no-repeat;
    background-position: center;
}

#card-view {
    background-image: url(./img/card-view.png);
}

#list-view {
    background-image: url(./img/list-view.png);
}

#items-container {
    padding-bottom: 2rem;
    margin-bottom: auto;
}

.card-view-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 3rem;
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;

    padding: 1.5rem;
    padding-left: calc(1.5rem + 24px);
    aspect-ratio: 6 / 7;
    border-radius: 5px;

    background: linear-gradient(180deg, white 50%,#dadada 100%); 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2),
                inset 4px -8px 1px rgba(0, 0, 0, 0.25),
                inset 24px 0 0 rgba(var(--primary-color), 0.85);
                ;
    transition: box-shadow 0.5s ease;
}

.card:hover {
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2),
                inset 4px -8px 1px rgba(0, 0, 0, 0.25),
                inset 24px 0 0 rgba(var(--primary-color), 0.85);
                ;
}

.card-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 0.5rem;
    padding: 1rem;
    padding-top: 1.5rem;
}

.book-title {
    font-size: 1.8rem;
    font-weight: 600;
    line-height: normal;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4; 
    line-clamp: 4;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-author {
    font-weight: 500;
    padding-left: 2px;
}

.card-details {
    display: flex;
    align-items: center;
    gap: 4px;
}

label {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.2rem;
}

label:hover, input[type="checkbox"] {
    cursor: pointer;
}

label:has(input:checked) {
    color: var(--green);
}

input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    width: 1em;
    height: 1em;
    border: 2px solid gray;
    border-radius: 3px;
    transform: translateY(-0.055em);

    display: grid;
    place-content: center;
}

input[type="checkbox"]::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    transform: scale(0);
    transition: 60ms transform ease-in-out;
    box-shadow: inset 1em 1em var(--green);
    transform-origin: bottom left;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.card input:checked {
    border: 2px solid var(--green);
}

.page-icon {
    margin-right: auto;
    width: 1.5rem;
    aspect-ratio: 1;
}

.remove-button, .edit-button {
    position: absolute;
    display: none;
    width: 1.5rem;
    aspect-ratio: 1;

    border: none;
    background: none;
    background-size: cover;
    transition: all 0.3s ease;
}

.card:hover .edit-button, .card:hover .remove-button {
    display: block;
}

.remove-button {
    top: 1rem;
    right: 1rem;
    background-image: url(./img/trash-icon.png);
}

.edit-button {
    top: 1rem;
    left: 2.5rem;
    background-image: url(./img/edit-icon.png);
}

.remove-button:hover, .edit-button:hover {
    transform: scale(1.5);
}

#add-button {
    position: fixed;
    bottom: 0;
    right: 0;

    margin: 50px;

    width: 64px;
    aspect-ratio: 1;

    border: none;
    border-radius: 50%;

    background: #5e1313;
    box-shadow: inset -5px -5px 10px #3e0d0d,
                inset 5px 5px 10px #7e1919,
                4px 4px 20px rgba(0, 0, 0, 0.25);
    background-image: url(./img/add.png);
    background-size: 30%;
    background-repeat: no-repeat;
    background-position: center;
}

#add-button:hover {
    filter: brightness(120%);
}

dialog {
    margin: 0;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    outline: none;
    border: none;
    background: none;
}

dialog form {
    display: flex;
    flex-direction: column;
    gap: 1rem;

    width: min(400px, 80vw);
    aspect-ratio: 2 / 3;
    padding: 2rem;

    border-radius: 5px;

    background-color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

form label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.modal-action {
    align-self: center;
    font-weight: bold;
}

.book-title-input, .book-author-input {
    border-bottom: 1px solid rgb(var(--primary-color), 0.8);
    cursor: text;
    overflow: auto;
    font-size: 2rem;
    font-weight: 600;
    overflow: auto;
}

.book-title-input {
    margin-top: 1rem;
}

.book-author-input{
    width: 100%;
    font-size: 1rem;
}

.book-title-input:focus, .book-author-input:focus {
    outline: none;
}

.book-title-input:empty:not(:focus):before, 
.book-author-input:empty:not(:focus):before,
.book-title-input:focus:empty:before, 
.book-author-input:focus:empty:before {
    content: attr(data-text);
    color: rgb(157, 157, 157);
    font-style: italic;
}

.book-title:blank {
    background: red;
}

.modal-buttons-container {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-buttons-container > button {
    color: white;
    padding: 0.5rem;
    border: none;
    border-radius: 5px;
}

#cancel-button {
    background-color: rgb(var(--primary-color), 0.9);
}

#save-button {
    background-color: var(--green);
}

.error-message {
    font-style: italic;
    color: rgb(248, 33, 33);
}

.table-remove-button {
    width: 2rem;
    aspect-ratio: 1;
    border: none;
    background: none;
    background-image: url(./img/trash-icon.png);
    background-repeat: no-repeat;
    background-size: 80%;
    background-position: center;

    transition: transform 0.5s ease;
}

.table-remove-button:hover {
    transform: scale(1.5);
}

table {
    border-collapse: separate;
    border-spacing: 0 1rem;
    width: 100%;
}

th {
    text-align: left;
    color: rgb(var(--primary-color));
    padding: 0 1rem;
}

tbody tr {
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.25);
}

tbody tr:hover {
    cursor: pointer;
}

td:first-child {
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    box-shadow: inset 8px 0 0 rgb(var(--primary-color), 0.8);
}

td:last-child {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

td {
    padding: 1.5rem 1rem;
}

footer {
    display: grid;
    gap: 0.5rem;
    text-align: center;
    padding: 2rem;
    border-radius: 5px;
    line-height: 1;
    font-size: 0.8rem;
    color: rgb(var(--primary-color), 0.8);
}

footer * {
    color: inherit;
}

#credits-github-link {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 0.5rem;
    align-items: center;

    font-weight: bold;
}

footer a img {
    width: 1.5rem;
}

#credits-github-link img {
    width: 1.5rem;
}

@media only screen and (max-width: 564px) { 
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

}

@media only screen and (max-width: 900px) { 
    .main-container {
        width: 80vw;
    }

    .options-container {
        flex-direction: column;
        align-items: center;
    }

    .options-container select {
        width: 100%;
    }

    .display-mode-buttons-container {
        order: 3;
    }

    .display-mode-buttons-container > button{
       height: 3rem;
    }

    #add-button {
        box-shadow: inset -5px -5px 10px #3e0d0d,
        inset 5px 5px 10px #7e1919,
        4px 4px 50px rgba(0, 0, 0, 0.55);
    }

    #items-container {
        padding-bottom: 20vh;
    }
}


@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeAndSlideIn {
    from { opacity: 0; 
        top: 50%;
        left: 50%;
        transform: translate(-50%, calc(-50% + 50px));}
    to { opacity: 1; 
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);}
}

dialog::backdrop {
    animation: fadeIn 0.5s ease-out;
}

dialog[open] {
    animation: fadeAndSlideIn 0.2s ease-out;
}

.title-input-container {
    position: relative;
}

.author-input-container {
    position: relative;
    display: flex;
    align-items: start;
    gap: 0.4rem;
    margin-bottom: 3rem;
}

.hidden {
    position: absolute;
    top: 100%;
    height: 0;
    opacity: 0;
    pointer-events: none;
}