/* ===============================================
   HARUTAKE 表札シミュレーター CSS - 非クリティカル部分
   Phase 3 Step 2: 遅延ロード用CSS
   =============================================== */

/* ===============================================
   1. アニメーション定義
   =============================================== */
@keyframes fadeIn {
  0% {
    display: none;
    opacity: 0;
  }
  1% {
    display: block;
    opacity: 0;
  }
  100% {
    display: block;
    opacity: 1;
  }
}
@keyframes fadeOut {
  0% {
    display: block;
    opacity: 1;
  }
  1% {
    display: block;
    opacity: 1;
  }
  100% {
    display: none;
    opacity: 0;
  }
}
@keyframes fadeInUp {
  0% {
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}
@keyframes fadeOutDown {
  0% {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(100%);
    opacity: 0;
    display: none;
  }
}

.text-controls {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  padding: 30px 30px 10px 30px;
  font-size: small;
}

.text-controls .control {
  margin: 0;
  display: flex;
  align-items: center;
  padding: 1px 10px;
  width: 360px;
}
.text-controls p {
  flex: 0 0 100px;
  width: 100px;
  background-color: #eee;
  padding: 5px;
  margin: 0 10px 0 0;
  text-align: center;
}
.text-controls input,.text-controls span,.text-controls span,.text-controls select{
  width: 150px;
}

/* スライダーをグレーに */
.text-controls input[type="range"] {
  accent-color: #4b5563; /* gray-600 */
}

.text-controls input[type="range"]::-webkit-slider-thumb {
  background-color: #4b5563;
}

.text-controls input[type="range"]::-moz-range-thumb {
  background-color: #4b5563;
  border: none;
}

#add-text-button{
  border-radius: 3px;
  padding: 2px 9px;
  font-size: 17px;
  margin-right: 20px;
  background-color: #f8f8f8;
  color: #000;
  border-color: #ccc;
  font-weight: bold;
  font-family: serif;
}
.goto-shopify{
  font-weight: normal;
  text-decoration: none;
  color: #FFF;
  font-size: x-small;
  margin-top: 3px;
}
.goto-rakuten{
  right: 20px;
  position: absolute;
  font-weight: normal;
  text-decoration: none;
  background-color: #6b7280; /* gray-500 */
  color: #FFF;
  font-size: x-small;
  padding: 2px 10px;
}

#open-font-selector{
  cursor: pointer;
}

.text-element.selected {
  border: solid #eee;
}

.text-element textarea {
  resize: none;
  width: 100%;
  height: 100%;
  border: none;
  background-color: transparent;
  font-size: 16px;
  line-height: 1.2;
}

.disabled {
  pointer-events: none;
  opacity: 0;
}

/* .nav スタイルはクリティカルCSSに移動済み（Above-the-fold LCP要素） */

.thumbnail-container {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  margin-top: 1rem;
}

.thumbnail {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  overflow-x: scroll;
  overflow-y: hidden;
  white-space: nowrap;
}
.thumbnail .selected {
  border-top: 2px solid #666;
  border-bottom: 2px solid #666;
}

.thumbnail div{
  position: relative;
  display: flex;
  align-items: center;
}
.thumbnail-image {
  display: inline-block;
  width: 80px;
  object-fit: cover;
  cursor: pointer;
}

.thumbnail span{
  font-size: xx-small;
  position: absolute;
  bottom: 0;
  left: 0;
  text-wrap: balance;
  text-align: center;
  background-color: rgba(0,0,0,0.6);
  width: 100%;
  color: #fff;
  display: none;
}

.processing-list{
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-option {
  cursor: pointer;
  display: inline-block;
  padding: 10px;
  text-align: center;
  transition: border-color 0.3s;
}

.image-option img {
  max-width: 60px;
  display: block;
}

.image-option img.selected{
  border-top: 2px solid #333;
  border-bottom: 2px solid #333;
}

.image-option input[type="radio"]:checked + img {
  border: 4px solid #000;
}

/* pickles */
.pickles .image-option.leaser{
  display: none;
}

#additional-information{
  display: none;
}
#additional-information.pickles{
  display: block;
  font-size: small;
  border: #dddddd solid 1px;
  padding: 7px;
  background-color: rgba(192, 173, 120, 0.1);
  text-indent: -13px;
  padding-left: 20px;
}

.layout-item,
.layout-item img{
  width: 40px;
  height: 40px;
}
.layout-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #222;
}
.layout-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  color: #222;
}

/* ===============================================
   モーダルスタイル
   ===============================================
   旧.modal構造は削除済み
   新しいht-modalスタイルは /app/css/modal.css を参照
   =============================================== */

#open-tutorial {
  cursor: pointer;
}

