/* CalWhat - Life in Weeks（Journey to Paradise）頁面專屬樣式 */
/* 這頁刻意是深色宇宙底：夜空 + 圓點矩陣 + 年齡漸層色是它的靈魂，不套一般白底 glass-card */

:root {
    /* 這頁的品牌紫漸層（hero CTA／編輯器 header／chips／按鈕共用），改色只改這裡 */
    --life-brand-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 滿版出血：body 的 layout padding 會在深色底左右切出白邊 */
body {
    padding: 0 !important;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.container {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
}

/* ===== 星空：宇宙感的顆粒層（純裝飾，點不到、讀屏跳過） ===== */
#starfield {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.star {
    position: absolute;
    border-radius: 50%;
    background: #fff;
    animation: twinkle 3.5s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: .15; }
    50% { opacity: .9; }
}

@media (prefers-reduced-motion: reduce) {
    .star { animation: none; opacity: .4; }
}

.life-canvas {
    position: relative;
    z-index: 1;
    padding: 20px 16px 40px;
}

/* ===== 1. 標題（點擊 = 專注模式） ===== */
h1#title {
    text-align: center;
    color: #fff;
    font-size: 2em;
    margin: 6px 0 4px;
    font-weight: 300;
    text-shadow: 2px 2px 4px rgba(0,0,0,.2);
    cursor: pointer;
    user-select: none;
    transition: transform .2s ease;
}

    h1#title:hover { transform: scale(1.02); }
    h1#title:active { transform: scale(.98); }

.life-subtitle {
    text-align: center;
    color: rgba(255,255,255,.72);
    margin: 0 auto 20px;
    max-width: 560px;
    line-height: 1.6;
}

/* ===== 2. Hero 卡：四色圓環先給答案（走過多少／還剩多少） ===== */
.hero-card {
    max-width: 480px;
    margin: 0 auto 22px;
    padding: 26px 20px 22px;
    border-radius: 20px;
    background: linear-gradient(160deg, rgba(255,255,255,.08) 0%, rgba(255,255,255,.03) 100%);
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 10px 40px rgba(0,0,0,.35);
    text-align: center;
}

.hero-ring-wrap {
    position: relative;
    width: 210px;
    height: 210px;
    margin: 0 auto 14px;
}

.hero-ring {
    width: 100%;
    height: 100%;
    display: block;
}

/* 四色軌道 = 人生四個階段（童年藍→青年綠→中年橙→老年紅），亮弧 = 你走到哪 */
.ring-track-quarter {
    fill: none;
    opacity: .32;
}

.ring-progress {
    fill: none;
    stroke-linecap: round;
    transition: stroke-dashoffset .7s cubic-bezier(.4,0,.2,1), stroke .4s ease;
}

.ring-marker {
    fill: #fff;
    stroke-width: 3;
    filter: drop-shadow(0 0 6px rgba(255,255,255,.7));
    animation: markerPulse 2.2s ease-in-out infinite;
    transition: cx .7s cubic-bezier(.4,0,.2,1), cy .7s cubic-bezier(.4,0,.2,1);
}

@keyframes markerPulse {
    0%, 100% { r: 6; }
    50% { r: 7.5; }
}

@media (prefers-reduced-motion: reduce) {
    .ring-progress, .ring-marker { transition: none; animation: none; }
}

.hero-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.hero-percent {
    font-size: 2.6em;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    letter-spacing: -.5px;
}

    .hero-percent .unit {
        font-size: .4em;
        font-weight: 500;
        margin-left: 2px;
        opacity: .85;
    }

.hero-remaining {
    margin-top: 8px;
    color: rgba(255,255,255,.72);
    line-height: 1.4;
    max-width: 150px;
}

    .hero-remaining strong {
        color: #ffd166;
        font-weight: 700;
    }

