:root {
    --color-bg-page: #f9fafb;
    --color-bg-section: #fff;
    --color-bg-code: #f3f4f6;
    --color-bg-button: #3b82f6;
    --color-bg-button-hover: #2563eb;
    --color-bg-button-secondary: #6b7280;
    --color-bg-button-secondary-hover: #4b5563;
    --color-text-primary: #111827;
    --color-text-button: #fff;
    --color-shadow: #0000001a;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    margin: 0;
    padding: 2rem;
    background: var(--color-bg-page);
}

.container {
    max-width: 40rem;
    margin: 0 auto;
}

.subtitle {
    margin: 0 0 2rem;
}

.section {
    background: var(--color-bg-section);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px 0 var(--color-shadow);
}

.section h2 {
        font-size: 1.25rem;
        font-weight: 600;
        margin: 0 0 1rem;
        color: var(--color-text-primary);
    }

.toasters {
    margin: 0 auto;
    flex-wrap: wrap;
    max-width: 30rem;
    display: flex;
    gap: 1rem;
}

.toasters button {
        min-height: 2.6rem;
        background: var(--color-bg-button);
        color: var(--color-text-button);
        border: none;
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
    }

:is(.toasters button):hover {
            background: var(--color-bg-button-hover);
        }

.secondary:is(.toasters button) {
            background: var(--color-bg-button-secondary);
        }

.secondary:is(.toasters button):hover {
                background: var(--color-bg-button-secondary-hover);
            }

.toast-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

code {
    background: var(--color-bg-code);
    padding: 0.125rem 0.375rem;
    font-family: 'Courier New', monospace;
}
/* Icon */
.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.toast-icon svg {
        width: 1.25rem;
        height: 1.25rem;
        display: block;
    }

substrate-toast {
    --toast-padding: 1rem;
    --toast-gap: 0.75rem;
    --toast-font-size: 1rem;
    --toast-line-height: 1.5;
    --toast-max-width: 24rem;
    --toast-border: #0003;

    /* Variant colors - can be customized */
    /* primary */
    --toast-primary-bg: #fff;
    --toast-primary-border: #3b82f6;
    --toast-primary-text: #1e40af;
    --toast-primary-icon: #3b82f6;
    /* success */
    --toast-success-bg: #fdfefd;
    --toast-success-border: #10b981;
    --toast-success-text: #065f46;
    --toast-success-icon: #10b981;
    /* neutral */
    --toast-neutral-bg: #f9fafb;
    --toast-neutral-border: #6b7280;
    --toast-neutral-text: #374151;
    --toast-neutral-icon: #6b7280;
    /* warning */
    --toast-warning-bg: #fbfaf6;
    --toast-warning-border: #f59e0b;
    --toast-warning-text: #92400e;
    --toast-warning-icon: #f59e0b;
    /* danger */
    --toast-danger-bg: #fff;
    --toast-danger-border: #ef4444;
    --toast-danger-text: #991b1b;
    --toast-danger-icon: #ef4444;

    /* Position toasts in top-right */
    position: fixed;
    top: 1rem;
    inset-inline-end: 1rem;
    z-index: 1000;

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    /* animation */
    transition: opacity 0.3s ease, visibility 0s ease 0.3s;


    /**
     * Don't show until JavaScript is ready
     */
}

substrate-toast:not(:defined) {
        visibility: hidden;
    }

substrate-toast.toast-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transition: opacity 0.3s ease, visibility 0s ease 0s;
    }

substrate-toast.toast-visible .toast {
            transform: scale(1);
        }

substrate-toast .toast {
        min-width: 30rem;
        display: flex;
        align-items: center;
        gap: var(--toast-gap);
        padding: var(--toast-padding);
        font-size: var(--toast-font-size);
        line-height: var(--toast-line-height);
        max-width: var(--toast-max-width);
        border: 1px solid #0003;
        border-left: 4px solid transparent;
        box-shadow: 0 4px 6px -1px rgb(0 0 0 / 10%), 0 2px 4px -1px rgb(0 0 0 / 6%);

        /* Animation */
        transform: scale(0.8);
        transform-origin: center;
        transition: transform 0.3s ease;
        will-change: transform;
    }

.toast-success:is(substrate-toast .toast) {
            background-color: var(--toast-success-bg);
            border-left: 4px solid var(--toast-success-border);
        }

.toast-success:is(substrate-toast .toast) .toast-icon {
                color: var(--toast-success-icon);
            }

/* Variant styles */

.toast-primary:is(substrate-toast .toast) {
            background-color: var(--toast-primary-bg);
            border-left: 4px solid var(--toast-primary-border);
        }

.toast-primary:is(substrate-toast .toast) .toast-icon {
                color: var(--toast-primary-icon);
            }

.toast-neutral:is(substrate-toast .toast) {
            background-color: var(--toast-neutral-bg);
            border-left: 4px solid var(--toast-neutral-border);
        }

.toast-neutral:is(substrate-toast .toast) .toast-icon {
                color: var(--toast-neutral-icon);
            }

.toast-warning:is(substrate-toast .toast) {
            background-color: var(--toast-warning-bg);
            border-left: 4px solid var(--toast-warning-border);
        }

.toast-warning:is(substrate-toast .toast) .toast-icon {
                color: var(--toast-warning-icon);
            }

.toast-danger:is(substrate-toast .toast) {
            background-color: var(--toast-danger-bg);
            border-left: 4px solid var(--toast-danger-border);
        }

.toast-danger:is(substrate-toast .toast) .toast-icon {
                color: var(--toast-danger-icon);
            }

/* Close button wrapper */

:is(substrate-toast .toast) .toast-close-wrapper {
            flex-shrink: 0;
            position: relative;
            display: flex;
            align-items: center;
            justify-content: center;
        }

/* Progress ring SVG - positioned absolutely to overlay button */

:is(substrate-toast .toast) .toast-progress-svg {
            position: absolute;
            width: 2rem;
            height: 2rem;
            pointer-events: none;
            top: 0;
            left: 0;
        }

/* Progress ring styles */

:is(substrate-toast .toast) .toast-progress-bg {
            stroke-width: 1.5;
            opacity: 0.2;
            fill: none;
        }

:is(substrate-toast .toast) .toast-progress-circle {
            stroke: #3b82f6;
            stroke-width: 2;
            fill: none;
            transform: rotate(-90deg);
            transform-origin: center;
            stroke-dasharray: 62.8319;  /* 2 * PI * 10 (radius) */
            stroke-dashoffset: 0;
            transition: stroke-dashoffset 0.1s linear;
        }

/* Close button */

:is(substrate-toast .toast) button.toast-close {
            transition: all 0.3s;
            flex-shrink: 0;
            background: none;
            border: none;
            padding: 0;
            cursor: pointer;
            color: inherit;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0.6;
            position: relative;
            z-index: 1;
        }

:is(:is(substrate-toast .toast) button.toast-close):hover {
                opacity: 1;
            }

:is(:is(substrate-toast .toast) button.toast-close):active {
                transform: scale(0.7);
            }

:is(:is(substrate-toast .toast) button.toast-close) svg {
                width: 2rem;
                height: 2rem;
                display: block;
                padding: 4px;
            }


/* Content */
.toast-content {
    flex: 1;
    min-width: 0;
}
.toast-content p {
        margin: 0;
    }
.toast-content p + p {
        margin-top: 0.5rem;
    }
