/* ==========================================================================
   Marcaí — Design Engineering Polish
   Principles: concentric radius, font smoothing, tabular nums, scale on press
   ========================================================================== */

/* ---------- Root font smoothing for crisper text on macOS ---------- */
html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ---------- Typography utilities ---------- */

/* Text wrapping for headings - prevents widows */
.text-wrap-balance {
    text-wrap: balance;
}

/* Text wrapping for body - avoids orphans */
.text-wrap-pretty {
    text-wrap: pretty;
}

/* Tabular numbers for dynamic/updating values (prevents layout shift) */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* ---------- Scale on press (tactile feedback) ---------- */

/* Base scale-on-press - subtle 0.96 scale */
.scale-on-press {
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1);
}

.scale-on-press:active:not(:disabled):not(.static) {
    transform: scale(0.96);
}

/* For buttons - combine with existing transitions */
.btn-press {
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1),
                filter 0.2s ease,
                box-shadow 0.2s ease;
}

.btn-press:active:not(:disabled):not(.static) {
    transform: scale(0.96);
}

/* ---------- Concentric Border Radius ---------- */
/* Formula: outer radius = inner radius + padding */

/* Card with 2rem (32px) radius - content inside should be ~1.5rem */
.radius-concentric-outer {
    border-radius: 2rem; /* 32px */
}

.radius-concentric-inner {
    border-radius: 1.5rem; /* 24px = 32px - 8px padding */
}

/* Card with 1.5rem (24px) radius - content inside should be ~1rem */
.radius-concentric-outer-sm {
    border-radius: 1.5rem; /* 24px */
}

.radius-concentric-inner-sm {
    border-radius: 1rem; /* 16px = 24px - 8px padding */
}

/* Button inside card - much smaller radius */
.radius-concentric-btn {
    border-radius: 9999px; /* Full rounded - works with any parent */
}

/* ---------- Shadows over borders ---------- */

/* Soft shadow that adapts to any background */
.shadow-soft {
    box-shadow:
        0 1px 2px rgba(255, 90, 31, 0.05),
        0 4px 8px rgba(255, 90, 31, 0.08),
        0 8px 16px rgba(255, 90, 31, 0.04);
}

.shadow-soft-hover {
    box-shadow:
        0 2px 4px rgba(255, 90, 31, 0.06),
        0 8px 16px rgba(255, 90, 31, 0.12),
        0 16px 32px rgba(255, 90, 31, 0.06);
}

/* Elevation layers */
.shadow-elevation-1 {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.shadow-elevation-2 {
    box-shadow:
        0 2px 4px rgba(0, 0, 0, 0.04),
        0 8px 16px rgba(0, 0, 0, 0.08);
}

.shadow-elevation-3 {
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.03),
        0 12px 24px rgba(0, 0, 0, 0.10);
}

/* ---------- Image outlines ---------- */

/* Subtle outline for images - adds depth */
.img-outline {
    outline: 1px solid rgba(0, 0, 0, 0.06);
    outline-offset: -1px;
}

.dark .img-outline {
    outline-color: rgba(255, 255, 255, 0.08);
}

/* Rounded image with outline */
.img-outline-rounded {
    outline: 1px solid rgba(0, 0, 0, 0.06);
    outline-offset: -1px;
    border-radius: 1rem;
}

.dark .img-outline-rounded {
    outline-color: rgba(255, 255, 255, 0.08);
}

/* ---------- Minimum hit areas (40×40px) ---------- */

/* Extend hit area with pseudo-element */
.hit-area-40 {
    position: relative;
}

.hit-area-40::before {
    content: '';
    position: absolute;
    inset: -8px; /* Extends 8px in all directions */
    min-width: 40px;
    min-height: 40px;
}

/* For small icon buttons */
.btn-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
}

/* ---------- Transition specificity (never use 'all') ---------- */

/* Specify exact properties for GPU compositing */
.transition-transform-opacity {
    transition-property: transform, opacity;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
    transition-duration: 200ms;
}

.transition-colors-opacity {
    transition-property: color, background-color, border-color, opacity;
    transition-timing-function: ease;
    transition-duration: 200ms;
}

.transition-shadow-transform {
    transition-property: box-shadow, transform;
    transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
    transition-duration: 300ms;
}

/* ---------- Interruptible animations ---------- */

/* Use transitions instead of keyframes for interactive states */
.interruptible {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.3s ease;
}