.hero-tagline {
    font-size: 1.08em;
    line-height: 1.75;
    color: #fff;
    margin: 2px auto 20px;
    max-width: 400px;
    min-height: 3.5em;
}

    .hero-tagline strong { color: #ffd166; font-weight: 700; }
    .hero-tagline .name-chip { color: #a3d9ff; font-weight: 700; }

.hero-cta-row {
    display: flex;
    gap: 10px;
}

.hero-cta {
    flex: 1;
    padding: 14px 10px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    min-height: 48px;
    transition: transform .15s ease, box-shadow .15s ease;
}

    .hero-cta:active { transform: scale(.97); }

.hero-cta-primary {
    background: var(--life-brand-gradient);
    color: #fff;
    box-shadow: 0 6px 18px rgba(102,126,234,.4);
}

    .hero-cta-primary:hover { box-shadow: 0 8px 22px rgba(102,126,234,.55); }

.hero-cta-outline {
    background: rgba(255,255,255,.08);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,.35);
}

    .hero-cta-outline:hover { background: rgba(255,255,255,.16); }

/* ===== 3. 圓點矩陣（頁面靈魂，緊接 hero） ===== */
#dots-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    width: 100%;
    color: white;
    padding: 16px;
    background-color: rgba(255,255,255,.05);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,.1);
    align-items: center;
}

.dot {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bolder;
    transition: transform .2s ease, box-shadow .2s ease;
}

    .dot:hover {
        transform: scale(1.1);
        box-shadow: 0 0 10px rgba(255,255,255,.3);
    }

.highlighted-dot {
    transform: scale(2);
    font-size: .8em;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,.9);
    z-index: 999;
    animation: pulse 2s ease-in-out infinite;
}

/* hero 圓環正在凝視的那個人，在矩陣裡也標出來 */
.is-focused-dot {
    outline: 2px solid #fff;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255,255,255,.5); }
    50% { box-shadow: 0 0 20px rgba(255,255,255,.8); }
}

.arrow {
    line-height: 5px;
    font-size: 1.5em;
    font-weight: bold;
    color: rgba(255,255,255,.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dot-wrapper {
    width: 15px;
    height: 15px;
    position: relative;
    flex-shrink: 0;
}

    .dot-wrapper > .dot {
        position: absolute;
        inset: 0;
    }

/* ===== 4. 時間尺度切換器 ===== */
.switch {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 18px 0;
    flex-wrap: wrap;
    background-color: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

    .switch label {
        display: flex;
        align-items: center;
        gap: 8px;
        color: #555;
        font-weight: 500;
        cursor: pointer;
        transition: color .2s ease;
        user-select: none;
    }

        .switch label:hover { color: #667eea; }

    .switch input[type="radio"],
    .switch input[type="checkbox"] {
        cursor: pointer;
        width: 18px;
        height: 18px;
        accent-color: #667eea;
    }

/* ===== 5. 進度條 ===== */
#bar-container {
    width: 100%;
    padding-bottom: 60px;
    margin-bottom: 18px;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 25px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    overflow: visible !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,.1);
}

.marker {
    position: absolute;
    bottom: -10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-shadow: 2px 2px 4px rgba(0,0,0,.3);
    white-space: nowrap;
    padding: 0 5px;
    font-weight: 600;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.2));
}

    .marker::after {
        content: '▲';
        color: #fff;
        font-size: 14px;
        margin-top: -60px;
        filter: drop-shadow(0 2px 3px rgba(0,0,0,.3));
    }

    .marker span {
        display: block;
        font-size: 13px;
        margin-top: 2px;
        text-align: center;
        transform: rotate(90deg);
        font-weight: 500;
    }

/* ===== 6. 成員編輯器 ===== */
#member-editor {
    background-color: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
    margin-bottom: 18px;
}

/* 摘要 chips：編輯器收折時仍看得見全家人，點一下切換圓環凝視對象 */
.member-summary-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(102,126,234,.08) 0%, rgba(118,75,162,.08) 100%);
    border-bottom: 1px solid #eee;
}

.member-summary-label {
    color: #666;
    white-space: nowrap;
}

