/**
 * Interactive Vector Tutorial Viewer Styles
 */

/*
 * Brand tokens, declared on the viewer itself.
 *
 * This file was themed in a green (#2c5530 / #1e3d22) that appears nowhere else
 * in the brand. The tokens are defined here rather than borrowed from the chat
 * widget because the viewer also runs inside wp-admin, where the widget's
 * variables do not exist.
 */
.ts-tutorial-viewer {
    --tsv-gold: #b8935f;
    --tsv-gold-dark: #9a7a4d;
    --tsv-black: #2b2b2b;
}

.ts-tutorial-viewer {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    margin: 24px 0;
}

.ts-tutorial-header {
    background: linear-gradient(135deg, var(--tsv-gold) 0%, var(--tsv-black) 100%);
    color: white;
    padding: 24px 32px;
    border-bottom: 3px solid rgba(255,255,255,0.1);
}

.ts-tutorial-title {
    margin: 0 0 16px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.ts-step-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.ts-nav-btn {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}

.ts-nav-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-2px);
}

.ts-nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ts-step-indicator {
    font-size: 16px;
    font-weight: 600;
    padding: 10px 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.ts-step-content {
    padding: 32px;
}

.ts-step-title {
    margin-bottom: 32px;
}

.ts-step-num {
    display: inline-block;
    background: linear-gradient(135deg, var(--tsv-gold) 0%, var(--tsv-black) 100%);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
    margin-right: 12px;
}

.ts-step-title h3 {
    display: inline;
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
}

.ts-panels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 28px;
}

.ts-panel-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0,0,0,0.06);
}

.ts-panel-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(44, 85, 48, 0.15);
}

.ts-panel-viewer {
    background: linear-gradient(135deg, #f5f5f5 0%, #e9ecef 100%);
    padding: 24px;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ts-panel-viewer svg {
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.1));
}

.ts-panel-loading {
    color: #999;
    font-size: 14px;
    text-align: center;
}

.ts-panel-error {
    color: #d32f2f;
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.ts-panel-caption {
    padding: 20px;
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: #333;
    background: white;
}

.ts-tutorial-footer {
    background: #f8f9fa;
    padding: 24px 32px;
    border-top: 1px solid rgba(0,0,0,0.08);
    display: flex;
    gap: 16px;
    align-items: center;
}

.ts-replay-btn,
.ts-download-link {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    text-decoration: none;
}

.ts-replay-btn {
    background: var(--tsv-gold);
    color: white;
    border: none;
}

.ts-replay-btn:hover {
    background: var(--tsv-black);
    transform: scale(1.02);
}

.ts-download-link {
    background: white;
    color: var(--tsv-gold);
    border: 2px solid var(--tsv-gold);
}

.ts-download-link:hover {
    background: var(--tsv-gold);
    color: white;
}

.ts-tutorial-error {
    padding: 60px 32px;
    text-align: center;
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
}

.ts-tutorial-error p {
    margin: 8px 0;
    font-size: 16px;
}

.ts-error-detail {
    color: #666;
    font-size: 14px !important;
}

/* Component animation classes */
.ts-cmp {
    transform-origin: center;
}

/* Responsive */
@media (max-width: 768px) {
    .ts-tutorial-header {
        padding: 20px;
    }

    .ts-tutorial-title {
        font-size: 22px;
    }

    .ts-step-nav {
        flex-direction: column;
    }

    .ts-nav-btn {
        width: 100%;
        justify-content: center;
    }

    .ts-step-content {
        padding: 20px;
    }

    .ts-panels-grid {
        grid-template-columns: 1fr;
    }

    .ts-tutorial-footer {
        flex-direction: column;
    }

    .ts-replay-btn,
    .ts-download-link {
        width: 100%;
        justify-content: center;
    }
}

/* ---------------------------------------------------------------------------
   Interaction: highlight, isolate, zoom, scrub
   Built on the <g class="ts-cmp" data-cmp data-cx data-cy> groups the
   Illustrator extraction already produced, so every part is addressable
   without touching the artwork.
   --------------------------------------------------------------------------- */

.ts-panel-viewer {
    position: relative;
    overflow: hidden;
    touch-action: none;
}

.ts-panel-viewer svg.ts-interactive {
    transition: transform 0.12s ease-out;
    will-change: transform;
    max-width: 100%;
}

.ts-panel-viewer.is-zoomed { cursor: grab; }
.ts-panel-viewer.is-panning { cursor: grabbing; }
.ts-panel-viewer.is-panning svg.ts-interactive { transition: none; }

/* Hovering one part fades the rest back so it reads as a single component
   rather than a highlight lost in a busy line drawing. */
.ts-cmp { transition: opacity 0.18s ease, filter 0.18s ease; }

svg.ts-hovering .ts-cmp { opacity: 0.28; }
svg.ts-hovering .ts-cmp.ts-cmp-hover {
    opacity: 1;
    filter: drop-shadow(0 0 3px var(--tsv-gold, #b8935f));
}

svg.ts-isolating .ts-cmp { opacity: 0.12; }
svg.ts-isolating .ts-cmp.ts-cmp-isolated {
    opacity: 1;
    filter: drop-shadow(0 0 4px var(--tsv-gold, #b8935f));
}

.ts-panel-viewer.is-isolating::after {
    content: 'Click anywhere to show the whole step';
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    background: rgba(43, 43, 43, 0.88);
    color: var(--tsv-gold, #b8935f);
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 10px;
    white-space: nowrap;
    pointer-events: none;
}

.ts-step-scrubber {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.ts-step-dot {
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 13px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: transparent;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ts-step-dot:hover {
    background: rgba(255, 255, 255, 0.16);
}

.ts-step-dot.is-current {
    background: var(--tsv-gold, #b8935f);
    border-color: var(--tsv-gold, #b8935f);
    color: var(--tsv-black, #2b2b2b);
}

/* ---------------------------------------------------------------------------
   Mounted inside the chat
   --------------------------------------------------------------------------- */

.ts-tutorial {
    margin: 12px 0;
    border: 1px solid #e8e2d8;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.ts-tutorial-head {
    background: var(--tsv-black, #2b2b2b);
    color: #fff;
    padding: 10px 14px;
    border-bottom: 3px solid var(--tsv-gold, #b8935f);
}

.ts-tutorial-heading {
    display: block;
    font-weight: 700;
    font-size: 14px;
}

.ts-tutorial-sub {
    display: block;
    color: var(--tsv-gold, #b8935f);
    font-size: 11px;
    margin-top: 2px;
}

/* Inside the chat the viewer supplies its own chrome, so drop the outer
   margin and shadow it uses when it stands alone on an admin screen. */
.ts-tutorial-mount .ts-tutorial-viewer {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
    .ts-cmp,
    .ts-panel-viewer svg.ts-interactive {
        transition: none;
    }
}
