/*
© 2025 Tord Dellsén
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

/*
**** CSS Reset ****
*/

*, ::after, ::before {
    box-sizing: border-box;
    margin: 0;
}

/*
Explicitly setting the color of the icons. We do this because on iOS if svg elements are placed
inside a-tags (links) then the color will be blue.
*/
svg{
    color: var(--clr-fg-primary);
    align-self: center;
}

/*
**** Constants ****
*/

@font-face {
    font-family: 'Gauntlet Thin';
    src: url('fonts/gauntlet/GauntletThin_TB.otf') format('truetype');
}
@font-face {
    font-family: 'Gauntlet Classic';
    src: url('fonts/gauntlet/GauntletClassic_TB.otf') format('truetype');
}

:root {
    /*Font*/
    --ff-base: system-ui, sans-serif;
    --ff-title: 'Gauntlet Thin', sans-serif;
    --ff-title-first-letter: 'Gauntlet Classic', sans-serif;
    --fw-bold: 600;
    --fs-smaller-12pt: 0.75rem;
    --fs-small-14pt: 0.875rem;
    --fs-base-16pt: 1rem;
    --fs-large-18pt: 1.125rem;
    --fs-larger-20pt: 1.25rem;

    /*Colors*/
    /* --clr-bg-primary: #F0F4F2; */
    --clr-bg-primary: linear-gradient(135deg, #f8f6f2 0%, #e8f4f2 100%);
    /*
    "background_color" in the manifest file:
    
    "Because this color appears before your stylesheets have loaded, set its value to the
    same color value as the background-color CSS property in your application's stylesheet."
    --- https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/How_to/Customize_your_app_colors
    */
    --clr-fg-primary: #122646;
    --clr-fg-secondary: #918F8D;
    --clr-bg-installation-banner: #FFE9A0;
    --clr-version-text: #D5D5D5;
    --clr-bg-share-btn: #E5E5E5;
    --clr-bg-row: #FFFFFF;
    --clr-row-practice-text: #4F7EF1;
    --clr-dlg-btn-background: #617BE8;
}

/*
**** Main Screen ****
*/

body {
    margin: 0 auto;
    max-width: 65ch;
    font-family: var(--ff-base);
    font-size: var(--fs-base-16pt);
    color: var(--clr-fg-primary);
    background: var(--clr-bg-primary);
    background-attachment: fixed;
}
#main-container {
    /*Flex parent*/
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;

    /*
    **** Main Screen: Header ****
    */

    #installation-banner{
        /*Sticky*/
        position: sticky;
        z-index: 1;
        top:0;

        width: 100%;
        background-color: var(--clr-bg-installation-banner);
        font-size: var(--fs-small-14pt);
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
        cursor: pointer;
    }

    header {
        margin-top: 0.5em;

        /*Flex parent*/
        display: flex;
        flex-direction: row;
        align-items: center;

        .empty-header-item {
            /*Flex child*/
            flex-grow: 1;
        }
        #active-date-relative {
            font-weight: var(--fw-bold);
            font-size: var(--fs-larger-20pt);
        }
        #active-date-absolute {
            color: var(--clr-fg-secondary);
        }
    }

    #intention-section {
        font-size: var(--fs-base-16pt);
        padding: 0.3rem 0.5rem;
        margin-top: 0.5rem;
        color: var(--clr-fg-secondary);
    }

    #practice-list{
        /*Flex parent*/
        display: flex;
        flex-direction: column;

        /*
        **** Main Screen: Rows ****
        */

        .row {
            /*Flex parent*/
            display: flex;
            flex-direction: row;
            align-items: center;
            flex-wrap: nowrap;

            margin: 0.5rem;
            padding: 0 1.0rem;
            background-color: var(--clr-bg-row);
            border-radius: 1.0rem;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

            .row-texts {
                /*Flex child*/
                flex-grow: 1;

                /*Flex parent*/
                display: flex;
                flex-direction: column;
            }
            .row-icon{
                padding-right: 0.25rem;    
            }
            .row-previous-days {
                /*Flex parent*/
                display: flex;
                flex-direction: column;
                
                padding: 0.5rem 0.5rem 0.5rem 0;
            }
            .practice{
                color: var(--clr-row-practice-text);
                font-weight: var(--fw-bold);
                padding: 0.75rem 0.5rem 0.25rem 0.5rem;
                cursor: pointer;
            }
            .smart-goal {
                color: var(--clr-fg-secondary);
                padding: 0.25rem 0.5rem 0.75rem 0.5rem;
                cursor: pointer;
            }
            .row-checkbox{
                cursor: pointer;
            }

        }

    }

    /**** Footer ****/

    footer {
        /*
        Warning: The footer may appear invisible on mobile browsers if the address bar is covering
        the footer
        */
        width: 100%;

        /*Flex child*/
        flex-shrink: 0;

        /*Flex parent*/
        display: flex;
        flex-direction: row;

        #share-btn {
            background-color: var(--clr-bg-share-btn);
            width: 100%;
        }
    }

}

/*
**** Onboarding dlg ****
*/