/* フォント・アイコン選択UI */
.font-list-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr); /* スマホ: 3列 */
  gap: 5px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 350px;
  padding: 10px;
}

/* PC: 4列 */
@media (min-width: 768px) {
  .font-list-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

#icon-list-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  flex-direction: row;
  min-height: 350px;
}

.font-list-container::-webkit-scrollbar,
#icon-list-container::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}

.font-list-container {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#icon-list-container {
  box-sizing: border-box;
}

.font-item {
    cursor: pointer;
    box-sizing: border-box;
    justify-content: space-around;
    flex-direction: column;
    align-items: center;
    display: flex;
    transition: opacity 0.2s ease-in-out;
    border: #eee solid;
    font-size: larger;
}

.font-item small {
  color: #333;
}

/* アイコンフィルター */
#icon-tag-filter {
  display: flex;
  font-size: small;
  gap: 0.5rem;
  overflow-x: hidden;
  flex-wrap: wrap;
  align-content: center;
  flex-direction: column;
  align-items: stretch;
  margin-bottom: 10px;
  width: 100%;
  box-sizing: border-box;
}

.icon-all-label {
  white-space: nowrap;
  margin-right: 10px;
}

.icon-item p {
  display: none;
}

#design-data{
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 500px;
  background-color: #fbfbfb;
  font-size: small;
  padding: 5px 10px;
  border: 1px solid #eee;
}

#design-data-header{
  border-bottom: dashed 1px #666;
  padding: 10px 20px;
  font-size: medium;
  font-weight: bold;
  display: flex;
  align-items: center;
}

#design-data-contents{
  padding: 10px;
}

#design-data .text {
  cursor: pointer;
}

#design-data p{
  margin: 0;
}
#design-data span.label{
  display: inline-block;
  width: 75px;
  padding: 2px 15px;
}

.tab-link {
  display: inline-block;
  font-size: small;
  padding: 4px 10px;
  background-color: #f8f8f8;
  border-radius: 5px 5px 0 0;
  cursor: pointer;
}

.tab-link.active {
  background-color: #FFF;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  border-top: 1px solid #ddd;
  border-bottom: none;
}

.tab-content {
  display: none;
  animation: fadeOut 0.2s ease-in-out;
  /* タブのコンテンツのスタイル */
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-content label{
  font-size: x-small;
}

.tab-content p{
  font-size: small;
  margin: 0;
  margin: auto;
  padding: 20px 20px 10px;
}

/* Info overlay - PC環境対応 */
.tab-content p.info {
  display: none !important;
  opacity: 0.9;
  padding: 12px 16px;
  font-size: small;
  z-index: 100;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  width: 90%;
  max-width: 400px;
  margin: 0;
  text-align: center;
  cursor: pointer;
}

/* Info非表示状態 - 詳細度を上げて確実に適用 */
.tab-content p.info.disabled {
  opacity: 0;
  pointer-events: none;
  animation: fadeOut 0.2s ease-in-out;
}

.add-text-control{
  display: flex;
  align-items: center;
  justify-content: center;
}


#tutorial-modal{
  font-size: small;
}

#tutorial-modal .modal-body h2{
  text-align: center;
  padding: 10px;
  font-size: x-large;
  line-height: 1.5em;
  border-bottom: 1px #666 dashed;
  border-top: 1px #666 dashed;
}

#tutorial-modal h3{
  padding: 30px 0 0;
  font-size: large;
  display: flex;
  align-items: center;
}

#tutorial-modal p{
  padding-left: 20px;
}

i {
  padding-right: 10px ;
}

