/* ===========================================================================
 * LinkGuard.ai unified hint system — visual layer.
 *
 * Spec: ai_docs/design/onboarding-and-hints.md §2.3.
 *
 * Phase 2 ships:
 *   .hint-trigger          — universal help-circle glyph (Tier 3 entry point)
 *   .hint-tooltip          — passive tooltip popover (Tier 3)
 *
 * Phase 3 will add: .onboarding-card, .onboarding-backdrop, spotlight pulse.
 * Phase 4 will add: .recurring-nudge, .empty-state.
 *
 * Motion vocabulary: calm-motion only here. No glitch, no pulse, no float.
 * Reduced-motion users get the static fallback at the bottom of the file.
 * ========================================================================= */

/* ---------------------------------------------------------------------------
 * .hint-trigger — Lucide help-circle, 14px, subtle cyan
 * ------------------------------------------------------------------------- */
.hint-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    padding: 2px;
    color: rgba(0, 245, 212, 0.4);
    cursor: help;
    border-radius: 50%;
    background: transparent;
    transition: color 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
                box-shadow 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
    vertical-align: middle;
}

.hint-trigger:hover,
.hint-trigger:focus,
.hint-trigger:focus-visible {
    color: var(--neon-cyan, #00f5d4);
    box-shadow: 0 0 6px rgba(0, 245, 212, 0.45);
    outline: none;
}

.hint-trigger:focus-visible {
    /* 1-px focus ring 2-px outside the glyph for keyboard users. */
    box-shadow: 0 0 6px rgba(0, 245, 212, 0.45),
                0 0 0 2px rgba(0, 245, 212, 0.6);
}

.hint-trigger svg {
    width: 14px;
    height: 14px;
    display: block;
    pointer-events: none;
}

/* Slightly bigger inside dense forms (16px instead of 14px). */
.hint-trigger--lg {
    width: 20px;
    height: 20px;
}
.hint-trigger--lg svg {
    width: 16px;
    height: 16px;
}

/* ---------------------------------------------------------------------------
 * .hint-tooltip — passive popover (Tier 3)
 * ------------------------------------------------------------------------- */
.hint-tooltip {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 200;                          /* above content, below modals (--z-dropdown=110, --z-modal=2000) */
    max-width: 280px;
    min-width: 180px;
    padding: 12px 14px;
    background: rgba(15, 15, 25, 0.96);
    border: 1px solid rgba(0, 245, 212, 0.35);
    color: var(--text-primary, #ffffff);
    font-family: var(--font-body, 'Rajdhani', sans-serif);
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0.2px;
    /* Cyberpunk clipped corner — top-right + bottom-left. */
    clip-path: polygon(
        0 0,
        calc(100% - 8px) 0,
        100% 8px,
        100% 100%,
        8px 100%,
        0 calc(100% - 8px)
    );
    box-shadow:
        0 0 18px rgba(0, 245, 212, 0.18),
        0 6px 24px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(4px);
    transition:
        opacity 150ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        transform 150ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
    pointer-events: none;
}

.hint-tooltip[data-state="open"] {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.hint-tooltip__title {
    display: block;
    margin: 0 0 4px;
    font-family: var(--font-display, 'Orbitron', monospace);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--neon-cyan, #00f5d4);
}

.hint-tooltip__body {
    margin: 0;
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
    font-size: 14px;
    line-height: 1.5;
}

.hint-tooltip__example {
    margin-top: 8px;
    padding: 6px 8px;
    background: rgba(0, 245, 212, 0.06);
    border-left: 2px solid var(--neon-cyan, #00f5d4);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 12px;
    color: var(--text-muted, rgba(255, 255, 255, 0.55));
    word-break: break-all;
}

/* ---------------------------------------------------------------------------
 * Mobile (<768px) — hint-tooltip becomes tap-to-open and slightly tighter.
 * ------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .hint-tooltip {
        max-width: calc(100vw - 32px);
        min-width: 0;
        font-size: 13px;
    }
    .hint-trigger {
        width: 22px;
        height: 22px;          /* easier to tap */
    }
}

/* ===========================================================================
 * Tier-1 onboarding tour (Phase 3) — backdrop + spotlight + card
 * ========================================================================= */

/* ---------------------------------------------------------------------------
 * .onboarding-backdrop — full-viewport dim with subtle blur
 * ------------------------------------------------------------------------- */
.onboarding-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.72);
    z-index: 1900;
    opacity: 0;
    transition: opacity 250ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
    pointer-events: auto;
    cursor: default;
}
.onboarding-backdrop[data-state="open"] { opacity: 1; }
.onboarding-backdrop[data-state="open"] {
    opacity: 1;
}

