/* 
 * css/ui/mypage-jigsaw.css
 * ジグソーパズル用スタイル定義 - ライトテーマ対応 (白・水色)
 */

/* メインコンテナ */
.jigsaw-container {
    display: flex;
    height: 700px;
    gap: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(0, 188, 212, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

/* 共通タイトル */
.jigsaw-section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.95rem;
    color: #00838f;
    margin: 0;
    font-weight: 700;
    letter-spacing: 1px;
}

/* ================================================================
   左サイド：インベントリ（ギャラリー）
   ================================================================ */
.jigsaw-sidebar {
    width: 240px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #eceff1;
    padding-right: 15px;
}

.jigsaw-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #eceff1;
    margin-bottom: 15px;
}

.jigsaw-key-count {
    background: rgba(0, 131, 143, 0.05);
    color: #00838f;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    border: 1px solid rgba(0, 131, 143, 0.2);
    font-family: 'Orbitron', sans-serif;
}

.jigsaw-inventory-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: row; /* 横並び（グリッド）に変更 */
    flex-wrap: wrap;    /* 折り返し有効 */
    gap: 8px;           /* タイトな隙間 */
    padding: 8px;
    padding-right: 4px;
    align-content: flex-start;
}

/* カスタムスクロールバー */
.jigsaw-inventory-list::-webkit-scrollbar { width: 5px; }
.jigsaw-inventory-list::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 5px; }
.jigsaw-inventory-list::-webkit-scrollbar-thumb { background: #cfd8dc; border-radius: 5px; }

/* 空の状態 */
.jg-empty-msg {
    color: #90a4ae;
    font-size: 0.75rem;
    text-align: center;
    margin-top: 40px;
    line-height: 1.6;
}

/* ピースカード */
.jg-piece-card {
    background: linear-gradient(135deg, #ffffff, #f9fbfd);
    border: 1px solid #e0e6ed;
    border-radius: 10px;
    padding: 8px;
    width: 88px; /* コンパクト化 */
    cursor: grab;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    position: relative;
    overflow: hidden;
    user-select: none;
}

.jg-piece-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 188, 212, 0.15);
    border-color: rgba(0, 188, 212, 0.4);
    z-index: 10;
}

