/* デフォルトスタイル（モバイル以外の環境用） */

/* この設定が先に宣言されることでSafariでの表示不具合（最終位置に表示されてからopenアニメーションになる問題）が解消される */
.JLTi_SidePanel[open] {
    /* 開いている状態の位置 */
    transform: translateX(0%); 
    animation: JLTi_ShowSidePanel .2s linear;
}

.JLTi_SidePanel.RightSidePanel[open] {
    transform: translateX(0%);
    animation: JLTi_ShowSidePanel_Right .2s linear;
}

.JLTi_SidePanel {
    all: unset;
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    bottom: 0;
    width: 600px; /* デフォルトはデスクトップ向け幅 */
    background-color: #fff;
    margin: 0;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1); /* デスクトップ用の影 */
    z-index: 1000; /* 最前面に表示：閉じるアニメーションでは他の要素に負けないように設定が必要 */

    transform: translateX(-100%); /* 閉じている状態の位置 */
    transition: all .2s allow-discrete; /* 閉じる時のアニメーションも可能に */
    
    /* 右から開くサイドパネルに設定するオプション */
    &.RightSidePanel {
        left: auto;
        right: 0;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        transform: translateX(100%);

        /* コンテンツ表示のため、幅を広く設定 */
        width: 85%;
        max-width: 500px;

        /* 狭い横幅では全幅表示しつつ、デスクトップでは500pxを上限にする */
        &.is-width-full {
            width: 100%;
            max-width: 500px;
        }
    }

    .CloseButton {
        all: unset;
        position: absolute;
        top: 0;
        left: 0;
        font-size: 30px; /* デフォルトで大きめのボタン */
        cursor: pointer;
        padding: 18px 35px; /* タップしやすいように広めのクリックエリアを確保 */
        color: #777;
        z-index: 1000; /* 最前面に表示 */
        /* モバイルタップ時の青いハイライトを抑制 */
        -webkit-tap-highlight-color: transparent;
        tap-highlight-color: transparent;
    }

    .SidePanelHeader {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 80px; /* ヘッダーの高さ */
        padding: 5px;
    }

    .ContentContainer {
        padding: 30px; /* 余白を広めに設定 */
        position: absolute;
        inset: 0;
        top: 80px; /* CloseButtonの高さに合わせて変更 */
        /* display: grid; */
        overflow-x: hidden;
        overflow-y: auto;
        /* この箱の中でオーバースクロールが発生しても外部のスクロールにつながることはなくなる */
        overscroll-behavior-y: contain;
    }

    &.is-width-full {
        .ContentContainer {
            /* 
                最大幅表示の右サイドパネルの場合 
                その用途は、フォーム表示が前提であり
                フォーム用の背景色を表示する
            */
            background-color: var(--BackgroundColor);
        }
    }

    /* モバイル環境用のスタイル */
    @media (max-width: 768px) {
        & {
            width: 80%;
            max-width: 300px; /* モバイル向けの最大幅 */
        }

        &.RightSidePanel.is-width-full {
            width: 100%;
            max-width: 500px;
        }

        .CloseButton {
            font-size: 25px; /* モバイル向けに小さく */
            padding: 16px 30px; /* タップしやすいように広めのクリックエリアを確保 */
        }

        .SidePanelHeader {
            height: 70px; /* ヘッダーの高さ */
        }

        .ContentContainer {
            padding: 16px 16px; /* 余白を減らしてコンパクトに */
            top: 70px; /* CloseButtonの下になるように調整 */
        }
    }
}

/* サイドパネルの表示アニメーション */
@keyframes JLTi_ShowSidePanel {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0%);
    }
}

@keyframes JLTi_ShowSidePanel_Right {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0%);
    }
}
