@import "../variables/variables";
@import "../mixins/private/token-mixins";

.page-notice {
    @include background-color-token(
        page-notice-general-background-color,
        color-background-inverse
    );
    @include border-color-token(
        page-notice-general-border-color,
        color-background-inverse
    );

    border-style: solid;
    border-width: 1px;
    font-size: var(--font-size-default);
    margin: var(--spacing-100) 0;
    padding: var(--spacing-200);
    @include color-token(page-notice-color, color-foreground-on-inverse);
}

div[role="region"].page-notice,
section.page-notice {
    display: grid;
    /* provide explicit structure up front, create loose markup model */
    grid-template-columns: 32px auto auto auto;
}

span[role="region"].page-notice {
    display: grid;
}

.page-notice__title {
    font-size: var(--font-size-default);
    font-weight: normal;
    margin: 1px 0 0;
}

/* legacy version with separate bold heading */
.page-notice__title:not(:only-child) {
    font-weight: bold;
}

.page-notice a {
    @include color-token(page-notice-color, color-foreground-on-inverse);

    font-size: var(--font-size-default);
    font-weight: bold;
}

/* force links with text having more than one word to remain on same line */
.page-notice__cta a {
    white-space: nowrap;
}

.page-notice__dismiss {
    cursor: pointer;
}

.page-notice a:hover {
    @include color-token(page-notice-color, color-foreground-on-inverse);
}

.page-notice button.fake-link {
    @include color-token(page-notice-color, color-foreground-on-inverse);

    font-size: var(--font-size-default);
    font-weight: bold;
}

.page-notice button.fake-link:hover {
    @include color-token(page-notice-color, color-foreground-on-inverse);
}

/* Override default outline color to avoid contrast issues */
/* with the darker background colors in page notices */
/* For explicit focus only: the `focus-visible` instead of `focus` */
/* is to exclude the styling on clicks (implied focus). */
.page-notice a:focus-visible,
.page-notice button.fake-link:focus-visible {
    outline: 2px solid var(--color-foreground-on-inverse);
    outline-offset: 2px;
}

.page-notice--attention {
    @include background-color-token(
        page-notice-attention-background-color,
        color-background-attention
    );
    @include border-color-token(
        page-notice-attention-border-color,
        color-stroke-attention
    );

    .page-notice__header svg {
        @include color-token(
            page-notice-attention-icon-color,
            color-foreground-on-attention
        );
    }
}

.page-notice--confirmation {
    @include background-color-token(
        page-notice-confirmation-background-color,
        color-background-confirmation
    );
    @include border-color-token(
        page-notice-confirmation-border-color,
        color-stroke-confirmation
    );

    .page-notice__header svg {
        @include color-token(
            page-notice-confirmation-icon-color,
            color-foreground-on-confirmation
        );
    }
}

.page-notice--information {
    @include background-color-token(
        page-notice-information-background-color,
        color-background-information
    );
    @include border-color-token(
        page-notice-information-border-color,
        color-stroke-information
    );

    .page-notice__header svg {
        @include color-token(
            page-notice-information-icon-color,
            color-foreground-on-information
        );
    }
}

.page-notice--general {
    @include background-color-token(
        page-notice-general-background-color,
        color-background-inverse
    );
}

.page-notice__header {
    grid-column: 1;
    grid-row: 1;
    margin-inline-end: var(--spacing-200);
}

.page-notice__main {
    grid-column: 1 / 3;
    grid-row: 1;
    margin-inline-end: var(--spacing-200);
}

.page-notice__header + .page-notice__main {
    grid-column: 2;
}

.page-notice__footer {
    grid-column: 4;
    grid-row: 1;
    text-align: right;
}

.page-notice__main p {
    font-size: var(--font-size-default);
    margin: 2px 0 0;
}

/* support legacy 6.5 notice with heading + paragaphs */
.page-notice__main .page-notice__title ~ p {
    margin: var(--spacing-50) 0 0;
}

p.page-notice__cta {
    grid-column: 2;
    grid-row: 2;
    justify-self: flex-start;
    margin-bottom: 0;
    margin-right: var(--spacing-200);
    margin-top: var(--spacing-200);
}

@media (min-width: $_screen-size-SM) {
    section.page-notice,
    div[role="region"].page-notice {
        margin: var(--spacing-200) 0;
    }

    .page-notice__title {
        margin-bottom: 2px;
    }

    p.page-notice__cta {
        grid-column: 4;
        grid-row: 1;
        justify-self: flex-end;
        margin-top: 1px;
        padding-right: var(--spacing-200);
    }

    .page-notice__footer {
        justify-self: flex-end;
        margin-top: 0;
    }
}

[dir="rtl"] {
    .page-notice__footer {
        margin-left: initial;
        margin-right: auto;
        padding-left: initial;
        padding-right: 16px;
    }
}
