/* Video Advanced — template-specific styles */

.type-btn-new {
    position: relative;
}

.type-new-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 3px 7px;
    border-radius: 999px;
    color: #1a1408;
    background: linear-gradient(135deg, #fde68a, #f59e0b);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.45);
    text-transform: uppercase;
}

/* Compact one-line stat rows: name | time [| trap] | × */
.va-stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.va-stat-row.is-deleted { display: none; }
.va-stat-name {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.va-stat-input {
    width: 72px;
    flex: 0 0 auto;
    padding: 6px 8px;
    background: #0f1419;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.va-stat-input::placeholder {
    color: rgba(255, 255, 255, 0.32);
    font-size: 0.7rem;
    font-style: italic;
}
.va-stat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}
.va-stat-input::-webkit-inner-spin-button,
.va-stat-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.va-stat-delete {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.va-stat-delete:hover {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.55);
    background: rgba(239, 68, 68, 0.12);
}

/* Inline validation status message */
.va-status-msg {
    margin-top: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-size: 0.78rem;
    line-height: 1.4;
    display: none;
}
.va-status-msg.is-visible { display: block; }

/* Bigger touch targets on mobile + larger inputs to match the global
   mobile rules. Keeps the layout dense but tappable. */
@media (max-width: 640px) {
    .va-stat-input {
        width: 86px;
        font-size: 1rem;
        padding: 8px 10px;
    }
    .va-stat-name { font-size: 0.95rem; }
    .va-stat-delete {
        width: 32px;
        height: 32px;
        font-size: 1.15rem;
    }
    .va-status-msg {
        font-size: 0.9rem;
        padding: 10px 12px;
    }
    .va-tl-track { height: 44px; }
    .va-tl-handle { width: 28px; }
    .va-tl-handle::after { width: 18px; height: 18px; }
    .va-tl-handle-grip { width: 5px; }
    .va-tl-labels { font-size: 0.85rem; }
    .va-bg-button, .va-bg-clear { font-size: 1rem; padding: 12px 14px; }
    .va-upload-title { font-size: 1.1rem; }
}

/* Background-video controls */
.va-bg-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.va-bg-button {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #1a2933, #3b82f6);
    color: #fff;
    border: 2px dashed rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 600;
    text-align: center;
    transition: filter 0.15s ease, border-color 0.15s ease,
                transform 0.15s ease, background 0.2s ease,
                box-shadow 0.2s ease;
    pointer-events: auto;
    line-height: 1.25;
    /* children must not steal drag events from the label, otherwise the
       counter-less dragenter/leave pair would flicker constantly */
}
.va-bg-button > * { pointer-events: none; }
.va-bg-button:hover {
    filter: brightness(1.1);
    border-color: rgba(255, 255, 255, 0.32);
}
.va-bg-button .va-bg-subhint {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.75;
    margin-top: 2px;
    letter-spacing: 0.02em;
}

/* Active drag-over state — clear "drop here" affordance */
.va-bg-button.is-drop-target {
    transform: scale(1.02);
    border-color: rgba(255, 255, 255, 0.85);
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    box-shadow: 0 0 24px rgba(96, 165, 250, 0.55);
}
.va-bg-button.is-drop-target::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 14px;
    border: 2px dashed rgba(96, 165, 250, 0.7);
    animation: va-drop-pulse 1.2s ease-in-out infinite;
    pointer-events: none;
}
@keyframes va-drop-pulse {
    0%, 100% { transform: scale(1);    opacity: 0.55; }
    50%      { transform: scale(1.04); opacity: 1;    }
}
.va-bg-clear {
    background: #2a1a1a;
    color: #fca5a5;
    border: 1px solid #7f1d1d;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 600;
}
.va-bg-clear:hover { background: #3a1a1a; }
.va-bg-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Cursor for the canvas is managed inline by the JS hit-test
   (move / nwse-resize / nesw-resize). The .va-draggable class is kept
   only as a marker hook; no cursor rule needed. */

/* Required-upload prompt overlaid on the preview canvas */
.va-upload-placeholder {
    display: none;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    /* parent .preview-canvas-wrap sets line-height: 0 to kill the canvas
       baseline gap; reset it here so the title/hint/sub don't collapse
       on top of each other */
    line-height: 1.3;
    border: 3px dashed rgba(96, 165, 250, 0.45);
    border-radius: 16px;
    background:
        radial-gradient(120% 120% at 50% 0%, rgba(59, 130, 246, 0.18) 0%, transparent 60%),
        rgba(15, 20, 25, 0.92);
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    text-align: center;
    padding: 24px;
    user-select: none;
    z-index: 5;
}
.va-upload-placeholder.is-visible { display: flex; }
.va-upload-placeholder:hover {
    border-color: rgba(96, 165, 250, 0.85);
    background:
        radial-gradient(120% 120% at 50% 0%, rgba(59, 130, 246, 0.25) 0%, transparent 60%),
        rgba(20, 28, 40, 0.95);
}
.va-upload-placeholder:focus-visible {
    outline: none;
    border-color: rgba(96, 165, 250, 1);
}

.va-upload-placeholder.is-drop-target {
    border-color: rgba(147, 197, 253, 1);
    background:
        radial-gradient(120% 120% at 50% 0%, rgba(96, 165, 250, 0.4) 0%, transparent 60%),
        rgba(30, 50, 80, 0.95);
    box-shadow: 0 0 32px rgba(96, 165, 250, 0.55) inset;
    transform: scale(1.005);
}
.va-upload-placeholder.is-drop-target::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 20px;
    border: 3px dashed rgba(96, 165, 250, 0.7);
    animation: va-drop-pulse 1.2s ease-in-out infinite;
    pointer-events: none;
}

