/*----------------------------------------
IM Mail Form
----------------------------------------*/

/*----------------------------------------
Hidden Fields
----------------------------------------*/
.im-mail-form__honeypot[hidden] {
    display: none !important;
}

.im-mail-form__input[hidden] {
    display: none !important;
}

/*----------------------------------------
Form Controls
----------------------------------------*/
.im-mail-form__input,
.im-mail-form__textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 0.75rem;
    border: solid 1px #cccccc;
    border-radius: 4px;
    background-color: #ffffff;
    color: inherit;
    font: inherit;
}

.im-mail-form__textarea {
    min-height: 10rem;
    resize: vertical;
}

.im-mail-form__select {
    box-sizing: border-box;
    width: 100%;
    padding: 0.75rem;
    border: solid 1px #cccccc;
    border-radius: 4px;
    background-color: #ffffff;
    color: inherit;
    font: inherit;
}

.im-mail-form__input:focus,
.im-mail-form__textarea:focus,
.im-mail-form__select:focus {
    border-color: #2271b1;
    outline: 2px solid rgba(34, 113, 177, 0.2);
    outline-offset: 1px;
}

.im-mail-form__control {
    min-width: 0;
}

/*----------------------------------------
Radio Buttons and Checkboxes
----------------------------------------*/
.im-mail-form__choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.im-mail-form__choice {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

.im-mail-form__choice input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    flex: 0 0 auto;
}

/*----------------------------------------
File Upload
----------------------------------------*/
.im-mail-form__input[type="file"] {
    padding: 0.5rem;
    border: solid 1px #cccccc;
    background-color: #f8f8f8;
}

.im-mail-form__input[type="file"]::file-selector-button {
    margin: -0.5rem 0.75rem -0.5rem -0.5rem;
    padding: 0.75rem 1rem;
    border: 0;
    border-right: solid 1px #cccccc;
    background-color: #eeeeee;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.im-mail-form__input[type="file"]::file-selector-button:hover {
    background-color: #e2e2e2;
}

.im-mail-form__selected-file {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border: solid 1px #cccccc;
    border-radius: 4px;
    background-color: #f8f8f8;
}

.im-mail-form__selected-file span {
    min-width: 0;
    overflow-wrap: anywhere;
}

/*
* テーマ側（例：IM Baseの.imb-article button）のbuttonスタイルが
* 混入しないよう、フォームのルート要素.im-mail-formを含めて
* セレクタ詳細度を確保し、影響を受けやすいプロパティを明示指定する。
*/
.im-mail-form .im-mail-form__selected-file-remove {
    position: static;
    display: inline-block;
    flex: 0 0 auto;
    padding: 0.4rem 0.75rem;
    border: solid 1px #999999;
    border-radius: 4px;
    background-color: #ffffff;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.im-mail-form .im-mail-form__selected-file-remove:hover {
    background-color: #eeeeee;
}

.im-mail-form .im-mail-form__selected-file-remove:active {
    border-color: #999999;
}

/*----------------------------------------
Submit Button
----------------------------------------*/
.im-mail-form__actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.im-mail-form .im-mail-form__submit {
    position: static;
    display: inline-block;
    min-width: 12rem;
    padding: 0.8rem 2rem;
    border: solid 1px #333333;
    border-radius: 4px;
    background-color: #333333;
    color: #ffffff;
    font: inherit;
    font-weight: normal;
    cursor: pointer;
}

.im-mail-form .im-mail-form__submit:hover {
    background-color: #111111;
}

.im-mail-form .im-mail-form__submit:active {
    border-color: #333333;
}

/*----------------------------------------
Confirmation Screen
----------------------------------------*/
/*
* p要素へテーマ側（例：IM Baseの.imb-article p）のスタイルが
* 混入しないよう、確認画面のルート要素.im-mail-form-confirmを
* 含めてセレクタ詳細度を確保する。
*/
.im-mail-form-confirm .im-mail-form-confirm__message {
    margin: 0 0 1.5rem;
    padding: 1rem;
    border: solid 1px #d9d9d9;
    border-radius: 4px;
    background-color: #f8f8f8;
    line-height: 1.7;
}