.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #f1f2f8;
    color: #444;
    font-weight: 600;
    border: 2px solid transparent;
    cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease;
}

    .member-chip:hover { background: #e3e6fb; }

    .member-chip.is-focused {
        background: var(--life-brand-gradient);
        color: #fff;
        border-color: rgba(255,255,255,.5);
        box-shadow: 0 3px 10px rgba(102,126,234,.4);
    }

.editor-header {
    background: var(--life-brand-gradient);
    color: white;
    padding: 15px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background .3s ease;
}

    .editor-header:hover { background: linear-gradient(135deg, #5568d3 0%, #653b8b 100%); }

    .editor-header h3 {
        margin: 0;
        font-size: 1.2em;
        font-weight: 500;
    }

    .editor-header .toggle-icon {
        transition: transform .3s ease;
        font-size: 1.2em;
    }

    .editor-header.collapsed .toggle-icon { transform: rotate(-90deg); }

.editor-content {
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
    transition: max-height .3s ease, padding .3s ease;
}

    .editor-content.collapsed {
        max-height: 0;
        padding: 0 20px;
        overflow: hidden;
    }

.editor-hint-box {
    background: linear-gradient(135deg, rgba(102,126,234,.1) 0%, rgba(118,75,162,.1) 100%);
    border-left: 4px solid #667eea;
    padding: 12px 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    color: #4a5568;
}

    .editor-hint-box .fa-lightbulb {
        color: #667eea;
        margin-right: 5px;
    }

.member-list {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.member-item {
    display: grid;
    grid-template-columns: 96px 1fr auto;
    gap: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
    align-items: center;
}

    .member-item input {
        padding: 8px 12px;
        border: 2px solid #e0e0e0;
        border-radius: 6px;
        width: 100%;
        transition: border-color .2s ease;
    }

        .member-item input:focus {
            outline: none;
            border-color: #667eea;
        }

.btn-delete {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    min-height: 44px;
    transition: transform .2s ease, box-shadow .2s ease;
}

    .btn-delete:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(255,107,107,.3);
    }

    /* 只剩一位成員：直接鎖住，不要讓人按了才吃錯誤訊息 */
    .btn-delete:disabled {
        background: #d9d9d9;
        color: #888;
        cursor: not-allowed;
        box-shadow: none;
    }

.btn-add-member {
    background: var(--life-brand-gradient);
    color: white;
    border: none;
    padding: 13px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    min-height: 48px;
    transition: transform .2s ease, box-shadow .2s ease;
}

    .btn-add-member:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(102,126,234,.3);
    }

.editor-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

    .editor-actions button {
        flex: 1;
        min-width: 100px;
        padding: 12px 8px;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-weight: 500;
        min-height: 46px;
        transition: transform .2s ease, box-shadow .2s ease;
    }

.editor-actions-secondary { margin-top: 10px; }

.btn-save {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

    .btn-save:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(72,187,120,.3);
    }

.btn-reset {
    background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
    color: white;
}

    .btn-reset:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(245,158,11,.3);
    }

.btn-share {
    background: var(--life-brand-gradient);
    color: white;
}

    .btn-share:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(102,126,234,.3);
    }

.btn-link-tool {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    width: 100%;
}

    .btn-link-tool:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(245,87,108,.3);
    }

/* ===== 7. SEO 說明區（深底上的白卡） ===== */
.seo-content h3 { margin-top: 22px; }

.info-box {
    background: linear-gradient(135deg, rgba(102,126,234,.08) 0%, rgba(118,75,162,.08) 100%);
    border-left: 4px solid #667eea;
    padding: 12px 15px;
    border-radius: 8px;
    margin: 14px 0;
}

    .info-box .fa-lightbulb {
        color: #667eea;
        margin-right: 5px;
    }

.info-box-green {
    background: linear-gradient(135deg, rgba(72,187,120,.1) 0%, rgba(56,161,105,.1) 100%);
    border-left: 4px solid #48bb78;
}

    .info-box-green .fa-mouse-pointer {
        color: #48bb78;
        margin-right: 5px;
    }

