/* Base styles built on the GroupUI design tokens, which each page loads from the CDN in its <head>.
   Dark mode is switched via [data-gui-mode="dark"] on <html> (see js/demo.js).
   :where() keeps the base styles at zero specificity so the page-specific rules below always win. */

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

body.demo-page {
    margin: 0;
    padding: clamp(1rem, 3vw, 2rem);
    background: var(--groupui-sys-color-background-base);
    color: var(--groupui-sys-color-text-normal);
    font-family: var(--groupui-sys-font-family-primary), system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
}

:where(.demo-page) :is(h2, h3, h4) {
    margin: 0 0 1rem;
    font-family: var(--groupui-sys-font-family-secondary), system-ui, sans-serif;
    line-height: 1.2;
}

:where(.demo-page) h2 {
    font-size: 1.75rem;
}

:where(.demo-page) h3 {
    font-size: 1.5rem;
}

:where(.demo-page) h4 {
    font-size: 1.25rem;
}

:where(.demo-page) p {
    margin: 0 0 1rem;
}

:where(.demo-page) hr {
    margin: 2rem 0;
    border: 0;
    border-top: 1px solid var(--groupui-sys-color-neutral-weak-default);
}

:where(.demo-page) a {
    color: var(--groupui-sys-color-link-primary-unvisited-default);
}

:where(.demo-page) a:hover {
    color: var(--groupui-sys-color-link-primary-unvisited-hover);
}

:where(.demo-page) img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

:where(.demo-page) :is(code, pre) {
    border-radius: var(--groupui-sys-border-radius-s);
    background: var(--groupui-sys-color-background-canvas);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875em;
}

:where(.demo-page) code {
    padding: 0.125em 0.375em;
}

:where(.demo-page) pre code {
    padding: 0;
    background: none;
}

:where(.demo-page) :is(input:not([type="checkbox"]), select) {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--groupui-sys-color-neutral-basic-default);
    border-radius: var(--groupui-sys-border-radius-s);
    background: var(--groupui-sys-color-background-base);
    color: var(--groupui-sys-color-text-normal);
    font: inherit;
}

/* Custom chevron so the dropdown arrow gets proper spacing to the right border. */
.demo-page select {
    appearance: none;
    padding-inline-end: 2.5rem;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--groupui-sys-color-text-normal) 50%),
        linear-gradient(135deg, var(--groupui-sys-color-text-normal) 50%, transparent 50%);
    background-position:
        calc(100% - 1.25rem) 50%,
        calc(100% - 0.9rem) 50%;
    background-size: 0.35rem 0.35rem;
    background-repeat: no-repeat;
}

:where(.demo-page) :is(button, input, select):focus-visible {
    outline: 2px solid var(--groupui-sys-color-text-normal);
    outline-offset: 2px;
}

.demo-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-block-end: 1.5rem;
}

.demo-theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.demo-theme-switch input[role="switch"] {
    margin: 0;
    accent-color: var(--groupui-sys-color-action-basic-default);
}

.demo-page > :first-child {
    margin-block-start: 0;
}

.demo-config-heading {
    margin-block-start: 2rem;
}

/* Buttons are secondary (muted) by default; only "Start stream" / "Stop stream" use .demo-primary. */
.demo-page button {
    margin: 0.25rem 0.25rem 0.75rem;
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: var(--groupui-sys-border-radius-s);
    background: var(--groupui-sys-color-action-muted-default);
    color: var(--groupui-sys-color-background-base);
    font: inherit;
    cursor: pointer;
}

.demo-page button:not(:disabled):hover {
    background: var(--groupui-sys-color-action-muted-hover);
}

.demo-page button:not(:disabled):active {
    background: var(--groupui-sys-color-action-muted-pressed);
}

.demo-page button.demo-primary {
    background: var(--groupui-sys-color-action-basic-default);
}

.demo-page button.demo-primary:not(:disabled):hover {
    background: var(--groupui-sys-color-action-basic-hover);
}

.demo-page button.demo-primary:not(:disabled):active {
    background: var(--groupui-sys-color-action-basic-pressed);
}

.demo-page button:disabled {
    background: var(--groupui-sys-color-action-basic-disabled);
    cursor: not-allowed;
}

.demo-page :is(input, select) {
    margin-block: 0.5rem 1rem;
}

.demo-input-group {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
    margin-block: 0.5rem 1rem;
}

.demo-input-group > :is(input, button) {
    margin: 0;
}

.demo-input-group > input {
    flex: 1;
    min-width: 0;
    width: auto;
}

.demo-input-group > button {
    flex-shrink: 0;
}

.demo-container {
    width: 75%;
    margin: 1.5rem auto;
}

@media (min-width: 1200px) {
    .demo-container {
        width: 90%;
    }
}

@media (max-width: 768px) {
    .demo-container {
        width: 100%;
    }
}
