/* tool-face-paint.html 專用樣式 (載入順序在 common.css 之後)
   Tailwind Play CDN 的 <style> 在執行時插入、排在本檔之後，同權重時會蓋過本檔：
   以 ID 開頭的規則權重已高於 Tailwind class；只用 class 的規則 (.fp-*) 不與 Tailwind class 搭配同一個屬性

   手機版 (與站內其他頁面相同的斷點)：main 不捲動，畫布佔滿剩餘空間；
   直向時工具列在底部、面板從工具列上方開啟；橫向時工具列在右側、面板從右側開啟 */

.fp-mobile-only {
    display: none;
}

#paint-viewport {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

@media (max-width: 767px),
(max-height: 480px) {
    /* 加上 ID 提高權重，蓋過同元素上 Tailwind 的 display class (grid) */
    #paint-tools .fp-desktop-only {
        display: none;
    }

    .fp-mobile-only {
        display: flex;
    }

    body.page-basic {
        height: 100dvh;
        overflow: hidden;
    }

    header {
        flex-shrink: 0;
    }

    #paint-main {
        position: relative;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        overscroll-behavior: none;
    }

    #paint-layout,
    #paint-grid,
    #paint-section {
        display: flex;
        flex: 1;
        min-height: 0;
        min-width: 0;
        max-width: none;
        margin: 0;
        padding: 0;
        gap: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    /* #paint-grid 有 Tailwind 的 items-start，改為讓畫布區撐滿高度 */
    #paint-grid {
        align-items: stretch;
    }

    #paint-intro {
        display: none;
    }

    #paint-viewport {
        flex: 1;
        max-width: none;
        aspect-ratio: auto;
        height: auto;
        border-radius: 0;
    }

    /* 工具面板：預設隱藏，data-open-panel 時只顯示對應的區塊 */
    #paint-tools {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        bottom: 56px;
        z-index: 40;
        max-height: 45%;
        overflow-y: auto;
        border-radius: 1rem 1rem 0 0;
        border-bottom: 0;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.15);
    }

    #paint-tools[data-open-panel] {
        display: block;
    }

    #paint-tools section[data-panel] {
        display: none;
    }

    #paint-tools[data-open-panel="brush"] #panel-brush,
    #paint-tools[data-open-panel="layers"] #panel-layers,
    #paint-tools[data-open-panel="guide"] #panel-guide {
        display: block;
    }

    #paint-tools[data-open-panel="more"] #panel-more {
        display: grid;
    }

    /* 3D 預覽：畫布右上角的小視窗；儲存在頂部列 */
    #paint-side {
        position: absolute;
        top: 8px;
        right: 8px;
        z-index: 30;
        width: 112px;
    }

    #save-panel,
    #preview-hint {
        display: none;
    }

    #preview-panel {
        padding: 4px;
        border-radius: 0.75rem;
        background: rgba(255, 255, 255, 0.9);
    }

    #preview-panel h2 {
        font-size: 11px;
        margin-left: 4px;
    }

    /* 小視窗放不下預覽方式切換：鏡頭試戴改由「更多」面板開啟 */
    #preview-mode {
        display: none;
    }

    #preview-panel .mb-2 {
        margin-bottom: 2px;
    }

    #paint-side.fp-collapsed {
        width: auto;
    }

    /* 鏡頭試戴時放大小視窗 */
    #paint-side[data-preview-mode="camera"]:not(.fp-collapsed) {
        width: min(45vw, 200px);
    }

    #paint-side.fp-collapsed #preview-container,
    #paint-side.fp-collapsed #preview-title {
        display: none;
    }

    #mobile-toolbar {
        flex-shrink: 0;
        height: 56px;
        background: white;
        border-top: 1px solid #e5e7eb;
        justify-content: space-around;
        align-items: stretch;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .fp-tool-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        font-size: 10px;
        color: #4b5563;
        min-width: 0;
    }

    .fp-tool-btn[aria-pressed="true"],
    .fp-tool-btn[aria-expanded="true"] {
        color: #7e22ce;
        background: #faf5ff;
    }

    .fp-tool-btn:disabled {
        opacity: 0.35;
    }
}

/* 手機橫向：工具列改到右側直排，面板從右側開啟 */
@media (max-height: 480px) {
    #paint-main {
        flex-direction: row;
    }

    #mobile-toolbar {
        flex-direction: column;
        width: 56px;
        height: auto;
        border-top: 0;
        border-left: 1px solid #e5e7eb;
        padding-bottom: 0;
        padding-right: env(safe-area-inset-right);
    }

    #paint-tools {
        left: auto;
        top: 0;
        right: 56px;
        bottom: 0;
        width: 280px;
        max-height: none;
        border-radius: 1rem 0 0 1rem;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
    }

    #paint-side {
        right: 64px;
    }
}
