/**
 * ColorRail: accent color picker + demo page styles.
 * (c) unparzd.com — https://unparzd.com
 * Licensed under the ColorRail License Agreement (see LICENSE_EN.txt / LICENSE_DE.txt).
 * You may remove or modify this notice for your own projects per the license terms.
 */

:root {
    --accent: #e1ff00;
    --theme-transition: 0.85s ease;
    --bg: #0d1117;
    --surface: #161b22;
    --text: #e6edf3;
    --muted: #8b949e;
    --font-mono: 'Courier New', Courier, monospace;
}

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

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

body.cr-color-changing *,
body.cr-color-changing *::before,
body.cr-color-changing *::after {
    transition: color var(--theme-transition),
                background-color var(--theme-transition),
                border-color var(--theme-transition),
                stroke var(--theme-transition),
                fill var(--theme-transition),
                box-shadow var(--theme-transition),
                filter var(--theme-transition),
                outline-color var(--theme-transition) !important;
}

/* ── Required for integrators: keep the block above + :root --theme-transition in your CSS.
   ColorRail.js adds body.cr-color-changing for ~0.9s on every color pick: that creates the smooth seam morph. ── */

/* ── Demo page ── */

.cr-page {
    max-width: 920px;
    margin: 0 auto;
    padding: 2rem 1.5rem 5rem;
}

.cr-page-header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.5rem 2rem;
    align-items: start;
    margin-bottom: 2rem;
}

.cr-page-header-copy {
    min-width: 0;
}

.cr-page-header-rail {
    flex-shrink: 0;
    padding-top: 0.15rem;
}

.cr-rail-label {
    margin: 0 0 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: bold;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
}

.cr-rail-shell {
    padding: 22px 20px 18px;
    background: linear-gradient(165deg, rgba(22, 27, 34, 0.96), rgba(10, 14, 20, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 22px;
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.cr-rail-shell:has(.cr-quantum-wrapper:hover),
.cr-rail-shell:has(.cr-touch-open) {
    border-color: color-mix(in srgb, var(--accent) 38%, rgba(255, 255, 255, 0.1));
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.42),
        0 0 20px color-mix(in srgb, var(--accent) 14%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.cr-rail-shell--preview {
    display: inline-block;
}

.cr-kicker {
    margin: 0 0 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent);
}

.cr-title {
    margin: 0 0 0.75rem;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(1.85rem, 4vw, 2.75rem);
    font-weight: normal;
    color: #fff;
}

.cr-lead {
    margin: 0 0 2rem;
    max-width: 620px;
    color: var(--muted);
}

.cr-section {
    margin-bottom: 2.5rem;
}

.cr-section-head {
    margin: 0 0 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
}

.cr-hero-panel {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1.25rem;
    align-items: center;
    padding: 1.25rem 1.35rem;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}

.cr-logo-mark {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
}

.cr-logo-mark svg {
    width: 100%;
    height: 100%;
}

.cr-hero-text h2 {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    color: #fff;
}

.cr-hero-text p {
    margin: 0;
    font-size: 0.92rem;
    color: var(--muted);
}

.cr-hex-badge {
    display: inline-block;
    margin-top: 0.65rem;
    padding: 0.25rem 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 2px;
}

.cr-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.cr-card {
    position: relative;
    padding: 1.1rem;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-top: 2px solid var(--accent);
    border-radius: 4px;
}

.cr-card h3 {
    margin: 0 0 0.45rem;
    font-size: 0.95rem;
    color: #fff;
}

.cr-card p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
}

.cr-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.cr-btn {
    padding: 0.55rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #0d1117;
    background: var(--accent);
    border: 2px solid var(--accent);
    border-radius: 2px;
    cursor: pointer;
}

.cr-btn-outline {
    color: var(--accent);
    background: transparent;
}

.cr-state-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.cr-state-panel {
    padding: 1.25rem;
    background: #0a0e14;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    text-align: center;
}

.cr-state-panel h3 {
    margin: 0 0 1rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--muted);
}

.cr-state-panel p {
    margin: 0.85rem 0 0;
    font-size: 0.78rem;
    color: #666;
}

.cr-rail-stage {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 220px;
    padding-top: 0.5rem;
}

/* Preview rails (static open/closed demo) */
.cr-rail-preview {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

.cr-rail-preview .cr-energy-node {
    opacity: 0;
    transform: translateY(-28px) scale(0.35);
    pointer-events: none;
}

.cr-rail-preview--open .cr-energy-node {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: none;
}

.cr-rail-preview--open .cr-energy-rail {
    pointer-events: none !important;
}

.cr-section-intro {
    margin: -0.35rem 0 1.1rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.cr-section-intro code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent);
}

.cr-callout {
    position: absolute;
    top: 0.65rem;
    right: 0.75rem;
    padding: 0.18rem 0.42rem;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.3px;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 2px;
}

.cr-callout--small {
    top: 0.55rem;
    right: 0.6rem;
    font-size: 0.54rem;
}

.cr-callout-note {
    margin: 0.85rem 0 0;
    font-size: 0.78rem;
    color: #666;
}

.cr-callout-note code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--accent);
}

