:root {
/* light mode default */
--text: #121212;
--hover: #295c47;
--hover-text: #ffffff;
--card-container: #d8e8e0;
--div: #cedcd5;
--button: #bac4bf;
--icon-fill: #378d6b;
--icon-stroke: #000000;
}

/** dark mode */ 
[data-theme='dark'] {
--text: #ffffff;
--hover: #7db39a;
--hover-text: #000000;
--card-container: #1c2822;
--div: #313c37;
--button: #5f6863;
--icon-fill: #d8e8e0;
--icon-stroke: #5f6863;
}

@font-face {
    font-family: "Raleway";
    src: url(./fonts/Raleway-VariableFont_wght.woff2);
}

@font-face {
    font-family: "Roboto";
    src: url(./fonts/Roboto-VariableFont_wdth\,wght.woff2);
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Oswald";
    src: url(./fonts/Oswald-VariableFont_wght.woff2);
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Montserrat";
    src: url(./fonts/Montserrat-VariableFont_wght.woff2);
    font-style: normal;
    font-display: swap;
}



* {
  margin: 0;
  padding: 0;
  font-family: "Raleway", sans-serif, system-ui;
  font-weight: 100 900;
  color: var(--text);
}

body {
    grid-template-rows: auto 1fr;
    grid-template-areas: 
    "header"
    "card-container";
    height: 100vh;
}

body,
#card-container,
#header,
.book-info {
    display: grid;
}

body::-webkit-scrollbar {
    width: 12px;
}

body::-webkit-scrollbar-track {
    background: var(--button);
}

body::-webkit-scrollbar-thumb {
    background-color: var(--card-container);
    border-radius: 20px;
    border: 3px solid var(--div);
}

#header {
    position: sticky;
    top: 0;
    z-index: 100;
    grid-area: header;
    grid-template-columns: auto auto 1fr auto auto;
    gap: 1.2em;
}

#header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(to bottom, var(--div), var(--button));
}

#header,
dialog,
.buttons-container button[type=button],
.book-card,
.book-card-btn-div button {
    background-color: var(--div);
}

.icon,
.title,
.light-dark-toggle,
li,
.cta-desktop,
.cta-mobile,
.text-inputs,
.book-card,
#book-descriptors,
#book-specifics,
.book-card-btn-div,
form,
.read-radio-container,
.buttons-container {
    display: flex;
}

.cta-desktop,
.cta-mobile,
#header,
.book-card {
    align-items: center;
}

.icon {
    align-items: start;
    justify-content: start;
    padding: 1.2em 0 1.2em 1.2em;
}

.icon svg {
    width: 60px;
    height: 60px;
}

.icon svg,
.cta-desktop svg,
.cta-mobile svg {
    display: block;
    stroke: var(--text);
    border: none;
}

.icon svg path {
    fill: var(--icon-fill);
    stroke: var(--icon-stroke)
}

.title,
.text-inputs,
.book-card,
#book-descriptors,
#book-specifics,
.book-card-btn-div,
form {
    flex-direction: column;
}

.title p,
dialog h3 {
    font-family: "Oswald", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.title p:first-child {
    font-size: 2em;
    line-height: 1em;
    align-items: end;
}

.title p:nth-child(2) {
    font-size: 0.8em;
    padding-top: 5px;
}

.light-dark-toggle {
    width: auto;
    white-space: nowrap;
}

ul {
    width: 100%;
}

li {
    width: 100px;
    align-items: center;
    justify-content: space-around;
    position: relative;
}

label {
    width: 20px;
    height: 20px;
    line-height: 20px;
    position: relative;
}

label span {
    position: absolute;
    width: max-content;
    font-weight: bold;
}

input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 44px;
    height: 24px;
    border-radius: 12px;
    border: 2px solid #121212;
    background: var(--icon-fill);
    transition: all 0.4s;
}

input[type="checkbox"]::before {
    width: 16px;
    height: 16px;
    border-radius: 9px;
    background-color: #121212;
    content: '';
    position: absolute;
    top: 4px;
    left: 16%;
    transition: all 0.4s;
}

input[type="checkbox"]:checked {
    background-color: var(--icon-fill);
    transition: all 0.4s;
}

input[type="checkbox"]:checked::before {
    left: 30%;
    transition: all 0.4s;
}

input[type="checkbox"] ~ label .dark, input[type="checkbox"]:checked ~ label .light {
    opacity: 0;
}

input[type="checkbox"] ~ label .light, input[type="checkbox"]:checked ~ label .dark {
    opacity: 1;
}

input:focus {
    outline: 1px dotted var(--text);
    caret-color: var(--text);
}

.cta-mobile {
    display: none;
}

.cta-desktop,
.cta-mobile {
    gap: 8px;
    width: auto;
    white-space: nowrap;
}

.cta-desktop svg,
.cta-mobile svg {
    width: 26px;
    height: 26px;
}

.cta-desktop svg path,
.cta-mobile svg path {
    stroke: var(--icon-fill);
}

button:hover {
    transform: scale(1.05) translateY(-1px);
    transition: transform 0.15s ease-out;
}

.add-new-book {
    padding: 1.2em 1.2em 1.2em 0
}

#openModal {
    line-height: 3.5em;
    width: 150px;
    border: none; 
}

#openModal,
.book-card-btn-div button {
    text-align: center;
    vertical-align: center;
    font-size: 0.9em;
}
#openModal,
.book-card-btn-div button,
.buttons-container button {
    border: 1px solid var(--button);
    box-shadow: 0px 1px var(--text);
    border-radius: 200px;
}

#openModal,
.book-card-btn-div button,
#book-descriptors,
label[for="title"],
label[for="author"],
label[for="pages"],
.buttons-container button {
    font-weight: bold;
}

