/* ============================================================
   BopoWrite App 下載提示
   - 手機：底部 sticky 大條（最顯眼）
   - 桌機：右下角浮動小卡
   - 列印與小型 webview 自動隱藏
   ============================================================ */

:root {
    --bopo-yellow: #FFC83D;
    --bopo-yellow-deep: #FFB327;
    --bopo-orange: #FF6B1A;
    --bopo-ink: #2A2A2A;
    --bopo-muted: #6B6B6B;
    --bopo-bg: #FFF8E7;
    --bopo-line: #EEE6CF;
    --bopo-shadow: 0 -8px 28px rgba(0, 0, 0, 0.15);
}

/* 容器：手機底部 sticky
   - 用 translate3d 強制 GPU layer，避免 iOS Safari 在 address bar 收合時
     計算 fixed 位置出錯（畫面下方跑出空白）
*/
.bopo-promo {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1080;
    background: #fff;
    border-top: 3px solid var(--bopo-yellow);
    box-shadow: var(--bopo-shadow);
    transform: translate3d(0, 110%, 0);
    -webkit-transform: translate3d(0, 110%, 0);
    will-change: transform;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.bopo-promo[hidden] {
    display: none !important;
}

.bopo-promo.is-visible {
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

.bopo-promo__inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 44px 12px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.bopo-promo__inner:focus-visible {
    background: #FFFAE8;
}

.bopo-promo__icon {
    flex: 0 0 auto;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(255, 179, 39, 0.35);
    animation: bopoBob 2.6s ease-in-out infinite;
}

@keyframes bopoBob {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-3px) rotate(2deg); }
}

.bopo-promo__text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.3;
}

.bopo-promo__title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--bopo-ink);
    margin: 0 0 2px;
}

.bopo-promo__badge {
    display: inline-block;
    background: var(--bopo-orange);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.bopo-promo__sub {
    font-size: 0.82rem;
    color: var(--bopo-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bopo-promo__cta-wrap {
    flex: 0 0 auto;
}

.bopo-promo__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--bopo-yellow) 0%, var(--bopo-orange) 100%);
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgba(255, 107, 26, 0.4);
    white-space: nowrap;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    pointer-events: none; /* 整個 inner 是可點區，這個只是視覺按鈕 */
}

.bopo-promo__inner:hover .bopo-promo__cta,
.bopo-promo__inner:active .bopo-promo__cta {
    transform: scale(1.04);
    box-shadow: 0 6px 18px rgba(255, 107, 26, 0.5);
}

.bopo-promo__cta-icon {
    margin-right: 1px;
}

.bopo-promo__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    color: var(--bopo-muted);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.bopo-promo__close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--bopo-ink);
}

/* ============================================================
   桌機：浮動右下小卡（≥ 768px）
   ============================================================ */
@media (min-width: 768px) {
    .bopo-promo {
        left: auto;
        right: 24px;
        bottom: 24px;
        width: 360px;
        border: 1px solid var(--bopo-line);
        border-top: 4px solid var(--bopo-yellow);
        border-radius: 16px;
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
        transform: translate3d(0, 150%, 0);
        -webkit-transform: translate3d(0, 150%, 0);
    }

    .bopo-promo.is-visible {
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
    }

    .bopo-promo__inner {
        flex-wrap: wrap;
        padding: 18px 44px 16px 16px;
    }

    .bopo-promo__text {
        flex: 1 1 calc(100% - 70px);
    }

    .bopo-promo__title {
        font-size: 1.15rem;
    }

    .bopo-promo__sub {
        white-space: normal;
        font-size: 0.88rem;
    }

    .bopo-promo__cta-wrap {
        flex: 1 1 100%;
        margin-top: 12px;
    }

    .bopo-promo__cta {
        display: flex;
        justify-content: center;
        width: 100%;
        padding: 12px 16px;
        font-size: 1rem;
    }
}

/* ============================================================
   詳細 Modal
   ============================================================ */
.bopo-modal {
    position: fixed;
    inset: 0;
    z-index: 1090;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

.bopo-modal[hidden] {
    display: none !important;
}

.bopo-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.bopo-modal.is-open .bopo-modal__backdrop {
    opacity: 1;
}

.bopo-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    background: var(--bopo-bg);
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
}

.bopo-modal.is-open .bopo-modal__dialog {
    transform: translateY(0);
}

@media (min-width: 768px) {
    .bopo-modal {
        align-items: center;
        padding: 20px;
    }
    .bopo-modal__dialog {
        border-radius: 20px;
        max-height: 90vh;
    }
}

/* close 按鈕：相對於 .bopo-modal（fixed inset:0），永遠固定在 viewport 右上，
   不會被 modal 內容捲動帶走。加 safe-area 給 iPhone notch */