.cr-transition-banner {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    font-size: 0.82rem;
    line-height: 1.55;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 3px solid var(--accent);
    border-radius: 0 4px 4px 0;
}

.cr-transition-banner strong {
    color: var(--accent);
}

.cr-guide-compact p {
    margin: 0 0 0.55rem;
    font-size: 0.86rem;
    color: var(--muted);
    line-height: 1.55;
}

.cr-guide-compact p:last-child {
    margin-bottom: 0;
}

.cr-guide-compact ul {
    margin: 0.35rem 0 0;
    padding-left: 1.15rem;
    font-size: 0.84rem;
    color: var(--muted);
    line-height: 1.6;
}

.cr-guide-compact li {
    margin-bottom: 0.35rem;
}

.cr-guide-compact code {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--accent);
}

.cr-guide-steps {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.cr-guide-step {
    padding: 1.1rem 1.15rem;
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
}

.cr-guide-step h3 {
    margin: 0 0 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #fff;
}

.cr-guide-step p {
    margin: 0 0 0.65rem;
    font-size: 0.86rem;
    color: var(--muted);
}

.cr-guide-step p:last-child {
    margin-bottom: 0;
}

.cr-guide-note {
    margin-top: 0.65rem !important;
    font-size: 0.78rem !important;
}

.cr-code {
    margin: 0;
    padding: 0.85rem 1rem;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.55;
    color: #c9d1d9;
    background: #0a0e14;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

.cr-code code {
    white-space: pre;
}

.cr-hint {
    margin: 0;
    padding: 0.85rem 1rem;
    font-size: 0.82rem;
    color: var(--muted);
    border-left: 3px solid var(--accent);
    background: rgba(255, 255, 255, 0.03);
}

.cr-hint strong {
    color: var(--accent);
}

.cr-footer-note {
    margin-top: 2rem;
    font-size: 0.78rem;
    color: #666;
    text-align: center;
}

/* ── Color rail widget ── */

.cr-quantum-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 52px;
    padding-top: 6px;
}

/* Docked in page column (demo default) */
.cr-quantum-wrapper--docked {
    position: relative;
    opacity: 1;
    transform: none;
    animation: none;
}

/* Optional: fixed to viewport edge (integrators) */
.cr-quantum-wrapper--fixed {
    position: fixed;
    right: max(15px, calc((100vw - 920px) / 2 + 15px));
    top: 2rem;
    z-index: 1000;
    opacity: 0;
    animation: cr-widget-swipe 1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    animation-delay: 0.35s;
}

@keyframes cr-widget-swipe {
    from {
        opacity: 0;
        transform: translateY(-8px) translateX(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0) translateX(0);
    }
}

.cr-quantum-core {
    width: 28px;
    height: 28px;
    padding: 0;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 50%, transparent);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.cr-quantum-core:hover {
    transform: scale(1.06);
    box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 65%, transparent);
}

.cr-quantum-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.cr-quantum-pulse::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px dotted var(--accent);
    opacity: 0.75;
    animation: cr-spin 5s linear infinite;
}

.cr-quantum-pulse::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 1.5px solid var(--accent);
    opacity: 0.18;
    animation: cr-spin 4s linear infinite reverse;
}

.cr-energy-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 0 2px;
    margin-top: 2px;
    pointer-events: none;
    width: 100%;
    position: relative;
}

.cr-energy-rail::before {
    content: '';
    position: absolute;
    top: 4px;
    bottom: 8px;
    left: 50%;
    width: 2px;
    transform: translateX(-50%) scaleY(0);
    transform-origin: top center;
    background: linear-gradient(180deg, var(--accent), rgba(255, 255, 255, 0.08));
    opacity: 0;
    border-radius: 2px;
    transition: transform 0.45s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.3s ease;
}

.cr-quantum-wrapper:is(:hover, .cr-touch-open) .cr-energy-rail::before,
.cr-rail-preview--open .cr-energy-rail::before {
    opacity: 0.55;
    transform: translateX(-50%) scaleY(1);
}

.cr-energy-node {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    opacity: 0;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    transform: translateY(-28px) scale(0.35);
    transition:
        transform 0.42s cubic-bezier(0.75, 0, 0.175, 1),
        opacity 0.32s ease,
        box-shadow 0.28s ease;
    box-shadow:
        inset 0 -2px 5px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgba(255, 255, 255, 0.14);
    outline: none;
}

