/* IHM Design System — demo site chrome.
 *
 * This stylesheet contains the layout / navigation / hero / etc. for the
 * demo site. It is NOT part of the design system itself — it ships only
 * to `dist/cdn-demo/assets/` and is consumed only by the demo HTML pages.
 *
 * Demo chrome uses its own `--demo-*` custom property namespace, separate
 * from the design system's tokens. This keeps the boundary clean and lets
 * a future restyle of the demo not touch the design system at all.
 *
 * Both light and dark themes are supported as of v1.1.0 (WA-1235). The
 * demo chrome tokens are defined under `:root` (light) and overridden
 * under `[data-theme='dark']` further down — kept in lock-step with the
 * design system's own `--ihm-color-*` overrides so the entire Pulse
 * page flips, not just the swatches.
 *
 * Loaded AFTER `ihm-base.css` so anywhere the demo shows actual design
 * system content (color swatches, type samples), the design system's
 * own typography / token values render normally.
 */

/* ─── Demo chrome tokens ────────────────────────────────────────────── */

:root {
    --demo-bg: #ffffff;
    --demo-surface: #f6f8f9;
    --demo-surface-2: #ffffff;
    --demo-border: #e6eaed;
    --demo-border-strong: #dadfe3;
    --demo-text: #27292d;
    --demo-text-muted: #717277;
    --demo-text-faint: #a9afb2;
    --demo-accent: #c6002b;
    --demo-accent-tint: #fdeaec;
    /* Code blocks stay a fixed charcoal in BOTH themes (white-on-dark, like a
       syntax highlighter) — must NOT be tied to --demo-text, which flips to
       near-white in dark mode and would render the white snippet text
       invisible. Not overridden under [data-theme='dark']. */
    --demo-code-bg: #27292d;
    --demo-mono: 'Roboto Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, 'Courier New', monospace;
}

/* Dark theme for the demo chrome itself. Layered on top of the design
 * system's [data-theme='dark'] block so the entire Pulse demo flips —
 * not just the swatches and design-system content. */
[data-theme='dark'] {
    --demo-bg: #191919;
    --demo-surface: #1f2125;
    --demo-surface-2: #2a2e33;
    --demo-border: #3f4447;
    --demo-border-strong: #4a4f54;
    --demo-text: #f7f7f7;
    --demo-text-muted: #c8cdd0;
    --demo-text-faint: #717277;
    --demo-accent: #f75761;
    --demo-accent-tint: #3a1f23;
}

/* ─── Reset / base ──────────────────────────────────────────────────── */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--demo-bg);
    color: var(--demo-text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

img,
svg {
    max-width: 100%;
    display: block;
}

/* ─── App grid (sidebar + content) ──────────────────────────────────── */

.demo-app {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

/* ─── Sidebar ───────────────────────────────────────────────────────── */

.demo-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid var(--demo-border);
    background: var(--demo-surface);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    overflow-y: auto;
}

.demo-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
    color: var(--demo-text);
}

.demo-brand .material-icons {
    color: var(--demo-accent);
    font-size: 28px;
}

.demo-brand-name {
    line-height: 1;
}

.demo-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.demo-nav-section {
    font-family: var(--demo-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--demo-text-muted);
    padding: 12px 12px 6px;
}

.demo-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--demo-text);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.12s ease;
}

.demo-nav-link:hover {
    background: var(--demo-border);
}

.demo-nav-link.is-active {
    background: var(--demo-accent-tint);
    color: var(--demo-accent);
    font-weight: 600;
}

.demo-nav-link .material-icons {
    font-size: 18px;
    color: inherit;
}

.demo-nav-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Category sub-nav under Components — always visible. The active category is
   highlighted by docs.js (initComponentSubnav): the component's category on a
   detail page, or the section scrolled into view on the catalog. */
.demo-nav-sub {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin: 2px 0 6px 22px;
    padding-left: 12px;
    border-left: 1px solid var(--demo-border);
}

.demo-nav-sublink {
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--demo-text-muted);
    font-size: 13px;
    transition:
        background 0.12s ease,
        color 0.12s ease;
}

.demo-nav-sublink:hover {
    background: var(--demo-border);
    color: var(--demo-text);
}