.bopo-modal__close {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: calc(12px + env(safe-area-inset-right, 0px));
    z-index: 10;
    width: 38px;
    height: 38px;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: var(--bopo-ink);
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
    transition: background 0.15s ease, transform 0.15s ease;
}

.bopo-modal__close:hover {
    background: #fff;
    transform: scale(1.05);
}

.bopo-modal__hero {
    width: 100%;
    background: linear-gradient(180deg, #FFE89A 0%, #FFC83D 100%);
    overflow: hidden;
    border-radius: 20px 20px 0 0;
}

.bopo-modal__hero img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 38vh;
    object-fit: cover;
    object-position: center top;
}

.bopo-modal__body {
    padding: 18px 20px 28px;
}

.bopo-modal__title {
    font-size: 1.55rem;
    font-weight: 900;
    color: var(--bopo-ink);
    margin: 0 0 6px;
    letter-spacing: 0.5px;
}

.bopo-modal__title-en {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--bopo-orange);
    letter-spacing: 1px;
    vertical-align: middle;
}

.bopo-modal__ver {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 8px;
    background: rgba(255, 107, 26, 0.12);
    color: var(--bopo-orange);
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 999px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}

/* 「最新」更新提示橫條 */
.bopo-modal__whats-new {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #FFF4D1 0%, #FFE89A 100%);
    border: 1px solid var(--bopo-yellow);
    border-radius: 12px;
    padding: 10px 14px;
    margin: 0 0 16px;
    font-size: 0.85rem;
    color: #7a5c00;
    line-height: 1.4;
}

.bopo-modal__whats-new-tag {
    flex: 0 0 auto;
    background: var(--bopo-orange);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
    letter-spacing: 1px;
}

.bopo-modal__lead {
    font-size: 0.95rem;
    color: #4a4a4a;
    line-height: 1.6;
    margin: 0 0 18px;
}

/* 上方主 CTA：一開啟 modal 就看見的橘色大鈕 */
.bopo-primary-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    margin: 4px 0 20px;
    background: linear-gradient(135deg, var(--bopo-yellow) 0%, var(--bopo-orange) 100%);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 800;
    text-decoration: none;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(255, 107, 26, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    letter-spacing: 0.5px;
    animation: bopoPulse 2.4s ease-in-out infinite;
}

.bopo-primary-cta:hover,
.bopo-primary-cta:focus {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(255, 107, 26, 0.5);
    color: #fff;
    text-decoration: none;
}

.bopo-primary-cta__arrow {
    transition: transform 0.2s ease;
}

.bopo-primary-cta:hover .bopo-primary-cta__arrow {
    transform: translateX(3px);
}

@keyframes bopoPulse {
    0%, 100% { box-shadow: 0 8px 20px rgba(255, 107, 26, 0.4); }
    50% { box-shadow: 0 8px 28px rgba(255, 107, 26, 0.65); }
}

.bopo-modal__screens {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 4px 0 20px;
}

.bopo-modal__screens img {
    width: 100%;
    height: auto;
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    background: #fff;
}

.bopo-modal__features {
    list-style: none;
    padding: 0;
    margin: 0 0 22px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 480px) {
    .bopo-modal__features {
        grid-template-columns: 1fr 1fr;
    }
}

.bopo-modal__features li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--bopo-line);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--bopo-ink);
}

.bopo-modal__feat-icon {
    flex: 0 0 auto;
    font-size: 1.25rem;
    line-height: 1;
}

.bopo-modal__features strong {
    display: block;
    color: var(--bopo-orange);
    font-weight: 800;
    margin-bottom: 2px;
}

.bopo-modal__cta-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.bopo-store {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    text-decoration: none;
    font-family: inherit;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.bopo-store__txt {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
    text-align: left;
}

.bopo-store__txt small {
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.85;
}

.bopo-store__txt strong {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.bopo-store--ios {
    background: #000;
    color: #fff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.bopo-store--ios:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.3);
    color: #fff;
}

.bopo-store--android {
    background: #f1f0eb;
    color: #9c9890;
    cursor: not-allowed;
}

.bopo-modal__note {
    text-align: center;
    font-size: 0.78rem;
    color: var(--bopo-muted);
    margin: 8px 0 0;
}

/* 列印與不適合的環境隱藏 */
@media print {
    .bopo-promo, .bopo-modal { display: none !important; }
}

/* 減少動畫偏好 */
@media (prefers-reduced-motion: reduce) {
    .bopo-promo,
    .bopo-modal__backdrop,
    .bopo-modal__dialog,
    .bopo-promo__icon,
    .bopo-promo__cta,
    .bopo-primary-cta,
    .bopo-store {
        transition: none !important;
        animation: none !important;
    }
}