@media screen and (max-width: 480px) {
	/* 480px以下に適用されるCSS（スマホ用） */

  /* はみ出し防止 */
  body, html {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .actions {
    overflow: visible; /* バリデーション吹き出し表示のため */
    max-width: 100%;
  }

  /* スライダー全体の幅を変更する例 */
  .text-controls input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    cursor: pointer;
    /* Track のスタイル */
    background: #eee;
    height: 10px;
  }

  /* Thumb: Chrome, Safari, Opera, Edge Chromium */
  .text-controls input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    width: 20px;
    background-color: #666;
    border-radius: 10px;
    cursor: pointer;
  }

  /* Thumb: Firefox */
  .text-controls input[type="range"]::-moz-range-thumb {
    border: none;
    height: 20px;
    width: 20px;
    background-color: #666;
    border-radius: 10px;
    cursor: pointer;
  }
  /* モバイル環境でのinfo調整 */
  .tab-content p.info {
    width: 80%;
    max-width: 80%;
    font-size: x-small;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 4px;
  }

  .tab-content p.info.disabled{
    opacity: 0;
    pointer-events: none;
    animation: fadeOut 0.2s ease-in-out;
  }
  .tab-content.multi p{
    display: none;
  }

  .text-controls {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    flex-direction: column;
    font-size: smaller;
    padding: 30px 10px 0 10px;
    width: 100%;
    overflow: visible; /* バリデーション吹き出し表示のため */
  }
  .text-controls .control{
    display: flex;
    width: 100%;
    gap: 5px;
    align-items: center;
    padding: 1px 0;
    box-sizing: border-box;
  }
  .text-controls p {
    flex: 0 0 70px;
    font-size: x-small;
  }
  .text-controls input[type="text"],
  .text-controls span,
  .text-controls select {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
  }

  /* input-textは縦書きチェックボックス分の余白を確保 */
  .text-controls #input-text {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
  }

  .text-controls input[type="checkbox"] {
    flex: 0 0 auto;
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    margin: 0 5px;
  }

  .text-controls label {
    flex: 0 0 auto;
    margin: 0;
    white-space: nowrap;
  }

  /* 縦書きチェックボックス専用：はみ出し防止 */
  .text-controls #writing-mode {
    flex: 0 0 20px;
    width: 20px;
    min-width: 20px;
    max-width: 20px;
    margin: 0 5px;
  }

  .text-controls label[for="writing-mode"] {
    flex: 0 0 auto;
    margin: 0;
    white-space: nowrap;
  }

  .text-controls input[type="range"] {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    margin-right: 10px;
  }

  #simulator-area {
    width: 90%;
    height: 90%;
    max-width: 320px;
    max-height: 320px;
  }
  .font-item{
    line-height: 25px;
  }
  .font-item small{
    font-size: x-small;
  }
  /* モバイルでdesign-dataを下からスライド表示 */
  #design-data {
    position: fixed;
    padding: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    transform: none;
    background-color: #fbfbfb;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease-out;
    z-index: 1000;
  }

  #design-data.collapsed {
    transform: translateY(calc(100% - 130px));
  }

  #design-data-header {
    font-size: 11px;
    cursor: pointer;
    user-select: none;
    position: relative;
    padding: 20px;
  }

  #design-data.collapsed #design-data-header::after {
    transform: translateY(-50%) rotate(180deg);
  }

  #design-data-contents {
    font-size: x-small;
    max-height: 60vh;
    overflow-y: auto;
    transition: opacity 0.3s ease;
  }

  #design-data.collapsed #design-data-contents {
    /* 100px分は表示してクリック可能にする */
  }

  #design-data.is-hidden-by-actions {
    transform: translateY(100%) !important;
    opacity: 0;
    pointer-events: none;
  }

  #design-data span.label {
    width: 50px;
    padding: 0 10px;
  }
  .block-title{
    width: 120px;
  }
  .tab-content label span{
    display: none;
  }
  .modal-content,.modal-header{
    background-color: #fff;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
  }
  .modal-header{
    background-color: #eee;
  }
  .modal-content .sticky{
    padding: 5px 0;
    flex-direction: column;
  }
  #tutorial-modal p{
    padding-left: 0;
  }
  #tutorial-modal ul{
    margin-inline-start: -25px;
  }
  #tutorial-modal h3{
    padding: 0;
  }
}


@media screen and (max-height: 600px) {
  .nav{
    padding: 5px 0;
  }
  .tab-link {
    font-size: x-small;
  }
  .thumbnail-image{
    width: 60px;
  }
}

/* モバイル専用のシミュレータエリア調整 */
@media screen and (max-width: 480px) {
  body {
    flex-direction: column;
    align-items: center;
  }

  .top-section {
    position: static;
    width: 100%;
    max-width: 500px;
    padding: 0 5px 12px;
    box-sizing: border-box;
  }

  #simulator-area-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    height: auto;
    min-height: 60vh;
    padding: 20px 10px 20px 10px;
    width: 100%;
    max-width: 500px;
    box-sizing: border-box;
  }

  #simulator-area {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: 85vw;
    height: 85vw;
    max-width: 320px;
    max-height: 320px;
    margin: 0 auto;
  }
}

/* アイコンフィルターアニメーション（ej-pictogramsと同じ） */
.icon-item {
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform-origin: center center;
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 10px 0 5px;
}

.icon-item.is-fading {
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
}

.icon-item.is-appearing {
  opacity: 0;
  transform: scale(0.8);
}

.icon-item.is-hidden {
  display: none;
}

/* アイコンフォントのサイズを大きく */
.icon-item span {
  font-size: 2.5em;
}

/* アイコン項目の子要素スタイル（パフォーマンス改善） */
.icon-char {
  margin-bottom: 5px;
}

.icon-name {
  font-size: 10px;
  text-align: center;
  max-width: 60px;
  word-wrap: break-word;
  line-height: initial;
  padding-top: 15px;
}

