/* ============================================
   Animation Container Styles
   Loaded on subject-viewer.html for GSAP-powered
   interactive diagrams.
   ============================================ */

/* Base container */
[data-animation] {
    position: relative;
    min-height: 200px;
    border-radius: 12px;
    overflow: hidden;
}

/* SVG canvas area */
[data-animation] .animation-canvas {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

[data-animation] .animation-canvas svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Mitosis frame layers — stacked via CSS grid */
.mitosis-frame-layer {
    grid-area: 1 / 1;
}

.mitosis-frame-layer svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Loading skeleton pulse */
[data-animation].animation-loading .animation-canvas::after {
    content: '';
    display: block;
    width: 100%;
    height: 350px;
    background: var(--bg-secondary, #f1f5f9);
    border-radius: 12px;
    animation: animation-pulse 1.5s ease-in-out infinite;
}

@keyframes animation-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* Ready state — canvas visible */
[data-animation].animation-ready .animation-canvas::after {
    display: none;
}

/* Fallback state */
[data-animation].animation-fallback .animation-canvas img {
    border-radius: 8px;
}

/* Stage indicator pills */
.animation-stage-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-top: 10px;
    padding: 0 8px;
}

.animation-stage-label {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text-secondary, #64748b);
    transition: background 0.3s, color 0.3s;
    cursor: default;
}

.animation-stage-label.active {
    background: var(--accent, #3b82f6);
    color: #fff;
}

/* Replay button — sits top-right of the animation canvas */
.animation-replay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border, #e2e8f0);
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 5;
}

.animation-replay:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Play/Pause button (learn mode) — centred above rail */
.animation-play-pause {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border, #e2e8f0);
    background: var(--bg-primary, #fff);
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 5;
    flex-shrink: 0;
    margin: 4px auto;
}

.animation-play-pause:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Scroll instruction hint */
.animation-scroll-hint {
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    text-align: center;
    margin-top: 6px;
    opacity: 0.7;
    font-style: italic;
}

/* Dark mode adjustments */
[data-theme="dark"] [data-animation].animation-loading .animation-canvas::after {
    background: var(--bg-secondary, #1e293b);
}

[data-theme="dark"] .animation-replay {
    background: var(--bg-secondary, #1e293b);
    border-color: var(--border, #334155);
}

/* ─── Description Panel (between SVG and rail) ─── */
.animation-description {
    padding: 8px 16px 4px;
    text-align: center;
}

.animation-stage-name {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 2px;
    color: var(--text-primary, #1e293b);
}

.animation-stage-desc {
    font-size: 0.85rem;
    margin: 0;
    color: var(--text-secondary, #64748b);
    line-height: 1.4;
}

/* ─── Caption (reuses description panel position) ─── */
.animation-caption-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0 0 2px;
}

.animation-caption-desc {
    font-size: 0.82rem;
    color: var(--text-secondary, #64748b);
    margin: 0;
    line-height: 1.35;
}

[data-theme="dark"] .animation-caption-name {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .animation-caption-desc {
    color: var(--text-secondary, #94a3b8);
}

/* ─── Bottom Progress Rail ─── */
.animation-progress-rail {
    padding: 4px 16px 12px;
    position: relative;
    z-index: 6;
}

.rail-track {
    position: relative;
    height: 3px;
    background: var(--border, #e2e8f0);
    border-radius: 2px;
    margin-bottom: 6px;
}

.rail-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent, #3b82f6);
    border-radius: 2px;
    transition: width 0.15s ease-out;
    width: 0%;
}

.rail-dots {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2px;
}

.rail-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 2px;
    min-width: 40px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.rail-dot-marker {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border, #e2e8f0);
    border: 2px solid var(--border, #e2e8f0);
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.rail-dot.active .rail-dot-marker {
    background: var(--accent, #3b82f6);
    border-color: var(--accent, #3b82f6);
}

.rail-dot.current .rail-dot-marker {
    background: #fff;
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.rail-dot-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    transition: color 0.3s, font-weight 0.3s;
}

.rail-dot.current .rail-dot-label {
    color: var(--accent, #3b82f6);
    font-weight: 700;
}

/* ─── Dark mode ─── */
[data-theme="dark"] .animation-stage-name {
    color: var(--text-primary, #f1f5f9);
}

[data-theme="dark"] .rail-dot.current .rail-dot-marker {
    background: var(--bg-primary, #0f172a);
}

[data-theme="dark"] .animation-progress-rail .rail-track {
    background: #64748b !important;
}

[data-theme="dark"] .animation-progress-rail .rail-fill {
    background: var(--accent, #3b82f6) !important;
}

[data-theme="dark"] .rail-dot-marker {
    background: #475569 !important;
    border-color: #475569 !important;
}

[data-theme="dark"] .rail-dot.active .rail-dot-marker {
    background: var(--accent, #3b82f6) !important;
    border-color: var(--accent, #3b82f6) !important;
}

[data-theme="dark"] .rail-dot-label {
    color: #94a3b8;
}

[data-theme="dark"] .rail-dot.current .rail-dot-label {
    color: var(--accent, #60a5fa);
}

[data-theme="dark"] .animation-play-pause {
    background: #1e293b;
    border-color: #475569;
    color: #94a3b8;
}

/* Reduced motion — hide replay, remove transitions */
@media (prefers-reduced-motion: reduce) {
    [data-animation] .animation-canvas svg * {
        animation: none !important;
        transition: none !important;
    }
    .animation-replay {
        display: none;
    }
    .animation-play-pause {
        display: none;
    }
}
