/*
 * paint.css
 * 何をするファイルなのか：
 *   Shiitake Paint フロントエンド（paint.html）のスタイルシート。
 *   以前は paint.html の <style> タグ内に直接記述されていたが、
 *   保守性向上のためこのファイルに分離した。
 */

/* ============================================================
 * 基本レイアウト
 * ============================================================ */

/* ページ全体：余白なし・システムフォント・薄いグレー背景 */
body { margin: 0; font-family: system-ui, sans-serif; background:#eee; }

/* アプリ全体：縦方向フレックス・画面高さいっぱいに広げる */
#app{ height: 100vh; display:flex; flex-direction:column; min-height:0; }

/* ============================================================
 * ツールバー
 * ============================================================ */

/* ツールバー：横並び・折り返し可能・中央揃え */
.toolbar{
  display:flex; flex-wrap:wrap; gap:10px; align-items:center;
  padding:10px; background:#f7f7f7; border-bottom:1px solid #ddd;
  user-select:none;
}
/* ツールバー内ラベル：横並び */
.toolbar label{ display:flex; gap:6px; align-items:center; }
/* ツールバー内ボタン：適度なパディング */
.toolbar button{ padding:6px 10px; }
/* ステータス表示：小さめ文字・グレー */
.status{ font-size:12px; color:#444; }

/* ============================================================
 * メインエリア（キャンバス + パレット）
 * ============================================================ */

/* メインエリア：残りの高さを使い切る・横並び・スクロール可能 */
#main{
  flex: 1 1 auto;
  min-height: 0;
  display:flex;
  gap:10px;
  padding:10px;
  box-sizing:border-box;
  overflow:auto;
}

/* ============================================================
 * キャンバスエリア
 * ============================================================ */

/* キャンバス外枠：pack.json のサイズに合わせて固定・白背景・丸角 */
#canvasArea{
  position:relative;
  /* 固定サイズ（pack.jsonのサイズに合わせる） */
  width: 800px;
  height: 600px;
  flex-shrink: 0;
  background:#fff;
  border:1px solid #ddd;
  border-radius:12px;
  overflow:hidden;
  margin: auto;
}

/* 線画SVGレイヤー（下敷き）：クリックを透過させる */
#lineartLayer{
  position:absolute; inset:0;
  z-index: 0;
  pointer-events:none;
}

/* ユーザー操作を受け付けるキャンバス（擬装パターン表示） */
canvas#preview{
  position:absolute; inset:0;
  width:100%; height:100%;
  background:transparent;
  touch-action:none;
  z-index: 1;
}

/* 操作中の図形プレビューなど（一時的な描画） */
canvas#tempOverlay{
  position:absolute; inset:0;
  width:100%; height:100%;
  background:transparent;
  pointer-events:none;
  z-index: 2;
}

/* 真の色を表示するキャンバス（デバッグ用・通常は非表示） */
canvas#truthView{
  position:absolute; inset:0;
  width:100%; height:100%;
  background:transparent;
  pointer-events:none;
  z-index: 3;
  display:none;
}

/* ============================================================
 * パレット（PC用：右サイドバー）
 * ============================================================ */

/* パレットサイドバー：固定幅320px・スクロール可能 */
#paletteSide{
  flex: 0 0 320px;
  background:#fafafa;
  border:1px solid #ddd;
  border-radius:12px;
  padding:10px;
  box-sizing:border-box;
  overflow:auto;
}

/* パレットヘッダー：タイトルとヒントを横並び */
#paletteHeader{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  padding:4px 2px 10px 2px;
  border-bottom:1px solid #e2e2e2;
  margin-bottom:10px;
}

/* パレットタイトル文字 */
#paletteTitle{ font-weight: 700; font-size: 14px; color:#333; }
/* パレットヒント文字 */
#paletteHint{ font-size: 12px; color:#666; }

/* ============================================================
 * パレット項目（スウォッチ）
 * ============================================================ */

/* 各パレット項目：グリッドで見本アイコンとラベルを横並び */
.swatch{
  width:100%;
  height:auto;
  border:1px solid #bbb;
  border-radius:12px;
  background:#fff;
  display:grid;
  grid-template-columns: 46px 1fr;
  align-items:flex-start;
  gap:10px;
  padding:10px;
  cursor:pointer;
  margin:0 0 10px 0;
  text-align:left;
}

/* 選択中のパレット項目：外枠でハイライト */
.swatch[aria-pressed="true"]{
  outline:2px solid #333;
  outline-offset:2px;
}

/* パレット見本キャンバス：正方形・丸角 */
.swatch canvas{
  width:42px;
  height:42px;
  border-radius:10px;
  border:1px solid rgba(0,0,0,0.25);
  background:#fff;
  display:block;
}

/* パレットラベルテキスト：折り返し可能・文字あふれなし */
.swatch .label{
  font-size:14px;
  line-height:1.35;
  word-break: break-word;
  white-space: normal;
  overflow: visible;
}

/* ============================================================
 * スマートフォン対応（幅900px以下：下ドロワー式パレット）
 * ============================================================ */
@media (max-width: 900px){
  /* メインエリア：パディング縮小・中央寄せ */
  #main{ padding:8px; justify-content: center; }

  /* パレット：画面下部から下ドロワーとしてスライドイン */
  #paletteSide{
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 48vh;
    border-radius: 16px 16px 0 0;
    z-index: 50;
    /* 初期状態：画面外に隠す */
    transform: translateY(100%);
    transition: transform 200ms ease;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
  }

  /* パレットオープン時：画面内にスライドイン */
  #paletteSide.open{ transform: translateY(0); }

  /* バックドロップ（パレット背後の暗幕）：初期非表示 */
  #backdrop{
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.25);
    z-index: 40;
    display:none;
  }

  /* バックドロップ表示状態 */
  #backdrop.show{ display:block; }
}
