body{
    background-color: #fcf9f2;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0; /* the sapce bettwen the site and like chrome cuz there is defult of like 8 */
    padding: 40px; /* space betten my tiles and like the edge of my site */
    display: flex; /* works w different devices, lets the centering work */
}
.grid-container{
    display: grid;
    justify-content: center;
    grid-template-columns: repeat(auto-fit, minmax(200px, 200px));
    column-gap: 15px;
    row-gap: 15px;
    width:100%;
    place-content: center;
}

.tile{

    /*shape and stuff for the cards */
    height: 200px;
    width: 200px;
    background-color: #ffc5d3;
    border-radius: 15px;

    /* the text styles */
    color: #3d251e;
    font-size: 5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    place-items: center;
}


.container{
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    width: 100%;
}

.s-container{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    width:100%;
    margin-top: 20px;
}

.page{
    width: 100%;
}


.menu-button-first:hover{
    transform: translateY(-10px) scale(1);
    transition: transform 0.4s ease;
}


.menu-button{
    height: 200px;
    width: 100%;
    border-radius: 15px;
    background-color: palegreen;

    /* txt stuff*/
    color:#3d251e;
    font-size: 5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    text-decoration: none;
}

.menu-button-first{
    height: 200px;
    width: 100%;
    border-radius: 15px;
    background-color: rgb(255, 161, 242);

    /* txt stuff*/
    color:#3d251e;
    font-size: 5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;

    text-decoration: none;
}

.s-menu-button{
    height: 200px;
    width: 90%;
    border-radius: 15px;
    background-color: rgb(152, 252, 232);

    /* txt stuff*/
    color:#3d251e;
    font-size: 5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;

    text-decoration: none;
}

/* adding some movement */
.tile:hover{

    transform: translateY(-10px) scale(1);
    transition: transform 0.4s ease;
}

.menu-button:hover{

    transform: translateY(-10px) scale(1);
    transition: transform 0.4s ease;
}

.menu-button-second:hover{
    transform: translateY(-10px) scale(1);
    transition: transform 0.4s ease;
}

/* i just want more colours cp*/
.menu-button-second{
    height: 200px;
    width: 100%;
    border-radius: 15px;
    background-color: rgb(236, 160, 255);
    text-align: center;

    /* txt stuff*/
    color:#3d251e;
    font-size: 5rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;

    text-decoration: none;

}
/*------------------------The hard card flipping part seprate to look at better-------------------------------*/
.card{
    height: 200px;
    width: 200px;
    border-radius: 15px;
    background-color: rgb(255, 154, 154);
    display: flex;
    justify-content: center;
    align-items: center;
    place-items: center;
    /*adding speaker icon to corner...*/
    position: relative;
}



.card-inner{
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;

}


.card.flipped .card-inner{
    transform: rotateY(180deg);

}

.card-front, .card-back{
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    justify-content: center;
    text-align: center;
    align-items: center;
    display: flex;
}


.card-front{
    color: #3d251e;
    font-size: 4rem;
}


.card-back{
    flex-direction: column;
    transform: rotateY(180deg);
    justify-content: center;
    text-align: center;
    gap: 8px;
}

.chinese{
    color: #3d251e;
}