.demo-nav-sublink.is-active {
    background: var(--demo-accent-tint);
    color: var(--demo-accent);
    font-weight: 600;
}

.demo-sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--demo-border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.demo-sidebar-footer a {
    font-size: 12px;
    color: var(--demo-text-muted);
    padding: 4px 12px;
}

.demo-sidebar-footer a:hover {
    color: var(--demo-text);
}

/* ─── Version expander (brand row + inline panel) ───────────────────── */
/*
 * Build identity surfaced at the top of the sidebar. Powered by Alpine.js
 * + /cdn/design-system/v1/version.json.
 *
 * Layout: the chip lives inline with the Pulse logo (flush-right in the
 * brand flex row). Clicking it toggles an inline panel that occupies its
 * own row directly below the brand — values are user-selectable so the
 * commit hash can be copied easily for incident triage.
 *
 * Why inline instead of a floating tooltip: the sidebar is 260px wide
 * and a 280px tooltip overflowed the viewport on narrow screens. An
 * in-flow panel sidesteps positioning entirely and is more touch-friendly.
 */

[x-cloak] {
    display: none !important;
}

/* ─── External link indicator ───────────────────────────────────────── */
/*
 * Any anchor that opens a new tab (target="_blank") gets an inline ↗
 * suffix. Covers GitHub repo links, markdown-doc deep links (which point
 * at github.com/.../blob/master/docs/X.md), Jira tickets, etc. — no need
 * to remember to add the icon manually.
 */

a[target='_blank']::after {
    content: ' ↗';
    color: inherit;
    opacity: 0.7;
    font-weight: 400;
    text-decoration: none;
    display: inline;
    white-space: nowrap;
}

.demo-brand-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ─── Theme toggle (brand row) ──────────────────────────────────────── */
/*
 * Small icon button in the brand row that flips data-theme on <html>.
 * State is persisted to localStorage('pulse:theme') and applied by an
 * inline bootstrap script in <head> before stylesheets parse — no FOUC.
 */

.demo-theme-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--demo-border);
    border-radius: 4px;
    background: var(--demo-surface-2, #f5f5f7);
    color: var(--demo-text-muted);
    cursor: pointer;
    transition:
        border-color 120ms ease,
        color 120ms ease,
        background 120ms ease;
}

