/* The demo on the home page: the tab buttons, the window and the eight panels in it. Layout is Relayout's classes in the
   markup; what is here is what they don't cover: the look of the boxes, fields, steps and results. On top of
   relayout.css, pages-base.css and brand.css, in the page's own tokens. */

/* ── Status colours ──
   Text for "it worked" and "it failed". The site has a green (--success) only as a graphic, so these two are the
   demo's own, measured 2026-11-17 in 8-bit sRGB on every surface they sit on (bg-elev, bg-alt, bg and bg-sunken) and on
   the 10% and 16% tints of themselves that the result banners and the done marks sit on:

       --demo-ok     light #15693b 5.29 to 6.74, dark #5fcf8f 5.60 to 10.20
       --demo-error  light #a82018 5.51 to 7.28, dark #ff8f85 5.10 to 8.98

   --demo-field is the fill of an input: the page's own colour on the white boxes in light, the darkest one in dark. */
.demo {
    --demo-ok: #15693b;
    --demo-error: #a82018;
    --demo-field: var(--bg);
}

[data-theme="dark"] .demo {
    --demo-ok: #5fcf8f;
    --demo-error: #ff8f85;
    --demo-field: var(--bg-sunken);
}

/* The class and the attribute both hide: a rule that sets `display` is stronger than the attribute alone */
.demo [hidden] {
    display: none !important;
}

/* ── The tab buttons ──
   Above the window, as the other product sites' demos have their presets. The chosen tab is in the brand's tone, as the
   Documentation button is at rest. */
.demo-tabs .btn[aria-selected="true"] {
    border-color: color-mix(in oklab, var(--brand) 50%, var(--border));
    color: var(--brand-text);
}

/* ── The window ──
   A title bar with window dots, the tab as a file name and a badge, over the panels. The code window's border, corners
   and shadow. */
.demo-window {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-alt);
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.1), 0 8px 16px -4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .demo-window {
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6), 0 8px 16px -4px rgba(0, 0, 0, 0.3);
}

/* Decoration, in the colours windows use for them */
.demo-window .code-dot:nth-child(1) {
    background: #ff5f57;
}

.demo-window .code-dot:nth-child(2) {
    background: #febc2e;
}

.demo-window .code-dot:nth-child(3) {
    background: #28c840;
}

.demo-window .badge {
    padding: 1px 8px;
    font-size: 0.75rem;
}

/* The body keeps a height, so the page doesn't jump when the first tab is replaced by another. A tab that needs more
   makes it taller. */
.demo-window-body {
    box-sizing: border-box;
    min-height: 26rem;
}

.demo-notice {
    margin: 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--demo-error);
    border-radius: 8px;
    background: color-mix(in oklab, var(--demo-error) 10%, var(--bg-elev));
    color: var(--text);
    font-size: 0.9375rem;
}

/* The line under the tab's title */
.demo-intro {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.9375rem;
    line-height: 1.6;
}

/* ── Boxes, steps and their parts ── */
.demo-box,
.demo-step {
    box-sizing: border-box;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-elev);
}

/* A step that isn't open yet: no fill and a dashed edge, in place of fading it, which would lower its text's contrast */
.demo-step[inert] {
    border-style: dashed;
    background: transparent;
}

.demo-step[inert] .demo-step-title {
    color: var(--text-muted);
}

.demo-step[inert] :is(input, textarea) {
    background: transparent;
}

.demo-box-title,
.demo-step-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* The box's title is the section label of the page, small and in mono, as the page's own */
.demo-box-title {
    color: var(--text-muted);
    font-family: var(--rl-font-mono);
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.demo-step-num {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-muted);
    font-family: var(--rl-font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
}

.demo-step-num.is-done {
    border-color: var(--demo-ok);
    background: color-mix(in oklab, var(--demo-ok) 16%, var(--bg-elev));
    color: var(--demo-ok);
}

.demo-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.6;
}

/* Between two steps: what the next one does, on a line from the one above */
.demo-connector {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

.demo-connector::before {
    content: "";
    display: block;
    width: 1px;
    height: 1rem;
    margin: 0 auto 0.375rem;
    background: var(--border);
}

.demo hr {
    width: 100%;
    margin: 0;
    border: 0;
    border-top: 1px solid var(--border);
}

/* ── Fields ── */
.demo label,
.demo-label {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}

.demo :is(input:not([type="file"]), textarea) {
    box-sizing: border-box;
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--demo-field);
    color: var(--text);
    font: inherit;
    font-size: 0.9375rem;
}

.demo textarea {
    min-height: 5.5rem;
    resize: vertical;
}