/* ===== 8. 手機快捷列：hero 捲出畫面後才浮出，控制項永遠一鍵可達 ===== */
.sticky-quickbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(15,20,40,.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255,255,255,.12);
    transform: translateY(120%);
    transition: transform .3s ease;
}

    .sticky-quickbar.visible { transform: translateY(0); }

    .sticky-quickbar button {
        flex: 1;
        padding: 13px 10px;
        border-radius: 10px;
        border: none;
        cursor: pointer;
        font-weight: 600;
        min-height: 46px;
    }

.qb-primary {
    background: var(--life-brand-gradient);
    color: #fff;
}

.qb-outline {
    background: rgba(255,255,255,.1);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,.3);
}

/* ===== 專注模式：只留進度條 + 圓點矩陣 ===== */
body.life-focus-mode nav,
body.life-focus-mode footer,
body.life-focus-mode .life-subtitle,
body.life-focus-mode .hero-card,
body.life-focus-mode .switch,
body.life-focus-mode #member-editor,
body.life-focus-mode .seo-section,
body.life-focus-mode .sticky-quickbar {
    display: none !important;
}

/* ===== Toast（頁面專屬，避免與全域 .toast 撞名） ===== */
.life-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,.97);
    color: #333;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    font-weight: 500;
    white-space: pre-line;
    z-index: 10000;
    max-width: calc(100vw - 40px);
    animation: slideIn .3s ease-out;
}

    .life-toast.success { background: rgba(72,187,120,.97); color: #fff; }
    .life-toast.error { background: rgba(239,68,68,.97); color: #fff; }

@keyframes slideIn {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(60px); }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

*:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.switch input:focus-visible { outline: 2px solid #667eea; }

/* ===== 手機微調 ===== */
@media (max-width: 480px) {
    h1#title { font-size: 1.7em; }
    .hero-ring-wrap { width: 180px; height: 180px; }
    .hero-percent { font-size: 2.2em; }
    #dots-container { padding: 12px; gap: 3px; }
    .dot-wrapper { width: 11px; height: 11px; }
    .highlighted-dot { transform: scale(1.6); font-size: .7em; }
    .life-canvas { padding-bottom: 88px; } /* 讓出 sticky quickbar 的高度 */
    .member-item { grid-template-columns: 1fr; }
    .btn-delete { width: 100%; }
}

@media (min-width: 481px) and (max-width: 1023px) {
    .life-canvas { padding-bottom: 88px; }
}

/* ===== 桌機（≥1024px）：hero 留左欄，矩陣／控制項走右欄；不用 order，DOM 順序＝視覺順序 ===== */
@media (min-width: 1024px) {
    .life-canvas {
        max-width: 1180px;
        margin: 0 auto;
        display: grid;
        grid-template-columns: 380px 1fr;
        grid-template-areas:
            "title  title"
            "sub    sub"
            "hero   dots"
            "hero   switch"
            "hero   bar"
            "ad     ad"
            "editor editor"
            "seo    seo";
        gap: 0 28px;
        padding: 36px 24px 50px;
    }

    .life-ad-slot { grid-area: ad; }

    h1#title { grid-area: title; font-size: 2.6em; }
    .life-subtitle { grid-area: sub; }

    /* 不用 position: sticky——hero 卡會滑出自己的 grid 區域、蓋住下方的成員編輯器 */
    .hero-card {
        grid-area: hero;
        max-width: none;
        align-self: start;
        margin-bottom: 0;
    }

    #dots-container { grid-area: dots; align-self: start; }
    .switch { grid-area: switch; }
    #bar-container { grid-area: bar; }
    #member-editor { grid-area: editor; }
    .seo-section { grid-area: seo; }
    .sticky-quickbar { display: none !important; }
}

@media (min-width: 1024px) and (max-width: 1240px) {
    .life-canvas { grid-template-columns: 320px 1fr; }
}

/* ===== 列印 ===== */
@media print {
    body { background: white; color: black; }
    .switch, #member-editor, .sticky-quickbar, #starfield { display: none; }
    #bar-container, #dots-container { page-break-inside: avoid; }
    .highlighted-dot { animation: none; }

    @page { margin: 2cm; }
}