.icon-code {
  font-size: 8px;
  color: #666;
  margin-top: 2px;
}

/* タグフィルターのスタイリング */
.filter-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.filter-all {
  display: flex;
  justify-content: center;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 100%;
  overflow: hidden;
  padding-top: 10px;
}

/* フィルターボタンスタイル */
.all-button, .tag-button {
  display: inline-block;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
  border: 1px solid #dee2e6;
  background-color: white;
  color: #6c757d;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.3s ease;
  user-select: none;
  outline: none;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  max-width: calc(50% - 3px); /* 最大幅を制限 */
  text-overflow: ellipsis;
  overflow: hidden;
}

.all-button {
  padding: 6px 12px;
  max-width: none; /* すべてボタンは制限なし */
}

.all-button:hover, .tag-button:hover {
  background-color: #e7f3ff;
  border-color: #007bff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,123,255,0.2);
}

/* アクティブ状態のスタイル */
.all-button.active {
  background-color: #3f5872;
  color: white;
  border-color: #0056b3;
  box-shadow: 0 2px 4px rgba(0,123,255,0.3);
}

.tag-button.active {
  background-color: #6c757d;
  color: white;
  border-color: #5a6268;
  box-shadow: 0 2px 4px rgba(108,117,125,0.3);
}

/* アクティブボタンのホバー */
.all-button.active:hover {
  background-color: #394959;
  transform: translateY(-2px);
}

.tag-button.active:hover {
  background-color: #5a6268;
  transform: translateY(-2px);
}

/* アイコンフォント入力部分のスタイリング */
.icon-placeholder {
  color: #6c757d;
  font-style: italic;
  font-size: 14px;
}

.icon-list-button {
  background-color: #6b7280; /* gray-500 */
  color: white;
  border: none;
  border-radius: 0; /* 角丸なし */
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 500;
  white-space: nowrap;
}

.icon-list-button:hover {
  background-color: #4b5563; /* gray-600 */
  transform: scale(1.05);
}

/* 位置調整ボタンのスタイル */
#center-button, #middle-button {
  margin-right: 5px;
  background-color: #6b7280; /* gray-500 */
  border: 1px solid #6b7280;
  border-radius: 0; /* 角丸なし */
  color: white;
}

#center-button:hover, #middle-button:hover {
  background-color: #4b5563; /* gray-600 */
  border-color: #4b5563;
}

.icon-list-button.bounce {
  animation: scaleUp 0.6s ease-out;
}

@keyframes scaleUp {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* ===============================================
   ローディング表示
   =============================================== */

/* Above-the-fold ローディングスタイルはクリティカルCSSに移動済み */
/* .model-select-container, .model-loading, .loading-spinner, .fullscreen-loading */

/* ===============================================
   カートボタンスタイル
   =============================================== */
.cart-button {
  height: 27px;
  background: #1a1a1a;
  color: #ffffff;
  border: none;
  border-radius: 0;
  margin-right: 10px;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-button:hover:not(:disabled) {
  background: #333333;
}

.cart-button:disabled {
  background: #a1a1a1;
  cursor: not-allowed;
  opacity: 0.5;
}

.cart-button svg {
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: middle;
  display: inline-block;
}

/* デザイン保存ボタン */
.save-design-btn {
  height: 27px;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}


.save-design-btn:disabled {
  background: #a1a1a1;
  cursor: not-allowed;
  opacity: 0.5;
}

.save-design-btn svg {
  width: 16px;
  height: 16px;
  margin-right: 4px;
  vertical-align: middle;
  display: inline-block;
}

/* 削除ボタンをアイコンのみに */
#delete-text-button {
  font-size: 0; /* テキストを非表示に */
  border: none;
  background-color: transparent;
  cursor: pointer;
}

#delete-text-button svg {
  width: 16px;
  height: 16px;
  stroke: #333; /* アイコンの色を黒系に設定 */
  fill: none;
}

/* ============================================================
   Phase 4.2: モデル読み込みローディングオーバーレイ
   ============================================================ */

.model-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8888;
  animation: fadeIn 0.2s ease-in-out;
}

.model-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.model-loading-spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: #333;
  border-radius: 50%;
  animation: spin 0.8s ease-in-out infinite;
}

.model-loading-message {
  font-family: "Inter", "Noto Sans JP", ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: #333;
  margin: 0;
  text-align: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .model-loading-overlay {
    background: rgba(0, 0, 0, 0.95);
  }

  .model-loading-spinner {
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
  }

  .model-loading-message {
    color: #fff;
  }
}

/* Mobile optimization */
@media (max-width: 640px) {
  .model-loading-spinner {
    width: 2.5rem;
    height: 2.5rem;
  }

  .model-loading-message {
    font-size: 0.875rem;
  }
}
