/* YouTube-style video assembly preview (workflow studio) */

#workflow-studio-view .wf-assembly-preview {
    width: calc(100% + 28px);
    max-width: 420px;
    margin: 52px -14px 0;
}

#workflow-studio-view .wf-assembly {
    position: relative;
}

/* ─── Card shell ─────────────────────────────────────────────────────────── */

#workflow-studio-view .wf-yt-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 0 2px;
}

/* ─── Thumbnail (16:9) ───────────────────────────────────────────────────── */

#workflow-studio-view .wf-yt-thumb {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-bg-secondary);
}

#workflow-studio-view .wf-yt-thumb.is-active {
    outline: 2px solid color-mix(in srgb, var(--color-text-primary) 12%, transparent);
    outline-offset: 1px;
}

#workflow-studio-view .wf-yt-thumb__media {
    position: relative;
    aspect-ratio: 16 / 9;
    width: 100%;
    overflow: hidden;
    background: #ececec;
}

#workflow-studio-view .wf-yt-thumb__placeholder {
    position: absolute;
    inset: 0;
    z-index: 1;
}

#workflow-studio-view .wf-yt-thumb.has-image .wf-yt-thumb__placeholder {
    opacity: 0;
    pointer-events: none;
}

#workflow-studio-view .wf-yt-scene {
    display: block;
    width: 100%;
    height: 100%;
}

#workflow-studio-view .wf-yt-scene__sky {
    fill: #e8e8e8;
}

#workflow-studio-view .wf-yt-scene__sun {
    fill: #fafafa;
    stroke: #b0b0b0;
    stroke-width: 2;
}

#workflow-studio-view .wf-yt-scene__mountain.is-back {
    fill: #c4c4c4;
}

#workflow-studio-view .wf-yt-scene__mountain.is-front {
    fill: #9a9a9a;
}

[data-theme='dark'] #workflow-studio-view .wf-yt-thumb__media {
    background: #2a2a2a;
}

[data-theme='dark'] #workflow-studio-view .wf-yt-scene__sky {
    fill: #3a3a3a;
}

[data-theme='dark'] #workflow-studio-view .wf-yt-scene__sun {
    fill: #525252;
    stroke: #737373;
}

[data-theme='dark'] #workflow-studio-view .wf-yt-scene__mountain.is-back {
    fill: #525252;
}

[data-theme='dark'] #workflow-studio-view .wf-yt-scene__mountain.is-front {
    fill: #404040;
}

#workflow-studio-view .wf-yt-thumb__img {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Thumbnail text — hidden once image is set (via JS) */
#workflow-studio-view .wf-yt-thumb__label {
    position: absolute;
    left: 8px;
    bottom: 8px;
    z-index: 4;
    max-width: calc(100% - 48px);
    padding: 4px 7px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.1;
    text-transform: uppercase;
}

/* Duration badge (YouTube-scale, matches composer mm:ss) */
#workflow-studio-view .wf-yt-duration {
    position: absolute;
    right: 4px;
    bottom: 4px;
    z-index: 5;
    padding: 0 3px;
    border-radius: 2px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 9px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    line-height: 1.45;
}

/* ─── Meta row ───────────────────────────────────────────────────────────── */

#workflow-studio-view .wf-yt-meta {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 24px;
    align-items: start;
    gap: 10px;
    padding: 0 2px;
}

#workflow-studio-view .wf-yt-avatar {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-text-muted) 18%, var(--color-bg-secondary));
    color: color-mix(in srgb, var(--color-text-primary) 70%, var(--color-text-muted));
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

#workflow-studio-view .wf-yt-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#workflow-studio-view .wf-yt-avatar.has-image span {
    display: none;
}

#workflow-studio-view .wf-yt-meta__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding-top: 1px;
}

/* Title */
#workflow-studio-view .wf-yt-title-row {
    width: 100%;
    min-height: 40px;
}

#workflow-studio-view .wf-yt-title {
    margin: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    color: var(--color-text-primary);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    will-change: transform, opacity;
}

#workflow-studio-view .wf-yt-title-placeholder {
    display: flex;
    flex-direction: column;
    gap: 7px;
    width: 100%;
    padding-top: 4px;
}

