/* ============================ */
/*     ROOT & GLOBAL STYLES     */
/* ============================ */
/* Light mode */
:root {
    --text-color: 51, 51, 51;
    --bg-color: 219, 219, 219;
    --card-bg: 255, 255, 255;

    --preview-color: 51, 51, 51;
    --accent-color: 30, 138, 255;
}

/* Dark mode */
:root.dark {
    --text-color: 239, 239, 239;
    --bg-color: 45, 45, 45;
    --card-bg: 30, 30, 30;
}

* {
    margin: 0;
    padding: 0;

    font-family:
        system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    font-size: 16px;
    color: rgb(var(--text-color));
    
    box-sizing: border-box;

    kbd {
        font-family:
            ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
            "Liberation Mono", "Courier New", monospace;
    }
}

/* ============================ */
/*            BODY              */
/* ============================ */
body {                                  /* Contains Header, Main, Footer */
    display: flex;
    flex-direction: column;

    margin: 0 auto;                     /* Center the body horizontally */
    padding: 30px;

    width: 100%;
    max-width: 1120px;
    height: 100%;
    min-height: 100vh;

    /* Background Patterns */
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.06) 1px, transparent 1px),
        linear-gradient(to right, rgba(0, 0, 0, 0.06) 1px, transparent 1px);
    background-size: 69px 69px;
    background-color: rgb(var(--bg-color));

    color: rgb(var(--text-color));
}

/* ============================ */
/*            HEADER            */
/* ============================ */
header {
    display: flex;
    flex-direction: column;
    align-items: center;

    text-align: center;
    margin-top: 30px;

    & h1 {
        font-size: clamp(1.5rem, 1.1528rem + 1.1111vw, 2rem);
        margin-bottom: 0.5rem;
    }

    & p {
        font-size: clamp(1.1rem, 1.0306rem + 0.2222vw, 1.2rem);
        color: rgba(var(--text-color), 0.7);
    }
}

/* ============================ */
/*            MAIN              */
/* ============================ */
main {
    display: flex;
    flex-direction: row;
    flex: 1;                            /* Pushes Footer to the bottom */

    margin: 50px 0;
}

/* ============================ */
/*          INPUT FORM          */
/* ============================ */
.input-form {
    display: flex;
    flex-direction: column;

    height: 100%;
    width: 50%;
    max-width: 540px;

    padding: 1.5rem;
    border-radius: 10px;
    background-color: rgb(var(--card-bg));
    box-shadow: 10px 30px 50px rgba(var(--text-color), 0.1);

    & label {
        font-size: 0.875rem;
        font-weight: 600;
    }

    & input,
    & select {
        -webkit-appearance: none; /* Safari / iOS */
        -moz-appearance: none;    /* Firefox */
        appearance: none;         /* Standard */

        margin: 0.5rem 0 1.5rem 0;
        padding: 1rem 1rem;
        
        font-size: 1rem;

        border: solid 1px rgba(var(--text-color), 0.2);
        background-color: rgba(var(--text-color), 0.05);
        border-radius: 5px;
    }

    & .definition-desc,
    & .definition-desc kbd,
    & .definition-desc strong {
        margin: 0.5rem 0 0.5rem 0;
        font-size: 0.875rem;
        color: rgba(var(--text-color), 0.7);
    }

    & textarea {
        padding: 10px;

        max-width: 540px;
        min-height: 100px;
        
        font-size: 1rem;
        line-height: 1.5em;

        border: solid 1px rgba(var(--text-color), 0.2);
        background-color: rgba(var(--text-color), 0.05);
        border-radius: 5px;
        
        resize: vertical;
    }

    & button {
        margin: 1.5rem 0 0 0;
        
        height: 50px;
        
        background-color: rgba(var(--accent-color), 0);
        border: 1px solid rgb(var(--accent-color));
        border-radius: 3px;
        
        font-weight: 600;
        color: rgb(var(--accent-color));
    }

    & button:hover {
        background-color: rgba(var(--accent-color), 1);
        color: white;
        cursor: pointer;
    }
}

