* {
    box-sizing: border-box;
}
:root {
    --fade: 1200ms;
}
/* 背景與版面 */
body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    overflow: hidden; /* 防止滾動條 */
}

main {
    min-height: 100vh;              /* 置中整頁 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    background: #000;              /* 萬一極短瞬間，也不會看到白底 */
}

/* 兩個疊在一起的圖層：永遠至少一層是 1 */
.bg .layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    /* 交疊淡入淡出靠 opacity 切換 */
    opacity: 0;
    transition: opacity var(--fade) linear;

    /* 流暢度與抗閃爍 */
    will-change: opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    pointer-events: none; /* 避免擋到前景的操作 */
}

/* 顯示中的那層會被加上 .show */
.bg .layer.show {
    opacity: 1;
}

/*（可選）如果使用者偏好減少動態，就關掉過渡 */
@media (prefers-reduced-motion: reduce) {
    .bg .layer { transition: none; }
}


/* 你的登入卡片外框（可保留你現有設定） */
.backLayer{
    width: 100%;
    max-width: 480px;
    background: rgba(252, 254, 255, 0.45); /* 更透明 */
    border-radius: 12px;
    padding: 32px 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.85); /* 外框 */
}

/* 登入表單 */
.loginForm {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-label {
    text-align: center;
    font-size: 36px;
    margin: 4px 0 8px;
}

/* 表單欄位 */
input, select {
    display: block;
    height: 40px;
    width: 100%;
    max-width: 100%;
    padding-left: 15px;
    border: 2px solid #ccc;
    outline: none;
    margin: 0;
}

input.focus {
    background-color: rgb(34, 45, 49);
}

label {
    font-weight: normal;
}

/* 按鈕 */
button {
    background: transparent;
    border: 2px solid;
    color: rgb(34, 45, 49);
    width: 100%;
    height: 44px;
    text-transform: uppercase;
    font-size: 16px;
    cursor: pointer;
    margin-top: 8px;
}

form button:hover {
    background-color: rgb(34, 45, 49);
    color: white;
}

/* ------------------------------ */
/* 模態視窗（錯誤訊息） */
.modal {
    display: none;
    position: fixed;
    z-index: 1001; /* 在最上層 */
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border-radius: 10px;
    width: 300px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    animation: slideDown 0.5s;
    z-index: 1002;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close:hover { color: black; }

@keyframes slideDown {
    from { transform: translateY(-50px); opacity: 0; }
    to   { transform: translateY(0);     opacity: 1; }
}

/* ------------------------------ */
/* 2FA 覆蓋層與內容（完整保留） */
.twofa-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding-top: 160px;
}
.twofa-overlay.show { display: flex; }

.twofa-box {
    background: white;
    padding: 8px;
    border-radius: 8px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.twofa-box h3 { font-size: 24px; }

.twofa-box input {
    height: 40px;
    width: 100%;
    padding: 0 10px;
    font-size: 16px;
}

.twofa-actions {
    display: flex;
    justify-content: center;
    gap: 150px;
    width: 100%;
}

.twofa-actions button {
    width: 100px;
    height: 36px;
    font-size: 16px;
}

.twofa-actions button:hover {
    background-color: rgb(34, 45, 49);
    color: white;
}

.twofa-inner-box {
    position: relative;
    padding: 20px;
    border-radius: 6px;
    background: white;
    z-index: 1;
}

.twofa-inner-box::before,
.twofa-inner-box::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 2px;
    background: linear-gradient(to left, #33fffc, #194b4f, #33fffc);
    background-size: 200% auto;
    z-index: -1;
    animation: moveLight 2s linear infinite;
}

.twofa-inner-box::before { top: 0; }
.twofa-inner-box::after  { bottom: 0; }

@keyframes moveLight {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* 按鈕本體：預設黑框；hover 變白框 */
#loginForm button[type="submit"] {
    position: relative;
    height: 44px;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: transparent;
    border: 2px solid #222;        /* 預設黑框 */
    cursor: pointer;
    font-size: 0;                  /* 隱藏原本字 */
    transition: border-color .2s ease;
}
#loginForm button[type="submit"]:hover {
    border-color: #fff;            /* 滑過 → 白框 */
}

/* 背景：滑過才顯示泥土 */
#loginForm button[type="submit"]::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0;                    /* 預設透明 */
    transition: opacity .25s ease;
    z-index: 0;

    background-image: url("/png/泥土.jpg");
    background-repeat: repeat-x;
    background-size: auto 100%;    /* 高度貼齊按鈕 */
    background-position: top left;
    image-rendering: pixelated;
}
#loginForm button[type="submit"]:hover::before {
    opacity: 1;                    /* 滑過 → 顯示泥土 */
}

/* 文字層：預設黑字；滑過 → 白字 */
#loginForm button[type="submit"]::after {
    content: "登入";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;

    font-size: 18px;
    font-weight: bold;
    letter-spacing: 2px;

    color: #222;                   /* 預設黑字 */
    text-shadow:
            0 1px 0 rgba(255,255,255,.25); /* 淡淡立體感，仍是黑字 */
    transition: color .2s ease, text-shadow .2s ease;
}
#loginForm button[type="submit"]:hover::after {
    color: #fff;                   /* 滑過 → 白字 */
    /* 為了在泥土上清楚，給白字加深色描邊 */
    text-shadow:
            -1px -1px 2px rgba(0,0,0,.8),
            1px -1px 2px rgba(0,0,0,.8),
            -1px  1px 2px rgba(0,0,0,.8),
            1px  1px 2px rgba(0,0,0,.8);
}
