/**
 * 이 파일은 아이모듈의 일부입니다. (https://www.imodules.io)
 *
 * 아이모듈 에러페이지 스타일시트를 정의한다.
 * 
 * @file /styles/error.css
 * @author Arzz <arzz@arzz.com> 
 * @license MIT License
 * @modified 2024. 5. 21.
 */
@import 'https://fonts.googleapis.com/css2?family=Nanum+Gothic+Coding&display=swap';

:root {
    --im-color-error-text-500: #342f5a;
    --im-color-error-text-400: #4f0f8f;
    --im-color-error-text-300: #9892a8;

    --im-color-error-background-400: #b0acc5;
    --im-color-error-background-300: #edd3fd;
    --im-color-error-background-200: #faf5fe;

    --im-color-error-accent-500: #4b476d;
    --im-color-error-accent-600: #342f5a;
    --im-color-error-accent-backward-500: #e8e5f0;
    --im-color-error-accent-backward-600: #fff;
}

html,
body {
    width: 100%;
    height: 100%;
    padding: 0px;
    margin: 0px;
    overflow: auto;
}

body {
    &[data-type='error'] {
        color: var(--im-color-foreground-500);
        background: var(--im-color-background-400);
        font-family: SUIT, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI',
            'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;

        * {
            padding: 0;
            margin: 0;
            font-family: inherit;
        }

        > main[data-type='error'] {
            min-height: 100%;

            > section {
                box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
            }
        }
    }

    &[data-color-scheme='dark'],
    &[data-color-scheme='auto'][data-prefers-color-scheme='dark'] {
        --im-color-error-text-500: #dad1fa;
        --im-color-error-text-400: #d2adea;
        --im-color-error-text-300: #9892a8;

        --im-color-error-background-400: #433f45;
        --im-color-error-background-300: #412e4f;
        --im-color-error-background-200: #342f36;
    }
}

