/* Styles for the mega-form-listener demo pages. These run inside an iframe on
   /content/more-consistent-form-listeners/, so they carry their own copy of the
   site's colour tokens rather than pulling in the full stylesheet. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

    --c-text: #334155;
    --c-text-light: #64748b;
    --c-bg: #f8fafc;
    --c-surface: #ffffff;
    --c-primary: #4f46e5;
    --c-border: #cbd5e1;
    --c-input-bg: #ffffff;
    --c-button-bg: #ffffff;
    --c-button-text: #334155;
    --c-ok: #15803d;
    --c-ok-bg: #f0fdf4;
    --c-ok-border: #86efac;
    --c-warn: #b45309;
    --c-warn-bg: #fffbeb;
    --c-warn-border: #fcd34d;

    --radius-sm: 4px;
    --radius-md: 6px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --c-text: #e2e8f0;
        --c-text-light: #94a3b8;
        --c-bg: #0f172a;
        --c-surface: #1e293b;
        --c-primary: #818cf8;
        --c-border: #334155;
        --c-input-bg: #1e293b;
        --c-button-bg: #1e293b;
        --c-button-text: #f1f5f9;
        --c-ok: #4ade80;
        --c-ok-bg: #052e16;
        --c-ok-border: #166534;
        --c-warn: #fbbf24;
        --c-warn-bg: #292018;
        --c-warn-border: #78350f;
        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    }
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 1rem;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--c-text);
    background: var(--c-bg);
}

h2 {
    font-size: 1.05rem;
    margin: 0 0 0.5rem;
}

p {
    margin: 0 0 0.75rem;
}

code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    padding: 0.05rem 0.25rem;
    color: var(--c-primary);
}

.demo-intro {
    color: var(--c-text-light);
    margin-bottom: 1rem;
}

.demo-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
    align-items: start;
}

@media (min-width: 620px) {
    .demo-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.demo-panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 0.9rem;
}

.demo-panel+.demo-panel {
    margin-top: 1rem;
}

.demo-grid .demo-panel+.demo-panel {
    margin-top: 0;
}

label {
    display: block;
    font-weight: 500;
    margin: 0.6rem 0 0.15rem;
}

input[type='text'],
input[type='email'],
input[type='search'],
input[type='tel'],
input[type='password'],
select,
textarea {
    font: inherit;
    color: inherit;
    width: 100%;
    padding: 0.4rem 0.6rem;
    background: var(--c-input-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 30%, transparent);
}

.demo-check {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    font-weight: 400;
    margin-top: 0.7rem;
}

.demo-check input {
    margin-top: 0.3rem;
}

button,
a.demo-button {
    display: inline-block;
    font: inherit;
    font-weight: 500;
    margin: 0.7rem 0.4rem 0 0;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    text-decoration: none;
    color: var(--c-button-text);
    background: var(--c-button-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

button:hover,
a.demo-button:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
}

button:focus-visible,
a.demo-button:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

.demo-thanks {
    margin-top: 0.5rem;
    padding: 0.7rem 0.9rem;
    color: var(--c-ok);
    background: var(--c-ok-bg);
    border: 1px solid var(--c-ok-border);
    border-radius: var(--radius-md);
    font-weight: 500;
}

.demo-note {
    margin: 0.7rem 0 0;
    padding: 0.6rem 0.8rem;
    font-size: 0.9em;
    color: var(--c-warn);
    background: var(--c-warn-bg);
    border: 1px solid var(--c-warn-border);
    border-radius: var(--radius-md);
}

.demo-url {
    font-family: var(--font-mono);
    font-size: 0.85em;
    word-break: break-all;
    color: var(--c-text-light);
}

.demo-output {
    margin: 0;
    padding: 0.7rem;
    min-height: 3rem;
    max-height: 22rem;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.45;
    white-space: pre;
    color: var(--c-text);
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
}

.demo-output:empty::before {
    content: "Waiting for a form_submit event…";
    color: var(--c-text-light);
}

.demo-facts {
    margin: 0;
    font-size: 0.9em;
}

.demo-facts dt {
    color: var(--c-text-light);
    margin-top: 0.4rem;
}

.demo-facts dd {
    margin: 0;
    font-weight: 500;
}

[hidden] {
    display: none !important;
}
