html {
    --card-colour: #FFFFFF;
    --background-colour: #FAF7F0;
    --page-colour: #46362a;
    --borders: #E5E7EB;

    --primary-highlight: #0B3B83;
    --secondary-highlight: #B45309;

    --text-colour: #1F2937;
    --subtext-colour: #6B7280;
    --grammar-heading: #0B3B83;

    --page-border: var(--text-colour);

    /* Word types (using highlighters) */
    /* From: https://www.reddit.com/r/GoodNotes/comments/jg3xzz/hex_set_of_bright_highlighters_enjoy_hex_codes/ */
    --lemon-sunshine: #FFDC7488;
    --beach-at-sunset: #FBAC8788;
    --watermelon-spring: #FF8C8788;
    --cotton-candy-cheeks: #F3A6C888;
    --moonlit-lilly: #DEACF988;
    --clear-sky-sea: #AEB5FF88;
    --mountain-breeze-waves: #95C8F388;
    --toes-in-the-lagoon: #81E3E188;
    --jungle-getaway: #7DE19888;
    --golf-club-special: #B3E56188;



    --line: #1F6FEB44;
    --line-gap: 35px;
    --line-thickness: 1px;
}

@media (prefers-color-scheme: dark) {
    body {
        --card-colour: #434343;
        --background-colour: #232323;
        --page-colour: #232E43;
        --borders: black;

        --primary-highlight: #0B3B83;
        --secondary-highlight: #B45309;

        --text-colour: #e5e5e5;
        --subtext-colour: #B1B5BE;
        --grammar-heading: #6895DF;

        --page-border: black;
    }
}

@font-face {
    font-family: "Liang Extended";
    src: url("../assets/liang_expanded.ttf");
}

body {
    color: var(--text-colour);

    background-repeat: repeat;
    background-size: contain;

    background-image: url("../assets/textured.png");
    background-color: var(--page-colour);

    background-blend-mode: multiply;
}

h1 {
    color: var(--grammar-heading);
    text-shadow: 2px 2px 2px #00000030;
}


.liang {
    font-family: "Liang Extended";
    font-size: 1.5em;
}

.liang.outline {
    color: #FDFFFF;
    -webkit-text-stroke: 1px var(--page-border);
}

.default-text {
    color: var(--text-colour);
    font-weight: normal;
}

/* #region The Base Container */
#container {
    width: 1300px;
    max-width: 90%;
    margin: auto;

}

.box {
    padding: 0 5px;
    border: 3px solid var(--page-border);
    border-radius: 5px;

    background-color: var(--background-colour);

    background:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--line-gap) - var(--line-thickness)),
      var(--line) calc(var(--line-gap) - var(--line-thickness)),
      var(--line) var(--line-gap)
    ),
    var(--background-colour);

    box-shadow: 2px 2px 10px 0px #00000030;
}

#card-container {
    padding: 1.5em 0.5em;
}

#card-container.number-mode {
    display: block;
}

#card-container.word-mode {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
}

#card-container.alphabet-mode {
    display: grid;
    grid-template-areas:
        "top"
        "left" 
        "right"
        "bottom";
    grid-gap: 2em;
}

.card {
    background-color: var(--card-colour);
    border: 5px solid var(--borders);
    border-radius: 5px;
    padding: 0.5em;
    margin: 0.5em;

    scroll-margin-top: 40px;

    
    box-shadow: 2px 2px 6px 0px #00000030;
}

.glow-anim {
    animation: glow 1.8s ease-in-out;
}
/* #endregion */

/* #region Display Characters */

.name-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: left;

    font-size: 4em;
    margin: 0.1em 0.4em;
    line-height: 1em;
}
/* #endregion */

/* #region Word Mode */
.word-card {
    flex-grow: 1;
}

.word-card.smushed {
    max-width: 100%;
}

.word-card.removed {
    display: none;
}

.word-card .card-name {
    font-size: x-large;
    text-decoration: underline;
    text-transform: capitalize;
    margin: 0.1em 1em;
}

.word-card .card-type-header {
    margin: 0.5em 1em 0.1em;
    font-style: italic;
    text-transform: capitalize;
    color: var(--subtext-colour);
}

.word-card ul, .word-card p {
    text-transform: capitalize;
    margin: 0.1em;
}

.word-card div {
    border-radius: 0.3em;
}

.word-card .card-footer {
    font-style: italic;
    margin: 0.1em 1em;
    color: var(--subtext-colour);
}

.word-card .derivation {
    display: inline-block;
    transition: scale 100ms;
    color: var(--text-colour);
}
.word-card .derivation:hover {
    scale: 1.2;
    transition: scale 100ms;
    cursor: pointer;
}

/* #endregion */

/* #region Number Mode */

.number-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-evenly;
    align-items: stretch;
}