main[data-type='error'] {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    width: 100%;
    height: fit-content;
    padding: 50px 15px;
    box-sizing: border-box;

    > section {
        width: 100%;
        max-width: 500px;
        border: 1px solid var(--im-color-background-200);
        background: var(--im-color-background-500);
        flex-grow: 0;
        flex-shrink: 0;
    }

    > section[data-role='message'] {
        > h4 {
            font-size: 16px;
            height: 50px;
            line-height: 50px;
            margin: 0px 15px;
            color: var(--im-color-foreground-500);
            border-bottom: 1px solid var(--im-color-background-200);
            font-weight: bold;
        }

        > article {
            margin: 20px 15px;
            font-size: 14px;

            > label {
                display: block;
                color: var(--im-color-error-text-300);
                font-size: 16px;
                line-break: 1.4;
                margin-bottom: 10px;
            }

            > b {
                display: block;
                color: var(--im-color-error-text-500);
                font-size: 18px;
                line-height: 1.4;
            }

            > small {
                display: block;
                color: var(--im-color-error-text-300);
                font-size: 14px;
                margin-top: 15px;
                word-break: break-all;
                line-height: 1.6;
            }
        }
    }

    > section[data-role='debug'] {
        margin-top: 20px;

        > ul {
            list-style: none;
            display: block;
            width: 100%;
            height: 46px;
            background: var(--im-color-error-accent-500);
            text-align: center;

            > li {
                display: inline-block;
                height: 40px;
                padding: 3px;
                font-size: 0;

                > button {
                    display: block;
                    width: 100%;
                    height: 40px;
                    line-height: 40px;
                    color: var(--im-color-error-accent-backward-500);
                    cursor: pointer;
                    padding: 0px 12px;
                    border: 0px;
                    background: transparent;
                    border-radius: 3px;
                    font-size: 14px;
                }

                > button.selected {
                    background: var(--im-color-error-accent-600);
                    color: var(--im-color-error-accent-backward-600);
                }
            }
        }

        > article {
            display: flex;
            align-items: stretch;

            > aside {
                width: 300px;
                flex-shrink: 0;
                z-index: 1;

                > div {
                    overflow: hidden;
                    width: 300px;
                    height: 100%;
                    background: var(--im-color-background-500);
                    border-right: 1px solid var(--im-color-background-200);

                    > ul {
                        list-style: none;
                        display: block;
                        width: 300px;

                        > li.title {
                            display: none;
                            background: var(--im-color-background-400);
                            border-bottom: 1px solid var(--im-color-background-300);

                            > button {
                                border: 0;
                                cursor: pointer;
                                width: 42px;
                                height: 40px;
                                color: var(--im-color-foreground-500);
                                border-right: 2px solid var(--im-color-background-200);
                                background: transparent;
                                font-size: 14px;

                                &[data-action='toggle'] {
                                    > i {
                                        font-family: moimz;
                                        font-style: normal;

                                        &::before {
                                            content: '\e306';
                                        }
                                    }
                                }
                            }
                        }

                        > li.stack {
                            display: block;
                            width: 100%;
                            border-bottom: 1px solid var(--im-color-background-300);

                            > button {
                                display: block;
                                width: 100%;
                                background: transparent;
                                border: 0;
                                padding: 14px 14px 14px 54px;
                                text-align: left;
                                cursor: pointer;
                                position: relative;

                                &::after {
                                    content: ' ';
                                    position: absolute;
                                    top: 0;
                                    left: 40px;
                                    width: 2px;
                                    height: 100%;
                                    background: var(--im-color-background-300);
                                }

                                > label {
                                    display: block;
                                    font-size: 14px;
                                    color: var(--im-color-error-text-400);
                                    line-height: 1.4;
                                    word-break: break-all;
                                    margin-bottom: 10px;
                                }

                                > p {
                                    display: flex;
                                    align-items: flex-end;
                                    position: relative;

                                    > b {
                                        flex-grow: 1;
                                        font-size: 14px;
                                        line-height: 20px;
                                        color: var(--im-color-error-text-300);
                                        word-break: break-all;
                                    }

                                    > small {
                                        flex-basis: auto;
                                        background: var(--im-color-background-200);
                                        color: var(--im-color-foreground-400);
                                        height: 20px;
                                        line-height: 20px;
                                        padding: 0px 4px;
                                        border-radius: 3px;
                                        font-size: 12px;
                                    }

                                    > i {
                                        position: absolute;
                                        top: 0;
                                        left: -54px;
                                        width: 40px;
                                        height: 20px;
                                        line-height: 20px;
                                        font-style: normal;
                                        color: var(--im-color-error-text-300);
                                        font-weight: bold;
                                        font-size: 12px;
                                        text-align: center;
                                    }
                                }
                            }

                            > button.selected {
                                background: var(--im-color-error-background-200);

                                &::after {
                                    background: var(--im-color-error-background-400);
                                }
                            }
                        }
                    }
                }
            }

            > div {
                flex-grow: 1;
                background: var(--im-color-background-500);

                > ul {
                    list-style: none;
                    display: none;
                    width: 100%;

                    > li {
                        width: 100%;
                        display: flex;
                        align-items: stretch;

                        > small {
                            flex-basis: 50px;
                            font-size: 12px;
                            background: var(--im-color-background-400);
                            border-right: 1px solid var(--im-color-background-200);
                            line-height: 20px;
                            flex-shrink: 0;
                            text-align: right;
                            padding-right: 8px;
                            font-variant: tabular-nums;
                            color: var(--im-color-foreground-300);
                        }

                        > pre {
                            line-height: 20px;
                            word-break: break-all;
                            width: 100%;
                            white-space: pre-wrap;
                            padding: 0px 8px;
                            font-family: 'Nanum Gothic Coding', monospace;
                            font-size: 14px;
                        }
                    }

                    > li.file {
                        display: block;
                        box-sizing: border-box;
                        background: var(--im-color-background-300);
                        padding: 10px 20px;
                        border-bottom: 1px solid var(--im-color-background-200);

                        > label {
                            display: block;
                            font-size: 14px;
                            color: var(--im-color-error-text-300);
                            line-height: 1.4;
                            word-break: break-all;
                            margin-bottom: 10px;
                            word-break: break-all;
                        }

                        > b {
                            display: block;
                            font-weight: normal;
                            color: var(--im-color-error-text-400);
                            font-size: 16px;
                            word-break: break-all;
                        }
                    }

                    > li.focused {
                        > small {
                            background: var(--im-color-error-background-300);
                        }

                        > pre {
                            background: var(--im-color-error-background-200);
                        }
                    }
                }

                > ul.selected {
                    display: block;
                }
            }
        }
    }
}

main[data-type='error'][data-mode='debug'] {
    > section {
        max-width: 1000px;
    }
}

@media (max-width: 800px) {
    main[data-type='error'] {
        > section[data-role='debug'] {
            > article {
                > aside {
                    width: 42px;

                    > div {
                        width: 42px;
                        border-right: 0px;
                        transition: width 0.5s;

                        > ul {
                            > li.title {
                                display: block;
                            }
                        }
                    }

                    > div.opened {
                        width: 300px;
                        border-right: 1px solid var(--im-color-background-200);

                        > ul {
                            > li.title {
                                > button {
                                    &[data-action='toggle'] {
                                        > i {
                                            &::before {
                                                content: '\e305';
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                > div {
                    > ul {
                        > li {
                            > pre {
                                font-size: 12px;
                            }
                        }
                    }
                }
            }
        }
    }
}
