/* ========================================
   零售之書 - 蘋果/小米極簡科技風格
   ======================================== */

/* CSS 變量定義 */
:root {
    /* 主要色調 - 極簡米白 */
    --color-bg: #fafafa;
    --color-bg-warm: #f5f5f4;
    --color-surface: #ffffff;

    /* 文字色調 */
    --color-text: #1d1d1f;
    --color-text-secondary: #6e6e73;
    --color-text-tertiary: #86868b;

    /* 強調色 - 專業墨綠 */
    --color-primary: #084741;
    --color-primary-hover: #0a5c54;

    /* 狀態色 - 柔和版本 */
    --color-success: #34c759;
    --color-success-bg: rgba(52, 199, 89, 0.1);
    --color-info: #5ac8fa;
    --color-info-bg: rgba(90, 200, 250, 0.1);
    --color-warning: #ff9500;
    --color-warning-bg: rgba(255, 149, 0, 0.1);
    --color-neutral: #8e8e93;
    --color-neutral-bg: rgba(142, 142, 147, 0.1);

    /* 邊框與分隔線 */
    --color-border: rgba(0, 0, 0, 0.06);
    --color-divider: rgba(0, 0, 0, 0.08);

    /* 陰影 - 精緻柔和 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);

    /* 過渡效果 */
    --transition-fast: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-medium: 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    --transition-slow: 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);

    /* 字體 - SF Pro 風格 */
    --font-sans: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;

    /* 圓角 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

/* 基礎重設 */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* 容器 */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 主要內容 */
.main-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    position: relative;
}

/* 區段樣式 */
.section {
    position: absolute;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition:
        opacity var(--transition-slow),
        visibility var(--transition-slow),
        transform var(--transition-slow);
}

.section.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ========================================
   圖示區塊 - 極簡購物袋
   ======================================== */
.icon-container {
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
}

.logo-icon {
    width: 44px;
    height: 44px;
    color: var(--color-text);
    stroke-width: 1.2;
}

/* ========================================
   標題與文字
   ======================================== */
.title {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

.subtitle {
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    margin-bottom: 2.5rem;
}

.instruction {
    font-size: 1.0625rem;
    font-weight: 400;
    line-height: 1.7;
    color: var(--color-text-secondary);
    margin-bottom: 2.5rem;
}

/* ========================================
   按鈕樣式 - 蘋果風格
   ======================================== */
.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    padding: 1rem 2rem;
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    font-weight: 500;
    color: white;
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.primary-button:hover {
    background: var(--color-primary-hover);
    transform: scale(1.02);
}

.primary-button:active {
    transform: scale(0.98);
}

.secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-primary);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-top: 1.5rem;
    transition: all var(--transition-fast);
}

.secondary-button:hover {
    background: rgba(0, 113, 227, 0.08);
}

.secondary-button .btn-icon {
    width: 18px;
    height: 18px;
}

/* ========================================
   指引卡片樣式 - 簡潔優雅
   ======================================== */
.card-container {
    width: 100%;
}

.guidance-card {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-card);
    animation: cardAppear 0.6s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes cardAppear {
    0% {
        opacity: 0;
        transform: scale(0.96) translateY(12px);
    }

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.card-tag {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--color-text-tertiary);
    padding: 0.375rem 0.75rem;
    background: var(--color-bg-warm);
    border-radius: var(--radius-sm);
}

.page-number {
    font-size: 0.75rem;
    color: var(--color-text-tertiary);
    font-weight: 400;
}

.card-divider {
    height: 1px;
    background: var(--color-divider);
    margin: 1.25rem 0;
}

/* ========================================
   運勢顯示區塊 - 簡約風格
   ======================================== */
.fortune-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem 0;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 0.2s forwards;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* 運勢大字 */
.fortune-text {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    line-height: 1.3;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
}

/* 運勢說明文字 */
.fortune-desc {
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--color-text-tertiary);
    margin-top: 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   運勢等級樣式 - 柔和優雅
   ═══════════════════════════════════════════════════════════════ */

/* 大吉 - 柔和綠色 */
.fortune-great .fortune-text {
    color: var(--color-success);
    background: var(--color-success-bg);
}

.fortune-great .fortune-desc {
    color: var(--color-success);
}

/* 中吉 - 科技藍 */
.fortune-good .fortune-text {
    color: var(--color-primary);
    background: rgba(8, 71, 65, 0.08);
}

