/**
 * Selection Studio — Timeline V1
 * Location: /studio/css/timeline.css
 *
 * Canonical presentation for Foundation and Capsule navigation.
 */

.timeline-root {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--color-bg-panel, #0f171e);
    color: var(--studio-text-primary);
}

.timeline-foundation-section {
    flex: 0 0 auto;
    padding: var(--space-3, 12px);
    border-bottom: 1px solid var(--color-border-subtle, rgba(255, 255, 255, 0.06));
}

.timeline-capsule-scroll-region {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
    scrollbar-width: thin;
}

.timeline-capsule-list {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: 0;
    padding: var(--space-2, 8px) var(--space-3, 12px);
    list-style: none;
}

.timeline-footer {
    flex: 0 0 auto;
    padding: var(--space-2, 8px) var(--space-3, 12px) var(--space-3, 12px);
    border-top: 1px solid var(--color-border-subtle, rgba(255, 255, 255, 0.06));
    background: var(--color-bg-panel, #0f171e);
}

.timeline-item {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 7px var(--space-2, 8px);
    border: 1px solid transparent;
    border-radius: var(--radius-small, 6px);
    background: transparent;
    color: var(--studio-text-primary);
    font: inherit;
    text-align: left;
    user-select: none;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button.timeline-item {
    appearance: none;
    cursor: pointer;
}

.timeline-item--foundation {
    background: rgba(255, 255, 255, 0.018);
}

.timeline-item--capsule {
    padding-right: 40px;
    cursor: pointer;
}

.timeline-item--capsule:hover,
.timeline-item--capsule:focus-within,
.timeline-item--foundation:hover {
    background: rgba(255, 255, 255, 0.045);
    border-color: var(--color-border-subtle, rgba(255, 255, 255, 0.06));
}

.timeline-item--selected {
    border-color: var(--color-accent-border, rgba(212, 180, 131, 0.28));
    background: var(--color-accent-soft, rgba(212, 180, 131, 0.10));
}

.timeline-item--selected:hover,
.timeline-item--selected:focus-within {
    border-color: var(--color-accent-border, rgba(212, 180, 131, 0.28));
    background: var(--color-accent-soft, rgba(212, 180, 131, 0.10));
}

.timeline-item:focus-visible,
.timeline-archive-button:focus-visible,
.timeline-add-capsule:focus-visible {
    outline: 2px solid var(--studio-gold, #d4b483);
    outline-offset: 2px;
}

.timeline-item--unknown-type {
    color: var(--color-text-secondary, rgba(255, 255, 255, 0.62));
}

.timeline-item__drag-handle {
    flex: 0 0 18px;
    width: 18px;
    margin-right: var(--space-1, 4px);
    color: var(--studio-text-muted);
    cursor: grab;
    font-size: 13px;
    line-height: 1;
    text-align: center;
    transition: color 160ms ease;
}

.timeline-item--capsule:hover .timeline-item__drag-handle,
.timeline-item--capsule:focus-within .timeline-item__drag-handle {
    color: var(--color-text-secondary, rgba(255, 255, 255, 0.62));
}

.timeline-item__index {
    flex: 0 0 24px;
    width: 24px;
    margin-right: var(--space-2, 8px);
    color: var(--color-text-muted, rgba(255, 255, 255, 0.40));
    font-family: var(--studio-font-mono);
    font-size: var(--studio-type-mono-meta-size);
    font-weight: var(--studio-font-weight-strong);
    line-height: var(--studio-type-mono-meta-line-height);
    letter-spacing: var(--studio-type-mono-meta-letter-spacing);
    text-align: right;
}

.timeline-item__icon {
    flex: 0 0 20px;
    width: 20px;
    margin-right: var(--space-2, 8px);
    color: var(--studio-text-accent);
    font-size: 13px;
    line-height: 1;
    text-align: center;
}

.timeline-item__copy {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.timeline-item__label,
.timeline-item__type-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-item__label {
    color: var(--studio-text-primary);
    font-size: var(--studio-type-ui-label-size);
    font-weight: var(--studio-font-weight-medium);
    line-height: var(--studio-type-ui-label-line-height);
    transition: color 160ms ease;
}

.timeline-item--capsule:hover .timeline-item__label,
.timeline-item--capsule:focus-within .timeline-item__label {
    color: #ffffff;
}

.timeline-item__type-label {
    color: var(--studio-text-muted);
    font-size: var(--studio-type-meta-size);
    font-weight: var(--studio-font-weight-regular);
    line-height: var(--studio-type-meta-line-height);
}

.timeline-item__status {
    flex: 0 0 auto;
    margin-left: var(--space-2, 8px);
    color: var(--studio-text-muted);
    font-size: var(--studio-type-status-size);
    font-weight: var(--studio-font-weight-label);
    line-height: var(--studio-type-status-line-height);
    letter-spacing: var(--studio-type-status-letter-spacing);
    text-transform: uppercase;
}

.timeline-capsule-entry {
    position: relative;
    min-width: 0;
    list-style: none;
}

.timeline-archive-button {
    position: absolute;
    top: 50%;
    right: var(--space-2, 8px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-small, 6px);
    background: transparent;
    color: var(--color-text-muted, rgba(255, 255, 255, 0.40));
    cursor: pointer;
    opacity: 0.58;
    transform: translateY(-50%);
    transition: background-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.timeline-capsule-entry:hover .timeline-archive-button,
.timeline-capsule-entry:focus-within .timeline-archive-button {
    color: var(--color-text-secondary, rgba(255, 255, 255, 0.62));
    opacity: 1;
}

.timeline-archive-button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--color-text-primary, rgba(255, 255, 255, 0.92));
}

.timeline-drop-target {
    position: relative;
    height: 8px;
    margin: 0;
    list-style: none;
}

.timeline-drop-target::after {
    position: absolute;
    top: 3px;
    right: var(--space-2, 8px);
    left: var(--space-2, 8px);
    height: 2px;
    border-radius: var(--radius-pill, 999px);
    background: transparent;
    content: '';
}

.timeline-drop-target.is-active::after {
    background: var(--color-accent, #d4b483);
}

.timeline-drop-target--final {
    margin-bottom: var(--space-1, 4px);
}

.timeline-empty-state {
    margin: 0;
    padding: var(--space-6, 32px) var(--space-3, 12px);
    color: var(--studio-text-muted);
    font-size: var(--studio-type-body-compact-size);
    font-weight: var(--studio-font-weight-regular);
    line-height: var(--studio-type-body-compact-line-height);
    list-style: none;
    text-align: center;
}

.timeline-add-capsule {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    gap: 6px;
    min-height: 40px;
    padding: 0 var(--space-3, 12px);
    border: 1px solid transparent;
    border-radius: var(--radius-small, 6px);
    background: transparent;
    color: var(--studio-text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: var(--studio-type-ui-label-size);
    font-weight: var(--studio-font-weight-medium);
    line-height: 1;
    transition: background-color 160ms ease, color 160ms ease;
}

.timeline-add-capsule:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.timeline-add-capsule:focus-visible {
    color: #ffffff;
}

.timeline-add-capsule__arrow {
    display: inline-block;
    transition: transform 180ms ease;
}

.timeline-add-capsule:hover .timeline-add-capsule__arrow {
    transform: translateX(4px);
}

.timeline-capsule-scroll-region::-webkit-scrollbar {
    width: 6px;
}

.timeline-capsule-scroll-region::-webkit-scrollbar-track {
    background: transparent;
}

.timeline-capsule-scroll-region::-webkit-scrollbar-thumb {
    border-radius: var(--radius-pill, 999px);
    background: rgba(255, 255, 255, 0.10);
}

.timeline-capsule-scroll-region::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.16);
}

@media (max-width: 640px) {
    .timeline-foundation-section,
    .timeline-capsule-list,
    .timeline-footer {
        padding-inline: var(--space-2, 8px);
    }

    .timeline-item--capsule {
        padding-right: 40px;
    }

    .timeline-item__drag-handle {
        flex-basis: 16px;
        width: 16px;
        margin-right: 0;
    }

    .timeline-item__index {
        flex-basis: 22px;
        width: 22px;
        margin-right: var(--space-1, 4px);
    }

    .timeline-item__icon {
        flex-basis: 18px;
        width: 18px;
        margin-right: var(--space-1, 4px);
    }

    .timeline-archive-button {
        width: 36px;
        height: 36px;
        right: var(--space-1, 4px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .timeline-item,
    .timeline-item__drag-handle,
    .timeline-item__label,
    .timeline-archive-button,
    .timeline-add-capsule {
        transition: none;
    }

    .timeline-add-capsule:hover .timeline-add-capsule__arrow {
        transform: none;
    }
}
