/**
 * 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: visible;
    background: var(--color-bg-panel, #121a21);
    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: auto;
}

.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-add-capsule-region {
    display: none;
}

.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-row-controls { position:absolute; top:50%; right:var(--space-1, 4px); display:flex; align-items:center; gap:2px; transform:translateY(-50%); }
.timeline-reorder-button { display:inline-flex; align-items:center; justify-content:center; width:40px; height:40px; padding:0; border:0; border-radius:var(--radius-small, 6px); background:transparent; color:var(--studio-text-muted); cursor:pointer; font:inherit; font-size:16px; }
.timeline-reorder-button:hover:not(:disabled), .timeline-reorder-button:focus-visible { color:var(--studio-text-accent); }
.timeline-reorder-button:disabled { cursor:default; opacity:.25; }
.timeline-reorder-button:focus-visible { outline:2px solid var(--studio-gold); outline-offset:2px; }

.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 {
    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__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: var(--studio-text-secondary);
}

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

.timeline-item--capsule .timeline-item__type-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 .timeline-item__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-capsule-entry {
    position: relative;
    min-width: 0;
    list-style: none;
}

.timeline-archive-button {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-small, 6px);
    background: transparent;
    color: var(--color-text-muted, rgba(255, 255, 255, 0.40));
    cursor: pointer;
    opacity: 0;
    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 {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-border-default, rgba(255, 255, 255, 0.10));
    color: var(--color-text-secondary, rgba(255, 255, 255, 0.62));
    opacity: 1;
}

.timeline-archive-button:hover,
.timeline-archive-button:focus-visible,
.timeline-archive-button:active {
    background: rgba(255, 105, 97, 0.14);
    border-color: rgba(255, 105, 97, 0.46);
    color: var(--color-danger, #ff6961);
}

.timeline-archive-button:focus-visible {
    outline-color: var(--color-danger, #ff6961);
}

.capsule-remove-picker {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: var(--space-6, 32px);
    color: var(--studio-text-primary);
}

.capsule-remove-picker__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4, 16px);
}

.capsule-remove-picker__title {
    margin: 0;
    font-size: var(--studio-type-dialog-title-size);
    font-weight: var(--studio-font-weight-medium);
    line-height: var(--studio-type-dialog-title-line-height);
    letter-spacing: var(--studio-type-dialog-title-letter-spacing);
}

.capsule-remove-picker__body {
    margin: var(--space-3, 12px) 0 0;
    color: var(--studio-text-secondary);
    font-size: var(--studio-type-body-compact-size);
    line-height: var(--studio-type-body-compact-line-height);
}

.capsule-remove-picker__close,
.capsule-remove-picker__cancel,
.capsule-remove-picker__confirm {
    appearance: none;
    border-radius: var(--radius-small, 6px);
    font: inherit;
    font-size: var(--studio-type-ui-label-size);
    cursor: pointer;
}

.capsule-remove-picker__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--studio-text-muted);
    font-size: 18px;
}

.capsule-remove-picker__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3, 12px);
    margin-top: auto;
}

.capsule-remove-picker__cancel,
.capsule-remove-picker__confirm {
    min-height: 36px;
    padding: 0 14px;
}

.capsule-remove-picker__cancel {
    border: 0;
    background: transparent;
    color: var(--studio-text-muted);
}

.capsule-remove-picker__confirm {
    border: 1px solid rgba(255, 105, 97, 0.46);
    background: rgba(255, 105, 97, 0.14);
    color: var(--color-danger, #ff6961);
    font-weight: var(--studio-font-weight-strong);
}

.capsule-remove-picker__close:hover,
.capsule-remove-picker__cancel:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--studio-text-primary);
}

.capsule-remove-picker__confirm:hover {
    background: rgba(255, 105, 97, 0.22);
    border-color: var(--color-danger, #ff6961);
}

.capsule-remove-picker__close:focus-visible,
.capsule-remove-picker__cancel:focus-visible,
.capsule-remove-picker__confirm:focus-visible {
    outline: 2px solid var(--studio-gold, #d4b483);
    outline-offset: 2px;
}

.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 {
    justify-content: flex-start;
    width: 100%;
    min-height: 40px;
    cursor: pointer;
}

.timeline-add-capsule__prefix {
    flex: 0 0 auto;
    margin-right: 6px;
}

.timeline-add-capsule__arrow {
    flex: 0 0 auto;
    margin-left: auto;
}

.timeline-positional-add {
    display: block;
    height: 8px;
    overflow: hidden;
    list-style: none;
    transition: height 160ms ease;
}

.timeline-positional-add__button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    border: 0;
    border-radius: var(--radius-small, 6px);
    background: transparent;
    color: var(--studio-text-accent, #d4b483);
    cursor: pointer;
    font: inherit;
    font-size: 22px;
    line-height: 1;
}

.timeline-positional-add__label {
    display: none;
    font-size: var(--studio-type-ui-label-size);
    font-weight: var(--studio-font-weight-medium);
}

.timeline-positional-add__button:focus-visible {
    outline: 2px solid var(--studio-gold, #d4b483);
    outline-offset: 2px;
}

.timeline-positional-add:hover,
.timeline-positional-add:focus-within {
    height: 44px;
}

.timeline-positional-add:hover .timeline-positional-add__label,
.timeline-positional-add:focus-within .timeline-positional-add__label {
    display: inline;
}

@media (max-width: 640px) {
    .timeline-foundation-section,
    .timeline-capsule-list,
    .timeline-add-capsule-region {
        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__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 (max-width: 700px) {
    .timeline-positional-add {
        height: 44px;
    }

    .timeline-positional-add__label {
        display: inline;
    }

    .timeline-positional-add__button:hover,
    .timeline-positional-add__button:focus-visible {
        background: rgba(212, 180, 131, 0.08);
    }

    .timeline-archive-button {
        opacity: 1;
        background: transparent;
        border-color: transparent;
        color: var(--color-text-muted, rgba(255, 255, 255, 0.40));
    }

    .capsule-remove-picker {
        padding: var(--space-4, 16px);
    }

    .capsule-remove-picker__actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .capsule-remove-picker__cancel,
    .capsule-remove-picker__confirm {
        width: 100%;
    }
}

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