/* ============================================
   Instagram Widget Styles
   ============================================ */

.ig-widget {
  --ig-columns: 3;
  --ig-gap: 4px;
  --ig-radius: 0px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── 共通: 各アイテム ── */

.ig-widget__item {
  position: relative;
  overflow: hidden;
  border-radius: var(--ig-radius);
  background: #f0f0f0;
}

.ig-widget__item::before {
  content: '';
  display: block;
  padding-top: 100%; /* 1:1 アスペクト比 */
}

.ig-widget__link {
  position: absolute;
  inset: 0;
  display: block;
}

.ig-widget__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.ig-widget__item:hover .ig-widget__image {
  transform: scale(1.05);
}

/* ── 右上アイコン（動画 / 複数枚） ── */

.ig-widget__type-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

/* 動画: ▶ 三角形 */
.ig-widget__type-icon--video::after {
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 5px 0 5px 10px;
  border-color: transparent transparent transparent #fff;
  margin-left: 2px;
}

/* 複数枚: 重なった正方形 */
.ig-widget__type-icon--carousel::after {
  content: '';
  display: block;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 1px;
  box-shadow: 3px -3px 0 0 rgba(255, 255, 255, 0.85);
}

/* ── ボトムバー（いいね数 + キャプション） ── */

.ig-widget__bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 28px 10px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
}

/* キャプション: 常時非表示 → ホバーで展開 */
.ig-widget__caption {
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-bottom: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, margin-bottom 0.3s ease;
}

.ig-widget__item:hover .ig-widget__caption {
  max-height: 56px;
  opacity: 1;
  margin-bottom: 4px;
}

/* いいね数: 常時表示 */
.ig-widget__meta {
  display: flex;
  align-items: center;
}

.ig-widget__like {
  color: #fff;
  font-size: 12px;
  line-height: 1;
}

/* ── ローディング ── */

.ig-widget__loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #999;
  font-size: 14px;
}

/* ── エラー ── */

.ig-widget__error {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #c00;
  font-size: 14px;
}

/* ============================================
   グリッドモード
   ============================================ */

.ig-widget--grid .ig-widget__container {
  display: grid;
  grid-template-columns: repeat(var(--ig-columns), 1fr);
  gap: var(--ig-gap);
}

/* ============================================
   カルーセルモード
   ============================================ */

.ig-widget--carousel {
  position: relative;
}

.ig-widget--carousel .ig-widget__container {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  gap: var(--ig-gap);
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  scroll-behavior: smooth;
}

.ig-widget--carousel .ig-widget__container::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.ig-widget--carousel .ig-widget__item {
  flex: 0 0 auto;
  width: calc((100% - var(--ig-gap) * (var(--ig-columns) - 1)) / var(--ig-columns));
  scroll-snap-align: start;
}

/* ── カルーセル: ナビゲーションボタン ── */

.ig-widget__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: opacity 0.2s;
  padding: 0;
}

.ig-widget__nav:hover {
  background: #fff;
}

.ig-widget__nav--prev {
  left: 8px;
}

.ig-widget__nav--next {
  right: 8px;
}

.ig-widget__nav::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  border-top: 2px solid #333;
  border-right: 2px solid #333;
}

.ig-widget__nav--prev::after {
  transform: rotate(-135deg);
  margin-left: 3px;
}

.ig-widget__nav--next::after {
  transform: rotate(45deg);
  margin-right: 3px;
}

.ig-widget__nav[disabled] {
  opacity: 0;
  pointer-events: none;
}

/* ============================================
   レスポンシブ
   ============================================ */

@media (max-width: 768px) {
  .ig-widget--grid .ig-widget__container {
    grid-template-columns: repeat(3, 1fr);
  }

  .ig-widget--carousel .ig-widget__item {
    --ig-columns: 2;
    width: calc((100% - var(--ig-gap)) / 2);
  }

  .ig-widget__nav {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 480px) {
  .ig-widget--grid .ig-widget__container {
    grid-template-columns: repeat(2, 1fr);
  }

  .ig-widget--carousel .ig-widget__item {
    --ig-columns: 1.5;
    width: 70%;
  }
}