/*
* dl/dt/ddへテーマ側（例：IM Baseの.imb-article dl/dt/dd）の
* スタイルが混入しないよう、確認画面のルート要素.im-mail-form-confirm
* を含めてセレクタ詳細度を確保し、影響を受けやすいプロパティは
* すべて明示的に指定する。
*/
.im-mail-form-confirm .im-mail-form-confirm__list {
    display: grid;
    grid-template-columns: minmax(8rem, 30%) minmax(0, 1fr);
    margin: 0;
    padding: 0;
    border: none;
    border-top: solid 1px #dddddd;
    background-color: transparent;
    box-sizing: border-box;
}

.im-mail-form-confirm .im-mail-form-confirm__label,
.im-mail-form-confirm .im-mail-form-confirm__value {
    position: static;
    margin: 0;
    padding: 1rem;
    border: none;
    border-bottom: solid 1px #dddddd;
    font-weight: normal;
    line-height: 1.7;
    box-sizing: border-box;
}

.im-mail-form-confirm .im-mail-form-confirm__label::before,
.im-mail-form-confirm .im-mail-form-confirm__label::after,
.im-mail-form-confirm .im-mail-form-confirm__value::before,
.im-mail-form-confirm .im-mail-form-confirm__value::after {
    content: none;
}

.im-mail-form-confirm .im-mail-form-confirm__label {
    background-color: #f8f8f8;
}

.im-mail-form-confirm .im-mail-form-confirm__value {
    background-color: transparent;
    overflow-wrap: anywhere;
}

.im-mail-form-confirm__empty {
    color: #777777;
    font-size: 0.875rem;
}

.im-mail-form-confirm__actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/*
* テーマ側（例：IM Baseの.imb-article button）のbuttonスタイルが
* 混入しないよう、確認画面のルート要素.im-mail-form-confirmを
* 含めてセレクタ詳細度を確保し、影響を受けやすいプロパティを明示指定する。
*/
.im-mail-form-confirm .im-mail-form-confirm__back,
.im-mail-form-confirm .im-mail-form-confirm__submit {
    position: static;
    display: inline-block;
    min-width: 10rem;
    padding: 0.8rem 2rem;
    border-radius: 4px;
    font: inherit;
    font-weight: normal;
    cursor: pointer;
}

.im-mail-form-confirm .im-mail-form-confirm__back {
    border: solid 1px #999999;
    background-color: #ffffff;
    color: inherit;
}

.im-mail-form-confirm .im-mail-form-confirm__back:hover {
    background-color: #eeeeee;
}

.im-mail-form-confirm .im-mail-form-confirm__back:active {
    border-color: #999999;
}

.im-mail-form-confirm .im-mail-form-confirm__submit {
    border: solid 1px #333333;
    background-color: #333333;
    color: #ffffff;
}

.im-mail-form-confirm .im-mail-form-confirm__submit:hover {
    background-color: #111111;
}

.im-mail-form-confirm .im-mail-form-confirm__submit:active {
    border-color: #333333;
}

/*----------------------------------------
Focus Styles
----------------------------------------*/
.im-mail-form__submit:focus-visible,
.im-mail-form__selected-file-remove:focus-visible,
.im-mail-form-confirm__back:focus-visible,
.im-mail-form-confirm__submit:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/*----------------------------------------
Completion Screen
----------------------------------------*/
.im-mail-form__success {
    padding: 1.5rem;
    border: solid 1px #d9d9d9;
    border-radius: 4px;
    background-color: #f8f8f8;
    line-height: 1.8;
}

.im-mail-form__success > :first-child {
    margin-top: 0;
}

.im-mail-form__success > :last-child {
    margin-bottom: 0;
}

/*----------------------------------------
Descriptions and Required Labels
----------------------------------------*/
/*
* p要素へテーマ側（例：IM Baseの.imb-article p）のスタイルが
* 混入しないよう、フォームのルート要素.im-mail-formを含めて
* セレクタ詳細度を確保する（詳細度で解決できるため!importantは不要）。
*/
.im-mail-form .im-mail-form__description {
    margin: 0.5rem 0 0;
    color: #5f7373;
    font-size: 0.75rem;
    line-height: 1.6;
}

.im-mail-form__required {
    margin-left: 0.35rem;
    color: #d63638;
    font-size: 0.875em;
    white-space: nowrap;
}

/*----------------------------------------
Error Messages
----------------------------------------*/
/*
* p要素へテーマ側（例：IM Baseの.imb-article p）のスタイルが
* 混入しないよう、フォームのルート要素.im-mail-formを含めて
* セレクタ詳細度を確保する。
*/
.im-mail-form .im-mail-form__error {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.5rem 0 0;
    color: #d63638;
    font-size: 0.875rem;
    line-height: inherit;
}

