/* ----------------------------------------------------------
  kimono-studio.css - デジタル試着室 共通スタイルシート
---------------------------------------------------------- */

/* ===============================================
  基本設定（共通）
=============================================== */
body {
  font-family: 'M PLUS Rounded 1c', sans-serif;
  background-color: #fefdf9;
  margin: 0;
  padding: 2em;
  color: #4b3621;
}

.data-load-error,
.storage-error {
  margin: 1em auto;
  padding: 0.8em 1em;
  max-width: 720px;
  color: #7a1f1f;
  background-color: #fff0f0;
  border: 1px solid #d99;
  border-radius: 6px;
  text-align: center;
}

h1 {
  text-align: center;
  color: #6b4f3b;
  margin-bottom: 0.3em; /* ← ★ここを調整する！ */
}

/* ===============================================
  materials.html 用スタイル
=============================================== */

/* カテゴリ見出し（折りたたみ可能） */
h2 {
  cursor: pointer;
  background-color: #f3e7dd;
  padding: 0.5em;
  border-radius: 8px;
}

/* カテゴリ全体囲み */
.category {
  margin-bottom: 1.5em;
  border: 1px solid #e8dcd4;
  border-radius: 8px;
  padding: 1em;
  background: #fffdf9;
}

/* 開閉アイコン（▶/▼） */
.toggle-icon {
  display: inline-block;
  width: 1em;
  text-align: center;
  margin-right: 0.4em;
}

/* カテゴリ内☑マーク */
.checked-indicator {
  color: #008000;
  font-weight: bold;
}

/* サブカテゴリ（小見出し・説明） */
.subcategory {
  margin-top: 1em;
  padding-left: 1em;
}

.subcategory h3 {
  margin-bottom: 0.2em;
}

.subcategory p {
  margin: 0.2em 0 0.6em 0;
  font-size: 0.95em;
}

/* 素材画像リスト */
.material-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

#materials-container {
  padding-bottom: calc(80px + 2em); /* 固定ボタンの高さ + αの余白 */
}

.material-item {
  width: 150px;
  text-align: center;
  position: relative;
}

.material-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 28px;
  margin-bottom: 4px;
}

.material-item input[type="checkbox"] {
  position: static;
  flex: 0 0 auto;
  margin: 0 2px;
  transform: scale(1.4);
  background: white;
  border-radius: 4px;
}

.material-item img {
  width: 100%;
  height: auto;
  object-fit: contain;
  aspect-ratio: 1/1;
  display: block;
  border-radius: 4px;
  cursor: pointer;
}

/* 素材画像の日本語ラベル */
.material-label {
  font-size: 0.8em;
  color: #666;
  margin: 0;
  text-align: left;
  word-break: break-word;
}

/* 布地はラベル付き画像が続くため、上下の間隔を広めにする */
.category[data-category-id="fabric"] .material-list {
  row-gap: 18px;
}

/* 素材紹介カード（shopリンク） */
.shop-card {
  background: #fffdf9;
  border: 1px solid #e8dcd4;
  border-radius: 8px;
  padding: 0.8em;
  max-width: 200px;
  text-align: center;
  box-shadow: 2px 2px 6px rgba(180,150,120,0.1);
  margin-top: 1em;
}

.shop-card img {
  width: 100%;
  border-radius: 4px;
  margin-bottom: 0.6em;
}

.shop-card a {
  display: inline-block;
  padding: 6px 12px;
  background-color: #f6e4e1;
  color: #6b4f3b;
  text-decoration: none;
  border-radius: 6px;
  font-weight: bold;
  transition: background-color 0.3s ease;
}

.shop-card a:hover {
  background-color: #efcec9;
}

/* 折りたたみ非表示 */
.collapsed .subcategory,
.collapsed p,
.collapsed .shop-card {
  display: none;
}

/* 試着室に戻るボタン */
.goto-button {
  display: block;
  max-width: 240px;
  width: 80%;
  margin: 1em auto;
  height: auto;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.goto-button:hover {
  transform: scale(1.03);
}

.fixed-goto-button {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255,253,249,0.95);
  text-align: center;
  padding: 0.5em 0;
  z-index: 100;
  box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
}

/* ===============================================
  index.html 用スタイル（試着室）
=============================================== */

html, body {
  height: 100vh; /* ← ここを100%ではなく100vhにする */
  margin: 0;
  padding: 0;
}

/* ドロップゾーン全体枠 */
.drop-zone-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  padding-bottom: 50px;
}

#drop-zone {
  position: absolute; /* ← relativeじゃなくabsoluteにする */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: auto;
  background: transparent;
  z-index: 1;
}

.drop-zone-frame {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border: 2px dashed #6b4f3d;
  border-radius: 12px;
  pointer-events: none;
  z-index: 2;
}

/* 画像配置ラッパー */
.image-wrapper {
  position: absolute;
  cursor: move;
  transform-origin: center center;
  touch-action: none;
}

.image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.image-wrapper.selected {
  outline: 2px dashed #ff3333;
  outline-offset: -4px;
}

/* 上下ボタン配置（スマホ時） */
.controls {
  text-align: center;
  margin-top: 1.5em;
}

.control-button {
  height: 42px;
  margin: 0 0.1em;
  cursor: pointer;
  transition: transform 0.2s;
}

.control-button:hover {
  transform: scale(1.05);
}

.bottom-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3em; /* ボタンの横方向の間隔 */
  margin-bottom: 0.5em; /* ボタン各行の下の余白 */
}

/* 最後の行だけ余白を無くす */
.bottom-row:last-child {
  margin-bottom: 0;
}

/* レスポンシブ切り替え（PC横長対応） */
.main-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.side-panel {
  width: 100%;
}

@media (min-width: 800px) {
  .main-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 2em;
  }

  .side-panel {
    width: 300px;
    flex-shrink: 0;
  }

  .drop-zone-wrapper {
    flex-grow: 1;
  }
}

/* モバイル向け調整 */
@media (max-width: 600px) {
  .controls {
    overflow-x: auto;
    white-space: nowrap;
    display: block;
    gap: 0.5em;
    justify-content: start;
    align-items: center;
    padding: 0.5em 0;
  }

  .controls button {
    flex: 0 0 auto;
    font-size: 0.85em;
    padding: 0.4em 0.8em;
  }

  #drop-zone {
    min-height: 300px;
  }

  body {
    padding: 1em;
  }

  h1 {
    font-size: 1.4em;
  }

  h2, h3 {
    font-size: 1em;
  }
}