.demo ::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* A box of ciphertext, keys or JSON: one piece of text in mono, broken anywhere, since it has no words to break at */
.demo .demo-mono {
    font-family: var(--rl-font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.demo :is(input, textarea):disabled {
    cursor: not-allowed;
}

.demo .btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* A disabled button is not a target: its hover would fill it as an active one */
.demo .btn:disabled:hover {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
    opacity: 0.5;
}

.demo .btn-brand:disabled:hover {
    border-color: color-mix(in oklab, var(--brand) 50%, var(--border));
    color: var(--brand-text);
}

.demo .btn-danger {
    border-color: color-mix(in oklab, var(--demo-error) 50%, var(--border));
    color: var(--demo-error);
}

@media (hover: hover) {
    .demo .btn-danger:not(:disabled):hover {
        background: var(--demo-error);
        border-color: var(--demo-error);
        color: var(--bg-elev);
    }
}

/* The line under a button: what happened. Always in the page, for a screen reader to find before it speaks. */
.status {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.4;
}

.status.ok {
    color: var(--demo-ok);
}

.status.error {
    color: var(--demo-error);
}

/* ── Files ── */
.demo-drop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 1.5rem 1rem;
    border: 1.5px dashed var(--border);
    border-radius: 8px;
    background: var(--demo-field);
    color: var(--text);
    cursor: pointer;
    text-align: center;
}

.demo-drop:hover,
.demo-drop.is-dragging {
    border-color: var(--brand);
}

.demo-drop:focus-within {
    outline: 2px solid var(--brand-text);
    outline-offset: 2px;
}

/* The file input is there for the keyboard and the picker: the label round it is what is seen and clicked */
.demo-drop input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

.demo-drop-hint {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.demo-file-info {
    font-family: var(--rl-font-mono);
    font-size: 0.8125rem;
}

.demo-file-size {
    color: var(--text-muted);
}

.demo-progress {
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--border);
}

.demo-progress-fill {
    width: 0;
    height: 100%;
    background: var(--brand);
    transition: width 0.2s;
}

/* ── Readouts: key thumbnails, the packet Bob receives, a signature ── */
.demo-readout {
    margin: 0;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--demo-field);
    font-family: var(--rl-font-mono);
    font-size: 0.8125rem;
}

.demo-readout-row {
    display: grid;
    grid-template-columns: 7.5rem minmax(0, 1fr);
    gap: 0.75rem;
    align-items: baseline;
    padding-block: 0.1875rem;
}

.demo-readout dt {
    color: var(--text-muted);
}

.demo-readout dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 30rem) {
    .demo-readout-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }
}

/* ── Results of a signature check ── */
.demo-verdict {
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.demo-verdict[data-state="valid"] {
    border-color: var(--demo-ok);
    background: color-mix(in oklab, var(--demo-ok) 10%, var(--bg-elev));
}

.demo-verdict[data-state="invalid"] {
    border-color: var(--demo-error);
    background: color-mix(in oklab, var(--demo-error) 10%, var(--bg-elev));
}

.demo-verdict-icon {
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.35;
}

.demo-verdict-headline {
    font-weight: 600;
}

.demo-verdict[data-state="valid"] :is(.demo-verdict-icon, .demo-verdict-headline) {
    color: var(--demo-ok);
}

.demo-verdict[data-state="invalid"] :is(.demo-verdict-icon, .demo-verdict-headline) {
    color: var(--demo-error);
}

.demo-verdict-detail {
    font-size: 0.875rem;
}

.demo-verdict-detail:empty {
    display: none;
}

/* ── P2P ──
   Alice and Bob side by side, with an arrow between them: what Alice sends goes to Bob. Under 56rem they stack, and the
   arrow points down. */
.demo-p2p {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
}

.demo-arrow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.125rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
    text-align: center;
}

.demo-arrow-mark {
    font-size: 1.5rem;
    line-height: 1;
    transform: rotate(90deg);
}

@media (min-width: 56rem) {
    .demo-p2p {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .demo-arrow-mark {
        transform: none;
    }
}

/* ── JWK ── */
.demo-fields {
    margin: 0;
}

.demo-field-row {
    display: grid;
    grid-template-columns: 9rem minmax(0, 1fr);
    gap: 0.75rem;
    padding-block: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.demo-field-row dt {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.demo-field-row dd {
    margin: 0;
    font-family: var(--rl-font-mono);
    font-size: 0.8125rem;
    overflow-wrap: anywhere;
}

@media (max-width: 30rem) {
    .demo-field-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.125rem;
    }
}

.demo-fingerprint {
    margin: 0;
    font-family: var(--rl-font-mono);
    font-size: 0.9375rem;
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
}