/* ---------------------------------------------------------------------------
 * Spotlight — applied directly to the target element via data attribute.
 * Lifts the element above the backdrop and pulses a calm cyan halo.
 * ------------------------------------------------------------------------- */
@keyframes hint-spotlight-pulse {
    0%, 100% {
        box-shadow:
            0 0 0 3px rgba(0, 245, 212, 0.95),
            0 0 0 8px rgba(0, 245, 212, 0.35),
            0 0 32px 10px rgba(0, 245, 212, 0.6),
            0 0 80px 28px rgba(0, 245, 212, 0.3);
    }
    50% {
        box-shadow:
            0 0 0 4px rgba(0, 245, 212, 1),
            0 0 0 14px rgba(0, 245, 212, 0.25),
            0 0 56px 20px rgba(0, 245, 212, 0.8),
            0 0 140px 50px rgba(0, 245, 212, 0.4);
    }
}

[data-hint-spotlight="active"] {
    position: relative;
    z-index: 1950;                          /* above backdrop, below card */
    animation: hint-spotlight-pulse 1.8s ease-in-out infinite;
    outline: 4px solid #00f5d4 !important;
    outline-offset: 4px;
    /* Background tint lifts the element out of the dimmed surroundings. */
    background-color: rgba(0, 245, 212, 0.10) !important;
    border-color: #00f5d4 !important;
    border-radius: inherit;
}

/* Bloom ring drawn as a sibling-positioned pseudo-element. We use a solid
 * cyan radial gradient inside ::before — it paints regardless of the
 * element's own background opacity, and unlike box-shadow it isn't clipped
 * by parents that might create stacking quirks. ::before sits inside the
 * spotlight element's stacking context (z-index 1950), so it always
 * paints above the backdrop (z-index 1900). */
[data-hint-spotlight="active"]::before {
    content: "";
    position: absolute;
    inset: -40px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(0, 245, 212, 0.55) 0%,
        rgba(0, 245, 212, 0.25) 40%,
        rgba(0, 245, 212, 0) 70%
    );
    pointer-events: none;
    z-index: -1;
    animation: hint-spotlight-bloom 1.8s ease-in-out infinite;
    filter: blur(12px);
}

@keyframes hint-spotlight-bloom {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.1); }
}

/* Form fields specifically: brighten the input itself so the user can
   actually see what they need to fill in. */
input[data-hint-spotlight="active"],
textarea[data-hint-spotlight="active"] {
    background-color: rgba(0, 245, 212, 0.08) !important;
    border-color: var(--neon-cyan, #00f5d4) !important;
    color: #ffffff !important;
}

/* Buttons: strong cyan tint so the call-to-action reads from across the page. */
button[data-hint-spotlight="active"],
a[data-hint-spotlight="active"] {
    filter: brightness(1.15);
}

/* ---------------------------------------------------------------------------
 * .onboarding-card — bottom-right step card
 * ------------------------------------------------------------------------- */
.onboarding-card {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 48px);
    background: var(--bg-card, rgba(15, 15, 25, 0.96));
    border: 1px solid rgba(0, 245, 212, 0.4);
    clip-path: polygon(
        0 0,
        calc(100% - 14px) 0,
        100% 14px,
        100% 100%,
        14px 100%,
        0 calc(100% - 14px)
    );
    box-shadow:
        0 0 30px rgba(0, 245, 212, 0.18),
        0 12px 40px rgba(0, 0, 0, 0.55);
    padding: 20px 22px 18px;
    z-index: 3000;                          /* --z-toast — above modals */
    transform: translateY(120%);
    opacity: 0;
    transition:
        transform 350ms var(--ease-smooth, cubic-bezier(0.4, 0, 0.2, 1)),
        opacity 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}
.onboarding-card[data-state="open"] {
    transform: translateY(0);
    opacity: 1;
}

