/* tutorial.css
 * Right-side interactive tutorial wizard for app.php.
 *
 * The panel is a normal positioned child of the workspace, not a full-screen
 * overlay: there is no backdrop, so every app control outside the card stays
 * clickable. The header/body/footer are a three-row flex column; only the body
 * scrolls, which keeps Back/Next pinned to the bottom edge of the card.
 */

.tutorial-wizard {
    position: absolute;
    top: 156px; /* 20px gap + 120px perspective cube + 16px gap */
    right: 20px;
    z-index: 900; /* above the canvas and cursor bar, below real modals */
    display: flex;
    flex-direction: column;
    width: min(344px, calc(100% - 40px));
    max-height: calc(100% - 176px);
    overflow: hidden;
    border: 1px solid var(--border-default);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
}

.tutorial-wizard.hidden,
.tutorial-wizard .hidden {
    display: none !important;
}

.tutorial-wizard:focus {
    outline: none;
}

.tutorial-wizard :focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.tutorial-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Thin progress line across the top of the card. */
.tutorial-wizard-progress {
    flex: 0 0 auto;
    height: 3px;
    background: var(--border-subtle);
}

#tutorial-progress-fill {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    transition: width 0.25s ease;
}

.tutorial-wizard-header {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 14px 11px 16px;
    background: var(--surface-bar);
    border-bottom: 1px solid var(--border-subtle);
}

.tutorial-wizard-identity {
    min-width: 0;
}

.tutorial-wizard-eyebrow {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 0 3px;
    color: var(--text-link);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.09em;
    line-height: 1.4;
    text-transform: uppercase;
}

.tutorial-wizard-eyebrow .tutorial-wizard-sep {
    color: var(--text-dim);
    font-weight: 400;
}

#tutorial-title {
    margin: 0;
    color: var(--text-strong);
    font-size: 1rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.tutorial-wizard-subtitle {
    margin: 4px 0 0;
    color: var(--text-body);
    font-size: 0.72rem;
    line-height: 1.45;
}

.tutorial-wizard-compact-meta {
    display: none;
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
}

.tutorial-wizard-controls {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
    margin-top: -2px;
}

.tutorial-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tutorial-icon-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s ease;
}

.tutorial-icon-btn:hover {
    border-color: var(--border-subtle);
    background: var(--surface-hover);
    color: var(--text-strong);
}

.tutorial-icon-btn:active {
    background: var(--surface-active);
}

/* Tutorial switcher + step counter. */
.tutorial-wizard-toolbar {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 14px 9px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--surface-raised);
}

.tutorial-switcher-wrap {
    position: relative;
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
}

.tutorial-switcher {
    width: 100%;
    min-width: 0;
    height: 28px;
    padding: 0 24px 0 8px;
    border: 1px solid var(--border-default);
    border-radius: 5px;
    background-color: var(--surface-deep);
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 12px) 12px, calc(100% - 8px) 12px;
    background-repeat: no-repeat;
    background-size: 4px 4px, 4px 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    appearance: none;
    cursor: pointer;
}

.tutorial-switcher:focus-visible {
    border-color: #3b82f6;
}

.tutorial-step-label {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* Scrolling step body. */
.tutorial-wizard-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 15px 18px 18px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.tutorial-wizard-body::-webkit-scrollbar {
    width: 8px;
}

.tutorial-wizard-body::-webkit-scrollbar-track {
    background: transparent;
}

.tutorial-wizard-body::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: var(--border-strong);
    background-clip: content-box;
}

.tutorial-step-kicker {
    margin: 0 0 3px;
    color: var(--text-link);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    line-height: 1.4;
    text-transform: uppercase;
}

.tutorial-step-title {
    margin: 0 0 10px;
    color: var(--text-strong);
    font-size: 1.02rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.tutorial-step-title:focus {
    outline: none;
}

.tutorial-step-copy {
    color: var(--text-body);
    font-size: 0.8rem;
    line-height: 1.6;
}

.tutorial-step-copy p {
    margin: 0 0 10px;
}

.tutorial-step-copy p:last-child,
.tutorial-step-copy ul:last-child {
    margin-bottom: 0;
}

.tutorial-step-copy strong {
    color: var(--text-primary);
    font-weight: 650;
}

.tutorial-step-copy ul,
.tutorial-step-copy ol {
    margin: 0 0 10px;
    padding-left: 18px;
}

.tutorial-step-copy li {
    margin-bottom: 4px;
}

.tutorial-step-copy a {
    color: var(--text-link);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Inline UI labels: "Front", "Apply", "Finger Count". */
.tutorial-ui {
    display: inline-flex;
    align-items: center;
    padding: 0 5px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    background: var(--surface-elevated);
    color: var(--text-primary);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.45;
    white-space: nowrap;
}

.tutorial-tip {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding: 9px 10px;
    border-left: 2px solid #3b82f6;
    border-radius: 0 6px 6px 0;
    background: var(--surface-inset);
    color: var(--text-muted);
    font-size: 0.73rem;
    line-height: 1.5;
}

.tutorial-tip-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    border-radius: 999px;
    background: var(--surface-accent-soft);
    color: var(--text-link);
    font-size: 10px;
    font-style: italic;
    font-weight: 700;
}

.tutorial-tip p {
    margin: 0;
}

/* Sticky footer: body content scrolls underneath these controls. */
.tutorial-wizard-footer {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 14px 12px 16px;
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-bar);
}

.tutorial-guide-link {
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: nowrap;
}

.tutorial-guide-link:hover {
    color: var(--text-link);
}

.tutorial-wizard-nav {
    display: flex;
    flex: 0 0 auto;
    gap: 7px;
}