#workflow-studio-view .wf-yt-title__bar {
    display: block;
    flex-shrink: 0;
    height: 12px;
    width: 96%;
    border-radius: 4px;
    background: color-mix(in srgb, var(--color-text-primary) 16%, var(--color-bg-secondary));
}

#workflow-studio-view .wf-yt-title__bar.is-short {
    width: 66%;
}

[data-theme='dark'] #workflow-studio-view .wf-yt-title__bar {
    background: color-mix(in srgb, var(--color-text-primary) 28%, var(--color-bg-secondary));
}

#workflow-studio-view .wf-yt-title-placeholder .wf-yt-title__bar {
    animation: wf-yt-shimmer 1.5s ease-in-out infinite;
}

#workflow-studio-view .wf-yt-title-placeholder .wf-yt-title__bar.is-short {
    animation-delay: 0.12s;
}

/* Channel */
#workflow-studio-view .wf-yt-channel {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    min-height: 14px;
    font-size: 12px;
    line-height: 1.2;
}

#workflow-studio-view .wf-yt-channel__name {
    overflow: hidden;
    color: var(--color-text-muted);
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#workflow-studio-view .wf-yt-channel__badge {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--color-text-muted);
    opacity: 0.5;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / 9px no-repeat;
}

/* Views placeholder (YouTube meta line) */
#workflow-studio-view .wf-yt-views {
    margin: 0;
    min-height: 10px;
}

#workflow-studio-view .wf-yt-views__bar {
    display: block;
    width: 48%;
    height: 9px;
    border-radius: 3px;
    background: color-mix(in srgb, var(--color-text-muted) 12%, var(--color-bg-secondary));
    animation: wf-yt-shimmer 1.5s ease-in-out infinite 0.1s;
}

/* Hook block — visually separate from channel */
#workflow-studio-view .wf-yt-hook-block {
    margin: 2px 2px 0 48px;
    padding: 8px 10px 8px 12px;
    border-left: 2px solid color-mix(in srgb, var(--color-text-muted) 28%, transparent);
    border-radius: 0 8px 8px 0;
    background: color-mix(in srgb, var(--color-text-muted) 6%, var(--color-bg-secondary));
    overflow: hidden;
}

#workflow-studio-view .wf-yt-hook-block.is-empty {
    min-height: 0;
    padding: 0;
    margin-top: 0;
    border: none;
    background: transparent;
    opacity: 0;
    pointer-events: none;
}

#workflow-studio-view .wf-yt-hook-block.is-filled {
    opacity: 1;
}

#workflow-studio-view .wf-yt-hook-block.is-active.is-filled {
    border-left-color: color-mix(in srgb, var(--color-text-primary) 35%, transparent);
    background: color-mix(in srgb, var(--color-text-primary) 5%, var(--color-bg-secondary));
}

#workflow-studio-view .wf-yt-hook {
    margin: 0;
    color: color-mix(in srgb, var(--color-text-primary) 78%, var(--color-text-muted));
    font-size: 11.5px;
    font-weight: 500;
    font-style: italic;
    line-height: 1.4;
    letter-spacing: 0.01em;
}

@keyframes wf-yt-shimmer {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.85; }
}

/* Kebab menu */
#workflow-studio-view .wf-yt-menu {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    margin-top: -2px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-muted);
    opacity: 0.65;
}

#workflow-studio-view .wf-yt-menu i,
#workflow-studio-view .wf-yt-menu svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 760px) {
    #workflow-studio-view .wf-assembly-preview {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        margin-top: 36px;
    }

    #workflow-studio-view .wf-yt-hook-block {
        margin-left: 42px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #workflow-studio-view .wf-yt-title-placeholder .wf-yt-title__bar,
    #workflow-studio-view .wf-yt-views__bar {
        animation: none;
    }

    #workflow-studio-view .wf-yt-card,
    #workflow-studio-view .wf-yt-thumb,
    #workflow-studio-view .wf-yt-thumb__placeholder,
    #workflow-studio-view .wf-yt-title,
    #workflow-studio-view .wf-yt-hook-block {
        transition: none !important;
    }
}
