/* --- 全域設定 --- */
:root {
    --primary-color: #333;
    --text-secondary: #666;
    --bg-gradient-start: #f6f9fc;
    --bg-gradient-end: #eef2f3;
    /* 各工具的主題色改在 tools.js 設定 */
}

body {
    font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    color: var(--primary-color);
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    position: relative;
    overflow-x: hidden;
}

/* --- 背景動態裝飾 --- */
.bg-decoration {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 50%);
    animation: rotate 60s linear infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- 容器佈局 --- */
.container {
    width: 100%;
    max-width: 1000px;
    padding: 40px 20px;
    z-index: 1;
    animation: fadeIn 0.8s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Header --- */
.main-header {
    text-align: center;
    margin-bottom: 60px;
}

.logo-badge {
    display: inline-block;
    background: #333;
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.main-header h1 {
    font-size: 42px;
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-weight: 900;
    letter-spacing: -1px;
    text-shadow: 2px 2px 0px rgba(255,255,255,0.5);
}

.main-header p {
    font-size: 18px;
    color: #7f8c8d;
    margin: 0;
    font-weight: 500;
}

/* --- 卡片網格 --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

/* --- 工具卡片 --- */
.tool-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 24px;
    padding: 40px 30px;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 15px 35px rgba(0,0,0,0.05), 0 5px 15px rgba(0,0,0,0.03);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.8);
}

/* Hover 特效 */
.tool-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1), 0 10px 20px rgba(0,0,0,0.05);
}

/* 卡片內部裝飾圓圈 */
.card-decoration {
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    opacity: 0.1;
    transition: transform 0.5s ease;
}

.tool-card:hover .card-decoration {
    transform: scale(1.2);
}

/* --- Icon 設計 --- */
.icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin-bottom: 25px;
    transition: transform 0.3s ease;
    position: relative;
    z-index: 2;
}

.tool-card:hover .icon-wrapper {
    transform: scale(1.1) rotate(5deg);
}

.emoji {
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* --- 文字內容 --- */
.card-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    z-index: 2;
}

.card-content h2 {
    font-size: 24px;
    margin: 0 0 12px 0;
    font-weight: 700;
    color: #2c3e50;
}

.card-content p {
    font-size: 15px;
    color: #666;
    line-height: 1.6;
    margin: 0 0 30px 0;
    flex-grow: 1;
}

/* --- 按鈕 --- */
.card-footer {
    margin-top: auto;
}

.btn-go {
    display: block;
    width: 100%;
    padding: 12px 0;
    border-radius: 12px;
    text-align: center;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.2s;
    letter-spacing: 1px;
}

/* --- 卡片配色 --- */
/* --card-color / --card-bg 由 script.js 依 tools.js 的 color / bg 設定在每張卡片上 */
.tool-card .icon-wrapper {
    background: var(--card-bg);
    color: var(--card-color);
}
.tool-card .card-decoration {
    background: var(--card-color);
}
.tool-card .btn-go {
    background-color: #f0f0f0;
    color: #333;
}
.tool-card:hover .btn-go {
    background-color: var(--card-color);
    color: white;
    box-shadow: 0 5px 15px color-mix(in srgb, var(--card-color) 30%, transparent);
}

/* --- Footer --- */
.main-footer {
    text-align: center;
    margin-top: 60px;
    color: #95a5a6;
    font-size: 13px;
    font-weight: 500;
}

/* --- RWD --- */
@media (max-width: 600px) {
    .main-header h1 { font-size: 32px; }
    .card-grid { grid-template-columns: 1fr; }
    .container { padding: 20px; }
}

/* ========================================= */
/* 🎯 新增樣式：Google 登入/登出 (不影響原版面) */
/* ========================================= */
#auth-container {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px; /* 預留高度避免跳動 */
}

/* 🎯 重新設計的使用者資訊區塊 (膠囊狀) */
#user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 6px 12px 6px 6px; /* 左側 padding 較小，因為有圖片 */
    border-radius: 30px; /* 更圓潤 */
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    cursor: pointer; /* 讓它看起來可點擊 */
    transition: all 0.2s;
    border: 1px solid rgba(0,0,0,0.05);
    /* 改成 <button> 後，清掉瀏覽器預設的按鈕字體樣式 */
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

#user-info:focus-visible,
.auth-btn.login:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* 懸停時的效果 */
#user-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.12);
    background: #f9f9f9;
}

/* 使用者頭像 */
#user-photo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover; /* 確保圖片不變形 */
    border: 2px solid white; /* 可選：白色邊框 */
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 沒有頭像或頭像載入失敗時的預設圖示 */
.user-photo-fallback {
    font-size: 32px;
    line-height: 1;
    color: #b0b8bf;
    display: inline-flex;
}

#user-photo[hidden],
.user-photo-fallback[hidden] {
    display: none;
}

/* 使用者名稱 */
#user-display-name {
    font-weight: 700;
    color: var(--primary-color);
    font-size: 14px;
}

/* 下拉箭頭 */
.dropdown-arrow {
    font-size: 12px;
    color: #999;
    transition: transform 0.2s;
}

#user-info:hover .dropdown-arrow {
    color: var(--primary-color);
    transform: translateY(1px);
}

/* 登入按鈕樣式 (保持不變) */
.auth-btn.login {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    border-radius: 20px;
    padding: 8px 16px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background-color: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.auth-btn.login:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Firebase 載入失敗時停用登入按鈕 */
.auth-btn.login:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

/* ========================================= */
/* 🎯 新增樣式：Github 角落連結 */
/* ========================================= */
.github-link {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem; /* 圖示大小 */
    color: var(--primary-color);
    opacity: 0.5; /* 預設半透明，避免太搶眼 */
    transition: all 0.3s ease;
    z-index: 100; /* 確保在最上層 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.github-link:hover {
    opacity: 1;
    transform: scale(1.1) rotate(10deg);
    color: #24292e; /* Github 品牌色 */
}

/* RWD: 手機版稍微縮小並調整位置 */
@media (max-width: 600px) {
    .github-link {
        top: 15px;
        right: 15px;
        font-size: 1.5rem;
    }
}

/* ========================================= */
/* 🎯 隱私權提示樣式 (補回) */
/* ========================================= */
.privacy-note {
    margin-top: 15px;
    font-size: 13px;
    color: #95a5a6; /* 使用低調的灰色 */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    opacity: 0.8;
}

.privacy-note i {
    font-size: 14px;
}

/* Firebase 載入失敗時，隱私權提示改顯示錯誤訊息 */
.privacy-note.is-error {
    color: #d35400;
    opacity: 1;
}