#openModal,
.toggle-read-btn.is-read,
.buttons-container button[type=submit] {
    background-color: var(--button);
}

#openModal:hover,
.book-card-btn-div button:hover,
.buttons-container button:hover {
    background-color: var(--hover);
    color: var(--hover-text);
}

.buttons-container {
    justify-content: space-evenly;
    width: 100%;
    gap: 1em;
}

.buttons-container button {
    width: 50%;
    padding: 0 5px;
    line-height: 2em;
    font-size: 1em;
}

#card-container {
    grid-area: card-container;
    background-color: var(--card-container);
    width: auto;
    grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
    grid-template-rows: repeat(auto-fit, minmax(200px, 400px));
    padding: 1.2em 1.2em;
    gap: 2em;
    position: relative;
}

.book-card {
    justify-content: space-between;
    border: none;
    border-radius: 20px;
    padding: 15px;

}

.book-card:hover {
    transform: translateY(-5px);
    transition: transform 0.15s ease-out;
    box-shadow: 
        inset 0 0 20px 5px var(--button),
        0 0 0 2px var(--button),
        0 0 15px 2px var(--button);
}

.book-title {
    font-size: 1.5em;
    font-family: "Oswald", system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    padding-top: 1em;
}

.book-info {
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 2em;
    margin: 0 auto;
    min-width: 215px;
    max-width: 100%;
    text-overflow: none;
    text-wrap: wrap;
}

#book-descriptors,
#book-specifics {
    font-size: 1em;
    gap: 1.5em;
    align-items: start;
    text-align: left;

}

.book-card-btn-div {
    height: 100px;
    padding-bottom: 1em;
}

.book-card-btn-div button {
    line-height: 2.5em;
    width: 200px;
    margin-top: auto;
}


dialog {
    &[open] {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
    max-height: 90vh;
    overflow-y: auto;
    inset-block-start: 5dvb;
    border: none;
    border-radius: 8px;
    margin: auto;
    inline-size: min(30ch, 40dvi);
    margin-inline: auto;
    padding: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

form {
    justify-content: flex-start;
    width: 90%;
    height: auto;
    gap: 2.3em;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.5);
}

dialog h3 {
    font-size: 1.6em;
    text-align: center;
}

dialog label {
    width: 100%;
}

.text-inputs,
.buttons-container {
    flex: 0 1 auto;
    gap: 1em;
}

input[type="text"],
input[type="number"],
.buttons-container button {
    border: 1px solid var(--button);
    border-radius: 10px;
}

input[type="text"],
input[type="number"] {
    line-height: 1.7em;
    text-indent: 8px;

    /* firefox, remove number input spinner */
    -moz-appearance: textfield;
}

/* remove number input spinner for chrome et al. */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.read-container h4 {
    margin-bottom: 1em;
}

.read-radio-container {
    justify-content: left;
    gap: 1em;
}

.read-radio-container label {
    width: auto;
    white-space: nowrap;
}

input[type=radio] {
    display: inline-grid;
    appearance: none;
    width: 20px;
    height: 20px;
    place-content: center;
    cursor: pointer;
    border: 2px solid var(--button);
    background-color: transparent;
    border-radius: 50%;
    transition: border-color 0.3 ease;
}

input[type="radio"]::before {
    display: block;
    content: " ";
    width: 10px;
    height: 10px;
    font-size: 1.2em;
    border-radius: 50%;
    background-color: var(--button);
    transform: scale(0);
    transform-origin: center;
    transition: all 0.3s ease-in;
}
input[type="radio"]:checked::before {
    transform: scale(1);
    transition: all 0.3s cubic-bezier(0.25, 0.25, 0.56, 2);
}

@media (max-width: 1000px) {
    #header {
        /* change from 5 columns to 1 single column */
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
        "icon title"
        "cta-mobile cta-mobile"
        "light-dark-toggle add-new-book";
        
        /* makes height accommodate the stack */
        height: auto; 
        
        /* vertical spacing */
        gap: 15px;
        padding: 20px;
    }

    .icon {
        padding: 0 15px 0 0;
        grid-area: icon;
        justify-self: end;
    }

    .icon svg {
        width: 90px;
        height: 90px;
    }
    
    .title {
        grid-area: title;
    }
    
    .add-new-book,
    .light-dark-toggle,
    .call-to-action,
    li,
    .cta-mobile {
        display: flex;
    }

    .add-new-book {
        justify-self: start;
        justify-content: start;
        grid-area: add-new-book;
        padding: 0;
        margin: 0;
    }

    .title,
    .add-new-book {
        /* padding-left: 15px; */
    }
    
    .light-dark-toggle {
        grid-area: light-dark-toggle;
        justify-content: end;
        width: 100%;
    }

    .call-to-action {
        grid-area: cta-mobile;
        justify-self: center;
        justify-content: center;
        
    }

    ul {
        padding: 0;
        /* padding-right: 15px; */
        list-style: none;
    }

    li {
        width: auto;
        justify-content: end; 
        align-items: center;     
        gap: 12px;               
    }

    li label {
        width: auto;
        position: relative;
        display: block;
        min-width: 90px;
    }

    li label span {
        width: max-content;
    }

    input[type="checkbox"] {
        flex-shrink: 0;
        position: relative;
    }

    input[type="checkbox"]::before {
        left: 4px;
        transform: translateY(-2px);
    }

    input[type="checkbox"]:checked::before {
        left: 20px;
        transform: translateY(-2px);
    }

    .cta-desktop {
        display: none;
    }

    .cta-mobile {
        font-size: clamp(0.8em, 2vw, 1em);
    }
}