/*—— 自訂字體 ——*/
@font-face {
  font-family: "GenSenRounded2TW-R";
  src: url("../font/GenSenRounded2TW-R.otf") format("opentype"),
       url("../font/GenSenRounded2TW-R.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "GenSenRounded2TW-L";
  src: url("../font/GenSenRounded2TW-L.otf") format("opentype"),
       url("../font/GenSenRounded2TW-L.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

html{
    background-image: url('../images/首頁背景星空.jpg');
}

:root {
    --primary-gradient: #9c7a5c;
    --secondary-gradient: #6c808f;
    --bg-color: #ffffff;
    --chat-bg: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --bot-message-bg: #ffffffcc;
    --user-message-bg: #ffffffcc;
    --border-color: #edf4fd;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    }

    .stars-bg {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: url("../images/首頁背景星星.png") no-repeat 0 0;
        background-size: cover;
        opacity: 0.3;
        pointer-events: none;
        z-index: 0;
        transform-origin: center center;
    }

    /* 從夢中醒來的初始狀態 */
    .story-body {
        font-family: "GenSenRounded2TW-R", sans-serif;
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100%;
        height: 100%;
        filter: blur(8px) brightness(0.3) contrast(0.8);
        opacity: 0.6;
        border-radius: 72px;
        transform: scale(1.05);
        transition: all 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
        position: relative;
        overflow-y: hidden;
    }

    .story-body.awakening {
        filter: blur(0px) brightness(1) contrast(1);
        opacity: 1;
        transform: scale(1);
    }

    /* 夢境霧氣效果 */
    .story-body::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(45deg, 
            rgba(255, 255, 255, 0.1) 0%,
            rgba(200, 220, 255, 0.15) 25%,
            rgba(255, 255, 255, 0.05) 50%,
            rgba(180, 200, 255, 0.1) 75%,
            rgba(255, 255, 255, 0.08) 100%);
        opacity: 1;
        border-radius: 72px;
        transition: opacity 2s ease-out;
        pointer-events: none;
        z-index: 5;
        animation: dreamMist 2s ease-out;
    }

    .story-body.awakening::before {
        opacity: 0;
    }

    @keyframes dreamMist {
        0% {
            opacity: 0.8;
            background-size: 300% 300%;
            background-position: 0% 50%;
        }
        50% {
            background-position: 100% 50%;
        }
        100% {
            opacity: 0;
            background-size: 100% 100%;
            background-position: 50% 50%;
        }
    }

    /* 文字逐漸聚焦效果 */
    .story-container {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 900px;
        max-width: 90vw;
        min-height: 27.8rem;
        max-height: 27.8rem;
        padding: 20px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 72px;
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        scroll-behavior: smooth;
        z-index: 10;
        transition: fliter 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) opacity 2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .story-body:not(.awakening) .story-container {
        filter: blur(2px);
        opacity: 0.7;
    }

    .story-container::before {
        content: "";
        position: absolute;
        inset: 0;
        -webkit-box-shadow:
            inset -7px -5.25px 2px -6.5px rgba(255, 255, 255), 
            inset 7px 5.25px 2px -6.5px rgb(255, 255, 255),
            inset -2.25px -8px 2px -6.75px rgb(255, 255, 255), 
            inset 2.25px 8px 2px -6.75px rgb(255, 255, 255),
            4px 8px 32px 0px rgba(110, 110, 110, 0.25);
        box-shadow:
            inset -7px -5.25px 2px -6.5px rgba(255, 255, 255), 
            inset 7px 5.25px 2px -6.5px rgb(255, 255, 255),
            inset -2.25px -8px 2px -6.75px rgb(255, 255, 255), 
            inset 2.25px 8px 2px -6.75px rgb(255, 255, 255),
            4px 8px 32px 0px rgba(110, 110, 110, 0.25);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: -1;
        border-radius: 72px;
    }

    .story-header {
    display: flex;
    justify-content: start;
    align-items: center;
    width: 95%;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    }

    .story-header-title {
    display: flex;
    width: 100%;
    padding: 0.5rem 1rem;
    gap: 1rem;
    }

    .story-header-profile-photo {
    width: 2.5rem;
    height: 2.5rem;
    background-image: url('../images/火箭貓.webp');
    background-size: 6.5rem auto;
    background-position: -1.55rem -0.75rem;
    background-repeat: no-repeat;
    border-radius: 50%;
    }


    .story-header-title h1 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 2px;
    }
    
    .story-header-title i {
    color: #6c808f;
    }

    .story-header-title-lt {
    display: flex;
    align-items: center;
    margin-right: auto;
    gap: 1rem;
    }

    .story-header-title-rt {
    display: flex;
    align-items: center;
    margin-right: 20px;
    gap: 1rem;
    }

    .story-chat-container {
    flex: 1;
    width: 95%;
    overflow-y: auto;
    padding: 1.25rem;
    scroll-behavior: smooth;
    }

    .skip-button {
    position: absolute;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.3s ease;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-box-shadow:
    inset -0.185rem -0.235rem 0.315rem -0.295rem rgba(255, 255, 255), 
    inset 0.185rem 0.25rem 0.315rem -0.295rem rgba(255, 255, 255),
    -0.06rem -0.03rem 0 0 rgba(255, 255, 255), 
    0.03rem 0.03rem 0 0 rgba(255, 255, 255);
    box-shadow:
    inset -0.285rem -0.235rem 0.1rem -0.295rem rgba(255, 255, 255), 
    inset 0.285rem 0.235rem 0.1rem -0.295rem rgba(255, 255, 255),
    -0.03rem -0.025rem 0 0 rgba(255, 255, 255), 
    0.025rem 0.025rem 0 0 rgba(255, 255, 255),
    4px 16px 48px 8px rgba(110, 110, 110, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    }

    .skip-button:hover {
        background: rgba(0, 0, 0, 0.9);
        transform: translateX(-50%) scale(1.1);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    }

    .skip-button:active {
        transform: translateX(-50%) scale(0.95);
    }

    .skip-button.hidden {
        opacity: 0;
        pointer-events: none;
    }

    .skip-button i {
        animation: bounce 1.5s infinite;
    }

    @keyframes bounce {
        0%, 20%, 50%, 80%, 100% {
            transform: translateY(0);
        }
        40% {
            transform: translateY(-5px);
        }
        60% {
            transform: translateY(-3px);
        }
    }

    .story-time-stamp {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    background-color: var(--bot-message-bg);
    padding: 0.4rem 0.8rem;
    border-radius: 1rem;
    margin: 0 auto 1.5rem auto;
    width: fit-content;
    box-shadow: var(--shadow-sm);
    animation: messageAppear 0.5s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    letter-spacing: normal;
    }

    .story-message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(20px);
    animation: messageAppear 0.5s ease forwards;
    }

    @keyframes messageAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
    }

    .story-avatar {
    min-width: 2.5rem;
    min-height: 2.5rem;
    border-radius: 50%;
    margin-right: 1rem;
        background-image: url('../images/火箭貓.webp');
    background-size: 6.5rem auto;
    background-position: -1.55rem -0.75rem;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    letter-spacing: normal;
    box-shadow: var(--shadow-md);
    }

    .story-user-message .story-avatar {
    background: var(--secondary-gradient);
    }

    .story-message-bubble {
    max-width: 70%;
    padding: 0.75rem 0.75rem 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-sm);
    line-height: 1.4;
    letter-spacing: 0.25rem;
    box-shadow: 0px 0px 4px #6c808f;
    }

    .story-cat-message .story-message-bubble {
    background-color: var(--bot-message-bg);
    border-top-left-radius: 0;
    font-size: 0.85rem;
    }

    .story-user-message .story-message-bubble {
    background: var(--user-message-bg);
    font-size: 0.85rem;
    border-top-right-radius: 0;
    }

    .story-user-message {
    flex-direction: row-reverse;
    }

    .story-user-message .story-avatar {
    margin-right: 0;
    margin-left: 1rem;
    }

    .story-body .input-container {
    width: 95%;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
    }

     /* 打字效果 */
    .typing-indicator {
        display: flex;
        align-items: center;
        gap: 10px;
        opacity: 0;
        animation: fadeInUp 0.3s ease forwards;
    }

    .typing-dots {
        background: white;
        border-radius: 18px;
        padding: 12px 16px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        display: flex;
        gap: 4px;
        align-items: center;
    }

    .typing-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #999;
        animation: typingDot 1.4s infinite ease-in-out;
    }

    .typing-dot:nth-child(1) { animation-delay: 0s; }
    .typing-dot:nth-child(2) { animation-delay: 0.2s; }
    .typing-dot:nth-child(3) { animation-delay: 0.4s; }

    @keyframes typingDot {
        0%, 60%, 100% {
            opacity: 0.3;
            transform: scale(0.8);
        }
        30% {
            opacity: 1;
            transform: scale(1);
        }
    }

    .input-container .input-wrapper {
    display: flex;
    background-color: var(--chat-bg);
    border-radius: 1.5rem;
    margin: 0.5rem 0;
    box-shadow: var(--shadow-sm);
    }

    .message-input {
    flex: 1;
    padding: 0.5rem 0.25rem;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.75rem;
    letter-spacing: 2px;
    }

    .message-input:focus {
    outline: none;
    }

    .message-input::placeholder {
    color: var(--text-secondary);
    }

    .action-buttons {
    display: flex;
    padding: 0.5rem;
    }

    .action-button:hover {
    background-color: var(--bot-message-bg);
    color: var(--text-primary);
    }

    .send-button {
    font-family: "GenSenRounded2TW-R", sans-serif;
    background: var(--primary-gradient);
    width: max-content;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: visible;
    z-index: 1;
    }

    /* 按鈕的脈動外環效果 */
    .send-button:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 125%;
    height: 125%;
    border-radius: 2rem;
    background: var(--primary-gradient);
    opacity: 0;
    z-index: -1;
    }

    /* 按鈕本體動畫類別（脈動） */
    .send-button.pulse {
    animation: pulse-button 2.5s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite both;
    }

    /* 外環動畫類別（脈動擴散） */
    .send-button.pulse::before {
    animation: pulse-ring 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite both;
    }

    @keyframes pulse-ring {
        0% {
            transform: translate(-50%, -50%) scale(.5);
            opacity: 0.8;
        }
        80%, 100% {
            opacity: 0;
            transform: translate(-50%, -50%) scale(1.2);
        }
    }

    @keyframes pulse-button {
        0% {
            transform: scale(.95);
        }
        50% {
            transform: scale(1);
        }
        100% {
            transform: scale(.95);
        }
    }

    @keyframes fadeInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* 滾動條樣式 */
    .story-chat-container::-webkit-scrollbar {
        width: 4px;
    }

    .story-chat-container::-webkit-scrollbar-track {
        background: transparent;
    }

    .story-chat-container::-webkit-scrollbar-thumb {
        background: #ddd;
        border-radius: 2px;
    }

    .story-chat-container::-webkit-scrollbar-thumb:hover {
        background: #bbb;
    }

    @media (max-width: 1024px) {
    .story-container {
        width: 80vw;
        height: 60vh;
        max-width: 90%;
    }
    }

    @media (max-width: 768px) {

    .story-header-title h1 {
        font-size: 1rem;
    }
    .story-message-bubble {
        max-width: 85%;
        padding: 0.75rem 1.25rem;
    }
    .send-button {
        padding: 0.5rem;
    }
    }

    @media (max-width: 600px) {
        .story-container, .story-container::before, .story-body , .story-body::before {
            border-radius: 32px;
        }
        .story-header-title {
            gap: 0;
        }
    }