/* Open state: all swatches visible */
.cr-quantum-wrapper:is(:hover, .cr-touch-open):not(.cr-rail-preview) .cr-energy-node,
.cr-quantum-wrapper.cr-touch-open .cr-energy-node {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.cr-quantum-wrapper:is(:hover, .cr-touch-open) .cr-energy-rail {
    pointer-events: all !important;
}

/* Closed: ALL swatches hide, including active selection */
.cr-quantum-wrapper:not(:hover):not(.cr-touch-open):not(.cr-rail-preview--open) .cr-energy-node {
    opacity: 0 !important;
    transform: translateY(-28px) scale(0.35) !important;
    pointer-events: none !important;
    transition-delay: 0s !important;
    box-shadow:
        inset 0 -2px 5px rgba(0, 0, 0, 0.28),
        0 0 0 1px rgba(255, 255, 255, 0.14) !important;
}

/* Hover on swatch: soft pop + glow ring (no spinning orbit) */
.cr-energy-node::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.9);
    opacity: 0;
    transform: scale(0.7);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.cr-quantum-wrapper:is(:hover, .cr-touch-open) .cr-energy-node:hover {
    transform: translateY(0) scale(1.16);
    box-shadow:
        inset 0 -2px 4px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.28),
        0 0 18px color-mix(in srgb, currentColor 50%, transparent);
}

.cr-quantum-wrapper:is(:hover, .cr-touch-open) .cr-energy-node:hover::after {
    opacity: 1;
    transform: scale(1);
}

.cr-energy-node:nth-child(1) { transition-delay: 0s; }
.cr-energy-node:nth-child(2) { transition-delay: 0.05s; }
.cr-energy-node:nth-child(3) { transition-delay: 0.1s; }
.cr-energy-node:nth-child(4) { transition-delay: 0.15s; }
.cr-energy-node:nth-child(5) { transition-delay: 0.2s; }

/* Active swatch: only styled while rail is open */
.cr-quantum-wrapper:is(:hover, .cr-touch-open) .cr-energy-node.cr-active {
    transform: translateY(0) scale(1.1);
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.95),
        0 0 0 1px rgba(0, 0, 0, 0.4),
        0 0 16px color-mix(in srgb, currentColor 45%, transparent);
}

.cr-yellow { background-color: #e1ff00 !important; color: #e1ff00; }
.cr-orange { background-color: #fb951d !important; color: #fb951d; }
.cr-cyan   { background-color: #0fd6f3 !important; color: #0fd6f3; }
.cr-green  { background-color: #39ff14 !important; color: #39ff14; }
.cr-purple { background-color: #f85ef3 !important; color: #f85ef3; }

@keyframes cr-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

@media (max-width: 720px) {
    .cr-grid { grid-template-columns: 1fr; }
    .cr-state-row { grid-template-columns: 1fr; }
    .cr-hero-panel { grid-template-columns: 1fr; text-align: center; }
    .cr-logo-mark { margin: 0 auto; }

    .cr-page-header {
        grid-template-columns: 1fr;
    }

    .cr-page-header-rail {
        justify-self: center;
    }
}

/* Embed mode: homepage iframe preview */
html.cr-embed,
html.cr-embed body {
    overflow: hidden;
    background: var(--bg);
}

html.cr-embed .cr-page {
    padding: 0.65rem 0.75rem 0.5rem;
    max-width: none;
}

html.cr-embed .cr-lead,
html.cr-embed .cr-section-intro,
html.cr-embed .cr-transition-banner,
html.cr-embed .cr-section--cards,
html.cr-embed .cr-section--guide,
html.cr-embed .cr-section--states,
html.cr-embed .cr-footer-note {
    display: none !important;
}

html.cr-embed .cr-page-header {
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

html.cr-embed .cr-title {
    font-size: 1.15rem;
    margin-bottom: 0.25rem;
}

html.cr-embed .cr-kicker {
    font-size: 0.62rem;
    margin-bottom: 0.25rem;
}

html.cr-embed .cr-hero-panel {
    padding: 0.75rem;
    gap: 0.75rem;
}

html.cr-embed .cr-logo-mark {
    width: 40px;
    height: 40px;
}

html.cr-embed .cr-hero-text h2 {
    font-size: 0.92rem;
}

html.cr-embed .cr-hero-text p {
    font-size: 0.75rem;
    display: none;
}

html.cr-embed .cr-rail-shell {
    padding: 16px 14px 12px;
}

html.cr-embed .cr-section {
    margin-bottom: 0;
}