.demo-theme-toggle:hover,
.demo-theme-toggle:focus-visible {
    border-color: var(--demo-accent, #c6002b);
    color: var(--demo-text);
    outline: none;
}

.demo-theme-toggle:focus-visible {
    box-shadow: 0 0 0 2px var(--demo-accent-tint, #fdeaec);
}

.demo-theme-toggle .material-icons {
    font-size: 16px;
}

/* When .demo-theme-toggle is present, the chip's margin-left:auto is
 * overridden by the toggle's margin-left:auto. Reset chip to no margin
 * so the toggle + chip cluster sits flush-right. */
.demo-theme-toggle + .demo-version-tag {
    margin-left: 6px;
}

.demo-version-tag {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 4px 8px;
    border-radius: 4px;
    background: var(--demo-surface-2, #f5f5f7);
    border: 1px solid var(--demo-border);
    font-size: 10px;
    line-height: 1;
    color: var(--demo-text-muted);
    font-weight: 600;
    font-family: var(--demo-mono);
    letter-spacing: 0.06em;
    cursor: pointer;
    user-select: none;
    transition:
        border-color 120ms ease,
        color 120ms ease,
        background 120ms ease;
}

.demo-version-tag:hover,
.demo-version-tag[aria-expanded='true'] {
    border-color: var(--demo-accent, #c6002b);
    color: var(--demo-text);
}

/* Keyboard-only focus ring — meets WCAG 2.4.7 by providing a visible
 * 2px indicator independent of the border-color change above (which is
 * too subtle on its own for keyboard navigation). */
.demo-version-tag:focus-visible {
    border-color: var(--demo-accent, #c6002b);
    color: var(--demo-text);
    outline: none;
    box-shadow:
        0 0 0 2px var(--demo-accent-tint, #fdeaec),
        0 0 0 3px var(--demo-accent, #c6002b);
}

.demo-version-tag[aria-expanded='true'] {
    background: var(--demo-accent-tint, #fdeaec);
}

.demo-version-tag-dirty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    margin-left: 2px;
    border-radius: 50%;
    background: #b54708;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0;
}

.demo-version-chevron {
    font-size: 14px !important;
    color: inherit;
    transition: transform 160ms ease;
}

.demo-version-chevron.is-open {
    transform: rotate(180deg);
}

.demo-version-panel {
    border: 1px solid var(--demo-border);
    background: var(--demo-surface-2, #ffffff);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 11px;
    line-height: 1.45;
    color: var(--demo-text);
    user-select: text;
}

.demo-version-row {
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 8px;
    padding: 3px 0;
    align-items: baseline;
}

.demo-version-row + .demo-version-row {
    border-top: 1px dashed var(--demo-border);
}

.demo-version-row strong {
    color: var(--demo-text-muted);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--demo-mono);
}

.demo-version-row span,
.demo-version-row code {
    word-break: break-all;
    font-size: 11px;
}

.demo-version-row code {
    font-family: var(--demo-mono);
    color: var(--demo-text);
    user-select: all;
}

.demo-version-panel-dirty {
    margin-top: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    background: #fff7ed;
    color: #b54708;
    border: 1px solid #fed7aa;
    font-weight: 600;
    font-size: 10px;
}

/* ─── Content area ──────────────────────────────────────────────────── */

.demo-content {
    padding: 0 0 64px;
    background: var(--demo-bg);
}

.demo-page-header {
    padding: 48px 64px 24px;
    border-bottom: 1px solid var(--demo-border);
}

.demo-eyebrow {
    font-family: var(--demo-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--demo-text-muted);
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.demo-eyebrow::after {
    content: '';
    flex: 0 0 60px;
    height: 1px;
    background: var(--demo-border-strong);
}

.demo-page-title {
    margin: 0 0 12px;
    font-family: 'Open Sans', sans-serif;
    font-weight: 700;
    font-size: 40px;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--demo-text);
}

.demo-page-lede {
    margin: 0;
    max-width: 64ch;
    font-size: 16px;
    line-height: 1.55;
    color: var(--demo-text-muted);
}

/* ─── Section blocks within a page ──────────────────────────────────── */

.demo-section {
    padding: 48px 64px;
    border-bottom: 1px solid var(--demo-border);
}

.demo-section:last-child {
    border-bottom: none;
}

.demo-section-header {
    margin-bottom: 32px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.demo-section-title {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--demo-text);
}

.demo-section-lede {
    margin: 0;
    max-width: 60ch;
    font-size: 14px;
    line-height: 1.55;
    color: var(--demo-text-muted);
}

.demo-ki-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--demo-accent-tint);
    color: var(--demo-accent);
    font-family: var(--demo-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.demo-ki-tag:hover {
    background: var(--demo-accent);
    color: #fff;
}

/* ─── Hero (index.html only) ────────────────────────────────────────── */

.demo-hero {
    position: relative;
    margin: 32px 32px 0;
    border-radius: 24px;
    background: var(--demo-accent);
    color: #fff;
    overflow: hidden;
    isolation: isolate;
}

.demo-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.1) 60%),
        radial-gradient(80% 60% at 100% 0%, rgba(255, 255, 255, 0.16), transparent 60%);
    pointer-events: none;
}

.demo-hero::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 60%;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.18), transparent);
    pointer-events: none;
}

.demo-hero-inner {
    position: relative;
    padding: 56px 56px 48px;
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 56px;
    align-items: center;
    min-height: 360px;
}

.demo-hero-eyebrow {
    font-family: var(--demo-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.demo-hero-eyebrow::after {
    content: '';
    flex: 0 0 80px;
    height: 1px;
    background: rgba(255, 255, 255, 0.4);
}

.demo-hero h1 {
    margin: 0;
    font-family: 'Open Sans', sans-serif;
    font-weight: 800;
    font-size: clamp(56px, 7vw, 96px);
    line-height: 0.95;
    letter-spacing: -0.03em;
    color: #fff;
}

.demo-hero h1 .tint {
    color: rgba(255, 255, 255, 0.5);
}

.demo-hero-lede {
    margin: 28px 0 0;
    max-width: 50ch;
    font-size: 18px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.92);
}

.demo-hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 36px;
    flex-wrap: wrap;
}

.demo-hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.02em;
    transition:
        transform 0.08s ease,
        background 0.12s;
    cursor: pointer;
    border: 1px solid transparent;
}

