/**
 * Timeline Process - Styles Frontend & Backend
 * Version: 1.0.8
 * Author: Menhirprod
 */

/* ==========================================================================
   Timeline Container (ol element with scoped CSS variables)
   ========================================================================== */

.tpg-timeline {
    /* Scoped CSS variables - no global :root pollution */
    --tpg-accent: #0073aa;
    --tpg-spacing: 2rem;
    --tpg-border-color: #e5e5e5;
    --tpg-text-primary: #1e1e1e;
    --tpg-text-secondary: #666;
    --tpg-bg-light: #f5f5f5;
    --tpg-transition: all 0.3s ease;
    
    /* Layout */
    display: flex;
    gap: var(--tpg-spacing);
    padding: 2rem 0;
    margin: 0;
    list-style: none;
    position: relative;
}

/* Horizontal orientation (default) */
.tpg-timeline--horizontal {
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--tpg-accent) var(--tpg-bg-light);
}

.tpg-timeline--horizontal .tpg-step {
    flex: 1 1 250px;
    min-width: 250px;
    max-width: 350px;
    scroll-snap-align: start;
}

/* Vertical orientation */
.tpg-timeline--vertical {
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
}

.tpg-timeline--vertical .tpg-step {
    flex: none;
    width: 100%;
}

/* ==========================================================================
   Step Container (li element)
   ========================================================================== */

.tpg-step {
    position: relative;
    padding: 1.5rem;
    background: #fff;
    border: 2px solid var(--tpg-border-color);
    border-radius: 12px;
    transition: var(--tpg-transition);
}

/* Hide default list marker */
.tpg-step::marker {
    content: none;
}

/* Custom number display using CSS counter from value attribute */
.tpg-step::before {
    content: attr(value);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--tpg-accent);
    color: #fff;
    font-weight: 700;
    font-size: 1.125rem;
    border-radius: 50%;
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: var(--tpg-transition);
    z-index: 1;
}

.tpg-step:hover {
    border-color: var(--tpg-accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-4px);
}

.tpg-step:hover::before {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}

/* Connection line between steps - Horizontal */
.tpg-timeline--horizontal .tpg-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 50%;
    right: calc(-1 * var(--tpg-spacing));
    width: var(--tpg-spacing);
    height: 2px;
    background: linear-gradient(
        to right,
        var(--tpg-accent) 0%,
        var(--tpg-accent) 50%,
        transparent 50%,
        transparent 100%
    );
    background-size: 8px 2px;
    transform: translateY(-50%);
    z-index: 0;
}

/* Connection line between steps - Vertical */
.tpg-timeline--vertical .tpg-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 2.5rem;
    bottom: calc(-1 * var(--tpg-spacing));
    width: 2px;
    height: var(--tpg-spacing);
    background: linear-gradient(
        to bottom,
        var(--tpg-accent) 0%,
        var(--tpg-accent) 50%,
        transparent 50%,
        transparent 100%
    );
    background-size: 2px 8px;
    z-index: 0;
}

/* ==========================================================================
   Step Header (Icon)
   ========================================================================== */

.tpg-step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-left: 56px; /* Space for the number */
}

/* When no icon is rendered, remove header spacing so the title aligns with the number */
.tpg-step-header:empty {
    margin-bottom: 0;
}


.tpg-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    font-size: 1.5rem; /* emoji */
    line-height: 1;
    color: var(--tpg-text-primary);
}

.tpg-step-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* ==========================================================================
   Step Content
   ========================================================================== */

.tpg-step-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-left: 56px; /* Align with header */
}

.tpg-step-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--tpg-text-primary);
}

.tpg-step-description {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--tpg-text-secondary);
}

.tpg-step-duration {
    display: inline-block;
    padding: 0.375rem 0.875rem;
    background: var(--tpg-bg-light);
    color: var(--tpg-accent);
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 16px;
    margin-top: 0.5rem;
    transition: var(--tpg-transition);
    width: fit-content;
}

.tpg-step:hover .tpg-step-duration {
    background: var(--tpg-accent);
    color: #fff;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    /* Force vertical layout on mobile */
    .tpg-timeline--horizontal {
        flex-direction: column;
        overflow-x: visible;
    }

    .tpg-timeline--horizontal .tpg-step {
        min-width: 100%;
        max-width: 100%;
    }

    /* Adjust connection lines for mobile */
    .tpg-timeline--horizontal .tpg-step:not(:last-child)::after {
        top: auto;
        right: auto;
        left: 2.5rem;
        bottom: calc(-1 * var(--tpg-spacing));
        width: 2px;
        height: var(--tpg-spacing);
        background: linear-gradient(
            to bottom,
            var(--tpg-accent) 0%,
            var(--tpg-accent) 50%,
            transparent 50%,
            transparent 100%
        );
        background-size: 2px 8px;
    }

    .tpg-step {
        padding: 1.25rem;
    }

    .tpg-step-title {
        font-size: 1.125rem;
    }

    .tpg-step-description {
        font-size: 0.875rem;
    }

    .tpg-step-header,
    .tpg-step-content {
        padding-left: 52px; /* Slightly less padding on mobile */
    }
}

@media (max-width: 480px) {
    .tpg-timeline {
        padding: 1rem 0;
    }

    .tpg-step {
        padding: 1rem;
    }

    .tpg-step::before {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        top: 1rem;
        left: 1rem;
    }

    .tpg-step-icon {
        font-size: 1.25rem;
    }

    .tpg-step-header,
    .tpg-step-content {
        padding-left: 48px;
    }

    .tpg-timeline--vertical .tpg-step:not(:last-child)::after {
        left: 2rem;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .tpg-timeline {
        flex-direction: column;
        gap: 1.5rem;
    }

    .tpg-step {
        break-inside: avoid;
        box-shadow: none !important;
        transform: none !important;
    }

    .tpg-step::after {
        display: none;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* High contrast mode */
@media (prefers-contrast: high) {
    .tpg-step {
        border-width: 3px;
    }

    .tpg-step::before {
        border: 2px solid #fff;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tpg-timeline *,
    .tpg-step,
    .tpg-step::before,
    .tpg-step-duration {
        transition: none !important;
        animation: none !important;
    }

    .tpg-step:hover {
        transform: none;
    }

    .tpg-step:hover::before {
        transform: none;
    }
}

/* Focus states for keyboard navigation */
/* Note: tabIndex={0} is added to <li> elements when enableKeyboardFocus is true */
/* This makes each step focusable via Tab key, improving accessibility */
/* :focus-visible only shows outline for keyboard navigation, not mouse clicks */
.tpg-step:focus-visible {
    outline: 3px solid var(--tpg-accent);
    outline-offset: 4px;
}

/* ==========================================================================
   Editor-specific styles (Gutenberg backend)
   ========================================================================== */

.wp-block-tpg-timeline-process .tpg-step-header {
    /* Allow controls to show properly in editor */
    z-index: 2;
}
