/* science_gallery.css v5 — 原比例 / 不留空白 / 所有照片閃爍 */

.sg-stage {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: 12px 18px;
  background: linear-gradient(180deg, #0b1730 0%, #050b1c 100%);
  color: #fff;
  font-family: -apple-system, "Noto Sans TC", "PingFang TC", sans-serif;
  gap: 10px;
  overflow: hidden;
}

/* ===== 頂部 ===== */
.sg-head {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sg-part-chip {
  display: inline-flex; align-items: center;
  background: #f72585; color: #fff;
  font-weight: 900; font-size: 17px;
  padding: 6px 14px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(247,37,133,.55);
  white-space: nowrap;
}
.sg-topic {
  margin: 0; font-size: 30px; font-weight: 900;
  color: #ffd166;
  letter-spacing: 0.04em;
  line-height: 1.1;
  flex: 1;
  text-shadow: 0 2px 16px rgba(255,209,102,.3);
}

/* ===== 照片區：原比例 fixed-height 排列 ===== */
.sg-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  min-height: 0;
  flex: 0 0 auto;
}
/* 有 diagram → 照片較矮 */
.sg-stage.has-diagram .sg-photos {
  --photo-h: 220px;
  flex: 0 0 auto;
}
/* 沒 diagram → 照片較高 */
.sg-stage.no-diagram .sg-photos {
  --photo-h: 380px;
  flex: 1;
}

.sg-photo {
  position: relative;
  margin: 0;
  display: flex; flex-direction: column;
  flex: 0 0 auto;
  border-radius: 14px;
  overflow: hidden;
  background: #0d1830;
  border: 3px solid #fbbf24;
  box-shadow: 0 0 0 0 rgba(251,191,36,.5), 0 8px 20px rgba(0,0,0,.5);
  animation: sgFadeIn .6s ease both, photoGlow 2.2s ease-in-out infinite;
}
.sg-photo-1 { animation-delay: 0s, 0s; }
.sg-photo-2 { animation-delay: .12s, .2s; }
.sg-photo-3 { animation-delay: .24s, .4s; }
.sg-photo-4 { animation-delay: .36s, .6s; }

.sg-photo img {
  display: block;
  height: var(--photo-h, 220px);
  width: auto;
  max-width: 460px;
  /* 圖片原比例顯示，不拉伸 */
  object-fit: contain;
  background: #0a1428;
}

.sg-photo figcaption {
  padding: 8px 12px;
  font-size: 17px;
  background: #0a1220;
  color: #ffd166;
  text-align: center;
  font-weight: 800;
  letter-spacing: .04em;
  border-top: 2px solid #fbbf24;
  /* 多行 caption 可以換行 */
  line-height: 1.3;
}

/* 主照片強閃 */
.sg-photo.is-hero {
  border-color: #f72585;
  animation: sgFadeIn .6s ease both, heroPulse 1.6s ease-in-out infinite 0.5s;
}
.sg-photo.is-hero::after {
  content: '👀';
  position: absolute;
  top: 6px; left: 6px;
  background: #f72585; color: white;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 18px;
  z-index: 3;
  box-shadow: 0 4px 10px rgba(247,37,133,.7);
  animation: tipBob 1.6s ease-in-out infinite;
}
.sg-photo.is-hero figcaption {
  background: #f72585;
  color: white;
  border-top-color: #fff;
}

@keyframes photoGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251,191,36,.5), 0 8px 20px rgba(0,0,0,.5); }
  50% { box-shadow: 0 0 0 6px rgba(251,191,36,0), 0 10px 28px rgba(251,191,36,.4); }
}
@keyframes heroPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(247,37,133,.85), 0 12px 32px rgba(247,37,133,.5); border-color: #f72585; }
  50% { box-shadow: 0 0 0 14px rgba(247,37,133,0), 0 12px 32px rgba(247,37,133,.7); border-color: #fbbf24; }
}
@keyframes tipBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
@keyframes sgFadeIn {
  from { opacity: 0; transform: translateY(20px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 教學圖 ===== */
.sg-diagram {
  background: #0d1a2e;
  border: 2px solid #4cc9f0;
  border-radius: 14px;
  padding: 10px;
  flex: 1;
  min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(76,201,240,.18);
}
.sg-diagram-title {
  text-align: center;
  font-size: 18px; font-weight: 800;
  color: #4cc9f0;
  margin-bottom: 6px;
  letter-spacing: .04em;
  flex-shrink: 0;
}
.sg-diagram svg {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
}

/* iPad Pro 12.9 橫向 */
@media (min-width: 1024px) and (orientation: landscape) {
  .sg-stage { padding: 16px 26px; gap: 12px; }
  .sg-topic { font-size: 38px; }
  .sg-part-chip { font-size: 19px; padding: 7px 16px; }
  .sg-photo figcaption { font-size: 19px; padding: 10px 14px; }
  .sg-stage.has-diagram .sg-photos { --photo-h: 280px; }
  .sg-stage.no-diagram .sg-photos { --photo-h: 440px; }
  .sg-photo img { max-width: 540px; }
  .sg-diagram-title { font-size: 22px; }
}

@media (max-width: 700px) {
  .sg-stage { padding: 8px 10px; }
  .sg-topic { font-size: 22px; }
  .sg-stage.has-diagram .sg-photos { --photo-h: 160px; }
  .sg-stage.no-diagram .sg-photos { --photo-h: 240px; }
  .sg-photo img { max-width: 280px; }
}
