/* Haven Claws Motion System
   Tokens, keyframes, and utilities for subtle and elegant animations.
   Follows my-brain/02_Personal_Haven/haven-design-direction.md */

:root {
    --ease-spring: cubic-bezier(0.2, 0.8, 0.2, 1);
    --duration-fast: 200ms;
    --duration-normal: 280ms;
    --duration-entrance: 450ms;
}

/* 1. Press and Settle (Buttons & Interactive Elements) */
.hc-press,
.btn,
.btn-glass-icon,
.time-pill,
.button,
.btn-primary,
.btn-secondary,
.btn-book-cta,
.admin-side-collapse-btn,
.admin-nav-item,
.nav-book-pill,
.theme-toggle-btn,
.toggle-segmented-item {
    transition: transform var(--duration-fast) var(--ease-spring),
                box-shadow var(--duration-fast) var(--ease-spring),
                background-color var(--duration-fast) var(--ease-spring),
                border-color var(--duration-fast) var(--ease-spring);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.hc-press:active,
.btn:active,
.btn-glass-icon:active,
.time-pill:active,
.button:active,
.btn-primary:active,
.btn-secondary:active,
.btn-book-cta:active,
.admin-side-collapse-btn:active,
.admin-nav-item:active,
.nav-book-pill:active,
.theme-toggle-btn:active,
.toggle-segmented-item:active {
    transform: scale(0.96);
}

/* Hover Lift (Fine Pointer Only) */
@media (hover: hover) and (pointer: fine) {
    .hc-lift:hover,
    .card-interactive:hover,
    .service-card:hover,
    .sideways-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 18px 40px rgba(185, 97, 123, 0.16);
    }
}

[data-theme="dark"] @media (hover: hover) and (pointer: fine) {
    .hc-lift:hover,
    .card-interactive:hover,
    .service-card:hover,
    .sideways-card:hover {
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
    }
}

/* 2. Skeleton Shimmer Loader */
.hc-skeleton {
    position: relative;
    overflow: hidden;
    background-color: rgba(231, 166, 185, 0.18);
    border-radius: 12px;
}

.hc-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.45) 50%,
        transparent 100%
    );
    animation: hcShimmer 1.6s infinite;
}

[data-theme="dark"] .hc-skeleton {
    background-color: rgba(90, 58, 70, 0.35);
}

[data-theme="dark"] .hc-skeleton::after {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.08) 50%,
        transparent 100%
    );
}

@keyframes hcShimmer {
    100% {
        transform: translateX(100%);
    }
}

/* 3. Reveal and Entrance Animations */
.hc-reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity var(--duration-entrance) var(--ease-spring),
                transform var(--duration-entrance) var(--ease-spring);
    will-change: opacity, transform;
}

.hc-reveal.hc-visible {
    opacity: 1;
    transform: translateY(0);
}

/* 4. Staggered Children Entrance */
.hc-stagger > * {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity var(--duration-entrance) var(--ease-spring),
                transform var(--duration-entrance) var(--ease-spring);
}