.jg-piece-card.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.jg-piece-meta {
    width: 100%;
    margin-top: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.jg-meta-date {
    font-size: 0.5rem;
    color: #b0bec5;
    font-weight: 400;
}

.jg-meta-diff {
    font-size: 0.55rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* 難易度別カラーバッジ */
.jg-meta-diff.diff-easy { color: #43a047; background: rgba(67, 160, 71, 0.1); }
.jg-meta-diff.diff-normal { color: #1e88e5; background: rgba(30, 136, 229, 0.1); }
.jg-meta-diff.diff-hard { color: #8e24aa; background: rgba(142, 36, 170, 0.1); }
.jg-meta-diff.diff-special { color: #f4511e; background: rgba(244, 81, 30, 0.1); }

/* ピースのミニプレビュー */
.jg-piece-preview {
    width: 50px;
    height: 50px;
    margin: 0 auto;
    position: relative;
    background: #f1f3f5;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ホバー時のバッジ発光 */
.jg-piece-card:hover .jg-meta-diff.diff-easy { box-shadow: 0 0 8px rgba(67, 160, 71, 0.25); }
.jg-piece-card:hover .jg-meta-diff.diff-normal { box-shadow: 0 0 8px rgba(30, 136, 229, 0.25); }
.jg-piece-card:hover .jg-meta-diff.diff-hard { box-shadow: 0 0 8px rgba(142, 36, 170, 0.25); }
.jg-piece-card:hover .jg-meta-diff.diff-special { box-shadow: 0 0 8px rgba(244, 81, 30, 0.25); }

/* ================================================================
   右メイン：ボード
   ================================================================ */
.jigsaw-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.jigsaw-board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.jigsaw-controls {
    display: flex;
    gap: 10px;
}

/* 汎用ボタンスタイル */
.jg-btn {
    background: white;
    border: 1px solid #cfd8dc;
    color: #546e7a;
    padding: 6px 16px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.jg-btn:hover:not(:disabled) {
    background: #f8f9fa;
    border-color: #b0bec5;
    color: #37474f;
}

.jg-btn.primary {
    background: #00bcd4;
    border-color: #00bcd4;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 188, 212, 0.2);
}

.jg-btn.primary:hover:not(:disabled) {
    background: #0097a7;
    border-color: #0097a7;
    box-shadow: 0 4px 8px rgba(0, 188, 212, 0.3);
}

.jg-btn.danger {
    color: #f44336;
    border-color: rgba(244, 67, 54, 0.3);
}

.jg-btn.danger:hover:not(:disabled) {
    background: rgba(244, 67, 54, 0.05);
    border-color: #f44336;
}

.jg-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ボードキャンバス */
.jigsaw-board-outer {
    flex: 1;
    background: #eceff1;
    border: 1px solid rgba(0, 188, 212, 0.2);
    border-radius: 12px;
    position: relative;
    overflow: auto; /* 見切れ防止のためスクロールを有効化 */
    padding: 40px;  /* スクロール時の余白を確保 */
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.jigsaw-board-canvas {
    width: 600px; /* 30px * 20 cells */
    height: 600px;
    flex-shrink: 0; /* 潰れないように固定 */
    margin: 0 auto;
    position: relative;
    background-color: white;
    background-image: 
        linear-gradient(rgba(0, 188, 212, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 188, 212, 0.08) 1px, transparent 1px);
    background-size: 30px 30px;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

/* ================================================================
   フッター：進行状況
   ================================================================ */
.jigsaw-board-footer {
    padding-top: 20px;
    border-top: 1px solid #eceff1;
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.jg-progress-wrap {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.jg-progress-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #546e7a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.jg-progress-bar-bg {
    flex: 0 1 350px;
    height: 8px;
    background: #eceff1;
    border-radius: 4px;
    overflow: hidden;
}

.jg-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00bcd4, #00838f);
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jg-progress-val {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #00838f;
    min-width: 65px;
}

/* ================================================================
   カスタムモーダル (jigsawUI用 - ライトテーマ)
   ================================================================ */
.jg-modal-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(84, 110, 122, 0.3); /* 薄いブルーグレーのオーバーレイ */
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    border-radius: 16px;
}

.jg-modal-content {
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid #00bcd4;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: jgZoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes jgZoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.jg-modal-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    color: #00838f;
    margin-bottom: 15px;
    font-weight: 700;
}

.jg-modal-body {
    color: #546e7a;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 25px;
    font-weight: 500;
}

.jg-modal-footer {
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* ================================================================
   トースト通知 (jigsawUI用 - ライトテーマ)
   ================================================================ */
.jg-toast-container {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 3500;
}

.jg-toast {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #00bcd4;
    color: #37474f;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: jgToastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.jg-toast.error {
    border-color: #f44336;
    color: #f44336;
}

@keyframes jgToastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   ドラッグ＆ドロップ拡張 (jigsawDrag.js 用)
   ================================================================ */

/* ドラッグ中のマウスに追従するゴーストピース */
.jg-dragging-piece {
    position: fixed;
    pointer-events: none;
    z-index: 5000;
    opacity: 0.8;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.2));
    transition: transform 0.05s linear; /* わずかなラグが滑らかさを演出 */
}

/* 盤目上の配置プレビュー（スナップ位置） */
.jg-drop-preview {
    position: absolute;
    pointer-events: none;
    background: rgba(0, 188, 212, 0.15);
    border: 2px solid #00bcd4;
    border-radius: 4px;
    z-index: 10;
    box-sizing: border-box;
    transition: all 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.jg-drop-preview.invalid {
    background: rgba(244, 67, 54, 0.15);
    border-color: #f44336;
}

/* 配置済みピースのドラッグ中スタイル */
.jg-placed-piece.dragging {
    opacity: 0.2;
}

/* 回転感応ゾーン */
.jg-rotate-zone {
    width: 24px;
    height: 36px;
    background: linear-gradient(135deg, rgba(0, 188, 212, 0.1), rgba(0, 151, 167, 0.2));
    border: 1px dashed #00bcd4;
    border-radius: 4px;
    color: #00838f;
    font-size: 0.6rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0;
    transition: all 0.2s ease;
    cursor: default;
    user-select: none;
    margin-right: 8px;
}

.jg-rotate-zone.active {
    background: rgba(0, 188, 212, 0.3);
    border-style: solid;
    transform: scale(1.05);
}

/* 回転成功時のフラッシュエフェクト */
.jg-rotate-zone.flash-active {
    animation: jg-flash-active 0.3s ease-out;
}

@keyframes jg-flash-active {
    0% { background-color: rgba(0, 188, 212, 0.8); box-shadow: 0 0 15px #00bcd4; color: white; }
    100% { background-color: rgba(0, 188, 212, 0.1); box-shadow: 0 0 0 transparent; color: #00838f; }
}

/* ピース内数字のスタイル（将来の拡張性用） */
.jg-cell-val {
    font-size: 0.75rem;
    font-family: 'Outfit', 'Inter', sans-serif;
    color: rgba(0, 0, 0, 0.4); /* 控えめな色使い */
    pointer-events: none;
    user-select: none;
    font-weight: 500;
}