.fortune-good .fortune-desc {
    color: var(--color-primary);
}

/* 小吉 - 清新青色 */
.fortune-small .fortune-text {
    color: #32ade6;
    background: var(--color-info-bg);
}

.fortune-small .fortune-desc {
    color: #32ade6;
}

/* 凶 - 柔和橙色（提醒而非警告） */
.fortune-bad .fortune-text {
    color: var(--color-warning);
    background: var(--color-warning-bg);
}

.fortune-bad .fortune-desc {
    color: var(--color-warning);
}

/* 答案文字 */
.answer-text {
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.8;
    color: var(--color-text);
    text-align: center;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 0.4s forwards;
    user-select: none;
}

/* ========================================
   顧問聯繫區塊
   ======================================== */
.consultant-info {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-divider);
    text-align: center;
    animation: fadeIn 0.5s ease-out 0.6s forwards;
    opacity: 0;
}

.consultant-text {
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-text-tertiary);
    margin-bottom: 1rem;
}

.consultant-text strong {
    color: var(--color-text-secondary);
    font-weight: 500;
}

.line-contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    color: #fff;
    background-color: #06C755;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.line-contact-btn:hover {
    background-color: #05b34d;
    transform: scale(1.02);
}

.line-contact-btn:active {
    transform: scale(0.98);
}

.line-icon {
    width: 18px;
    height: 18px;
}

/* ========================================
   頁腳
   ======================================== */
.footer {
    padding: 2rem;
    text-align: center;
}

.footer-text {
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--color-text-tertiary);
}

.footer-copyright {
    font-size: 0.6875rem;
    font-weight: 400;
    color: var(--color-text-tertiary);
    opacity: 0.6;
    margin-top: 0.5rem;
}

/* ========================================
   SEO 隱藏內容 - 視覺隱藏但對搜尋引擎可見
   ======================================== */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ========================================
   響應式設計
   ======================================== */
@media (max-width: 768px) {
    .main-content {
        padding: 2rem 1.5rem;
    }

    .guidance-card {
        padding: 1.5rem;
    }

    .icon-container {
        width: 72px;
        height: 72px;
        margin-bottom: 1.5rem;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .title {
        font-size: 2rem;
    }

    .instruction {
        font-size: 1rem;
        margin-bottom: 2rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1.5rem 1rem;
    }

    .guidance-card {
        padding: 1.25rem;
        border-radius: var(--radius-lg);
    }

    .primary-button {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .secondary-button {
        padding: 0.75rem 1.25rem;
        font-size: 0.875rem;
    }

    .fortune-text {
        font-size: 1.75rem;
    }

    .answer-text {
        font-size: 1rem;
    }
}

/* ========================================
   頁面過渡動畫
   ======================================== */
.fade-out {
    animation: fadeOut var(--transition-medium) forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

/* 載入動畫 */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-divider);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ========================================
   按鈕群組
   ======================================== */
.button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.share-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.share-button:hover {
    background: var(--color-bg-warm);
    border-color: var(--color-text-tertiary);
}

.share-button .btn-icon {
    width: 18px;
    height: 18px;
}

/* ========================================
   分享 Modal
   ======================================== */
.share-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-medium);
    padding: 1rem;
}

.share-modal.active {
    opacity: 1;
    visibility: visible;
}

.share-modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-medium);
}

.share-modal.active .share-modal-content {
    transform: scale(1) translateY(0);
}

.share-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-divider);
}

.share-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

.close-modal-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-warm);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

.close-modal-btn:hover {
    background: var(--color-divider);
    color: var(--color-text);
}

.close-modal-btn svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   分享卡片 - 用於截圖
   ======================================== */
/* ========================================
   分享卡片 - 直式籤詩/報告風格
   ======================================== */