#onboarding-dlg{
    width: 100%;
    height: 85%;
    text-align: center;
    font-size: var(--fs-large-18pt);

    h1 {
        font-size: 3.5rem;
    }

    ul{
        list-style-type: none;
        padding-left: 0;
        text-align: left;
        display: inline-block;
        margin-left: auto;
        margin-right: auto;
    }
    p, ol, ul, textarea{
        margin-bottom: 1.2rem;
    }

    .onboarding-outer-div{
        width: 100%;
        height: 100%;
        padding: 1rem;

        .onboarding-inner-div{
            width: 100%;
            max-height: 100%;
            overflow-y: auto;
            align-self: center;

            #ob-1-text{
                padding-left: 0;
                text-align: left;
                display: inline-block;
                margin-left: auto;
                margin-right: auto;
                font-family: var(--ff-title);

                h1::first-letter{
                    font-family: var(--ff-title-first-letter);
                }

                #ot7-practice-selection{
                    margin-bottom: 1.25rem;

                    .ot7-part-of-day{
                        margin-bottom: 0.75rem;
                    }
                }
            }

            .selection-row{
                opacity: 0.5;
                cursor: pointer;

                &.selected{
                    opacity: 1;
                }
            }
        }
    }
}

/*
**** Other Dialogs ****
*/

dialog {
    margin: auto;
    max-width: 65ch;
    font-family: inherit;
    padding: 0; /*reset (default is 1em)*/
    border-radius: 1.0rem;

    .dlg-content{
        padding: 0 1rem 0.5rem 1rem;
    }

    &::backdrop{
        background: rgba(0,0,0,0.7);
    }
    &[open]{
        animation: fadeIn 0.3s ease-out;
    }
    &.closing{
        animation: fadeOut 0.3s ease-out forwards;
    }

    /**** Header ****/

    header{
        text-align: center;
        background: white;

        /*Ensure the title is sticking to the top*/
        position: sticky;
        top:0;
        z-index: 1;

        /*Flex parent*/
        display: flex;
        flex-direction: row;
        align-items: center;

        h2{
            /*Flex child*/
            flex-grow: 1;
        }
        .x-close-btn{
            /*Flex child*/
            flex-shrink: 0;

            padding: 0.75rem;

            svg{
                width: 1.625rem;
                height: 1.625rem;
                cursor: pointer;
            }
        }
    }

    /**** Main Menu Content ****/

    .menu-items{
        list-style-type: none;
        padding-left: 0;
        ul{
            list-style-type: none;
            padding-left: 1.5rem;
        }
        button, a{
            padding: 0.75rem 1.0rem;
            font-size: var(--fs-larger-20pt);
            border-radius: 0.5rem;
            cursor: pointer;

            /*Flex parent*/
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 0.5rem;

            /*Donate a/href link*/
            text-decoration: none;
            color: black;
        }
        svg{
            width: 1.625rem;
            height: 1.625rem;

            /*Flex child*/
            flex-shrink: 0;
        }
    }
    #version{
        font-size: var(--fs-small-14pt);
        color: var(--clr-version-text);
    }

    /**** Other Contents ****/

    .other-attributions{
        font-size: var(--fs-smaller-12pt);
        overflow-wrap: anywhere;
    }

    .youtube-video-container {
        position: relative;
        width: 100%;
        height: 0;
        padding-bottom: 56.25%; /* for the 16:9 aspect ratio */
        /* overflow: hidden; */
        margin: 0.75rem 0;

        iframe {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
    }

    .practice-short-description{
        color: var(--clr-fg-secondary);
    }

    /**** Footer ****/

    .dialog-buttons{
        text-align: center;

        /*Flex parent*/
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        flex-wrap: wrap;
        margin-bottom: 0.5rem;

        button{
            background-color: var(--clr-dlg-btn-background);
            color: white;
            border-radius: 3rem;

            font-weight: var(--fw-bold);
            font-size: var(--fs-large-18pt);
            padding: 0.9rem 1.7rem;
            min-height: 44px;
            min-width: 44px;

            &.inactive{
                background-color: var(--clr-fg-secondary);
            }
        }
    }
}

/*
**** Dialog animation ****
*/

@keyframes fadeIn{
    from{
        opacity: 0;
        transform: scale(0.95);
    }
    to{
        opacity: 1;
        transform: scale(1);
    }
}
@keyframes fadeOut{
    from{
        opacity: 1;
        transform: scale(1);
    }
    to{
        opacity: 0;
        transform: scale(0.95);
    }
}

/*
**** General ****
*/

button {
    padding: 0.2rem 0.4rem;
    background-color: inherit;
    border: none;
    cursor: pointer;
    &.bordered {
        border: 1px solid var(--clr-fg-primary);
        font-size: var(--fs-base-16pt);
        padding: 0.7rem 1rem;
        min-height: 44px;
        min-width: 44px;
    }
}

h1, h2, h3, h4, h5, h6 {
    text-wrap: balance;
}
@supports(text-wrap: pretty){
    h1, h2, h3, h4, h5, h6 {
        text-wrap: pretty;
    }
}
label{
    display: block;
}
details{
    cursor: pointer;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.centered {
    text-align: center;
}

p, ol, ul{
    margin-bottom: 0.7rem;
}

.invisible-btn{
    visibility: hidden;
}
.removed-btn{
    display: none;
}

input[type="text"], textarea {
    display: block; /*otherwise some browsers may give inline which results in the wrong width*/
    resize: none; /*for textarea*/
    width: 100%;
    font-size: var(--fs-large-18pt);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.75rem;
    border: 2px solid var(--clr-fg-secondary);
}
