/**
 * 3Syxty Studio — Utility Classes
 *
 * Custom utility classes that complement TailwindCSS. These provide
 * studio-specific patterns that Tailwind doesn't cover natively.
 * All utilities use design tokens from tokens.css.
 */

/* -----------------------------------------------------------------------
   Typography Utilities
   ----------------------------------------------------------------------- */

.type-display { font: var(--type-display); color: var(--text-primary); letter-spacing: -0.02em; }
.type-h1 { font: var(--type-h1); color: var(--text-primary); letter-spacing: -0.01em; }
.type-h2 { font: var(--type-h2); color: var(--text-primary); }
.type-h3 { font: var(--type-h3); color: var(--text-primary); }
.type-body { font: var(--type-body); color: var(--text-secondary); }
.type-body-sm { font: var(--type-body-sm); color: var(--text-secondary); }
.type-caption { font: var(--type-caption); color: var(--text-muted); }
.type-overline { font: var(--type-overline); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.type-mono { font: var(--type-mono); color: var(--text-secondary); }

/* -----------------------------------------------------------------------
   Surface Utilities
   ----------------------------------------------------------------------- */

.surface-primary { background-color: var(--surface-primary); }
.surface-secondary { background-color: var(--surface-secondary); }
.surface-tertiary { background-color: var(--surface-tertiary); }
.surface-elevated { background-color: var(--surface-elevated); }

/* -----------------------------------------------------------------------
   Glass / Frosted Panel
   ----------------------------------------------------------------------- */

.glass {
    background: color-mix(in srgb, var(--surface-primary) 75%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid color-mix(in srgb, var(--border-subtle) 50%, transparent);
}

.glass-heavy {
    background: color-mix(in srgb, var(--surface-primary) 90%, transparent);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid color-mix(in srgb, var(--border-subtle) 60%, transparent);
}

/* -----------------------------------------------------------------------
   Gradient Utilities
   ----------------------------------------------------------------------- */

.gradient-accent {
    background: var(--accent-gradient);
}

.gradient-accent-vivid {
    background: var(--accent-gradient-vivid);
}

.gradient-text {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gradient-border {
    position: relative;
    background: var(--surface-secondary);
    border-radius: var(--radius-lg);
}
.gradient-border::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: var(--accent-gradient);
    z-index: -1;
}

/* -----------------------------------------------------------------------
   Glow Effects
   ----------------------------------------------------------------------- */

.glow-accent {
    box-shadow: var(--shadow-glow);
}

.glow-success {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2), 0 0 60px rgba(16, 185, 129, 0.08);
}

.glow-error {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2), 0 0 60px rgba(239, 68, 68, 0.08);
}

/* -----------------------------------------------------------------------
   Focus Ring
   ----------------------------------------------------------------------- */

.focus-ring:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

.focus-ring-inset:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: -2px;
}

.focus-within-ring:focus-within {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------
   Scrollbar Styling
   ----------------------------------------------------------------------- */

.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.scrollbar-thin::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

.scrollbar-thin::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.scrollbar-thin::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: calc(var(--scrollbar-width) / 2);
}

.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.scrollbar-hidden {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.scrollbar-hidden::-webkit-scrollbar {
    display: none;
}

/* -----------------------------------------------------------------------
   Animation Keyframes
   ----------------------------------------------------------------------- */

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-down {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slide-in-left {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes scale-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes scale-out {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(108, 92, 231, 0); }
    100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bounce-in {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.animate-fade-in { animation: fade-in var(--motion-fast); }
.animate-fade-out { animation: fade-out var(--motion-fast); }
.animate-slide-up { animation: slide-up var(--motion-normal); }
.animate-slide-down { animation: slide-down var(--motion-normal); }
.animate-slide-in-right { animation: slide-in-right var(--motion-normal); }
.animate-slide-in-left { animation: slide-in-left var(--motion-normal); }
.animate-scale-in { animation: scale-in var(--motion-fast); }
.animate-scale-out { animation: scale-out var(--motion-fast); }
.animate-pulse-ring { animation: pulse-ring 2s infinite; }
.animate-shimmer { animation: shimmer 2s infinite linear; }
.animate-bounce-in { animation: bounce-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* -----------------------------------------------------------------------
   Accessibility
   ----------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.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;
}

.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    padding: var(--space-2) var(--space-4);
    background: var(--accent-primary);
    color: var(--text-on-accent);
    font: var(--type-body);
    font-weight: 600;
    z-index: var(--z-max);
    border-radius: 0 0 var(--radius-md) 0;
    transition: top var(--motion-fast);
}

.skip-link:focus {
    top: 0;
}

@media (forced-colors: active) {
    .glow-accent,
    .glow-success,
    .glow-error {
        box-shadow: none;
        outline: 2px solid currentColor;
    }
}

/* -----------------------------------------------------------------------
   Interactive States
   ----------------------------------------------------------------------- */

.interactive {
    transition: background-color var(--motion-instant), color var(--motion-instant),
                border-color var(--motion-instant), box-shadow var(--motion-instant);
    cursor: pointer;
}

.interactive:hover {
    background-color: var(--accent-primary-subtle);
}

.interactive:active {
    background-color: var(--accent-primary-muted);
}

/* -----------------------------------------------------------------------
   Truncation
   ----------------------------------------------------------------------- */

.truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* -----------------------------------------------------------------------
   Layout Helpers
   ----------------------------------------------------------------------- */

.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--space-4); }

.stack-sm > * + * { margin-top: var(--space-2); }
.stack-lg > * + * { margin-top: var(--space-6); }
.stack-xl > * + * { margin-top: var(--space-8); }

.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); }

.center-content {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* -----------------------------------------------------------------------
   Keyboard-Only Focus Rings
   When user navigates with mouse, hide focus outlines globally.
   When Tab is pressed, body gets .using-keyboard and rings appear.
   ----------------------------------------------------------------------- */

body:not(.using-keyboard) *:focus {
    outline: none;
}

body:not(.using-keyboard) *:focus-visible {
    outline: none;
}

body.using-keyboard *:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------
   High Contrast Mode Overrides
   ----------------------------------------------------------------------- */

@media (forced-colors: active) {
    .btn {
        border: 1px solid ButtonText;
    }

    .input, .select, .toggle-track, .checkbox-box, .radio-circle {
        border: 1px solid ButtonText;
    }

    .badge {
        border: 1px solid currentColor;
    }

    .card {
        border: 1px solid CanvasText;
    }

    .toast {
        border: 1px solid CanvasText;
    }

    .modal {
        border: 2px solid CanvasText;
    }

    .skeleton {
        background: Canvas;
        border: 1px solid GrayText;
        animation: none;
    }
}
