/* 語系偵測視窗（只在英文首頁出現）
   上半是一小塊棋盤，一顆寫著 EN 的黑子翻成訪客語言的白子 ——
   「換語言」這件事直接用黑白棋自己的動作來說。 */

.language-detector-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(18, 32, 25, 0.62);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.language-detector-overlay.show {
    opacity: 1;
    visibility: visible;
}

.language-detector-modal {
    position: relative;
    width: 100%;
    max-width: 400px;
    max-height: 100%;
    overflow-y: auto;
    background-color: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(8, 24, 16, 0.35);
    transform: translateY(12px) scale(0.98);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}

.language-detector-overlay.show .language-detector-modal {
    transform: none;
    opacity: 1;
}

/* ── 棋盤區 ── */
.language-detector-board {
    --ld-cell: 76px;
    position: relative;
    height: 132px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #1f8a57;
    /* 格線：以正中央的一格為基準向四周延伸 */
    background-image:
        linear-gradient(rgba(6, 40, 24, 0.55) 0 0),
        linear-gradient(rgba(6, 40, 24, 0.55) 0 0),
        linear-gradient(rgba(6, 40, 24, 0.55) 0 0),
        linear-gradient(rgba(6, 40, 24, 0.55) 0 0),
        radial-gradient(ellipse at 50% 40%, #2a9d66 0%, #1b8050 70%, #16683f 100%);
    background-size: 1.5px 100%, 1.5px 100%, 100% 1.5px, 100% 1.5px, 100% 100%;
    background-position:
        calc(50% - var(--ld-cell) / 2) 0,
        calc(50% + var(--ld-cell) / 2) 0,
        0 calc(50% - var(--ld-cell) / 2),
        0 calc(50% + var(--ld-cell) / 2),
        0 0;
    background-repeat: no-repeat;
}

.language-detector-disc {
    position: relative;
    width: 58px;
    height: 58px;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.1, 0.3, 1);
}

/* 視窗出現後稍等一下再翻，訪客才看得到黑子原本寫著 EN */
.language-detector-overlay.show .language-detector-disc {
    transform: rotateY(180deg);
    transition-delay: 0.55s;
}

.language-detector-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', sans-serif;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.language-detector-face.is-black {
    color: #f1f1ee;
    background: radial-gradient(circle at 34% 28%, #4a4a4a 0%, #1c1c1c 46%, #050505 100%);
    box-shadow:
        inset 0 -3px 5px rgba(0, 0, 0, 0.55),
        inset 0 2px 3px rgba(255, 255, 255, 0.10),
        0 4px 8px rgba(0, 0, 0, 0.38);
}

.language-detector-face.is-white {
    transform: rotateY(180deg);
    color: #17231c;
    background: radial-gradient(circle at 34% 28%, #ffffff 0%, #f4f4f2 48%, #d8d8d4 100%);
    box-shadow:
        inset 0 -3px 5px rgba(0, 0, 0, 0.16),
        inset 0 2px 3px rgba(255, 255, 255, 0.95),
        0 4px 8px rgba(0, 0, 0, 0.28);
}

.language-detector-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(6, 40, 24, 0.35);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.language-detector-close:hover {
    background: rgba(6, 40, 24, 0.6);
}

/* ── 文字區 ── */
.language-detector-body {
    padding: 22px 24px 20px;
    text-align: center;
}

.language-detector-title {
    margin: 0 0 8px;
    font-size: 21px;
    font-weight: 700;
    line-height: 1.35;
    color: #20332a;
    text-wrap: balance;
}

.language-detector-message {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #51635a;
    text-wrap: pretty;
}

.language-detector-primary-btn,
.language-detector-stay-btn {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border-radius: 10px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.language-detector-primary-btn {
    padding: 13px 20px;
    border: none;
    background-color: #1b8050;
    color: #fff;
}

.language-detector-primary-btn:hover {
    background-color: #15683f;
}

.language-detector-stay-btn {
    margin-top: 8px;
    padding: 11px 20px;
    border: none;
    background: transparent;
    color: #51635a;
    font-size: 15px;
    font-weight: 500;
}

.language-detector-stay-btn:hover {
    background-color: #eef4f0;
    color: #20332a;
}

.language-detector-other-languages {
    margin-top: 14px;
    padding-top: 16px;
    border-top: 1px solid #e3ebe6;
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-detector-other-label {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7c73;
}

.language-detector-other-label i {
    font-size: 15px;
    color: #1b8050;
}

.language-detector-select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid #cfdcd4;
    border-radius: 8px;
    background-color: #fff;
    color: #20332a;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
}

.language-detector-select:hover {
    border-color: #1b8050;
}

.language-detector-primary-btn:focus-visible,
.language-detector-stay-btn:focus-visible,
.language-detector-close:focus-visible,
.language-detector-select:focus-visible {
    outline: 2px solid #1b8050;
    outline-offset: 2px;
}

.language-detector-close:focus-visible {
    outline-color: #fff;
}

@media (max-width: 420px) {
    .language-detector-board {
        height: 116px;
        --ld-cell: 68px;
    }

    .language-detector-disc {
        width: 52px;
        height: 52px;
    }

    .language-detector-body {
        padding: 18px 18px 16px;
    }

    .language-detector-title {
        font-size: 19px;
    }
}

/* 不要動畫的訪客：直接看到翻好的白子 */
@media (prefers-reduced-motion: reduce) {
    .language-detector-overlay,
    .language-detector-modal,
    .language-detector-disc {
        transition: none;
    }
}
