/**
 * Component: Favorite Button
 * お気に入りボタンコンポーネント
 */

/* Base Button */
:where(.c-favorite-btn) {
    display: inline-flex;
    align-items: center;
    gap: var(--wp--preset--spacing--xs);
    padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--base);
    background: var(--wp--preset--color--white);
    border: var(--wp--custom--border--width--1) solid var(--wp--preset--color--gray-light);
    border-radius: var(--wp--custom--border--radius--full);
    color: var(--wp--preset--color--gray-dark);
    font-size: var(--wp--preset--font-size--sm);
    font-weight: var(--wp--custom--font-weight--medium);
    cursor: pointer;
    transition: all var(--wp--custom--transition--duration--base) var(--wp--custom--transition--timing--ease);
    white-space: nowrap;
}

:where(.c-favorite-btn:hover) {
    background: var(--wp--preset--color--gray-lightest);
    border-color: var(--wp--preset--color--gray);
    opacity: 0.9;
}

/* Icon */
:where(.c-favorite-btn__icon) {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    flex-shrink: 0;
}

:where(.c-favorite-btn__icon svg) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: all var(--wp--custom--transition--duration--base) var(--wp--custom--transition--timing--ease);
}

/* Outline icon (default state) */
:where(.c-favorite-btn__icon-outline) {
    opacity: 1;
}

/* Filled icon (favorited state) */
:where(.c-favorite-btn__icon-filled) {
    opacity: 0;
}

:where(.c-favorite-btn[data-favorited="true"] .c-favorite-btn__icon-outline) {
    opacity: 0;
}

:where(.c-favorite-btn[data-favorited="true"] .c-favorite-btn__icon-filled) {
    opacity: 1;
}

/* Text states */
:where(.c-favorite-btn__text) {
    position: relative;
    line-height: 1;
}

:where(.c-favorite-btn__text-add),
:where(.c-favorite-btn__text-remove) {
    display: block;
    transition: opacity var(--wp--custom--transition--duration--fast) var(--wp--custom--transition--timing--ease);
}

:where(.c-favorite-btn__text-remove) {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

:where(.c-favorite-btn[data-favorited="true"] .c-favorite-btn__text-add) {
    opacity: 0;
    display: none;
}

:where(.c-favorite-btn[data-favorited="true"] .c-favorite-btn__text-remove) {
    opacity: 1;
    position: static;
}

/* Icon only variant */
:where(.c-favorite-btn--icon-only) {
    padding: var(--wp--preset--spacing--sm);
    border-radius: var(--wp--custom--border--radius--circle);
}

/* Size variants */
:where(.c-favorite-btn--small) {
    padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--sm);
    font-size: var(--wp--preset--font-size--sm);
}

:where(.c-favorite-btn--small .c-favorite-btn__icon) {
    width: 2rem;
    height: 2rem;
}

:where(.c-favorite-btn--large) {
    padding: var(--wp--preset--spacing--base) var(--wp--preset--spacing--lg);
    font-size: var(--wp--preset--font-size--base);
}

:where(.c-favorite-btn--large .c-favorite-btn__icon) {
    width: 2.8rem;
    height: 2.8rem;
}

/* Single page positioning */
:where(.c-favorite-btn--single) {
    position: absolute;
    top: var(--wp--preset--spacing--base);
    right: var(--wp--preset--spacing--base);
    z-index: var(--wp--custom--z-index--10);
}

/* Post type specific colors - Default state */

/* Clinic - Tertiary (Gold) */
:where(.c-favorite-btn--clinic) {
    border-color: var(--wp--preset--color--tertiary-light);
}

:where(.c-favorite-btn--clinic .c-favorite-btn__icon-outline),
:where(.c-favorite-btn--clinic .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--tertiary);
}

/* Treatment - Primary (Pink) */
:where(.c-favorite-btn--treatment) {
    border-color: var(--wp--preset--color--primary-light);
}

:where(.c-favorite-btn--treatment .c-favorite-btn__icon-outline),
:where(.c-favorite-btn--treatment .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--primary);
}

/* Column - Success (Green) */
:where(.c-favorite-btn--c-column),
:where(.c-favorite-btn--column) {
    border-color: var(--wp--preset--color--success-light);
}