.number-container .name-container {
    justify-content: center;
}

.number-word {
    min-width: 30%;
    width: fit-content;
    max-width: 90%;
    border: 3px solid var(--borders);
    border-radius: 5px;
    margin: 0.1em 0;
}

.number-container .card-type-header {
    text-align: center;
}

.romanisation {
    text-align: center;
    color: var(--subtext-colour);
}

/* #endregion */

/* #region Alphabet Mode */

.alphabet-grid {
    display: grid;
    row-gap: 0;
    grid-template-columns: repeat(3, minmax(calc(30px + 41.6px), 1fr));
    /* width: fit-content; */
    width:auto;
}

.top-alphabet {
    grid-area: top;
}

.left-alphabet {
    grid-area: left;
}

.right-alphabet {
    grid-area: right;
}

.bottom-alphabet {
    grid-area: bottom;
}

.word-card.blanked {
    background-color: #00000000;
    border: none;
}

.alphabet-mode .word-card {
    text-align: center;
}

.alphabet-mode .name-container {
    justify-content: center;
}
.alphabet-mode .card-name {
    margin: auto;
}

.alphabet-mode .liang {
    font-size: 4em;
    line-height: 1em;
}

/* #endregion */

/* #region Grammar Mode */

.grammar-card {
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
    font-size: 14px;
}

.text-line {
    margin: 1em 0;
    line-height: 2em;
}

.text-line.dropdown {
    cursor: pointer;
}

.dropdown :after {
    content: " ";
    border: solid var(--text-colour);
    border-width: 0 5px 5px 0;
    padding: 5px;
    float: right;
    margin-right: 1em;
    transform: rotate(45deg);
    -webkit-transform: rotate(45deg);

    transition: transform 100ms;
}
  
.dropdown.active :after {
    transform: rotate(-135deg);
    -webkit-transform: rotate(-135deg);
}

.grammar-paragraph {
    display: none;
}

.grammar-paragraph.active {
    display: block;
}

.grammar-card h1, .grammar-card h2 {
    text-align: center;
}

.grammar-card .name-container {
    display: inline-flex;

    align-items: center;
    vertical-align: middle;

    height: fit-content;
    margin: 0 0.1em;

    position: relative;
    top: -0.18em;
}

.grammar-card .display-character {
    height: 1.8em;
}

.text-line table {
    display: table;
    width: 100%;
    border-spacing: 0;
}

.text-line tbody {
    background-color: var(--card-colour);
    border: 1px solid var(--borders);
    border-radius: 2px;
}

.text-line tr:nth-child(even) {
    background-color: rgb(from var(--primary-highlight) r g b / 0.2);

}

.text-line th, .text-line td {
    display: table-cell;
    border: 1px solid var(--borders);
    text-align: center;
    padding: 0.5em;
}

.grammar-card strong.head {
    font-size: 1.2em;
}

/* #endregion */

/* #region Filters */
.filters {
    display: grid;
    grid-template-areas: "top" "mid" "bottom";
    grid-gap: 0;
    padding: 5px;
}

/* Search Bar */
#searchbar-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* align-items: center; */
}

.search-bar {
    padding: 0.5em;
    width: 90%;
    margin: 1em auto 0;
}

#search-bar {
    font-size: 16px;
    height: 2em;
    width: calc(100% - (3.2px + 4px));
    border: 1.6px solid var(--subtext-colour);
    border-radius: 4px;
}

.under-bar {
    display: flex;
    flex-direction: row;

    align-items: center;
    justify-content: space-evenly;

    border: none;
    border-top: solid 3px;
    border-bottom: solid 3px;
    border-color: var(--page-border);
}

.under-bar p {
    text-align: center;
    margin: 0;
}

.under-bar label {
    text-align: center;
}

.search-terms {
    padding: 0.5em;
    width: 90%;
    margin: 0 auto;

    font-size: 1.25em;
    color: var(--subtext-colour);
}

.search-term {
    margin-right: 0.25em;
}

.search-term:hover {
    cursor: pointer;
    scale: 1.1;
}

.search-term.selected {
    color: var(--text-colour);

    border: 3px solid var(--line);
    border-radius: 4px;
}

.sort-button {
    padding: 0.1em;
    border: 3px solid var(--subtext-colour);
    border-radius: 0.5em;
    margin: 5px;
    background-color: rgb(from var(--borders) r g b / 0.3);
}
.sort-button:hover {
    background-color: rgb(from var(--primary-highlight) r g b / 0.3);
    cursor: pointer;
}
.sort-button:has(input:checked) {
    background-color: rgb(from var(--secondary-highlight) r g b / 0.5);
}