.hc-stagger.hc-visible > *:nth-child(1) { transition-delay: 40ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(2) { transition-delay: 80ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(3) { transition-delay: 120ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(4) { transition-delay: 160ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(5) { transition-delay: 200ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(6) { transition-delay: 240ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(7) { transition-delay: 280ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(8) { transition-delay: 320ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(9) { transition-delay: 360ms; opacity: 1; transform: translateY(0); }
.hc-stagger.hc-visible > *:nth-child(10) { transition-delay: 400ms; opacity: 1; transform: translateY(0); }

/* 5. Nudge (Bouncing Pill Icon) */
@keyframes hcNudge {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.hc-nudge {
    animation: hcNudge 1.6s var(--ease-spring) infinite;
}

/* Blur-in titles */
.hc-title-blur,
.page-title,
.book-title {
    animation: hcTitleBlurIn var(--duration-entrance) var(--ease-spring) both;
}

@keyframes hcTitleBlurIn {
    0% {
        opacity: 0;
        filter: blur(8px);
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        filter: blur(0);
        transform: translateY(0);
    }
}

/* Check-mark draw on "Booking sent" (soft Apple-style checkmark draw, no sparkles) */
.booking-sent-badge {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--blush);
    border: 1px solid var(--edge);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(176, 90, 116, 0.2);
}

[data-theme="dark"] .booking-sent-badge {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.hc-checkmark {
    display: block;
    stroke-width: 2.4;
    stroke: var(--rose);
}

.hc-checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-miterlimit: 10;
    stroke: var(--edge);
    animation: hcStroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.hc-checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke: var(--rose);
    animation: hcStroke 0.35s cubic-bezier(0.65, 0, 0.45, 1) 0.4s forwards;
}

@keyframes hcStroke {
    100% {
        stroke-dashoffset: 0;
    }
}

/* iOS Toggle Spring Animation */
.switch .slider::before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    top: 3px;
    background-color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    border-radius: 50%;
    transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1),
                width 180ms ease,
                background-color 200ms ease;
    will-change: transform, width;
}

.switch:active .slider::before {
    width: 28px;
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.switch:active input:checked + .slider::before {
    transform: translateX(18px);
}

/* Theme Toggle Button Styles */
.theme-toggle-btn {
    border: none;
    background: transparent;
    color: var(--deep-rose);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle-compact {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 999px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    color: var(--deep-rose);
}

.theme-toggle-full {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 14px;
    border-radius: 14px;
    background: transparent;
    color: var(--ink);
    transition: background-color var(--duration-fast) var(--ease-spring);
}

.theme-toggle-full:hover {
    background: var(--petal);
}

.theme-icon {
    flex-shrink: 0;
    transition: transform 240ms var(--ease-spring);
}

.theme-toggle-btn:hover .theme-icon {
    transform: rotate(18deg) scale(1.08);
}

/* 6. View Transitions between pages */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 220ms;
    animation-timing-function: var(--ease-spring);
}

/* 7. Client Home Scroll-Driven Hero and Sideways Gallery */
:root {
    --hero-inset-top: 56px;
    --hero-inset-x: 16px;
    --hero-inset-bottom: 350px;
}

@media (min-width: 600px) {
    :root {
        --hero-inset-top: 72px;
        --hero-inset-x: 24px;
        --hero-inset-bottom: 370px;
    }
}

.hero-scroll-track {
    position: relative;
    width: 100%;
    height: 180vh;
    --hero-p: 0;
}

.hero-sticky-frame {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-photo-box {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 440px;
    margin: 0 auto;
    transform-origin: center center;
    clip-path: inset(
        calc(var(--hero-p, 0) * var(--hero-inset-top))
        calc(var(--hero-p, 0) * var(--hero-inset-x))
        calc(var(--hero-p, 0) * var(--hero-inset-bottom))
        calc(var(--hero-p, 0) * var(--hero-inset-x))
        round calc(var(--hero-p, 0) * 28px)
    );
    transform: scale(calc(1 - var(--hero-p, 0) * 0.04));
    box-shadow: 0 16px 38px rgba(185, 97, 123, calc(0.18 * var(--hero-p, 0)));
    will-change: clip-path, transform;
    z-index: 1;
}

.hero-overlay-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: clamp(60px, 12vh, 100px);
    text-align: center;
    z-index: 2;
    opacity: calc(1 - var(--hero-p, 0) * 2.5);
    transition: opacity 120ms linear;
    pointer-events: auto;
}

.hero-card-headline {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: clamp(36px, 8vh, 76px);
    max-width: 440px;
    margin: 0 auto;
    z-index: 2;
    text-align: left;
    opacity: calc(clamp(0, (var(--hero-p, 0) - 0.45) / 0.55, 1));
    transform: translateY(calc((1 - var(--hero-p, 0)) * 24px));
    will-change: opacity, transform;
}

/* Sideways Gallery */
.sideways-scroll-track {
    position: relative;
    width: 100%;
    height: 240vh;
    --sideways-p: 0;
    --sideways-x: 0px;
}

.sideways-sticky-frame {
    position: sticky;
    top: 0;
    width: 100%;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 0 36px;
}

.sideways-gallery-row {
    display: flex;
    gap: 16px;
    padding: 0 24px;
    transform: translate3d(calc(-1 * var(--sideways-x, 0px)), 0, 0);
    will-change: transform;
}

.sideways-card {
    position: relative;
    flex-shrink: 0;
    width: 260px;
    height: 380px;
    border-radius: 28px;
    overflow: hidden;
    border: 1px solid #F6CDD9;
    box-shadow: 0 16px 38px rgba(185, 97, 123, 0.14);
    cursor: pointer;
    transition: transform 120ms ease;
    will-change: transform;
    background: #F7DCE5;
}

.sideways-progress-fill {
    height: 100%;
    width: calc(20% + var(--sideways-p, 0) * 80%);
    background: #B05A74;
    border-radius: 999px;
}

/* 8. Accessibility - Reduced Motion */
@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;
    }

    .hc-reveal,
    .hc-stagger > * {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }

    .hc-title-blur,
    .page-title,
    .book-title,
    .hc-checkmark-circle,
    .hc-checkmark-check {
        animation: none !important;
        opacity: 1 !important;
        filter: none !important;
        transform: none !important;
        stroke-dashoffset: 0 !important;
    }

    .switch .slider::before {
        transition: none !important;
    }

    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation: none !important;
    }

    .hc-nudge,
    .hc-skeleton::after {
        animation: none !important;
    }

    .hero-scroll-track {
        height: auto !important;
    }

    .hero-sticky-frame {
        position: static !important;
        height: auto !important;
        overflow: visible !important;
    }

    .hero-photo-box {
        position: relative !important;
        height: 420px !important;
        clip-path: none !important;
        transform: none !important;
        border-radius: 28px !important;
        overflow: hidden !important;
    }

    .hero-overlay-content {
        display: none !important;
    }

    .hero-card-headline {
        position: static !important;
        opacity: 1 !important;
        transform: none !important;
        margin-top: 20px !important;
    }

    .sideways-scroll-track {
        height: auto !important;
    }

    .sideways-sticky-frame {
        position: static !important;
        height: auto !important;
        overflow: visible !important;
    }

    .sideways-gallery-row {
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        transform: none !important;
        padding-bottom: 12px !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .sideways-card {
        scroll-snap-align: start !important;
        transform: none !important;
    }

    .sideways-progress-track {
        display: none !important;
    }
}

