/* ZapStays — global styles, animations, transitions
   Loaded after Tailwind Play CDN; additive only. */

/* ── Base niceties ──────────────────────────────────────────────────────── */
html { scroll-behavior: smooth; }
body { -webkit-tap-highlight-color: transparent; }

/* ── Skip to main content — visually hidden until keyboard focus ────────── */
/* Uses the standard "sr-only" visually-hidden pattern to guarantee it never
   shows on screen unless a keyboard user tabs to it. */
.skip-link {
    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:focus {
    position: fixed;
    top: 8px; left: 8px;
    width: auto; height: auto;
    padding: 10px 18px; margin: 0;
    clip: auto; overflow: visible;
    background: #1A1A1A; color: #F7B500;
    border-radius: 8px;
    font-weight: 700; font-size: 14px;
    z-index: 9999;
    outline: 2px solid #F7B500; outline-offset: 2px;
}

*, *::before, *::after {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 180ms;
}

/* Skip transitions for certain elements where they cause jank */
img, video, canvas, svg { transition: none; }

/* ── Focus rings — consistent across the app ─────────────────────────────── */
/* Solid brand amber + dark inner halo so the ring stays visible on both light
   and dark backgrounds and meets WCAG 2.1 SC 1.4.11 (3:1 against adjacent
   colours). Previous rgba(...,0.55) version measured ~3.2:1 on white — failing
   the UI-component contrast threshold for keyboard users in bright environments. */
:focus-visible {
    outline: 2px solid #B07F00;
    outline-offset: 2px;
    border-radius: 4px;
    box-shadow: 0 0 0 4px rgba(247, 181, 0, 0.35);
}
button:focus-visible, a:focus-visible {
    outline-offset: 3px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem; padding: 0.625rem 1.25rem; border-radius: 0.75rem;
    font-weight: 600; font-size: 0.875rem; line-height: 1;
    transition: all 180ms cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap; cursor: pointer; border: 1px solid transparent;
    position: relative; overflow: hidden;
}
/* .btn gets ripple by default */
.btn::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), rgba(255,255,255,0.45) 0%, transparent 50%);
    opacity: 0; transition: opacity 240ms;
    pointer-events: none;
}
.btn:active::after { opacity: 1; transition: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: #F7B500; color: #1A1A1A; }
.btn-primary:hover { background: #D99B00; box-shadow: 0 6px 20px -6px rgba(247,181,0,0.5); }
.btn-dark { background: #1A1A1A; color: #fff; }
.btn-dark:hover { background: #333; box-shadow: 0 6px 20px -6px rgba(0,0,0,0.3); }
.btn-outline { background: transparent; color: #1A1A1A; border-color: #E5E7EB; }
.btn-outline:hover { background: #F9FAFB; border-color: #9CA3AF; }
.btn-ghost { background: transparent; color: #374151; }
.btn-ghost:hover { background: #F3F4F6; color: #1A1A1A; }
.btn-danger { background: #DC2626; color: #fff; }
.btn-danger:hover { background: #B91C1C; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* ── Card hover lift ─────────────────────────────────────────────────────── */
.card-hover {
    transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1), box-shadow 220ms cubic-bezier(0.4, 0, 0.2, 1), border-color 220ms;
}
.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 45px -20px rgba(0, 0, 0, 0.18);
}

/* ── Animated entrance ───────────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes pulseBrand {
    0%, 100% { box-shadow: 0 0 0 0 rgba(247,181,0,0.4); }
    50% { box-shadow: 0 0 0 8px rgba(247,181,0,0); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-fade-up { animation: fadeInUp 520ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.animate-fade-in { animation: fadeIn 400ms ease both; }
.animate-slide-left { animation: slideInLeft 380ms cubic-bezier(0.16, 1, 0.3, 1) both; }

/* Stagger helpers — add to siblings */
.stagger > * { animation: fadeInUp 520ms cubic-bezier(0.16, 1, 0.3, 1) both; }
.stagger > *:nth-child(1) { animation-delay: 60ms; }
.stagger > *:nth-child(2) { animation-delay: 120ms; }
.stagger > *:nth-child(3) { animation-delay: 180ms; }
.stagger > *:nth-child(4) { animation-delay: 240ms; }
.stagger > *:nth-child(5) { animation-delay: 300ms; }
.stagger > *:nth-child(6) { animation-delay: 360ms; }
.stagger > *:nth-child(7) { animation-delay: 420ms; }
.stagger > *:nth-child(8) { animation-delay: 480ms; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 600ms ease, transform 600ms cubic-bezier(0.16,1,0.3,1); }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ── Skeleton loader ─────────────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #F3F4F6 0%, #E5E7EB 50%, #F3F4F6 100%);
    background-size: 200% 100%;
    animation: shimmer 1.6s infinite;
    border-radius: 8px;
}

/* ── Inputs ──────────────────────────────────────────────────────────────── */
.input {
    width: 100%; padding: 0.625rem 0.875rem;
    border: 1px solid #E5E7EB; border-radius: 0.75rem;
    font-size: 0.875rem; background: #fff;
    transition: border-color 160ms, box-shadow 160ms, background 160ms;
}
.input:hover { border-color: #D1D5DB; }
.input:focus {
    outline: none;
    border-color: #F7B500;
    box-shadow: 0 0 0 3px rgba(247, 181, 0, 0.2);
}
.input:disabled { background: #F9FAFB; color: #6B7280; }

/* ── Toast / flash polish ────────────────────────────────────────────────── */
.flash-toast {
    animation: fadeInUp 300ms ease both;
}

/* ── Scrollbar polish (desktop) ──────────────────────────────────────────── */
@media (hover: hover) {
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 999px; }
    ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }
    ::-webkit-scrollbar-track { background: transparent; }
}

/* ── Mobile sidebar overlay ──────────────────────────────────────────────── */
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 40; backdrop-filter: blur(2px);
    animation: fadeIn 220ms ease both;
}

/* ── Motion polish (v2) ─────────────────────────────────────────────────── */
/* View Transitions API — progressive enhancement; browsers without support ignore */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; }

/* Modal fade + scale (data-open="true" to show) */
.zs-modal { transform: scale(0.96); opacity: 0; transition: opacity 180ms, transform 220ms cubic-bezier(0.16,1,0.3,1); pointer-events: none; }
.zs-modal[data-open="true"] { transform: scale(1); opacity: 1; pointer-events: auto; }
.zs-modal-backdrop { opacity: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); transition: opacity 180ms; pointer-events: none; }
.zs-modal-backdrop[data-open="true"] { opacity: 1; pointer-events: auto; }

/* Button ripple (opt-in via .btn-ripple) */
.btn-ripple { position: relative; overflow: hidden; }
.btn-ripple::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle at var(--rx, 50%) var(--ry, 50%), rgba(255,255,255,0.45) 0%, transparent 50%);
    opacity: 0; transition: opacity 240ms;
    pointer-events: none;
}
.btn-ripple:active::after { opacity: 1; transition: none; }

/* Form error shake */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}
.input-error { border-color: #DC2626 !important; animation: shake 280ms cubic-bezier(0.36, 0.07, 0.19, 0.97); }

/* Arrow-slide on "View all" style links */
.link-arrow { display: inline-flex; align-items: center; gap: 0.25rem; }
.link-arrow::after { content: '→'; transition: transform 180ms; display: inline-block; }
.link-arrow:hover::after { transform: translateX(4px); }

/* Compare button (paired with heart; sits just below it) */
.zs-compare {
    position: absolute; top: 3.25rem; right: 0.625rem; z-index: 5;
    min-width: 34px; height: 26px; padding: 0 0.5rem;
    display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
    border-radius: 9999px;
    background: rgba(255,255,255,0.9); backdrop-filter: blur(4px);
    color: #6B7280; border: 1px solid rgba(0,0,0,0.04);
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    cursor: pointer; transition: color 160ms, background 160ms, transform 180ms;
}
.zs-compare:hover { color: #1A1A1A; transform: scale(1.06); }
.zs-compare[data-compare-on="1"] { background: #1A1A1A; color: #F7B500; }

/* Wishlist heart */
.zs-heart {
    position: absolute; top: 0.625rem; right: 0.625rem; z-index: 5;
    width: 34px; height: 34px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9999px;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    color: #6B7280;
    border: 1px solid rgba(0,0,0,0.04);
    cursor: pointer;
    transition: transform 180ms cubic-bezier(0.16,1,0.3,1), color 160ms, background 160ms;
}
.zs-heart:hover { color: #DC2626; transform: scale(1.08); }
.zs-heart[data-saved="1"] { color: #DC2626; background: rgba(254, 226, 226, 0.95); }
.zs-heart[data-saved="1"]::before {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    animation: heartPop 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}
@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

/* Skeleton sizing variants */
.skeleton-card { height: 280px; border-radius: 1rem; }
.skeleton-text { height: 0.85rem; border-radius: 0.25rem; }
.skeleton-avatar { width: 2.5rem; height: 2.5rem; border-radius: 9999px; }
.skeleton-line { height: 1rem; border-radius: 0.5rem; }

/* Tap highlight removal on touch devices — prevents blue flash */
button, a, [role="button"] { -webkit-tap-highlight-color: transparent; }

/* ── Reduced motion respect ──────────────────────────────────────────────── */
@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;
    }
    .reveal { opacity: 1; transform: none; }
}

/* ── Line clamp helper (in case Tailwind JIT doesn't cover it) ───────────── */
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
