/* Design system reference page. Page-scoped: every rule is prefixed sg-. */

[data-theme] .sg-page {
    max-width: 72rem;
}

/* Header and live theme readout */

[data-theme] .sg-header {
    position: sticky;
    top: 3.25rem;
    z-index: 5;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    margin-bottom: 1.5rem;
}

[data-theme] .sg-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1.25rem;
}

[data-theme] .sg-theme-readout {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface-alt);
    font-family: monospace;
    font-size: var(--text-sm);
    font-weight: 700;
}

[data-theme] .sg-audit {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

[data-theme] .sg-audit.is-flagged {
    color: var(--danger);
    font-weight: 700;
}

/* Contents */

[data-theme] .sg-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 2rem;
}

[data-theme] .sg-toc a {
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    text-decoration: none;
}

[data-theme] .sg-toc a:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Sections */

[data-theme] .sg-section {
    margin-bottom: 3rem;
    scroll-margin-top: 8rem;
}

[data-theme] .sg-section-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 0.35rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0.35rem;
}

[data-theme] .sg-section-note {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

[data-theme] .sg-group {
    margin-bottom: 1.75rem;
    scroll-margin-top: 8rem;
}

[data-theme] .sg-tone-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

[data-theme] .sg-group-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

/* Token swatches */

[data-theme] .sg-swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
    gap: 0.6rem;
}

[data-theme] .sg-swatch {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface);
}

/* The chip is a checkerboard; the fill sits on top of it. Where a token is
   undeclared or transparent the checkerboard shows through, which makes a gap
   obvious at a glance. The fill is also what the page probes with
   getComputedStyle to report the resolved value. */
[data-theme] .sg-swatch-chip {
    height: 3rem;
    background-image:
        linear-gradient(45deg, var(--border) 25%, transparent 25%),
        linear-gradient(-45deg, var(--border) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--border) 75%),
        linear-gradient(-45deg, transparent 75%, var(--border) 75%);
    background-size: 12px 12px;
    background-position: 0 0, 0 6px, 6px -6px, -6px 0;
    border-bottom: 1px solid var(--border);
}

[data-theme] .sg-swatch-fill {
    display: block;
    height: 100%;
    background-color: var(--sg-token);
}

[data-theme] .sg-swatch-shadow {
    height: 3rem;
    margin: 0.75rem;
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--sg-token);
}

[data-theme] .sg-swatch-meta {
    padding: 0.4rem 0.5rem 0.5rem;
}

[data-theme] .sg-swatch-name {
    display: block;
    font-family: monospace;
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-all;
}

[data-theme] .sg-swatch-value {
    display: block;
    font-family: monospace;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    word-break: break-all;
}

[data-theme] .sg-swatch.is-undeclared {
    border-color: var(--danger);
}

[data-theme] .sg-swatch.is-undeclared .sg-swatch-value {
    color: var(--danger);
    font-weight: 700;
}

/* Specimen rows */

[data-theme] .sg-specimen {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    margin-bottom: 0.6rem;
}

[data-theme] .sg-specimen.is-stacked {
    display: block;
}

[data-theme] .sg-specimen-label {
    flex: 0 0 100%;
    font-family: monospace;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

/* Scale exhibits */

[data-theme] .sg-scale-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
    gap: 0.6rem;
}

[data-theme] .sg-radius-sample {
    height: 3.5rem;
    border: 1px solid var(--primary);
    background: var(--primary-light);
    border-radius: var(--sg-radius);
    margin-bottom: 0.3rem;
}

[data-theme] .sg-scale-name {
    font-family: monospace;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

[data-theme] .sg-type-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid var(--border);
}

[data-theme] .sg-type-row:last-child {
    border-bottom: none;
}

[data-theme] .sg-type-key {
    flex: 0 0 7rem;
    font-family: monospace;
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

[data-theme] .sg-type-sample {
    font-size: var(--sg-size);
}

/* Timeline exhibit needs a sized bar to render into */

[data-theme] .sg-timeline-demo {
    width: 100%;
    max-width: 34rem;
}

/* Timeline exhibit block positions. Production positions these inline from the
   model; fixed demo positions keep this page free of inline geometry. */

[data-theme] .sg-tl-a { left: 2%; width: 20%; }
[data-theme] .sg-tl-b { left: 25%; width: 18%; }
[data-theme] .sg-tl-c { left: 46%; width: 17%; }
[data-theme] .sg-tl-d { left: 67%; width: 27%; }
[data-theme] .sg-tl-now { left: 56%; }

[data-theme] .sg-space-sample {
    display: inline-block;
    height: 1rem;
    width: var(--sg-space);
    background: var(--primary);
    border-radius: var(--radius-sm);
}

[data-theme] .sg-motion-sample {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-alt);
    font-family: monospace;
    font-size: var(--text-xs);
    transition: background-color var(--sg-duration) var(--ease-standard), color var(--sg-duration) var(--ease-standard);
}

[data-theme] .sg-motion-sample:hover {
    background: var(--primary);
    color: var(--button-primary-text);
}

[data-theme] .sg-toc-label {
    align-self: center;
    margin-right: 0.15rem;
    font-size: var(--text-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
}