/* Adaptive: when spotlight target lives in the lower half of the viewport,
 * the card flips to the top-right so the two don't overlap. Triggered by
 * JS adding .onboarding-card--top. */
.onboarding-card--top {
    bottom: auto !important;
    /* Clear the fixed dashboard header (~64px) so the card never overlaps the
     * notification bell / avatar when it flips to the top-right. */
    top: 84px;
    transform: translateY(-180%);
}
.onboarding-card--top[data-state="open"] {
    transform: translateY(0);
}

/* Final-step variant — center the card and make it a touch wider. */
.onboarding-card--final {
    bottom: auto;
    right: auto;
    top: 50%;
    left: 50%;
    width: 420px;
    transform: translate(-50%, -42%) scale(0.96);
    text-align: center;
}
.onboarding-card--final[data-state="open"] {
    transform: translate(-50%, -50%) scale(1);
}

.onboarding-card__step {
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 11px;
    color: var(--neon-cyan, #00f5d4);
    letter-spacing: 2px;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.onboarding-card__title {
    font-family: var(--font-display, 'Orbitron', monospace);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
    color: var(--text-primary, #ffffff);
}

.onboarding-card__body {
    font-family: var(--font-body, 'Rajdhani', sans-serif);
    font-size: 14px;
    color: var(--text-secondary, rgba(255, 255, 255, 0.75));
    line-height: 1.55;
    margin: 0 0 14px;
}

.onboarding-card__progress {
    display: flex;
    gap: 4px;
    margin: 0 0 14px;
}
.onboarding-card__progress span {
    flex: 1;
    height: 3px;
    background: rgba(0, 245, 212, 0.15);
    transition: background 300ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}
.onboarding-card__progress span.is-done {
    background: var(--neon-cyan, #00f5d4);
}
.onboarding-card__progress span.is-active {
    background: var(--neon-cyan, #00f5d4);
    box-shadow: 0 0 6px rgba(0, 245, 212, 0.55);
}

.onboarding-card__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.onboarding-card--final .onboarding-card__actions {
    justify-content: center;
}

.onboarding-card__btn {
    font-family: var(--font-display, 'Orbitron', monospace);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 10px 18px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
    cursor: pointer;
    transition:
        background 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        border-color 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        color 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        box-shadow 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
    clip-path: polygon(
        0 0,
        calc(100% - 6px) 0,
        100% 6px,
        100% 100%,
        6px 100%,
        0 calc(100% - 6px)
    );
}

.onboarding-card__btn--ghost {
    border-color: rgba(255, 255, 255, 0.15);
}
.onboarding-card__btn--ghost:hover,
.onboarding-card__btn--ghost:focus-visible {
    color: var(--text-primary, #fff);
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.05);
}

.onboarding-card__btn--primary {
    background: rgba(0, 245, 212, 0.12);
    border-color: var(--neon-cyan, #00f5d4);
    color: var(--neon-cyan, #00f5d4);
}
.onboarding-card__btn--primary:hover,
.onboarding-card__btn--primary:focus-visible {
    background: rgba(0, 245, 212, 0.22);
    box-shadow: 0 0 14px rgba(0, 245, 212, 0.45);
    color: #fff;
}

/* ---------------------------------------------------------------------------
 * Mobile (<768px) — card becomes a bottom sheet
 * ------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .onboarding-card {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        padding: 18px 16px 16px;
        clip-path: polygon(
            0 0,
            calc(100% - 14px) 0,
            100% 14px,
            100% 100%,
            0 100%
        );
    }
    .onboarding-card--final {
        top: auto;
        left: 0;
        bottom: 0;
        transform: translateY(120%);
    }
    .onboarding-card--final[data-state="open"] {
        transform: translateY(0);
    }
}

/* ===========================================================================
 * Tier-2 recurring nudge (Phase 4) — bottom-right slide-in
 * ========================================================================= */
.recurring-nudge {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    max-width: calc(100vw - 48px);
    background: var(--bg-card, rgba(15, 15, 25, 0.96));
    border: 1px solid rgba(0, 245, 212, 0.4);
    clip-path: polygon(
        0 0,
        calc(100% - 12px) 0,
        100% 12px,
        100% 100%,
        12px 100%,
        0 calc(100% - 12px)
    );
    box-shadow:
        0 0 24px rgba(0, 245, 212, 0.15),
        0 12px 32px rgba(0, 0, 0, 0.5);
    padding: 16px 18px 14px;
    z-index: 2800;                                          /* below modals/toasts */
    transform: translateX(120%);
    opacity: 0;
    transition:
        transform 350ms var(--ease-smooth, cubic-bezier(0.4, 0, 0.2, 1)),
        opacity 200ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}
.recurring-nudge[data-state="open"] {
    transform: translateX(0);
    opacity: 1;
}

.recurring-nudge__title {
    font-family: var(--font-display, 'Orbitron', monospace);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--neon-cyan, #00f5d4);
    margin: 0 0 6px;
}
.recurring-nudge__body {
    font-family: var(--font-body, 'Rajdhani', sans-serif);
    font-size: 13px;
    color: var(--text-secondary, rgba(255, 255, 255, 0.75));
    line-height: 1.5;
    margin: 0 0 12px;
}
.recurring-nudge__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.recurring-nudge__btn {
    font-family: var(--font-display, 'Orbitron', monospace);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 8px 14px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition:
        background 180ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        color 180ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        border-color 180ms var(--ease-out, cubic-bezier(0.25, 0.46, 0.45, 0.94));
    clip-path: polygon(
        0 0,
        calc(100% - 5px) 0,
        100% 5px,
        100% 100%,
        5px 100%,
        0 calc(100% - 5px)
    );
}
.recurring-nudge__btn--ghost {
    border-color: rgba(255, 255, 255, 0.15);
}
.recurring-nudge__btn--ghost:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}
.recurring-nudge__btn--primary {
    background: rgba(0, 245, 212, 0.12);
    border-color: var(--neon-cyan, #00f5d4);
    color: var(--neon-cyan, #00f5d4);
}
.recurring-nudge__btn--primary:hover {
    background: rgba(0, 245, 212, 0.22);
    color: #fff;
    box-shadow: 0 0 12px rgba(0, 245, 212, 0.4);
}

@media (max-width: 767px) {
    .recurring-nudge {
        bottom: 12px;
        right: 12px;
        left: 12px;
        width: auto;
    }
}

/* ===========================================================================
 * Empty state (Phase 4) — calm invitation when there's no data yet
 * ========================================================================= */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
}
.empty-state__icon {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    color: var(--neon-cyan, #00f5d4);
    opacity: 0.6;
}
.empty-state__icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 1.4;
}
.empty-state__title {
    font-family: var(--font-display, 'Orbitron', monospace);
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-primary, #fff);
    margin: 0 0 8px;
}
.empty-state__body {
    font-family: var(--font-body, 'Rajdhani', sans-serif);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted, rgba(255, 255, 255, 0.55));
    margin: 0 0 20px;
    max-width: 380px;
}
.empty-state__cta {
    font-family: var(--font-display, 'Orbitron', monospace);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 10px 18px;
    border: 1px solid var(--neon-cyan, #00f5d4);
    background: rgba(0, 245, 212, 0.10);
    color: var(--neon-cyan, #00f5d4);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 180ms ease, box-shadow 180ms ease, color 180ms ease;
    clip-path: polygon(
        0 0,
        calc(100% - 6px) 0,
        100% 6px,
        100% 100%,
        6px 100%,
        0 calc(100% - 6px)
    );
}
.empty-state__cta:hover {
    background: rgba(0, 245, 212, 0.22);
    color: #fff;
    box-shadow: 0 0 14px rgba(0, 245, 212, 0.35);
}

/* ---------------------------------------------------------------------------
 * Reduced motion — drop transitions/animations, keep visibility
 * ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .hint-tooltip,
    .hint-trigger,
    .onboarding-card,
    .onboarding-backdrop,
    .recurring-nudge {
        transition: none !important;
    }
    .hint-tooltip,
    .onboarding-card,
    .recurring-nudge {
        transform: none !important;
    }
    .onboarding-card--final {
        transform: translate(-50%, -50%) !important;
    }
    [data-hint-spotlight="active"]::before,
    [data-hint-spotlight="active"] {
        animation: none !important;
    }
    [data-hint-spotlight="active"] {
        box-shadow: 0 0 0 2px var(--neon-cyan, #00f5d4) !important;
    }
}