/* Type Filters */
select {
    color: var(--text-colour);
    padding: 0.1em;
    border: 3px solid var(--subtext-colour);
    border-radius: 0.5em;
    margin: 5px;
    background-color: rgb(from var(--borders) r g b / 0.3);

    text-align: center;
}
select:hover {
    background-color: rgb(from var(--primary-highlight) r g b / 0.3);
    cursor: pointer;
}

.error {
    color: red;
    font-weight: bold;
    width: 90%;
    margin: auto;
    padding: 4px;
}

.error .name-container {
    display: inline-flex;

    align-items: center;
    vertical-align: middle;

    font-size: 1.5em;

    height: fit-content;
    margin: 0 0.1em;

    position: relative;
    top: -0.18em;
}

.error .display-character {
    height: 1.8em;
}

/* Filter Buttons */
#filter-button-container {
    display: grid;

    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));

    /* flex-direction: row;
    flex-wrap: wrap; */
    /* justify-content: space-evenly;
    align-items: center; */
    height: fit-content;
    margin-top: auto;
    margin-bottom: auto;
}

.filter-button {
    padding: 0.5em;
    border: 3px solid var(--subtext-colour);
    border-radius: 0.5em 0.5em 0 0;
    height: fit-content;
    margin: 5px;
    text-transform: capitalize;

    transform-origin: bottom;
    transition: scale 100ms ease-in, box-shadow 100ms ease-in;
}
.filter-button:has(input:checked) {
    /* font-weight: bold; */
    border-color: var(--primary-highlight);
    box-shadow: 
        inset 0 0 3px rgb(from var(--text-colour) r g b / 0.3);
        /* 0 0 5px 2px rgb(from var(--text-colour) r g b / 0.3); */
}
.filter-button:hover {
    cursor: pointer;

    scale: 1.05;
    box-shadow: 
        0 0 3px rgb(from var(--text-colour) r g b / 0.3);
    transition: scale 100ms ease-in, box-shadow 100ms ease-in;
}

/* #endregion */

/* #region Back To Top Button */

#back-to-top {
    position: fixed;
    bottom: 10px;
    right: 5px;

    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;

    height: 50px;
    min-width: 100px;
    width: 20%;
    background-color: lightsteelblue;
    border: 3px solid var(--page-border);
    border-radius: 3em;
}

#back-to-top:hover {
    background-color: var(--secondary-highlight);
    cursor: pointer;
    scale: 1.05;
}

#back-to-top .back-to-top-text {
    color: var(--page-border);
}

/* #endregion */

/* #region Word Types */

.noun {
    background-color: var(--toes-in-the-lagoon);
}

.proper {
    background-color: var(--toes-in-the-lagoon);
}

.verb {
    background-color: var(--golf-club-special);
}

.adjective {
    background-color: var(--watermelon-spring);
}

.genitive {
    background-color: var(--jungle-getaway);
}

.adverb {
    background-color: var(--cotton-candy-cheeks);
}

.interjection {
    background-color: var(--moonlit-lilly);
}

.auxillary {
    background-color: var(--beach-at-sunset);
}

.determiner {
    background-color: var(--lemon-sunshine);
}

.prefix, .suffix {
    background-color: var(--mountain-breeze-waves);
}

.postposition {
    color: #1F2937;
    background-color: whitesmoke;
}

.compound {
    background-color: var(--clear-sky-sea);
    /* color: white; */
}
/* #endregion */

@media screen and (min-width: 900px) {
    #card-container {
        padding: 1.5em 1em;
    }

    .word-card.smushed {
        max-width: 50%;
    }
}

@media screen and (min-width: 800px) {
    #container {
        max-width: 80%;
    }

    #card-container.alphabet-mode {
        grid-template-columns: repeat(2, 1fr);
        grid-template-areas:
            "top blank"
            "left right"
            "bottom bottom";
            grid-gap: 1em;
    }

    .alphabet-grid {
        display: grid;
        grid-template-columns: repeat(3, minmax(50px, 1fr));
        width: auto;
    }

    .bottom-alphabet {
        grid-template-columns: repeat(6, minmax(50px, 1fr));
    }

    .filters {
        display: grid;
        grid-template-columns: 65% 130px 1fr;
        grid-template-areas: "left mid right";
        grid-gap: 0;
    }

    .under-bar {
        display: flex;
        flex-direction: column;

        border: none;
        border-left: solid 3px;
        border-right: solid 3px;
        border-color: var(--page-border);
    }

    .sort-button {
        width: 80%;
    }
}

@keyframes glow {
    0% {
        box-shadow: 0px 0px 15px 10px var(--lemon-sunshine);
        scale: 1.05;
    }
    50% {
        box-shadow: 0px 0px 10px 5px var(--lemon-sunshine);
        scale: 1.025;
    }
    100% {
        box-shadow: 2px 2px 10px 0px #00000030;
        scale: 1;
    }
}