.english{
    font-size: 3rem;
    color: #3d251e;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.english.long-text{
    font-size: 1.5rem;
    color: #3d251e;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.pinyin{
    font-size: 3rem;
    color: #3d251e;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.chinese.long-char{
    font-size: 3rem;
    color: #3d251e;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.chinese.long-charC{
    font-size: 2rem;
    color: #3d251e;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

.pinyin.long-textp{
    font-size: 2rem;
    color: #3d251e;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
}

/*Following is so the pages with the alrge AND small buttons on the same screen*/

/* the whole page: tiles on top, green button(s) underneath, never wider than 6 tiles */
.tile-page{
    width: 100%;
    max-width: 1275px; /* 6 tiles x 200px + 5 gaps x 15px */
    margin: 0 auto;    /* keeps it centered */
}

/* 6 tiles across, they shrink if the screen is smaller */
.tile-page .grid-container{
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
}

/* tiles fill their column and stay square */
.tile-page .card{
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    container-type: inline-size; /* lets the text size itself off the tile width (cqi) */
}

/* text shrinks with the tile, but never gets bigger than before
   (cqi = 1% of the tile width, so 32cqi on a 200px tile = 64px = 4rem) */
.tile-page .chinese{ font-size: min(4rem, 32cqi); }
.tile-page .chinese.long-char{ font-size: min(3rem, 24cqi); }
.tile-page .chinese.long-charC{ font-size: min(2rem, 16cqi); }
.tile-page .pinyin{ font-size: min(3rem, 24cqi); }
.tile-page .pinyin.long-textp{ font-size: min(2rem, 16cqi); }
.tile-page .english{ font-size: min(3rem, 24cqi); }
.tile-page .english.long-text{ font-size: min(1.5rem, 12cqi); }

/* green button(s) go full width under the tiles */
.tile-page .s-container{
    grid-template-columns: 1fr;
}
.tile-page .menu-button{
    font-size: clamp(1.5rem, 6vw, 5rem); /* shrinks on small screens so the words fit */
    text-align: center;
}


/*------------------------Sentence pages (the s- ones), 2 wide tiles across-------------------------------*/

.grid-container.sentence-grid{
    grid-template-columns: repeat(2, 1fr);
    max-width: 1275px;
    margin: 0 auto;
}

.sentence-grid .card{
    width: 100%;
    height: 200px;
    container-type: inline-size; /* text sizes itself off the tile width (cqi) */
}

/* a bit of space at the sides so long sentences dont touch the edge */
.sentence-grid .card-front, .sentence-grid .card-back{
    padding: 0 5%;
    box-sizing: border-box;
}

/* --len is the number of characters (cards.js sets it), so longer sentence = smaller text.
   min() = never bigger than the max size, max(1rem) = never too tiny, it wraps to 2 lines instead */
.sentence-grid .chinese{
    font-size: max(1rem, min(3.5rem, calc(85cqi / var(--len))));
}
.sentence-grid .pinyin, .sentence-grid .english{
    font-size: max(1rem, min(2.5rem, calc(160cqi / var(--len))));
}


/*changes thing for phone sizes, hopfully lol*/
@media (max-width: 600px){
    .grid-container.sentence-grid{
        grid-template-columns: 1fr; /* 1 across on phone, 2 makes sentences too tiny */
        gap: 10px;
    }
    .sentence-grid .card{
        height: 160px;
    }
    body{
        padding: 15px;
    }
    .tile-page .grid-container{
        grid-template-columns: repeat(3, 1fr); /* 3 across on phone, 6 is too tiny */
        gap: 10px;
    }
    .tile-page .menu-button{
        height: 100px;
    }
}


/* i want more colours !! */
.menu-button:nth-child(6n+1) { background-color: #b5ead7; } /* mint */
.menu-button:nth-child(6n+2) { background-color: #a8d8ff; } /* sky blue */
.menu-button:nth-child(6n+3) { background-color: #d4c1ff; } /* lavender */
.menu-button:nth-child(6n+4) { background-color: #fff1a8; } /* butter yellow */
.menu-button:nth-child(6n+5) { background-color: #ffd8a8; } /* peach */
.menu-button:nth-child(6n+6) { background-color: #a0e7e5; } /* aqua */

/*adding my speaker icon hopfully lol*/

.speaker{
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    background-color: rgba(255, 255, 255, 0.6);
}

.speaker:hover{
    background-color: white;
}
/*speace between the tones ive addaed!*/
.tone-group {
    margin-bottom: 40px;
}

/*yay published it!! but it looks ugo on my phone, so lets fix*/

@media (max-width: 600px){

    .grid-container{
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .tile {
        width: auto;
        height: 90px;
        font-size: 1.8rem;
    }


    .card{
        width: 100%;
        height: 150px;
    }
    .card-front{
        font-size: 2.8rem;
    }
    .pinyin {
        font-size: 1.1rem;
    }

        .pinyin.long-textp {
            font-size: 0.9rem;
        }

    .english {
        font-size: 0.85rem;
    }

        .english.long-text {
            font-size: 0.75rem;
        }

    .chinese.long-char {
        font-size: 2rem;
    }

    .chinese.long-charC {
        font-size: 1.3rem;
    }

    .card-back {
        padding: 30px 6px 6px;
        box-sizing: border-box;
        gap: 4px;
    }

    .menu-button,
    .menu-button-first,
    .menu-button-second,
    .s-menu-button {
        height: 90px;
        width: 100%;
       
        font-size: 1.1rem;
      
    }


}

/*the hovering thing looks dumb on touch screen lets remove*/
@media (hover: none) {
    .tile:hover,
    .menu-button:hover,
    .menu-button-first:hover,
    .menu-button-second:hover,{
        transform: none;
    }
}