.im-mail-form__error::before {
    content: "";
    display: block;
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background-color: #d63638;
    background-image:
        linear-gradient(
            45deg,
            transparent 43%,
            #ffffff 43%,
            #ffffff 57%,
            transparent 57%
        ),
        linear-gradient(
            -45deg,
            transparent 43%,
            #ffffff 43%,
            #ffffff 57%,
            transparent 57%
        );
    background-position: center;
    background-size: 0.5rem 0.5rem;
    background-repeat: no-repeat;
}

.im-mail-form__error-summary,
.im-mail-form__mail-error {
    padding: 1rem;
    border: solid 1px #d63638;
    border-radius: 4px;
    background-color: #fff5f5;
    color: #d63638;
    line-height: 1.7;
}

/*
* テーマ側（例：IM Baseの.imb-article p）とセレクタ詳細度が
* 同点（class1 + 要素1）になり読み込み順に結果が左右されるため、
* フォームのルート要素.im-mail-formを含めて詳細度を確保する。
*/
.im-mail-form .im-mail-form__error-summary p,
.im-mail-form .im-mail-form__mail-error p {
    margin: 0;
    line-height: inherit;
}

.im-mail-form__field--error
.im-mail-form__input,
.im-mail-form__field--error
.im-mail-form__textarea,
.im-mail-form__field--error
.im-mail-form__select {
    border-color: #d63638;
    background-color: #fff5f5;
}

.im-mail-form__field--error
.im-mail-form__input[type="file"] {
    border: solid 1px #d63638;
}

.im-mail-form__field--error
.im-mail-form__choices {
    padding: 0.75rem;
    border: solid 1px #d63638;
    background-color: #fff5f5;
}

/*----------------------------------------
Mobile
----------------------------------------*/
@media screen and (max-width: 764px) {

    .im-mail-form-confirm .im-mail-form-confirm__list {
        grid-template-columns: 1fr;
    }

    .im-mail-form-confirm .im-mail-form-confirm__label {
        padding: 0.3rem 1rem;
        color: #555555;
        font-size: 0.875rem;
    }

    .im-mail-form-confirm .im-mail-form-confirm__value {
        padding: 0.75rem 1rem 1.25rem;
    }

    .im-mail-form-confirm__actions {
        flex-direction: column;
    }

    .im-mail-form__submit {
        width: 100%;
    }

    .im-mail-form-confirm__back,
    .im-mail-form-confirm__submit {
        width: 100%;
    }

    .im-mail-form__field {
        margin-bottom: 2.2rem;
    }

    .im-mail-form__html-block {
        margin-bottom: 2.2rem;
    }

    .im-mail-form__label {
        display: block;
        margin-bottom: 0.5rem;
        font-size: 1rem;
        font-weight: bold;
    }

    .im-mail-form__input,
    .im-mail-form__textarea,
    .im-mail-form__select {
        display: block;
    }

    .im-mail-form__choices {
        flex-direction: column;
        align-items: flex-start;
    }

    .im-mail-form__choice {
        box-sizing: border-box;
        width: 100%;
        padding: 0.75rem 1rem;
        border: solid 1px #dddddd;
        border-radius: 4px;
        background-color: #f8f8f8;
    }

    .im-mail-form__choice:hover {
        background-color: #eeeeee;
    }

    .im-mail-form__choice:has(input:checked) {
        border-color: #2271b1;
        background-color: #f0f7fc;
    }

    .im-mail-form .im-mail-form__description {
        margin: 0.5rem 0;
    }
}

/*----------------------------------------
Desktop
----------------------------------------*/
@media screen and (min-width: 765px) {

    .im-mail-form {
        display: grid;
        grid-template-columns: max-content minmax(0, 1fr);
        gap: 2rem;
    }

    .im-mail-form__field {
        display: grid;
        grid-template-columns: subgrid;
        grid-column: 1 / -1;
        align-items: center;
    }

    .im-mail-form__html-block {
        grid-column: 1 / -1;
    }

    .im-mail-form__label {
        grid-column: 1;
        font-size: 0.875rem;
    }

    .im-mail-form__control {
        grid-column: 2;
    }

    .im-mail-form__description {
        grid-column: 2;
    }

    .im-mail-form__error {
        grid-column: 2;
    }

    .im-mail-form__actions,
    .im-mail-form__error-summary,
    .im-mail-form__mail-error,
    .im-mail-form__success {
        grid-column: 1 / -1;
    }
}