/* ==========================================
   16. 動畫關鍵幀 (Keyframes & Effects)
   ========================================== */
@keyframes cardEntrance {
    0% {
        opacity: 0;
        transform: translateY(24px) translateZ(0);
    }

    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes cardEntranceDone {
    0% {
        opacity: 0;
        transform: translateY(24px) translateZ(0);
    }

    100% {
        opacity: 0.4;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes headerTitleEntrance {
    0% {
        opacity: 0;
        transform: translateY(24px) translateZ(0);
    }

    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes headerTimeEntrance {
    0% {
        opacity: 0;
        transform: translateY(24px) translateZ(0);
    }

    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes tabsBarEntrance {
    0% {
        opacity: 0;
        transform: translateY(24px) translateZ(0);
    }

    100% {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

.title-entrance {
    animation: headerTitleEntrance 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) both !important;
}

.time-entrance {
    animation: headerTimeEntrance 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) both !important;
}

.tabs-entrance {
    animation: tabsBarEntrance 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) 0.12s both !important;
}

.action-bar-entrance {
    animation: tabsBarEntrance 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) 0.18s both !important;
}

body.is-chapter-scrolling .title-entrance,
body.is-chapter-scrolling .time-entrance,
body.is-chapter-scrolling .tabs-entrance,
body.is-chapter-scrolling .action-bar-entrance,
body.is-chapter-scrolling .subtitle-entrance {
    animation: none !important;
}

@keyframes shakeError {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translate(calc(-50% - 2.5px), -50%) scale(1);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translate(calc(-50% + 2.5px), -50%) scale(1);
    }
}

.shake-animation {
    animation: shakeError 0.4s cubic-bezier(.36, .07, .19, .97) both !important;
}

@keyframes titleScalePulse {
    0% {
        transform: scale(1) translateZ(0);
    }

    45% {
        transform: scale(1.25) translateZ(0);
    }

    75% {
        transform: scale(0.96) translateZ(0);
    }

    100% {
        transform: scale(1) translateZ(0);
    }
}

.title-scale-pop {
    animation: titleScalePulse 0.52s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
    transform-origin: left center !important;
    will-change: transform;
}

@keyframes reminderCardPopDesktop {
    0% {
        transform: scale(1) translateZ(0);
    }

    45% {
        transform: scale(1.05) translateZ(0);
    }

    75% {
        transform: scale(0.99) translateZ(0);
    }

    100% {
        transform: scale(1) translateZ(0);
    }
}

@keyframes reminderCardPopMobile {
    0% {
        transform: scale(1) translateZ(0);
    }

    40% {
        transform: scale(1.04) translateZ(0);
    }

    75% {
        transform: scale(0.99) translateZ(0);
    }

    100% {
        transform: scale(1) translateZ(0);
    }
}

.reminder-card-pop,
.reminder-card.reminder-card-pop {
    animation: reminderCardPopDesktop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
    transform-origin: center center !important;
    z-index: 10 !important;
    will-change: transform;
}

@keyframes reminderBreathingGlow {

    0%,
    100% {
        opacity: 0;
    }

    50% {
        opacity: 1;
    }
}

@media (max-width: 768px) {

    .reminder-card-pop,
    .reminder-card.reminder-card-pop {
        animation: reminderCardPopMobile 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
    }
}

.card-pending {
    opacity: 0 !important;
    transform: translateY(24px) translateZ(0) !important;
    pointer-events: none;
}

.subtitle-pending {
    opacity: 0;
}

.subtitle-entrance,
.card-entrance {
    animation: cardEntrance 0.85s cubic-bezier(0.2, 0.9, 0.3, 1) 0.24s both !important;
}

.reminder-card.is-done.card-entrance {
    animation-name: cardEntranceDone !important;
}

body.is-chapter-scrolling .note-card,
body.is-chapter-scrolling .reminder-card {
    transition: none !important;
    animation: none !important;
}

body.is-chapter-scrolling .card-entrance {
    animation: none !important;
}

body:has(div[id$="-modal"].active) .note-card.reminder-glowing::before,
body:has(div[id$="-modal"].active) .reminder-card.reminder-glowing::before {
    animation-play-state: paused !important;
}

.btn-primary,
.btn-danger,
.btn-cancel,
.icon-btn,
.year-item,
.note-card,
.reminder-card,
.action-delete-btn,
.settings-action-btn,
.circle-btn,
.cal-btn,
.date-ui-display,
#bookmark-content,
#reminder-content,
.reminder-modal-checkbox,
.collapsed-icon-btn,
.category-more-btn {
    transform: translateZ(0);
    transition-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1) !important;
}

.btn-primary:active,
.btn-danger:active,
.btn-cancel:active,
.icon-btn:active,
.settings-action-btn:active,
.circle-btn:active,
.cal-btn:active,
.settings-action-btn:active+span,
#settings-modal div:has(> .settings-action-btn):active span {
    transform: scale(0.92) translateZ(0) !important;
    transition: transform 0.04s ease-out !important;
}