/* For elements that can be hovered/clicked mid-animation */
.interruptible-fast {
    transition: transform 0.15s ease-out,
                opacity 0.15s ease;
}

/* ---------- Contextual icon animations ---------- */

/* Icon swap animation - crossfade */
.icon-swap {
    position: relative;
}

.icon-swap .icon-enter,
.icon-swap .icon-exit {
    transition: opacity 0.2s cubic-bezier(0.2, 0, 0, 1),
                transform 0.2s cubic-bezier(0.2, 0, 0, 1),
                filter 0.2s ease;
}

.icon-swap .icon-enter {
    opacity: 0;
    transform: scale(0.25);
    filter: blur(4px);
}

.icon-swap.active .icon-enter {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

.icon-swap .icon-exit {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

.icon-swap.active .icon-exit {
    opacity: 0;
    transform: scale(0.25);
    filter: blur(4px);
}

/* ---------- Stagger animations ---------- */

/* Stagger children with ~100ms delay */
.stagger-children > * {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.stagger-children.animate > *:nth-child(1) { transition-delay: 0ms; opacity: 1; transform: translateY(0); }
.stagger-children.animate > *:nth-child(2) { transition-delay: 80ms; opacity: 1; transform: translateY(0); }
.stagger-children.animate > *:nth-child(3) { transition-delay: 160ms; opacity: 1; transform: translateY(0); }
.stagger-children.animate > *:nth-child(4) { transition-delay: 240ms; opacity: 1; transform: translateY(0); }
.stagger-children.animate > *:nth-child(5) { transition-delay: 320ms; opacity: 1; transform: translateY(0); }
.stagger-children.animate > *:nth-child(6) { transition-delay: 400ms; opacity: 1; transform: translateY(0); }
.stagger-children.animate > *:nth-child(7) { transition-delay: 480ms; opacity: 1; transform: translateY(0); }
.stagger-children.animate > *:nth-child(8) { transition-delay: 560ms; opacity: 1; transform: translateY(0); }

/* ---------- Subtle exit animations ---------- */

/* Exit should be softer than enter */
.exit-subtle {
    transition: opacity 0.2s ease,
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.exit-subtle.exiting {
    opacity: 0;
    transform: translateY(8px); /* Small fixed translate, not full height */
}

/* ---------- will-change (use sparingly) ---------- */

/* Only for properties GPU can composite */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Remove will-change after animation */
.will-change-transform:hover,
.will-change-opacity:hover {
    will-change: auto;
}

/* ---------- Optical alignment ---------- */

/* For icons that look off-center geometrically */
.optical-center {
    transform: translateY(0.5px);
}

/* For play buttons, triangles, asymmetric icons */
.optical-center-left {
    transform: translateX(-0.5px);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .scale-on-press,
    .btn-press {
        transition: none;
    }
    
    .scale-on-press:active:not(:disabled),
    .btn-press:active:not(:disabled) {
        transform: none;
    }
    
    .stagger-children > * {
        transition: none;
        opacity: 1;
        transform: none;
    }
    
    .interruptible,
    .interruptible-fast {
        transition: none;
    }
    
    .icon-swap .icon-enter,
    .icon-swap .icon-exit {
        transition: none;
    }
    
    .exit-subtle {
        transition: opacity 0.1s ease;
    }
    
    .will-change-transform,
    .will-change-opacity {
        will-change: auto;
    }
}

/* ---------- Utility combinations ---------- */

/* Perfect button: press effect + hit area + transition specificity */
.btn-polished {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 10px 20px;
    border-radius: 9999px;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1),
                box-shadow 0.2s ease,
                background-color 0.2s ease;
}

.btn-polished:active:not(:disabled):not(.static) {
    transform: scale(0.96);
}

/* Card with concentric radius and shadow */
.card-polished {
    border-radius: 2rem;
    box-shadow:
        0 1px 2px rgba(255, 90, 31, 0.05),
        0 4px 12px rgba(255, 90, 31, 0.08);
    transition: box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-polished:hover {
    box-shadow:
        0 2px 4px rgba(255, 90, 31, 0.06),
        0 12px 24px rgba(255, 90, 31, 0.12);
}

/* Content inside card (concentric radius) */
.card-polished-inner {
    border-radius: 1.5rem; /* 2rem - 0.5rem padding */
}
