/* PostVault 網站版：示範動畫（首頁與介紹頁共用）。
   樣式沿用 app.css 的 .bar、.btn，所以動畫裡看到的就是產品本身的長相。 */

/* =====================================================================
   動態示範
   原則：基本樣式就是「播完之後的樣子」，所以關掉動畫（減少動態）或不支援時看到的是完整內容；
   keyframes 只負責從隱藏的起點播到終點再重來。畫面外的動畫暫停（.anim 沒有 .is-live）。
   ===================================================================== */

.anim *,
.anim *::before,
.anim *::after {
    animation-play-state: paused;
}

.anim.is-live *,
.anim.is-live *::before,
.anim.is-live *::after {
    animation-play-state: running;
}

.reveal {
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.js-motion .reveal:not(.is-in) {
    opacity: 0;
    transform: translateY(28px);
}

/* ---------- 骨架：用在所有示範裡「一則貼文」的樣子 ---------- */

.mock-post {
    display: grid;
    gap: 8px;
}

.mock-post__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.mock-post__avatar {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    background: var(--surface-2, var(--line));
}

.mock-post__who {
    display: grid;
    flex: 1;
    gap: 6px;
}

.mock-post__line {
    display: block;
    width: 100%;
    height: 0.65rem;
    border-radius: 999px;
    background: var(--surface-2, var(--line));
}

.mock-post__line--short {
    width: 62%;
}

.mock-post__line--name {
    width: 42%;
    height: 0.75rem;
}

.mock-post__line--handle {
    width: 26%;
}

.mock-tiles {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    overflow: hidden;
    border-radius: 14px;
}

.mock-tiles--3 {
    grid-template-columns: repeat(3, 1fr);
}

.mock-tile {
    display: block;
    aspect-ratio: 1;
}

.mock-tile--0 {
    background: linear-gradient(135deg, #38bdf8, #34d399);
}

.mock-tile--1 {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

.mock-tile--2 {
    background: linear-gradient(135deg, #a78bfa, #38bdf8);
}

/* ---------- 開場示範：手機外框裡循環「貼上、讀取、儲存」 ---------- */

.demo {
    width: min(100%, 21rem);
    margin: 0 auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 38px;
    background: var(--surface);
    box-shadow: 0 36px 64px -36px rgba(0, 0, 0, 0.55);
}

.demo__screen {
    position: relative;
    display: grid;
    align-content: start;
    gap: 16px;
    min-height: 22rem;
    padding: 20px 14px 16px;
    overflow: hidden;
    border-radius: 28px;
    background: var(--bg);
}

.demo__bar {
    position: relative;
    min-width: 0;
    margin-top: 0;
    min-height: 3.25rem;
}

.demo__placeholder {
    position: absolute;
    left: 20px;
    color: var(--faint);
    font-size: 0.9375rem;
    white-space: nowrap;
    opacity: 0;
    animation: demo-placeholder 10s infinite;
}

.demo__typed {
    flex: 0 1 auto;
    width: min(22ch, calc(100% - 7.5rem));
    overflow: hidden;
    color: var(--ink);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.875rem;
    white-space: nowrap;
    animation: demo-typed 10s steps(22) infinite;
}

.demo__paste {
    margin-left: auto;
    animation: demo-press 10s infinite;
}

.demo__card {
    display: grid;
    animation: demo-card 10s infinite;
}

.demo__skeleton,
.demo__content {
    grid-area: 1 / 1;
}

.demo__skeleton {
    opacity: 0;
    animation: demo-skeleton 10s infinite;
}

.demo__content {
    animation: demo-content 10s infinite;
}

.demo__save {
    position: relative;
    width: 100%;
    overflow: hidden;
    animation: demo-save 10s infinite;
}

.demo__fill {
    position: absolute;
    inset: 0;
    background: var(--on-primary);
    opacity: 0.2;
    transform: scaleX(0);
    transform-origin: left;
    animation: demo-fill 10s infinite;
}

.demo__label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.demo__label .icon {
    width: 1.1875rem;
    height: 1.1875rem;
}

.demo__label--idle {
    opacity: 0;
    animation: demo-idle 10s infinite;
}

.demo__label--done {
    animation: demo-done 10s infinite;
}

@keyframes demo-placeholder {
    0%, 10% { opacity: 1; }
    12%, 96% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes demo-typed {
    0%, 10% { width: 0; }
    32%, 92% { width: min(22ch, calc(100% - 7.5rem)); }
    100% { width: 0; }
}

@keyframes demo-press {
    0%, 31% { transform: scale(1); }
    34% { transform: scale(0.9); }
    38%, 100% { transform: scale(1); }
}

@keyframes demo-card {
    0%, 36% { opacity: 0; transform: translateY(14px); }
    42%, 92% { opacity: 1; transform: translateY(0); }
    98%, 100% { opacity: 0; transform: translateY(0); }
}

@keyframes demo-skeleton {
    0%, 36% { opacity: 0; }
    40%, 50% { opacity: 1; }
    56%, 100% { opacity: 0; }
}

@keyframes demo-content {
    0%, 48% { opacity: 0; }
    58%, 92% { opacity: 1; }
    98%, 100% { opacity: 0; }
}

@keyframes demo-save {
    0%, 56% { opacity: 0; transform: translateY(10px); }
    64%, 92% { opacity: 1; transform: translateY(0); }
    98%, 100% { opacity: 0; transform: translateY(0); }
}

@keyframes demo-fill {
    0%, 66% { transform: scaleX(0); }
    78% { transform: scaleX(1); }
    92% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

@keyframes demo-idle {
    0%, 77% { opacity: 1; }
    79%, 96% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes demo-done {
    0%, 77% { opacity: 0; }
    82%, 94% { opacity: 1; }
    98%, 100% { opacity: 0; }
}

/* ---------- 三步驟 ---------- */

.about-step {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    transition: transform 0.2s, border-color 0.2s;
}

.about-step:hover {
    transform: translateY(-3px);
    border-color: var(--faint);
}

.about-step__visual {
    padding: 14px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.about-step__body {
    display: grid;
    gap: 6px;
    padding: 18px 22px 24px;
}

.about-step__number {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    margin-bottom: 4px;
    border-radius: 50%;
    background: var(--ink);
    color: var(--bg);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.vis {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 12px;
    min-height: 12rem;
    padding: 14px;
    overflow: hidden;
    border-radius: 16px;
    background: var(--surface);
}

/* 1. 複製連結：點「分享」，跳出「已複製」 */
.vis-copy__share {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--bg);
    animation: copy-press 4.5s infinite;
}

.vis-copy__tap {
    position: absolute;
    inset: -4px;
    border: 2px solid var(--ok);
    border-radius: 50%;
    opacity: 0;
    animation: copy-tap 4.5s infinite;
}

.vis-copy__chip {
    position: absolute;
    left: 14px;
    bottom: 18px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--ok);
    color: var(--bg);
    font-size: 0.875rem;
    font-weight: 700;
    animation: copy-chip 4.5s infinite;
}

.vis-copy__chip .icon {
    width: 1rem;
    height: 1rem;
}

@keyframes copy-press {
    0%, 30% { transform: scale(1); }
    34% { transform: scale(0.86); }
    40%, 100% { transform: scale(1); }
}

@keyframes copy-tap {
    0%, 30% { opacity: 0; transform: scale(0.7); }
    36% { opacity: 0.9; }
    55%, 100% { opacity: 0; transform: scale(1.7); }
}

@keyframes copy-chip {
    0%, 40% { opacity: 0; transform: translateY(8px); }
    50%, 86% { opacity: 1; transform: translateY(0); }
    96%, 100% { opacity: 0; transform: translateY(0); }
}

/* 2. 貼上：網址打進去，貼文出現 */
.vis-paste__bar {
    padding-left: 14px;
}

.vis-paste__typed {
    animation: paste-typed 5s steps(22) infinite;
}

.vis-paste__paste {
    animation: paste-press 5s infinite;
}

.vis-paste__result {
    animation: paste-result 5s infinite;
}

@keyframes paste-typed {
    0%, 6% { width: 0; }
    38%, 92% { width: min(22ch, calc(100% - 7.5rem)); }
    100% { width: 0; }
}

@keyframes paste-press {
    0%, 40% { transform: scale(1); }
    44% { transform: scale(0.9); }
    48%, 100% { transform: scale(1); }
}

@keyframes paste-result {
    0%, 48% { opacity: 0; transform: translateY(10px); }
    58%, 90% { opacity: 1; transform: translateY(0); }
    98%, 100% { opacity: 0; transform: translateY(0); }
}

/* 3. 儲存：進度填滿，檔案掉進來 */
.vis-save__btn {
    animation: none;
}

.vis-save__fill {
    animation: save-fill 5s infinite;
}

.vis-save__idle {
    opacity: 0;
    animation: save-idle 5s infinite;
}

.vis-save__done {
    animation: save-done 5s infinite;
}

.vis-save__files {
    display: flex;
    justify-content: center;
    gap: 12px;
    padding-top: 6px;
}

.vis-save__file {
    display: grid;
    place-items: center;
    width: 3.25rem;
    height: 3.25rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--bg);
}

.vis-save__file .icon {
    width: 1.5rem;
    height: 1.5rem;
}

.vis-save__file--1 { animation: save-file-1 5s infinite; }
.vis-save__file--2 { animation: save-file-2 5s infinite; }
.vis-save__file--3 { animation: save-file-3 5s infinite; }

@keyframes save-fill {
    0%, 8% { transform: scaleX(0); }
    48% { transform: scaleX(1); }
    92% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

@keyframes save-idle {
    0%, 47% { opacity: 1; }
    50%, 96% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes save-done {
    0%, 47% { opacity: 0; }
    52%, 92% { opacity: 1; }
    98%, 100% { opacity: 0; }
}

@keyframes save-file-1 {
    0%, 50% { opacity: 0; transform: translateY(-18px) scale(0.8); }
    60%, 90% { opacity: 1; transform: translateY(0) scale(1); }
    98%, 100% { opacity: 0; transform: translateY(0) scale(1); }
}

@keyframes save-file-2 {
    0%, 56% { opacity: 0; transform: translateY(-18px) scale(0.8); }
    66%, 90% { opacity: 1; transform: translateY(0) scale(1); }
    98%, 100% { opacity: 0; transform: translateY(0) scale(1); }
}

@keyframes save-file-3 {
    0%, 62% { opacity: 0; transform: translateY(-18px) scale(0.8); }
    72%, 90% { opacity: 1; transform: translateY(0) scale(1); }
    98%, 100% { opacity: 0; transform: translateY(0) scale(1); }
}


@media (prefers-reduced-motion: reduce) {
    .anim *,
    .anim *::before,
    .anim *::after {
        animation: none !important;
    }
}

/* ---------- 首頁的「三步驟」區塊（步驟卡片與介紹頁共用） ---------- */

.about-step .about-card__title {
    margin: 0;
    font-size: 1.1875rem;
    font-weight: 700;
    line-height: 1.35;
}

.about-step .about-card__desc {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
    text-wrap: pretty;
}

.howto {
    margin-top: clamp(40px, 8vh, 72px);
}

.howto__title {
    margin: 0;
    font-size: clamp(1.25rem, 4.6vw, 1.625rem);
    font-weight: 700;
    line-height: 1.3;
    text-align: center;
}

.howto__grid {
    display: grid;
    gap: 16px;
    margin: 24px 0 0;
    padding: 0;
    list-style: none;
}

.howto__more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 2.75rem;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9375rem;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.howto__more:hover {
    color: var(--ink);
}

.howto__more .icon {
    width: 1rem;
    height: 1rem;
}

/* 有貼文或正在讀取時，首頁只留輸入列與內容 */
[data-status="loading"] .howto,
[data-status="ready"] .howto {
    display: none;
}

@media (min-width: 760px) {
    .howto__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 24px;
    }
}