.year-item:not(:where(#category-list *)):not(.is-renaming):not(.is-dragging):not(.placeholder):not(:has(.category-more-btn:active)):active {
    transform: scale(0.95) translateZ(0) !important;
    transition: transform 0.04s ease-out !important;
}

.year-item.is-renaming:active,
.year-item.is-dragging:active,
.year-item.placeholder:active,
.year-item:has(.category-more-btn:active) {
    transform: none !important;
}

.date-ui-display:active,
#bookmark-content:active,
#reminder-content:active {
    transform: scale(0.97) translateZ(0) !important;
    transition: transform 0.05s ease-out !important;
}

.note-card:active,
.reminder-card:active {
    transform: scale(0.96) translateZ(0) !important;
    transition: transform 0.04s ease-out !important;
}

body.no-scroll {
    overflow: hidden !important;
    touch-action: none;
}

textarea,
#full-note-content {
    touch-action: pan-y !important;
    overscroll-behavior: contain;
    overflow-y: auto;
}

/* ==========================================
   17. 互動回饋懸停規則 (@media hover: hover)
   ========================================== */
@media (hover: hover) {
    .collapsed-icon-btn:hover {
        transform: scale(1.2) translateZ(0);
        color: var(--primary);
        transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.2s ease;
    }

    .chapter-nav-rail:hover .chapter-tick:not(.active) {
        opacity: 0.65;
        transform: scaleX(1.1) translateZ(0);
    }

    .chapter-nav-rail:hover {
        filter: drop-shadow(0 0 6px rgba(154, 135, 30, 0.45));
    }

    .chapter-item:hover:not(.active) {
        background: transparent !important;
        color: var(--text);
        opacity: 1;
    }

    .icon-btn:hover {
        background: rgba(150, 150, 150, 0.2);
    }

    .fab-main-btn:hover:not(.toast-mode):not(.fab-morph-squeeze) {
        transform: scale(1.15) translateZ(0) !important;
    }

    body:not(.is-dragging-item) .year-item:hover:not(.active) {
        background: transparent !important;
        color: var(--text);
        opacity: 1;
    }

    .category-popover-item:hover:not(.danger),
    .context-item:hover:not(.danger) {
        background: transparent !important;
        color: var(--text);
        opacity: 1;
    }

    .btn-primary:hover,
    .btn-danger:hover,
    .btn-cancel:hover {
        transform: scale(1.03);
    }

    .note-card:hover,
    .reminder-card:hover {
        background: linear-gradient(rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.035)), var(--card-glass-bg) !important;
    }

    .reminder-modal-checkbox:not(.checked):hover {
        background: rgba(150, 150, 150, 0.15);
        color: var(--text);
        border-color: var(--glass-border);
        transform: scale(1.08) translateZ(0);
    }

    .reminder-modal-checkbox:not(.checked):hover svg {
        color: var(--text);
    }

    .reminder-modal-checkbox.checked:hover {
        transform: scale(1.08) translateZ(0);
        box-shadow: 0 0 24px rgba(154, 135, 30, 0.7), 0 4px 18px rgba(154, 135, 30, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.22);
    }

    .segment-btn:not(.active):hover {
        color: var(--primary);
    }

    #editor-external-top-bar #unified-type-selector .segment-btn:not(.active):hover {
        color: var(--text) !important;
    }

    .date-ui-display:hover {
        border-color: var(--glass-border);
        box-shadow: var(--glass-inner-highlight);
    }

    .cal-btn:hover {
        background: rgba(154, 135, 30, 0.2);
    }

    .cal-day-cell:not(.selected):hover {
        background: rgba(154, 135, 30, 0.3);
    }

    .action-delete-btn:hover:not(:active) {
        background: transparent;
        color: #ff5c6a;
        transform: none !important;
    }

    .action-delete-btn:hover:active {
        background: transparent;
        color: #ff5c6a !important;
        transform: scale(0.85) translateZ(0) !important;
        transition: transform 0.04s ease-out !important;
    }

    .action-delete-btn[style*="pointer-events: none"]:hover {
        color: var(--text-secondary) !important;
    }

    .fab-main-btn.tucked:hover {
        transform: translateX(calc(100% + 6px)) scale(1) translateZ(0) !important;
        opacity: 0.8 !important;
    }

    .settings-action-btn:hover,
    div:has(> .settings-action-btn):hover .settings-action-btn {
        background: rgba(150, 150, 150, 0.15);
        color: var(--text);
        border-color: var(--glass-border);
        transform: scale(1.15) translateZ(0);
        transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.25s ease, color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    }

    .settings-action-btn:hover+span,
    div:has(> .settings-action-btn):hover span {
        color: var(--text) !important;
        transform: scale(1.15) translateZ(0);
        transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.2s ease;
    }

    .circle-btn.done-btn:hover {
        transform: scale(1.15);
        background: var(--primary);
    }

    .text-toolbar .icon-btn:hover {
        background: transparent !important;
        transform: scale(1.15);
    }

    #mobile-sidebar-overlay,
    #modal-overlay,
    #confirm-overlay,
    #calendar-overlay,
    .context-menu {
        transition: none !important;
    }
}