.share-card-vertical {
    margin: 1.5rem;
    position: relative;
    /* 設定長寬比，模擬直式紙張 */
    width: 300px;
    /* 固定寬度以確保布局 */
    margin-left: auto;
    margin-right: auto;
    background: #fdfbf7;
    /* 米白色紙張質感 */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.share-border-outer {
    padding: 12px;
    border: 1px solid var(--color-primary);
    /* 外細框 */
    height: 100%;
}

.share-border-inner {
    border: 4px double var(--color-primary);
    /* 內雙線框 */
    height: 100%;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background-image: radial-gradient(#e0ddd5 1px, transparent 1px);
    background-size: 20px 20px;
    /* 點狀底紋 */
    background-position: 0 0;
}

/* 頭部 */
.share-header {
    text-align: center;
    width: 100%;
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: 16px;
    margin-bottom: 24px;
}

.share-date {
    font-family: 'Courier New', monospace;
    /* 打字機字體感 */
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.share-report-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: 0.2em;
}

/* 內容區 */
.share-content {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0 30px;
}

/* 運勢印章 */
.share-fortune-stamp {
    width: 80px;
    height: 80px;
    border: 3px solid currentColor;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    /* 改用 Flex 垂直排列 */
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    transform: rotate(-5deg);
    /* 模擬蓋章傾斜 */
    mix-blend-mode: multiply;
    line-height: 1.1;
}

.stamp-text {
    font-size: 2rem;
    font-weight: 700;
    /* 改用 flex-column 排列，取消 writing-mode */
    letter-spacing: 0;
}

/* 運勢配色 */
.share-fortune-stamp.fortune-great {
    color: var(--color-success);
    background: rgba(52, 199, 89, 0.05);
}

.share-fortune-stamp.fortune-good {
    color: var(--color-primary);
    background: rgba(8, 71, 65, 0.05);
}

.share-fortune-stamp.fortune-small {
    color: #32ade6;
    background: rgba(50, 173, 230, 0.05);
}

.share-fortune-stamp.fortune-bad {
    color: var(--color-warning);
    background: rgba(255, 149, 0, 0.05);
}

.share-fortune-desc-vertical {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
    font-weight: 500;
    letter-spacing: 0.05em;
    position: relative;
    padding: 0 10px;
}

.share-fortune-desc-vertical::before,
.share-fortune-desc-vertical::after {
    content: '—';
    margin: 0 8px;
    color: var(--color-border);
}

.share-text-container {
    width: 100%;
}

.share-answer-text-vertical {
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.8;
    color: var(--color-text);
    text-align: justify;
    /* 左右對齊 */
    letter-spacing: 0.05em;
}

/* 底部 */
.share-footer {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 16px;
    border-top: 1px solid var(--color-divider);
}

.share-brand-vertical {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.brand-icon-sm {
    width: 18px;
    height: 18px;
}

.share-url-vertical {
    font-family: 'Courier New', monospace;
    font-size: 0.65rem;
    color: var(--color-text-tertiary);
    letter-spacing: 0.05em;
}

/* ========================================
   分享選項按鈕
   ======================================== */
.share-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    padding: 0 1.5rem 1.5rem;
}

.share-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--color-bg-warm);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.share-option-btn:hover {
    transform: translateY(-2px);
}

.share-option-btn:active {
    transform: translateY(0);
}

.share-icon {
    width: 24px;
    height: 24px;
}

/* LINE 按鈕 */
.share-line {
    color: #06C755;
}

.share-line:hover {
    background: rgba(6, 199, 85, 0.1);
}

/* Threads 按鈕 */
.share-threads {
    color: #000000;
}

.share-threads:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* 下載按鈕 */
.share-download {
    color: var(--color-text-secondary);
}

.share-download:hover {
    background: var(--color-divider);
    color: var(--color-text);
}

/* 複製按鈕 */
.share-copy {
    color: var(--color-text-secondary);
}

.share-copy:hover {
    background: var(--color-divider);
    color: var(--color-text);
}

/* ========================================
   響應式 - 分享功能
   ======================================== */
@media (max-width: 480px) {
    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .secondary-button,
    .share-button {
        width: 100%;
        justify-content: center;
    }

    .share-modal-content {
        max-width: 100%;
        border-radius: var(--radius-lg);
    }

    .share-card {
        margin: 1rem;
        padding: 1.25rem;
    }

    .share-options {
        padding: 0 1rem 1rem;
        gap: 0.5rem;
    }

    .share-option-btn {
        padding: 0.875rem;
    }
}

/* ========================================
   圖片預覽 Modal (手機長按儲存)
   ======================================== */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1100;
    /* 比 share-modal 更高 */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 20px;
}

.image-preview-modal.active {
    opacity: 1;
    visibility: visible;
}

.preview-content {
    background: transparent;
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: white;
}

.preview-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.preview-header .close-modal-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.preview-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#generated-image {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.preview-tip {
    color: white;
    font-size: 0.9375rem;
    font-weight: 500;
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}