:where(.c-favorite-btn--c-column .c-favorite-btn__icon-outline),
:where(.c-favorite-btn--c-column .c-favorite-btn__icon-filled),
:where(.c-favorite-btn--column .c-favorite-btn__icon-outline),
:where(.c-favorite-btn--column .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--success);
}

/* Case - Secondary (Pink) */
:where(.c-favorite-btn--case) {
    border-color: var(--wp--preset--color--secondary-light);
}

:where(.c-favorite-btn--case .c-favorite-btn__icon-outline),
:where(.c-favorite-btn--case .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--secondary);
}

/* Post type specific colors - Hover state */
:where(.c-favorite-btn--clinic:hover) {
    background: var(--wp--preset--color--tertiary-lightest);
    border-color: var(--wp--preset--color--tertiary);
}

:where(.c-favorite-btn--treatment:hover) {
    background: var(--wp--preset--color--primary-lightest);
    border-color: var(--wp--preset--color--primary);
}

:where(.c-favorite-btn--c-column:hover),
:where(.c-favorite-btn--column:hover) {
    background: var(--wp--preset--color--success-lightest);
    border-color: var(--wp--preset--color--success);
}

:where(.c-favorite-btn--case:hover) {
    background: var(--wp--preset--color--secondary-lightest);
    border-color: var(--wp--preset--color--secondary);
}

/* Post type specific colors - Favorited state */
:where(.c-favorite-btn--clinic[data-favorited="true"]) {
    background: var(--wp--preset--color--tertiary-lightest);
    border-color: var(--wp--preset--color--tertiary);
    color: var(--wp--preset--color--tertiary-dark);
}

:where(.c-favorite-btn--clinic[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--tertiary);
}

:where(.c-favorite-btn--treatment[data-favorited="true"]) {
    background: var(--wp--preset--color--primary-lightest);
    border-color: var(--wp--preset--color--primary);
    color: var(--wp--preset--color--primary-dark);
}

:where(.c-favorite-btn--treatment[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--primary);
}

:where(.c-favorite-btn--c-column[data-favorited="true"]),
:where(.c-favorite-btn--column[data-favorited="true"]) {
    background: var(--wp--preset--color--success-lightest);
    border-color: var(--wp--preset--color--success);
    color: var(--wp--preset--color--success-dark);
}

:where(.c-favorite-btn--c-column[data-favorited="true"] .c-favorite-btn__icon-filled),
:where(.c-favorite-btn--column[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--success);
}

:where(.c-favorite-btn--case[data-favorited="true"]) {
    background: var(--wp--preset--color--secondary-lightest);
    border-color: var(--wp--preset--color--secondary);
    color: var(--wp--preset--color--secondary-dark);
}

:where(.c-favorite-btn--case[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--secondary);
}

/* Fixed position favorite button (bottom-left) */
:where(.c-favorite-btn-fixed) {
    position: fixed;
    bottom: var(--wp--preset--spacing--2-xl);
    left: var(--wp--preset--spacing--2-xl);
    z-index: var(--wp--custom--z-index--fixed);
}

:where(.c-favorite-btn-fixed__button) {
    width: 6rem;
    height: 6rem;
    padding: 0;
    border-radius: var(--wp--custom--border--radius--circle);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wp--custom--shadow--lg);
    transition: all var(--wp--custom--transition--duration--base) var(--wp--custom--transition--timing--ease);
}

:where(.c-favorite-btn-fixed__button:hover) {
    box-shadow: var(--wp--custom--shadow--xl);
    transform: scale(1.05);
}

:where(.c-favorite-btn-fixed__button .c-favorite-btn__icon) {
    width: 3.6rem;
    height: 3.6rem;
}