.va-upload-placeholder > * { pointer-events: none; }

.va-upload-icon {
    font-size: 3.6rem;
    line-height: 1;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}
.va-upload-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.01em;
}
.va-upload-hint {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.78);
}
.va-upload-sub {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    margin-top: 6px;
}

/* Timeline scrubber — lives inside .preview-wrapper, directly below the
   canvas. Width follows the canvas's displayed width because the wrapper
   is a flex column with align-items: center. */
.va-timeline {
    display: none;
    width: 100%;
    margin-top: 6px;
}
.va-timeline.is-visible { display: block; }

.va-tl-track {
    position: relative;
    height: 36px;
    background: rgba(15, 22, 32, 0.95);
    border: 1px solid rgba(96, 165, 250, 0.18);
    border-radius: 8px;
    overflow: visible;
    user-select: none;
    cursor: default;
}

.va-tl-bgvideo-region,
.va-tl-freeze-region {
    position: absolute;
    top: 0;
    height: 100%;
    pointer-events: none;
}
.va-tl-bgvideo-region {
    left: 0;
    border-radius: 7px 0 0 7px;
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.45), rgba(59, 130, 246, 0.18));
}
.va-tl-freeze-region {
    background-color: rgba(60, 60, 70, 0.45);
    background-image: repeating-linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.05) 0,
        rgba(255, 255, 255, 0.05) 4px,
        rgba(255, 255, 255, 0.10) 4px,
        rgba(255, 255, 255, 0.10) 8px
    );
}

.va-tl-overlay-region {
    position: absolute;
    top: 25%;
    height: 50%;
    background: rgba(34, 197, 94, 0.45);
    border: 1px solid rgba(34, 197, 94, 0.7);
    border-radius: 4px;
    pointer-events: auto;
    cursor: grab;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.25) inset;
    transition: background 0.12s ease;
    touch-action: none;
}
.va-tl-overlay-region:hover {
    background: rgba(34, 197, 94, 0.55);
}
.va-tl-overlay-region.is-dragging {
    cursor: grabbing;
    background: rgba(74, 222, 128, 0.6);
}

/* Hatched cap on the right end of the overlay band — marks the freeze tail
   between "stats finished animating" and "clip end". Sits ON TOP of the
   green region with pointer-events: none so panning still works through it. */
.va-tl-overlay-freeze {
    position: absolute;
    top: 25%;
    height: 50%;
    pointer-events: none;
    border-radius: 4px;
    border: 1px solid rgba(34, 197, 94, 0.55);
    background-image: repeating-linear-gradient(
        135deg,
        rgba(34, 197, 94, 0.55) 0,
        rgba(34, 197, 94, 0.55) 4px,
        rgba(15, 22, 32, 0.45) 4px,
        rgba(15, 22, 32, 0.45) 8px
    );
    box-sizing: border-box;
    display: none;
}
.va-tl-overlay-freeze.is-visible { display: block; }

/* Vertical tick at the moment the stats animation completes. */
.va-tl-anim-end-tick {
    position: absolute;
    top: 12%;
    height: 76%;
    width: 2px;
    transform: translateX(-1px);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    pointer-events: none;
    display: none;
}
.va-tl-anim-end-tick.is-visible { display: block; }