/* ============================ */
/*       FLASHCARD PREVIEW      */
/* ============================ */
.preview {
    display: flex;
    
    margin: 3rem 0 3rem 3rem;
    
    height: 100%;
    width: 50%;
    max-width: 540px;

    align-items: center;
    justify-content: center;
}

#flashcard-preview {
    display: flex;
    flex-direction: column;
    justify-content: center;
    
    width: 100%;
    padding: 5rem;
    
    background-color: #f5f5f4;
    color: rgb(var(--preview-color));
    border-radius: 1rem;
    text-align: center;
    box-shadow: 10px 30px 50px rgba(var(--text-color), 0.1);

    & > * {
        margin-top: 1rem;
    }

    & #word-preview {
        font-size: 3rem;
        font-weight: 700;
        line-height: 3.5rem;
        overflow-wrap: break-word;
        color: rgb(var(--preview-color));
    }

    & #pronunciation-preview {
        font-size: 1.5rem;
        line-height: 2rem;
        color: rgba(var(--preview-color), 0.5);
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    & #type-preview {
        font-size: 1.2rem;
        line-height: 2rem;
        font-style: italic;
        color: rgba(var(--preview-color), 0.5);
    }

    & #definition-preview, 
    & #definition-preview strong {
        font-size: 1.1rem;
        line-height: 1.5rem;
        overflow-wrap: break-word;
        word-wrap: break-word;
        color: rgb(var(--preview-color));
    }
}

/* ============================ */
/*            FOOTER            */
/* ============================ */
footer {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    & a {
        text-underline-offset: 3px;;
    }

    p, a {
        font-size: 0.875rem;
        color: rgba(var(--text-color), 0.7);
    }
}

/* Github icon */
.footer-icon {
    width: 19px;
    height: 19px;
    fill: currentColor;
    margin: 5px 0;
}
/* Default: show light icon */
.icon-dark { display: none; }
.icon-light { display: inline; }
/* Dark mode: swap */
@media (prefers-color-scheme: dark) {
    .icon-dark { display: inline; }
    .icon-light { display: none; }
}

/* ============================ */
/*          RESPONSIVE          */
/* ============================ */
@media (max-width: 1024px) {
    body {
        padding: 20px;
    }

    main {
        flex-wrap: wrap;
        justify-content: center;
    }

    .input-form, .preview {
        width: 100%;
    }

    .preview {
        margin-left: 0;
        margin-right: 0;
    }
}

/* ============================ */
/*    LIGHT/DARK MODE SWITCH    */
/* ============================ */
.light-switch {
    --input-focus: rgb(var(--accent-color));
    --font-color: #323232;
    --font-color-sub: #666;
    --bg-color: #fff;
    --bg-color-alt: #666;
    --main-color: #323232;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
    
    position: relative;
    width: 50px;
    height: 20px;

    margin-top: 30px;
}

.toggle {
    width: 0;
    height: 0;
    opacity: 0;
}

.slider {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    border-radius: 5px;
    box-sizing: border-box;
    border: 2px solid var(--main-color);
    box-shadow: 4px 4px var(--main-color);
    position: absolute;
    cursor: pointer;
    background-color: var(--bg-color);
    transition: 0.3s;
}

.slider:before {
    box-sizing: border-box;
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    border: 2px solid var(--main-color);
    border-radius: 5px;
    left: -2px;
    bottom: 2px;
    background-color: var(--bg-color);
    box-shadow: 0 3px 0 var(--main-color);
    transition: 0.3s;
}

.toggle:checked + .slider {
    background-color: var(--input-focus);
}

.toggle:checked + .slider:before {
    transform: translateX(30px);
}

/* Remove box-shadow when in Dark mode */
:root.dark .input-form,
:root.dark #flashcard-preview {
    box-shadow: none;
}