/* Fixed button - Theme-specific colors for clinic */
:where(.c-favorite-btn-fixed__button.c-favorite-btn--clinic[data-favorited="true"]) {
    background: var(--wp--preset--color--tertiary);
    border-color: var(--wp--preset--color--tertiary-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--clinic[data-favorited="true"]:hover) {
    background: var(--wp--preset--color--tertiary-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--clinic .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--clinic .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--tertiary);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--clinic[data-favorited="true"] .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--clinic[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--white);
}

/* Fixed button - Theme-specific colors for treatment */
:where(.c-favorite-btn-fixed__button.c-favorite-btn--treatment[data-favorited="true"]) {
    background: var(--wp--preset--color--primary);
    border-color: var(--wp--preset--color--primary-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--treatment[data-favorited="true"]:hover) {
    background: var(--wp--preset--color--primary-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--treatment .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--treatment .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--primary);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--treatment[data-favorited="true"] .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--treatment[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--white);
}

/* Fixed button - Theme-specific colors for column */
:where(.c-favorite-btn-fixed__button.c-favorite-btn--c-column[data-favorited="true"]),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--column[data-favorited="true"]) {
    background: var(--wp--preset--color--success);
    border-color: var(--wp--preset--color--success-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--c-column[data-favorited="true"]:hover),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--column[data-favorited="true"]:hover) {
    background: var(--wp--preset--color--success-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--c-column .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--c-column .c-favorite-btn__icon-filled),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--column .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--column .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--success);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--c-column[data-favorited="true"] .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--c-column[data-favorited="true"] .c-favorite-btn__icon-filled),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--column[data-favorited="true"] .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--column[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--white);
}

/* Fixed button - Theme-specific colors for case */
:where(.c-favorite-btn-fixed__button.c-favorite-btn--case[data-favorited="true"]) {
    background: var(--wp--preset--color--secondary);
    border-color: var(--wp--preset--color--secondary-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--case[data-favorited="true"]:hover) {
    background: var(--wp--preset--color--secondary-dark);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--case .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--case .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--secondary);
}

:where(.c-favorite-btn-fixed__button.c-favorite-btn--case[data-favorited="true"] .c-favorite-btn__icon-outline),
:where(.c-favorite-btn-fixed__button.c-favorite-btn--case[data-favorited="true"] .c-favorite-btn__icon-filled) {
    color: var(--wp--preset--color--white);
}

/* Click Animation */
@keyframes favorite-btn-click {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes favorite-btn-icon-rotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes favorite-particle {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

:where(.c-favorite-btn.is-animating) {
    animation: favorite-btn-click var(--wp--custom--transition--duration--base) var(--wp--custom--transition--timing--ease);
}

:where(.c-favorite-btn.is-animating .c-favorite-btn__icon) {
    animation: favorite-btn-icon-rotate var(--wp--custom--transition--duration--slow) var(--wp--custom--transition--timing--ease);
}

:where(.c-favorite-btn-fixed__button.is-animating) {
    animation: favorite-btn-click var(--wp--custom--transition--duration--base) var(--wp--custom--transition--timing--ease);
}

:where(.c-favorite-btn-fixed__button.is-animating .c-favorite-btn__icon) {
    animation: favorite-btn-icon-rotate var(--wp--custom--transition--duration--slow) var(--wp--custom--transition--timing--ease);
}

/* Particle container */
:where(.c-favorite-btn__particles) {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    pointer-events: none;
}

:where(.c-favorite-btn__particle) {
    position: absolute;
    width: 1rem;
    height: 1rem;
    animation: favorite-particle var(--wp--custom--transition--duration--slow) var(--wp--custom--transition--timing--ease forwards;
}

:where(.c-favorite-btn__particle svg) {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* Responsive */
@media (max-width: 768px) {
    :where(.c-favorite-btn) {
        padding: var(--wp--preset--spacing--xs) var(--wp--preset--spacing--sm);
        font-size: var(--wp--preset--font-size--sm);
    }

    :where(.c-favorite-btn__icon) {
        width: 2rem;
        height: 2rem;
    }

    :where(.c-favorite-btn--single) {
        top: var(--wp--preset--spacing--sm);
        right: var(--wp--preset--spacing--sm);
    }

    /* Fixed button on mobile */
    :where(.c-favorite-btn-fixed) {
        bottom: var(--wp--preset--spacing--xl);
        left: var(--wp--preset--spacing--base);
    }

    :where(.c-favorite-btn-fixed__button) {
        width: 5rem;
        height: 5rem;
    }

    :where(.c-favorite-btn-fixed__button .c-favorite-btn__icon) {
        width: 3rem;
        height: 3rem;
    }
}
