/* フロントエンド用スタイル */
.character-profile-block {
  /* Default Light Theme Colors */
  --accent-color: #3b82f6; /* Blue */
  --bg-color: #ffffff; /* White */
  --sub-bg-color: #f8fafc; /* Off-white */
  --text-color: #1e293b; /* Dark Slate */
  --sub-text-color: #64748b; /* Slate */
  --border-color: #e2e8f0; /* Light Gray */
  --header-text-color: #ffffff;
  --briefing-text-color: #64748b;
  --briefing-bg-color: #f8fafc;

  /* Default Layout Vars */
  --block-border: 1px solid;
  --section-border: 1px solid;
  --table-border: 1px solid;
  --item-border: 1px solid;
  --main-title-font-size: 18px;
  --header-font-size: 16px;
  --item-font-size: 14px;
  --briefing-title-font-size: 16px;
  --briefing-font-size: 14px;

  /* Default Border Radius */
  --block-border-radius: 8px;
  --banner-border-radius: 6px;
  --main-image-border-radius: 4px;
  --table-border-radius: 4px;

  max-width: 1200px;
  margin: 2em auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  border: var(--block-border) var(--border-color);
  border-radius: var(--block-border-radius);
  overflow: hidden;
}

/* バナー */
.profile-banners {
  display: grid;
  gap: 12px;
  padding: 15px;
  grid-template-columns: repeat(var(--banner-columns, 4), 1fr);
  border-bottom: var(--section-border) var(--border-color);
}
.profile-banner {
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: all 0.25s ease;
  padding: 0;
  background: #eee;
  height: var(--banner-height, 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--banner-border-radius);
}
.profile-banner:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.profile-banner.active {
  border-color: var(--accent-color);
  transform: translateY(-3px);
  box-shadow: 0 0 0 3px var(--accent-color-translucent, rgba(59, 130, 246, 0.2));
}
.profile-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
  /* object-position は PHP で動的に設定 */
}
.profile-banner:hover img {
  transform: scale(1.05);
}
.banner-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  padding: 15px 8px 8px;
}
.banner-name {
  color: white;
  font-weight: 600;
  text-align: center;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* プロフィール本体 */
.profile-item {
  display: none;
  animation: fadeIn 0.5s ease-out;
  overflow: hidden;
}
.profile-item.active {
  display: block;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.profile-main {
  display: grid;
  grid-template-columns: var(--main-image-width, 35%) 1fr;
  gap: 15px;
  padding: 15px;
}
.profile-image-wrapper {
  align-self: start;
}
.profile-image {
  width: 100%;
  display: flex;
  border-radius: var(--main-image-border-radius);
  overflow: hidden;
}
.profile-image-wrapper.size-small .profile-image {
  max-height: 300px;
}
.profile-image-wrapper.size-medium .profile-image {
  max-height: 500px;
}
.profile-image-wrapper.size-large .profile-image {
  max-height: 700px;
}
.profile-image img {
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
}
.profile-info {
  padding: 0;
  min-width: 0;
}
.profile-title {
  font-size: var(--main-title-font-size);
  font-weight: 700;
  margin: 0 0 15px 0;
  line-height: 1.3;
  color: var(--text-color);
}

/* プロフィールテーブル部分を以下のように修正 */

/* プロフィールテーブル - 修正版 */
.profile-table {
  display: flex;
  flex-direction: column;
  border: var(--table-border) var(--border-color);
  border-radius: var(--table-border-radius);
  font-size: var(--item-font-size);
  overflow: hidden;
}

/* ヘッダー */
.profile-data-header {
  background-color: var(--accent-color);
  color: var(--header-text-color);
  font-weight: bold;
  padding: 4px 8px;
  text-align: center;
  font-size: var(--header-font-size);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: var(--item-border) var(--border-color);
}

/* 基本項目 */
.profile-data-item {
  display: grid;
  border-bottom: var(--item-border) var(--border-color);
  align-items: stretch;
  min-height: 40px;
}

.profile-data-item:last-child {
  border-bottom: none;
}

/* 1カラム項目 */
.profile-data-item:not(.is-2col):not(.is-fullwidth) {
  grid-template-columns: var(--key-width, minmax(60px, max-content)) 1fr;
}

.profile-data-item:not(.is-2col):not(.is-fullwidth) .profile-key {
  font-weight: bold;
  padding: 4px 8px;
  color: var(--sub-text-color);
  background-color: var(--sub-bg-color);
  border-right: var(--item-border) var(--border-color);
  word-wrap: break-word;
  hyphens: auto;
  line-height: 1.4;
  display: flex;
  align-items: center;
}

.profile-data-item:not(.is-2col):not(.is-fullwidth) .profile-value {
  padding: 4px 8px;
  line-height: 1.6;
  word-wrap: break-word;
  display: flex;
  align-items: center;
}

/* 2カラム項目 */
.profile-data-item.is-2col {
  grid-template-columns: var(--key-width, minmax(60px, max-content)) 1fr var(--key-width, minmax(60px, max-content)) 1fr;
}

.profile-data-item.is-2col .profile-key {
  font-weight: bold;
  padding: 4px 8px;
  color: var(--sub-text-color);
  background-color: var(--sub-bg-color);
  border-right: var(--item-border) var(--border-color);
  word-wrap: break-word;
  hyphens: auto;
  line-height: 1.4;
  display: flex;
  align-items: center;
}

.profile-data-item.is-2col .profile-key:nth-child(3) {
  border-left: var(--item-border) var(--border-color);
}

.profile-data-item.is-2col .profile-value {
  padding: 4px 8px;
  line-height: 1.6;
  word-wrap: break-word;
  display: flex;
  align-items: center;
}

/* 全幅項目 */
.profile-data-item.is-fullwidth {
  grid-template-columns: 1fr;
}

.profile-data-item.is-fullwidth .profile-value {
  padding: 4px 8px;
  line-height: 1.6;
  word-wrap: break-word;
}

/* リンクスタイル */
.profile-value a {
  color: var(--accent-color);
  text-decoration: none;
}
.profile-value a:hover {
  text-decoration: underline;
}

/* 詳細セクション */
.profile-briefing {
  padding: 15px;
  background: var(--briefing-bg-color);
  border-top: var(--section-border) var(--border-color);
}
.briefing-title {
  font-size: var(--briefing-title-font-size);
  font-weight: 700;
  margin: 0 0 15px 0;
  color: var(--text-color);
}
.briefing-content {
  font-size: var(--briefing-font-size);
  line-height: 1.8;
  color: var(--briefing-text-color);
}
.briefing-content > *:first-child {
  margin-top: 0;
}
.briefing-content > *:last-child {
  margin-bottom: 0;
}
.briefing-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* 点線スタイルの改善 */
.character-profile-block *[style*="dotted"] {
  border-style: dotted !important;
  border-width: 2px !important;
}

/* レスポンシブ */
@media (max-width: 960px) {
  /* タブレットサイズ：横並びは維持、少し調整 */
  .profile-main {
    gap: 12px;
    padding: 12px;
  }
}

@media (max-width: 782px) {
  /* バナーが3列になる、横並び維持、メイン画像は中サイズ */
  .profile-banners {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* メイン画像を中サイズに強制 */
  .profile-image-wrapper .profile-image {
    max-height: 500px !important;
  }

  /* テーブルは横並び維持だが、項目は縦並びに */
  .profile-data-item.is-2col {
    grid-template-columns: 1fr;
  }

  .profile-data-item.is-2col .profile-key {
    border-right: none;
    border-left: none;
    border-bottom: var(--item-border) var(--border-color);
  }

  .profile-data-item.is-2col .profile-value {
    border-top: none;
    border-bottom: var(--item-border) var(--border-color);
  }

  .profile-data-item.is-2col .profile-key:nth-child(3) {
    border-left: none;
  }
}

@media (max-width: 480px) {
  /* 480px以下でレイアウト変更：縦並び、メイン画像小サイズ */
  .profile-banners {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
    padding: 12px;
  }

  /* プロフィール項目を画像の下に移動 */
  .profile-main {
    grid-template-columns: 1fr !important;
    gap: 15px;
    padding: 12px;
  }

  /* メイン画像を中央寄せ、小サイズに */
  .profile-image-wrapper {
    justify-self: center;
    max-width: 300px;
    width: 100%;
  }

  .profile-image-wrapper .profile-image {
    max-height: 300px !important;
  }

  /* プロフィール情報の調整 */
  .profile-info {
    padding-top: 0;
  }

  /* テーブルは縦並びに */
  .profile-table {
    grid-template-columns: 1fr;
  }

  .profile-data-item:not(.is-fullwidth) .profile-key {
    border-right: none;
    border-left: none;
    border-bottom: var(--item-border) var(--border-color);
  }

  .profile-data-item:not(.is-fullwidth) .profile-value {
    border-top: none;
    border-bottom: var(--item-border) var(--border-color);
  }

  /* フォントサイズも少し小さく */
  .profile-title {
    font-size: calc(var(--main-title-font-size) * 0.9);
  }
}