.tutorial-btn {
    min-width: 66px;
    height: 31px;
    padding: 0 12px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.73rem;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tutorial-btn:disabled,
.tutorial-btn[aria-disabled="true"] {
    opacity: 0.42;
    cursor: not-allowed;
}

.tutorial-btn--back {
    background: var(--surface-elevated);
    color: var(--text-body);
}

.tutorial-btn--back:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    color: var(--text-strong);
}

.tutorial-btn--next {
    border-color: #2563eb;
    background: #2563eb;
    color: #ffffff;
}

.tutorial-btn--next:hover {
    border-color: #1d4ed8;
    background: #1d4ed8;
}

.tutorial-btn--next:active {
    background: #1e40af;
}

/* Minimised state exposes just the title, progress and two window controls. */
.tutorial-wizard.is-minimized {
    width: min(286px, calc(100% - 40px));
    max-height: none;
}

.tutorial-wizard.is-minimized .tutorial-wizard-header {
    align-items: center;
    padding: 10px 12px 10px 14px;
    border-bottom: none;
}

.tutorial-wizard.is-minimized .tutorial-wizard-eyebrow,
.tutorial-wizard.is-minimized .tutorial-wizard-subtitle,
.tutorial-wizard.is-minimized .tutorial-wizard-toolbar,
.tutorial-wizard.is-minimized .tutorial-wizard-body,
.tutorial-wizard.is-minimized .tutorial-wizard-footer {
    display: none;
}

.tutorial-wizard.is-minimized .tutorial-wizard-compact-meta {
    display: block;
}

.tutorial-wizard.is-minimized #tutorial-title {
    overflow: hidden;
    font-size: 0.84rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tutorial-wizard.is-minimized #tutorial-minimize svg {
    transform: rotate(180deg);
}

.tutorial-wizard.is-minimized .tutorial-wizard-controls {
    margin-top: 0;
}

@media (max-width: 1100px) {
    .tutorial-wizard {
        top: 148px;
        right: 14px;
        width: min(314px, calc(100% - 28px));
        max-height: calc(100% - 164px);
    }
}

@media (max-width: 900px) {
    .tutorial-wizard {
        top: auto;
        right: 12px;
        bottom: 74px;
        left: 12px;
        width: auto;
        max-height: min(58vh, 460px);
    }

    .tutorial-wizard.is-minimized {
        right: 12px;
        left: auto;
        width: min(286px, calc(100% - 24px));
    }
}

@media (max-width: 560px) {
    .tutorial-wizard {
        bottom: 68px;
        max-height: 54vh;
        border-radius: 9px;
    }

    .tutorial-wizard-header {
        padding: 11px 12px 9px 14px;
    }

    .tutorial-wizard-toolbar {
        padding: 8px 12px;
    }

    .tutorial-wizard-body {
        padding: 13px 14px 15px;
    }

    .tutorial-wizard-footer {
        padding: 9px 12px 10px;
        gap: 8px;
    }

    .tutorial-guide-link {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tutorial-wizard,
    .tutorial-wizard * {
        transition: none !important;
        animation: none !important;
    }
}

/* --- "Show me where" ------------------------------------------------ */

.tutorial-showme-row {
    display: flex;
    justify-content: flex-start;
    margin-top: 13px;
}

.tutorial-showme {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border: 1px solid var(--border-default);
    border-radius: 6px;
    background: var(--surface-elevated);
    color: var(--text-link);
    font: inherit;
    font-size: 0.71rem;
    font-weight: 650;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tutorial-showme svg {
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
}

.tutorial-showme:hover {
    border-color: #3b82f6;
    background: var(--surface-hover);
    color: var(--text-strong);
}

.tutorial-showme:active {
    background: var(--surface-active);
}

.tutorial-showme:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

/* The highlight layers are fixed and pointer-events:none. Nothing in the
   ribbon, side panel or modal gets a border, margin or transform, so the
   surrounding interface cannot move while the hint pulses. */
.tutorial-highlight-ring {
    position: fixed;
    z-index: 9500;
    box-sizing: border-box;
    border: 2px solid #2563eb;
    border-radius: 7px;
    pointer-events: none;
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.9),
        0 0 0 6px rgba(37, 99, 235, 0.3),
        0 0 22px rgba(37, 99, 235, 0.55);
    transform-origin: center;
    animation:
        tutorial-highlight-pulse 0.55s ease-in-out 3,
        tutorial-highlight-fade 0.3s ease 1.65s forwards;
}

.tutorial-highlight-ring.is-workspace {
    /* Sits above the 3D canvas but below the tutorial card, so the ring is
       never painted across the card when the 3D view is the target. */
    z-index: 850;
    border-style: dashed;
    border-radius: 9px;
    box-shadow:
        0 0 0 3px rgba(37, 99, 235, 0.16),
        0 0 24px rgba(37, 99, 235, 0.24);
}

.tutorial-highlight-arrow {
    position: fixed;
    z-index: 9501;
    width: 0;
    height: 0;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.4));
    animation:
        tutorial-highlight-arrow-bob 0.55s ease-in-out 3,
        tutorial-highlight-fade 0.3s ease 1.65s forwards;
}

.tutorial-highlight-arrow.is-below-target {
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 11px solid #2563eb;
}

.tutorial-highlight-arrow.is-above-target {
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 11px solid #2563eb;
}

@keyframes tutorial-highlight-pulse {
    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.012);
    }
}

@keyframes tutorial-highlight-arrow-bob {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-3px);
    }
}

@keyframes tutorial-highlight-fade {
    to {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tutorial-highlight-ring,
    .tutorial-highlight-arrow {
        animation: none !important;
        opacity: 1;
    }
}
