/* =========================================
   木木島 - 數學沙灘訓練場專屬樣式 (math.css)
   ========================================= */

/* =========================================
   1. 基礎設定與共用變數 (預設風格)
   ========================================= */
   .math-wrapper {
    /* 預設主題顏色 (讀取全站設定，若無則提供備用色) */
    --math-primary: var(--link-color, #0056b3);
    --math-primary-active: #3e2723;
    --math-border: var(--accent-light, #e0e0e0);
    --math-question-bg: var(--accent-light, #f5f5f5);
    --math-input-focus: var(--link-color, #0056b3);
    --math-shadow: rgba(93, 64, 55, 0.08);
}

/* 針對 iOS 防縮放與版面微調 */
html, body, #math-widget, #math-widget-settings {
    -webkit-text-size-adjust: 100% !important;
}

/* 去除數字輸入框的上下箭頭 (spin 按鈕) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* =========================================
   2. 導覽列與標題設計
   ========================================= */
.math-wrapper .page-header {
    margin-bottom: 20px;
    padding-bottom: 10px;
    text-align: center;
}

.math-wrapper .page-header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    color: var(--text-main, #333);
}

.math-wrapper .page-header p {
    color: var(--text-light, #666);
    font-size: 1rem;
    margin-top: 5px;
}

.math-nav-buttons {
    margin-bottom: 20px;
    text-align: left;
}

.math-nav-buttons a {
    display: inline-block;
    padding: 8px 16px;
    background-color: #f0f0f0;
    color: var(--text-main, #333);
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    transition: background 0.2s;
}

.math-nav-buttons a:hover {
    background-color: #e0e0e0;
}

/* =========================================
   3. 面板共用容器 (設定區 & 答題區)
   ========================================= */
#math-widget-settings, #math-widget {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 350px;
    width: 100%;
    margin: 0 auto 1rem auto;
    border: 2px solid var(--math-border);
    box-shadow: 0 4px 12px var(--math-shadow);
    box-sizing: border-box;
}

/* =========================================
   4. 設定面板區塊 (#math-widget-settings)
   ========================================= */
#math-widget-settings h3 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    color: var(--text-main, #333);
    border-bottom: 1px solid var(--math-border);
    padding-bottom: 8px;
    text-align: center;
}

.setting-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    justify-content: center;
}

.setting-row label {
    font-size: 16px;
    color: var(--text-main, #333);
    display: flex;
    align-items: center;
    gap: 4px;
}

#math-widget-settings input[type="number"] {
    width: 3.5rem;
    padding: 4px;
    border: 1px solid var(--accent-dark, #aaa);
    border-radius: 4px;
    text-align: center;
    font-size: 16px;
    color: var(--text-main, #333);
}

.op-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--math-primary);
}

/* =========================================
   5. 核心答題 Widget (#math-widget)
   ========================================= */
#math-widget {
    visibility: hidden; /* 預設隱藏，由 JS 控制顯示 */
}

#math-widget .question {
    color: var(--text-main, #333);
    font-size: 2.2rem;
    font-weight: bold;
    margin-bottom: 1rem;
    text-align: center;
    background-color: var(--math-question-bg);
    padding: 15px;
    border-radius: 8px;
    transition: background-color 0.3s;
}

#math-widget input#answer {
    width: 100%;
    padding: 12px;
    font-size: 1.5rem;
    color: var(--text-main, #333);
    background: #fff;
    border: 2px solid var(--accent-dark, #aaa);
    border-radius: 8px;
    box-sizing: border-box;
    margin-bottom: 15px;
    text-align: center;
    transition: border-color 0.2s;
}

#math-widget input#answer:focus {
    border-color: var(--math-input-focus);
    outline: none;
}

/* =========================================
   6. 共用按鈕與回饋資訊
   ========================================= */
button#applySettings, button#submitBtn {
    width: 100%;
    padding: 12px;
    font-size: 1.2rem;
    font-weight: bold;
    background-color: var(--math-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

button#applySettings:active, button#submitBtn:active {
    transform: scale(0.98);
    background-color: var(--math-primary-active);
}

#math-widget .feedback {
    margin-top: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    min-height: 26px;
}

#math-widget .score {
    margin-top: 8px;
    font-size: 1rem;
    color: var(--text-light, #666);
    text-align: center;
    font-weight: bold;
}

.timer {
    margin-top: 10px;
    font-size: 1.1rem;
    color: #d32f2f; /* 警告紅 */
    text-align: center;
    font-weight: bold;
}

/* =========================================
   7. 關卡專屬主題 (Theming)
   ========================================= */

/* 主題 A：九九乘法專區 (橘色系) */
.theme-mul99 {
    --math-primary: #ff9800;
    --math-primary-active: #f57c00;
    --math-border: #ff9800;
    --math-question-bg: #fff3e0;
    --math-input-focus: #ff9800;
    --math-shadow: rgba(255, 152, 0, 0.15);
}

/* 主題 B：(未來擴充) 三位數加減法 (綠色系範例) */
.theme-add3d {
    --math-primary: #4caf50;
    --math-primary-active: #388e3c;
    --math-border: #4caf50;
    --math-question-bg: #e8f5e9;
    --math-input-focus: #4caf50;
    --math-shadow: rgba(76, 175, 80, 0.15);
}