.demo-hero-btn--primary {
    background: #fff;
    color: var(--demo-accent);
}

.demo-hero-btn--primary:hover {
    transform: translateY(-1px);
}

.demo-hero-btn--ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.demo-hero-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.1);
}

.demo-hero-side {
    display: grid;
    place-items: center;
}

.demo-hero-card {
    width: 100%;
    background: rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    padding: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.demo-hero-card-stat {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.demo-hero-card-stat:last-child {
    border-bottom: none;
}

.demo-hero-card-stat .label {
    font-family: var(--demo-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.75;
}

.demo-hero-card-stat .value {
    font-weight: 700;
    font-size: 18px;
}

/* ─── Section cards (used on index) ─────────────────────────────────── */

.demo-section-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 24px;
}

.demo-section-card {
    background: var(--demo-surface-2);
    border: 1px solid var(--demo-border);
    border-radius: 16px;
    padding: 28px;
    transition:
        border-color 0.15s,
        transform 0.15s;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.demo-section-card:hover {
    border-color: var(--demo-accent);
    transform: translateY(-2px);
}

.demo-section-card .material-icons {
    color: var(--demo-accent);
    font-size: 28px;
}

.demo-section-card h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.demo-section-card p {
    margin: 0;
    color: var(--demo-text-muted);
    font-size: 14px;
    line-height: 1.5;
}

/* ─── Swatches (color grids) ────────────────────────────────────────── */

.demo-swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.demo-swatch {
    border: 1px solid var(--demo-border);
    border-radius: 12px;
    background: var(--demo-surface-2);
    padding: 20px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.demo-swatch-chip {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.demo-swatch-name {
    font-family: var(--demo-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--demo-text);
    word-break: break-all;
}

.demo-swatch-legacy {
    font-family: var(--demo-mono);
    font-size: 10px;
    color: var(--demo-text-faint);
    word-break: break-all;
}

.demo-swatch-hex {
    font-family: var(--demo-mono);
    font-size: 11px;
    color: var(--demo-text-muted);
    text-transform: uppercase;
}

/* Dark-mode hex sub-row — shown only when a Figma dark value is documented.
 * Faded slightly compared to the light hex so the active value (driven by
 * the chip's CSS custom property + data-theme) reads as primary. */
.demo-swatch-hex-dark {
    font-family: var(--demo-mono);
    font-size: 10px;
    color: var(--demo-text-faint);
    text-transform: uppercase;
    margin-top: 2px;
}

.demo-swatch-desc {
    font-size: 11px;
    line-height: 1.4;
    color: var(--demo-text-muted);
}

/* ─── Typography ladder ─────────────────────────────────────────────── */

.demo-ladder {
    display: flex;
    flex-direction: column;
}

.demo-ladder-row {
    display: grid;
    grid-template-columns: 100px 1fr 200px;
    gap: 24px;
    padding: 20px 0;
    border-bottom: 1px solid var(--demo-border);
    align-items: baseline;
}

.demo-ladder-row:last-child {
    border-bottom: none;
}

.demo-ladder-token {
    font-family: var(--demo-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--demo-text);
}

.demo-ladder-sample {
    color: var(--demo-text);
}

.demo-ladder-meta {
    font-family: var(--demo-mono);
    font-size: 11px;
    color: var(--demo-text-muted);
    text-align: right;
    line-height: 1.6;
}

/* ─── Spacing tiles ─────────────────────────────────────────────────── */

.demo-spacing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.demo-spacing-tile {
    background: var(--demo-surface-2);
    border: 1px solid var(--demo-border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.demo-spacing-bar {
    background: var(--demo-accent);
    border-radius: 4px;
    height: 8px;
}

.demo-spacing-label {
    font-family: var(--demo-mono);
    font-size: 11px;
    font-weight: 600;
}

.demo-spacing-value {
    font-family: var(--demo-mono);
    font-size: 11px;
    color: var(--demo-text-muted);
}

/* ─── Radius tiles ──────────────────────────────────────────────────── */

.demo-radius-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.demo-radius-tile {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.demo-radius-box {
    width: 100%;
    aspect-ratio: 1.4;
    background: var(--demo-accent-tint);
    border: 1px solid var(--demo-accent);
}

.demo-radius-label {
    font-family: var(--demo-mono);
    font-size: 11px;
}

/* ─── Icons grid ────────────────────────────────────────────────────── */

.demo-icon-search {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: var(--demo-surface-2);
    color: var(--demo-text);
    margin-bottom: 32px;
}

.demo-icon-search:focus-visible {
    outline: none;
    border-color: var(--demo-accent);
    background: var(--demo-surface-2);
    box-shadow: 0 0 0 2px var(--demo-accent-tint, #fdeaec);
}

/* Visually-hidden but screen-reader-accessible labels.
 * Used by `<label for="icon-search">` in icons.html. */
.demo-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.demo-icon-category-title {
    font-family: var(--demo-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--demo-text-muted);
    margin: 24px 0 12px;
}

.demo-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}

.demo-icon-tile {
    background: var(--demo-surface-2);
    border: 1px solid var(--demo-border);
    border-radius: 8px;
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition:
        border-color 0.12s,
        background 0.12s;
}

.demo-icon-tile:hover {
    border-color: var(--demo-accent);
    background: var(--demo-accent-tint);
}

.demo-icon-tile .material-icons {
    font-size: 28px;
    color: var(--demo-text);
}

.demo-icon-tile-name {
    font-family: var(--demo-mono);
    font-size: 10px;
    color: var(--demo-text-muted);
    text-align: center;
    word-break: break-all;
}

.demo-icon-tile.is-copied {
    border-color: var(--demo-accent);
    background: var(--demo-accent);
}

.demo-icon-tile.is-copied .material-icons,
.demo-icon-tile.is-copied .demo-icon-tile-name {
    color: #fff;
}

.demo-icon-empty {
    padding: 32px;
    text-align: center;
    color: var(--demo-text-muted);
    font-size: 14px;
}

/* ─── Product SVG grid ──────────────────────────────────────────────── */

.demo-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.demo-product-tile {
    background: var(--demo-surface-2);
    border: 1px solid var(--demo-border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.demo-product-tile svg {
    width: 48px;
    height: 48px;
}

.demo-product-tile-name {
    font-weight: 600;
    font-size: 14px;
}

.demo-product-tile-token {
    font-family: var(--demo-mono);
    font-size: 10px;
    color: var(--demo-text-muted);
}

.demo-product-tile-hex {
    font-family: var(--demo-mono);
    font-size: 10px;
    color: var(--demo-text-muted);
}

.demo-product-tile.is-missing {
    opacity: 0.6;
    border-style: dashed;
}

/* ─── Phase 2 / placeholder banner ──────────────────────────────────── */

.demo-phase-banner {
    background: var(--demo-accent-tint);
    border: 1px solid var(--demo-accent);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
    font-size: 13px;
    color: var(--demo-text);
}

.demo-phase-banner .material-icons {
    color: var(--demo-accent);
    font-size: 20px;
}

.demo-phase-banner strong {
    color: var(--demo-accent);
}

/* ─── Code blocks ───────────────────────────────────────────────────── */

.demo-code {
    position: relative;
    background: var(--demo-code-bg);
    color: #fff;
    border: 1px solid var(--demo-border);
    border-radius: 10px;
    padding: 16px 18px;
    font-family: var(--demo-mono);
    font-size: 12px;
    line-height: 1.6;
    overflow-x: auto;
}

.demo-code pre {
    margin: 0;
    white-space: pre;
}

.demo-code-copy {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: var(--demo-mono);
    font-size: 10px;
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s;
}

.demo-code-copy:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.34);
}

.demo-code-copy.is-copied {
    background: var(--demo-accent);
    border-color: var(--demo-accent);
}

/* ─── Demo composition stages (playground) ──────────────────────────── */

.demo-stage {
    background: var(--demo-surface-2);
    border: 1px solid var(--demo-border);
    border-radius: 12px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.demo-stage-label {
    font-family: var(--demo-mono);
    font-size: 11px;
    color: var(--demo-text-muted);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.demo-stage-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* ─── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 900px) {
    .demo-app {
        grid-template-columns: 1fr;
    }
    .demo-sidebar {
        position: relative;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--demo-border);
    }
    .demo-page-header,
    .demo-section,
    .catalog-body {
        padding-left: 24px;
        padding-right: 24px;
    }
    .demo-hero {
        margin: 16px 16px 0;
    }
    .demo-hero-inner {
        grid-template-columns: 1fr;
        padding: 32px 24px;
    }
    .demo-hero-side {
        display: none;
    }
}

/* ─── "See it in action" cycler (components.html) ───────────────────── */
/*
 * The Alpine-powered button-state cycler on components.html. Lives in
 * the same .demo-stage grid as the static button previews, so it can
 * share visual rhythm with neighbors while announcing the JS hook.
 */

.demo-stage--action {
    background: linear-gradient(180deg, var(--demo-surface-2, #fff) 0%, var(--demo-surface, #f6f8f9) 100%);
    border: 1px solid var(--demo-border);
}

.demo-stage--action .demo-stage-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.demo-action-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px 4px 6px;
    border: 1px solid var(--demo-border);
    background: var(--demo-bg, #fff);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--demo-text-muted);
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    font-family: inherit;
    transition:
        border-color 120ms ease,
        color 120ms ease;
}

.demo-action-toggle .material-icons {
    font-size: 14px;
}

.demo-action-toggle:hover {
    border-color: var(--demo-accent, #c6002b);
    color: var(--demo-text);
}

.demo-action-toggle[aria-pressed='true'] {
    background: var(--demo-accent-tint, #fdeaec);
    border-color: var(--demo-accent, #c6002b);
    color: var(--demo-accent, #c6002b);
}

.demo-action-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 28px 16px 20px;
}

.demo-action-button {
    padding: 10px 20px;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    font-family: inherit;
    font-size: 14px;
    min-width: 120px;
    cursor: pointer;
    transition: background 220ms ease;
}

.demo-action-readout {
    font-size: 12px;
    color: var(--demo-text-muted);
    font-family: 'Open Sans', sans-serif;
}

.demo-action-readout strong {
    color: var(--demo-text);
    font-weight: 700;
    text-transform: capitalize;
}

.demo-action-pips {
    display: flex;
    gap: 6px;
}

.demo-action-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid var(--demo-border-strong);
    background: transparent;
    padding: 0;
    cursor: pointer;
    transition:
        background 120ms ease,
        border-color 120ms ease;
}

.demo-action-pip:hover {
    border-color: var(--demo-accent, #c6002b);
}

.demo-action-pip.is-current {
    background: var(--demo-accent, #c6002b);
    border-color: var(--demo-accent, #c6002b);
}

.demo-action-note {
    margin: 0;
    font-size: 12px;
    color: var(--demo-text-muted);
    line-height: 1.5;
    text-align: center;
    padding-top: 8px;
    border-top: 1px dashed var(--demo-border);
}

/* ─── Component demo pages (WA-1279) ─────────────────────────────────────
 *
 * Self-contained per-component showcase pages under cdn-demo/components/.
 * Reuses the demo chrome tokens so light/dark flips automatically.
 */

.demo-component {
    max-width: 880px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.demo-component-head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.demo-back {
    color: var(--demo-text-muted);
    text-decoration: none;
    font-size: 13px;
}

.demo-back:hover {
    color: var(--demo-accent);
}

/* States / variants grid */
.demo-states {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.demo-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 24px;
    background: var(--demo-surface);
    border: 1px solid var(--demo-border);
    border-radius: 10px;
    min-width: 120px;
}

.demo-state-label {
    font-family: var(--demo-mono);
    font-size: 11px;
    color: var(--demo-text-muted);
}

.demo-toggle {
    font-family: var(--demo-mono);
    font-size: 13px;
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid var(--demo-border-strong);
    background: var(--demo-surface-2);
    color: var(--demo-text);
    cursor: pointer;
}

.demo-toggle.is-on {
    background: var(--demo-accent);
    border-color: var(--demo-accent);
    color: #fff;
}

.demo-muted {
    color: var(--demo-text-muted);
    font-size: 13px;
}

/* ─── ⓘ Source-provenance widget ([data-ihm-source]) ─────────────────────
 *
 * Built once in docs.js, reused by every component demo. The info button
 * expands a popover listing the source git repo(s) a component was derived
 * from (docs/ComponentSourceMap.md).
 */

.ihm-source {
    position: relative;
    display: inline-block;
}

.ihm-source-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--demo-mono);
    font-size: 11px;
    line-height: 1;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--demo-border-strong);
    background: var(--demo-surface-2);
    color: var(--demo-text-muted);
    cursor: pointer;
}

.ihm-source-btn:hover,
.ihm-source-btn[aria-expanded='true'] {
    color: var(--demo-accent);
    border-color: var(--demo-accent);
}

.ihm-source-pop {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    left: 0;
    min-width: 260px;
    max-width: 360px;
    padding: 14px 16px;
    background: var(--demo-surface-2);
    border: 1px solid var(--demo-border);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

.ihm-source-pop[hidden] {
    display: none;
}

.ihm-source-title {
    margin: 0 0 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--demo-text-faint);
}

.ihm-source-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ihm-source-item {
    font-size: 13px;
    line-height: 1.4;
}

.ihm-source-item a {
    color: var(--demo-accent);
    text-decoration: none;
    font-weight: 600;
    word-break: break-word;
}

.ihm-source-item a:hover {
    text-decoration: underline;
}

.ihm-source-path {
    display: block;
    margin-top: 2px;
    font-family: var(--demo-mono);
    font-size: 11px;
    color: var(--demo-text-faint);
    word-break: break-all;
}

/* ─── Component catalog (gallery) ────────────────────────────────────────
 *
 * Rendered from components.json by docs.js (initComponentCatalog). Search
 * toolbar + category-grouped card grid.
 */

/* Inset the catalog content to match .demo-page-header / .demo-section
   (64px desktop, 24px mobile via the layout media query). Without this the
   catalog sits flush against the sidebar. */
.catalog-body {
    padding: 40px 64px 0;
}

.catalog-toolbar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 28px;
}

.catalog-search {
    flex: 1;
    max-width: 360px;
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid var(--demo-border-strong);
    background: var(--demo-surface-2);
    color: var(--demo-text);
}

.catalog-search:focus {
    outline: none;
    border-color: var(--demo-accent);
}

.catalog-count {
    font-family: var(--demo-mono);
    font-size: 12px;
    color: var(--demo-text-muted);
}

.catalog-group {
    margin-bottom: 44px;
}

.catalog-group-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--demo-border);
}

.catalog-group-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--demo-text);
}

.catalog-group-count {
    font-family: var(--demo-mono);
    font-size: 12px;
    color: var(--demo-text-faint);
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}

.catalog-card {
    display: flex;
    flex-direction: column;
    min-height: 122px;
    padding: 18px 20px;
    border-radius: 12px;
    border: 1px solid var(--demo-border);
    background: var(--demo-surface-2);
    text-decoration: none;
    color: inherit;
    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease,
        transform 0.12s ease;
}

a.catalog-card:hover {
    border-color: var(--demo-accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Planned components have no detail page yet — a dashed border reads as
   "coming soon" without washing the card out the way opacity did. */
.catalog-card.is-planned {
    border-style: dashed;
    background: var(--demo-surface);
}

.catalog-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.catalog-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--demo-text);
}

.catalog-card-summary {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--demo-text-muted);
    flex: 1;
}

.catalog-card-src {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.catalog-src {
    font-family: var(--demo-mono);
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--demo-surface);
    border: 1px solid var(--demo-border);
    color: var(--demo-text-muted);
}

.catalog-card.is-planned .catalog-src {
    background: var(--demo-surface-2);
}

.catalog-badge {
    font-family: var(--demo-mono);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--demo-surface);
    border: 1px solid var(--demo-border);
    color: var(--demo-text-muted);
}

.catalog-badge.is-available {
    background: var(--demo-accent-tint);
    border-color: var(--demo-accent);
    color: var(--demo-accent);
}

.catalog-footnote {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid var(--demo-border);
}

/* ─── Component detail: expandable sections + API table ───────────────── */

.demo-details {
    margin: 16px 0;
    border: 1px solid var(--demo-border);
    border-radius: 10px;
    background: var(--demo-surface-2);
}

.demo-details-summary {
    cursor: pointer;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 14px;
    color: var(--demo-text);
    list-style: none;
}

.demo-details-summary::-webkit-details-marker {
    display: none;
}

.demo-details-summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 10px;
    color: var(--demo-text-muted);
    transition: transform 0.12s;
}

.demo-details[open] .demo-details-summary::before {
    transform: rotate(90deg);
}

.demo-details-body {
    padding: 0 18px 18px;
}

.demo-api-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.demo-api-table th,
.demo-api-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--demo-border);
}

.demo-api-table th {
    color: var(--demo-text-muted);
    font-weight: 600;
}

/* ─── Deep links — bookmarkable sections & icons (WA-1279) ───────────────
 *
 * Anchorable headings show a "#" on hover and copy a shareable link on
 * click; the shared target flashes briefly via .is-linked. docs.js owns
 * the behavior; this is the chrome.
 */

.demo-anchorable {
    cursor: pointer;
    scroll-margin-top: 24px;
}

/* Bookmarkable items (color swatches, component cards, [data-deeplink]). */
.demo-deeplink {
    cursor: pointer;
}

/* Content-swap (not opacity) so the "#" takes no layout space at rest —
   keeps section headings from shifting and visual baselines stable. */
.demo-anchorable::after {
    content: '';
    color: var(--demo-text-faint);
}

.demo-anchorable:hover::after {
    content: ' #';
}

/* Flash a shared-link target so the recipient sees where they landed. */
.is-linked {
    animation: ihm-linkflash 1.4s ease;
    scroll-margin-top: 24px;
}

/* Two-pulse blink so a bookmarked section is unmistakable on arrival. */
@keyframes ihm-linkflash {
    0%,
    20% {
        background: var(--demo-accent-tint);
        border-radius: 6px;
    }
    40% {
        background: transparent;
    }
    60% {
        background: var(--demo-accent-tint);
    }
    100% {
        background: transparent;
        border-radius: 6px;
    }
}

/* Icon tiles have their own background — pulse an accent ring instead. */
/* Items with their own background (icon tiles, color swatches, component
   cards) pulse an accent ring rather than a background flash. */
.demo-icon-tile.is-linked,
.demo-swatch.is-linked,
.catalog-card.is-linked {
    animation: ihm-tileflash 1.4s ease;
    border-radius: 10px;
    scroll-margin-top: 80px;
}

@keyframes ihm-tileflash {
    0%,
    20% {
        box-shadow: 0 0 0 2px var(--demo-accent);
    }
    40% {
        box-shadow: 0 0 0 0 transparent;
    }
    60% {
        box-shadow: 0 0 0 2px var(--demo-accent);
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

.demo-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 10px 16px;
    background: var(--demo-code-bg);
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.15s ease,
        transform 0.15s ease;
    z-index: 200;
}

.demo-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Brand & Illustrations page ─────────────────────────────────────── */

/* Pending-UX wrapper — a caution-yellow outline that wraps the whole asset
   card, with the "Need UX Verification" label sitting above it, so the entire
   card reads as having an open issue. */
.demo-verify-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 2px solid var(--ihm-color-status-caution);
    border-radius: 12px;
}

/* The wrapped card stretches to fill the outline. */
.demo-verify-wrap > .demo-product-tile {
    flex: 1 1 auto;
}

/* "Need UX Verification" label — amber chip, dark text (≈12:1, theme-stable). */
.demo-verify-badge {
    align-self: flex-start;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--ihm-color-status-caution);
    color: var(--ihm-color-text-on-light);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Dark tile so white / reverse logos are visible in both themes. */
.demo-product-tile--dark {
    background: #27292d;
}

.demo-product-tile-file {
    font-family: var(--demo-mono);
    font-size: 11px;
    color: var(--demo-text-muted);
    word-break: break-all;
}