.va-tl-playhead {
    position: absolute;
    top: -3px;
    width: 2px;
    height: calc(100% + 6px);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
    pointer-events: none;
    transform: translateX(-1px);
}

.va-tl-handle {
    position: absolute;
    top: -8px;
    width: 18px;
    height: calc(100% + 16px);
    transform: translateX(-50%);
    cursor: ew-resize;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}
.va-tl-handle-grip {
    width: 4px;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
    transition: background 0.12s ease, box-shadow 0.12s ease;
}
.va-tl-handle::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(96, 165, 250, 0.85);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    transition: transform 0.12s ease, border-color 0.12s ease;
}
.va-tl-handle:hover::after,
.va-tl-handle.is-dragging::after {
    transform: translate(-50%, -50%) scale(1.15);
    border-color: rgba(147, 197, 253, 1);
}
.va-tl-handle.is-dragging .va-tl-handle-grip {
    background: rgba(147, 197, 253, 1);
    box-shadow: 0 0 12px rgba(96, 165, 250, 0.7);
}

.va-tl-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.va-tl-labels strong {
    color: #fff;
    font-weight: 600;
}
.va-tl-freeze-note {
    color: #fbbf24;
    margin-right: 8px;
    font-style: italic;
    display: none;
}
.va-tl-freeze-note.is-visible { display: inline; }

/* ===== Video Advanced — Tutorial popup ===== */
.va-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.va-tutorial-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(77, 184, 184, 0.12);
    color: #4DB8B8;
    border: 1px solid rgba(77, 184, 184, 0.4);
    border-radius: 999px;
    padding: 4px 10px 4px 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.va-tutorial-btn:hover {
    background: rgba(77, 184, 184, 0.22);
    transform: translateY(-1px);
}
.va-tutorial-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4DB8B8;
    color: #0a0e0a;
    font-weight: 800;
    font-size: 0.78rem;
    line-height: 1;
}

.va-tutorial-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.va-tutorial-modal.hidden { display: none; }
.va-tutorial-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.va-tutorial-card {
    position: relative;
    width: min(960px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: var(--bg-card, #1a1f1a);
    border: 1px solid var(--border-color, #2a2f2a);
    border-radius: 16px;
    padding: 28px 28px 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    color: var(--text-primary, #fff);
    animation: va-tutorial-pop 0.18s ease-out;
}
@keyframes va-tutorial-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.va-tutorial-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: transparent;
    border: 0;
    color: var(--text-secondary, #b0b0b0);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.va-tutorial-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}
.va-tutorial-title {
    margin: 0 0 6px;
    font-size: 1.45rem;
    font-weight: 700;
}
.va-tutorial-sub {
    margin: 0 0 22px;
    color: var(--text-secondary, #b0b0b0);
    font-size: 0.92rem;
}

.va-tutorial-steps {
    display: flex;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 22px;
}
.va-tutorial-step {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.va-tutorial-step-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #4DB8B8;
    color: #0a0e0a;
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.va-tutorial-step-img {
    width: 100%;
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color, #2a2f2a);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}
.va-tutorial-step-img img,
.va-tutorial-step-img video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #000;
}
.va-tutorial-step-label {
    margin-bottom: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
}
.va-tutorial-arrow {
    align-self: center;
    flex: 0 0 auto;
    color: #4DB8B8;
    font-size: 1.6rem;
    font-weight: 700;
    padding: 0 4px;
}

.va-tutorial-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.va-tutorial-dontshow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary, #b0b0b0);
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}
.va-tutorial-dontshow input { accent-color: #4DB8B8; width: 16px; height: 16px; }
.va-tutorial-continue {
    background: #4DB8B8;
    color: #0a0e0a;
    border: 0;
    padding: 10px 22px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.va-tutorial-continue:hover {
    background: #3fa6a6;
    transform: translateY(-1px);
}

@media (max-width: 720px) {
    .va-tutorial-steps { flex-direction: column; gap: 8px; align-items: center; }
    .va-tutorial-arrow { transform: rotate(90deg); padding: 4px 0; }
    /* Keep portrait 9:16 on mobile (illustrations & generated.mp4 are all
       portrait — forcing 16:9 here was cropping the upload icon off step 1
       and the stats panel off step 2). Constrain width so a single card
       doesn't fill the viewport vertically. */
    .va-tutorial-step { width: 100%; max-width: 240px; }
    .va-tutorial-step-img { aspect-ratio: 9 / 16; }
}
