/* ═══════════════════════════════════════════════════════
   State Transition Diagram — Styles
   Standalone reusable CSS for the state transition diagram library.
   3-tier: π (Start) → Hidden States → Observations
   ═══════════════════════════════════════════════════════ */

/* ── Canvas ── */
.std-canvas,
.hmm-canvas {
    position: relative;
    width: 100%;
    min-height: 420px;
    border-radius: 8px;
    background: linear-gradient(170deg, #fafbfc 0%, #f1f5f9 100%);
    overflow-x: auto;
    overflow-y: hidden;
    transition: background 0.5s;
}

.std-canvas svg,
.hmm-canvas svg {
    display: block;
    min-width: 100%;
    height: 100%;
}

/* 3D View Mode */
.std-canvas.view-3d,
.hmm-canvas.view-3d {
    perspective: 1500px;
    overflow: visible;
    background: linear-gradient(170deg, #f1f5f9 0%, #e2e8f0 100%);
}

.std-canvas.view-3d svg,
.hmm-canvas.view-3d svg {
    transform-style: preserve-3d;
    transform: rotateX(55deg) rotateZ(-15deg) scale(0.75) translateY(-50px);
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Layers in 3D */
.std-canvas.view-3d .layer-1,
.hmm-canvas.view-3d .layer-1 {
    transform: translateZ(120px);
}

/* Start */
.std-canvas.view-3d .layer-2,
.hmm-canvas.view-3d .layer-2 {
    transform: translateZ(60px);
}

/* Transitions */
.std-canvas.view-3d .layer-3,
.hmm-canvas.view-3d .layer-3 {
    transform: translateZ(0px);
}

/* States */
.std-canvas.view-3d .layer-4,
.hmm-canvas.view-3d .layer-4 {
    transform: translateZ(-80px);
}

/* Emissions */

.layer-1,
.layer-2,
.layer-3,
.layer-4 {
    transition: transform 0.8s;
}

/* ── Replay control bar ── */
.std-controls,
.hmm-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.std-ctrl-btn,
.hmm-ctrl-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
}

.std-ctrl-btn:hover:not(:disabled),
.hmm-ctrl-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.std-ctrl-btn:disabled,
.hmm-ctrl-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.std-ctrl-btn.active,
.hmm-ctrl-btn.active {
    background: #ede9fe;
    border-color: #8b5cf6;
    color: #6d28d9;
}

/* Speed dropdown */
.std-speed-select,
.hmm-speed-select {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
    font-size: 12px;
    color: #334155;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
}

/* Timeline slider */
.std-timeline,
.hmm-timeline {
    flex: 1;
    min-width: 80px;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    cursor: pointer;
    margin: 0 4px;
    touch-action: none;
    user-select: none;
}

.std-timeline::-webkit-slider-runnable-track,
.hmm-timeline::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #8b5cf6 var(--progress, 0%), #e2e8f0 var(--progress, 0%));
}

.std-timeline::-moz-range-track,
.hmm-timeline::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #8b5cf6 var(--progress, 0%), #e2e8f0 var(--progress, 0%));
    border: none;
}

.std-timeline::-webkit-slider-thumb,
.hmm-timeline::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #7c3aed;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.3);
    cursor: grab;
    margin-top: -5px;
}

.std-timeline::-moz-range-thumb,
.hmm-timeline::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #7c3aed;
    border: 2px solid #fff;
    cursor: grab;
}

/* Iter label */
.std-iter-label,
.hmm-iter-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    min-width: 80px;
    text-align: center;
}

.std-mode-label,
.hmm-mode-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: #64748b;
    white-space: nowrap;
    min-width: 42px;
    text-align: left;
}

/* ── Inspector panel ── */
.std-inspector,
.hmm-inspector {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 0 12px;
    font-size: 12px;
}

.std-inspector.visible,
.hmm-inspector.visible {
    max-height: 600px;
    padding: 12px;
    border-color: #e2e8f0;
}

.std-inspector h4,
.hmm-inspector h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
}

.std-inspector table,
.hmm-inspector table {
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    margin-bottom: 8px;
}

.std-inspector th,
.std-inspector td,
.hmm-inspector th,
.hmm-inspector td {
    border: 1px solid #e2e8f0;
    padding: 3px 8px;
    text-align: center;
}

.std-inspector th,
.hmm-inspector th {
    background: #f1f5f9;
    font-weight: 600;
    color: #475569;
}

.std-inspector td,
.hmm-inspector td {
    color: #334155;
}

/* ── Particle glow ── */
@keyframes particle-glow {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

/* ── Fullscreen mode ── */
#diagram-card:fullscreen,
#diagram-card:-webkit-full-screen {
    background: #ffffff;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#diagram-card:fullscreen .std-canvas,
#diagram-card:fullscreen .hmm-canvas,
#diagram-card:-webkit-full-screen .std-canvas,
#diagram-card:-webkit-full-screen .hmm-canvas {
    flex: 1 1 0%;
    min-height: 0;
    height: auto !important;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#diagram-card:fullscreen .std-canvas svg,
#diagram-card:fullscreen .hmm-canvas svg,
#diagram-card:-webkit-full-screen .std-canvas svg,
#diagram-card:-webkit-full-screen .hmm-canvas svg {
    width: 100% !important;
    height: 100% !important;
    max-width: 100%;
    max-height: 100%;
}

#diagram-card:fullscreen .std-controls,
#diagram-card:fullscreen .hmm-controls,
#diagram-card:-webkit-full-screen .std-controls,
#diagram-card:-webkit-full-screen .hmm-controls {
    flex-shrink: 0;
    margin-top: 12px;
}

#diagram-card:fullscreen .std-inspector,
#diagram-card:fullscreen .hmm-inspector,
#diagram-card:-webkit-full-screen .std-inspector,
#diagram-card:-webkit-full-screen .hmm-inspector {
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
}

/* ── Mobile responsive ── */
@media (max-width: 640px) {
    .std-controls,
    .hmm-controls {
        flex-wrap: wrap;
        gap: 4px;
        padding: 4px 6px;
    }

    .std-canvas,
    .hmm-canvas {
        min-height: 300px;
    }

    .std-timeline,
    .hmm-timeline {
        min-width: 100%;
        order: 20;
    }

    .std-iter-label,
    .hmm-iter-label {
        min-width: auto;
        font-size: 10px;
        order: 21;
    }

    .std-ctrl-btn,
    .hmm-ctrl-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .std-speed-select,
    .hmm-speed-select {
        font-size: 11px;
        padding: 2px 4px;
    }

    .std-inspector table,
    .hmm-inspector table {
        font-size: 9px;
    }

    .std-inspector th,
    .std-inspector td,
    .hmm-inspector th,
    .hmm-inspector td {
        padding: 2px 4px;
    }
}
