/* 全站終端機方塊游標樣式（VS Code Terminal Style：字元等寬、亮黃色、恆亮無閃爍、文字反白、圖層分離果凍彈簧） */
.terminal-block-caret {
    position: fixed;
    pointer-events: none;
    z-index: 999999;
    background-color: transparent !important;
    border: none !important;
    display: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: visible;
    /* 外層定位容器平滑追隨位移與換行飛躍，具備輕微彈性阻尼感 */
    transition: left 0.16s cubic-bezier(0.25, 1, 0.5, 1),
        top 0.18s cubic-bezier(0.25, 1, 0.5, 1),
        width 0.1s ease,
        height 0.1s ease;
}

/* 底層：亮黃色果凍彈簧動畫圖層（單獨承擔 scaleX/scaleY 彈性形變，與文字徹底解耦） */
.terminal-block-caret .terminal-caret-jelly-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--primary, #F0B90B);
    border-radius: 2px;
    z-index: 1;
    pointer-events: none;
    will-change: transform;
    transform-origin: center center;
    transition: transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(1, 1);
}

/* 頂層：文字反白圖層（100% 原始字型比例，完全不受任何縮放與形變影響） */
.terminal-block-caret .terminal-caret-char {
    position: relative;
    z-index: 2;
    display: inline-block;
    color: #121212 !important;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    transform: none !important;
}

/* 前向錨定：向右移動時以左邊為錨點向前伸長，絕不往後擠壓覆蓋已鍵入的字元 */
.terminal-block-caret.jelly-move-right .terminal-caret-jelly-bg {
    transform-origin: left center;
    transform: scaleX(1.32) scaleY(0.9);
}

/* 後向錨定：向左移動時以右邊為錨點向後伸長 */
.terminal-block-caret.jelly-move-left .terminal-caret-jelly-bg {
    transform-origin: right center;
    transform: scaleX(1.32) scaleY(0.9);
}

/* 縱向向下換行或欄位切換：以頂端為錨點向下伸長拉曳 */
.terminal-block-caret.jelly-move-down .terminal-caret-jelly-bg {
    transform-origin: center top;
    transform: scaleX(0.88) scaleY(1.32);
}

/* 縱向向上換行或欄位切換：以底端為錨點向上伸長拉曳 */
.terminal-block-caret.jelly-move-up .terminal-caret-jelly-bg {
    transform-origin: center bottom;
    transform: scaleX(0.88) scaleY(1.32);
}

/* 獲得焦點初次登場：彈性微縮放淡入動畫（方案 A：帶有果凍回彈感） */
@keyframes terminalCaretPopIn {
    0% {
        opacity: 0;
        transform: scale(0.65);
    }
    60% {
        opacity: 1;
        transform: scale(1.14);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.terminal-block-caret.caret-pop {
    animation: terminalCaretPopIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

[data-no-glass] .terminal-block-caret.caret-pop {
    animation: none !important;
}

/* 減少動態效果（data-no-glass）：立即停用所有彈簧動畫與延遲 */
[data-no-glass] .terminal-block-caret {
    transition: none !important;
}

[data-no-glass] .terminal-block-caret .terminal-caret-jelly-bg {
    transition: none !important;
    transform: none !important;
}

/* 手機與觸控裝置：強制取消電腦版打字機方塊游標，完全使用原生選取與輸入效果 */
@media (max-width: 768px), (pointer: coarse) {
    .terminal-block-caret {
        display: none !important;
    }
    body.has-terminal-caret input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    body.has-terminal-caret textarea,
    body.has-terminal-caret [contenteditable="true"] {
        caret-color: auto !important;
    }
}

/* 啟用終端機方塊游標時，隱藏原生細線閃爍游標 */
body.has-terminal-caret input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.has-terminal-caret textarea,
body.has-terminal-caret [contenteditable="true"] {
    caret-color: transparent !important;
}

/* 輸入框取得焦點時，預設文字（placeholder）暫時隱藏；失去焦點且無內容時自動恢復顯示 */
input:focus::placeholder,
textarea:focus::placeholder,
.custom-input:focus::placeholder,
#full-reminder-title-input:focus::placeholder,
.profile-underline-input:focus::placeholder {
    opacity: 0 !important;
    color: transparent !important;
    transition: opacity 0.12s ease, color 0.12s ease;
}

input:focus::-webkit-input-placeholder,
textarea:focus::-webkit-input-placeholder,
.custom-input:focus::-webkit-input-placeholder,
#full-reminder-title-input:focus::-webkit-input-placeholder,
.profile-underline-input:focus::-webkit-input-placeholder {
    opacity: 0 !important;
    color: transparent !important;
    transition: opacity 0.12s ease, color 0.12s ease;
}

/* 內容可編輯區域（contenteditable）獲得焦點時，:empty:before 偽元素預設文字平滑淡出，與 input placeholder 動畫完全一致 */
#reminder-content:focus:before,
#bookmark-content:focus:before,
#full-note-content:focus:before {
    opacity: 0 !important;
    color: transparent !important;
    pointer-events: none !important;
    transition: opacity 0.12s ease, color 0.12s ease;
}
