/* ============================================================
 * BioQuest — PhET 互动模拟实验页样式
 * 遵循 Trae 设计系统：Modern Botanical Laboratory
 * ============================================================ */

.phet-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ---------- 顶部介绍区 ---------- */
.phet-header {
  text-align: center;
  padding: 40px 20px 32px;
  background: linear-gradient(135deg, var(--surface-primary, #fff) 0%, var(--surface-secondary, #faf7f2) 100%);
  border-radius: var(--radius-lg, 20px);
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(26,58,42,0.06));
  margin-bottom: 24px;
}

.phet-header-icon {
  font-size: 3rem;
  margin-bottom: 8px;
}

.phet-title {
  font-family: var(--font-serif, 'Noto Serif SC', serif);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--color-deep, #1a3a2a);
  margin-bottom: 6px;
}

.phet-subtitle {
  font-size: 0.85rem;
  color: var(--color-sage, #5a7d5c);
  margin-bottom: 12px;
  font-weight: 500;
}

.phet-desc {
  font-size: 0.92rem;
  color: var(--text-secondary, #4a4a4a);
  line-height: 1.7;
  max-width: 720px;
  margin: 0 auto 16px;
}

.phet-attribution {
  display: inline-block;
  padding: 6px 14px;
  background: rgba(90, 125, 92, 0.08);
  border-radius: var(--radius-full, 9999px);
  font-size: 0.78rem;
}

.phet-attribution-link {
  color: var(--color-sage, #5a7d5c);
  text-decoration: none;
  font-weight: 500;
}

.phet-attribution-link:hover {
  text-decoration: underline;
}

/* ---------- 主题筛选 ---------- */
.phet-topic-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 24px;
}

.phet-topic-btn {
  padding: 8px 18px;
  border: 1px solid var(--border-default, #e0dcd5);
  background: var(--surface-primary, #fff);
  color: var(--text-secondary, #4a4a4a);
  border-radius: var(--radius-full, 9999px);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.phet-topic-btn:hover {
  border-color: var(--color-sage, #5a7d5c);
  color: var(--color-sage, #5a7d5c);
}

.phet-topic-btn--active {
  background: var(--color-sage, #5a7d5c);
  border-color: var(--color-sage, #5a7d5c);
  color: #fff;
}

.phet-topic-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  min-width: 18px;
  text-align: center;
  border-radius: 9999px;
  background: rgba(90, 125, 92, 0.12);
  color: var(--color-sage, #5a7d5c);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: 1px;
}

.phet-topic-btn--active .phet-topic-count {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

/* ---------- 模拟卡片网格 ---------- */
.phet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.phet-card {
  display: flex;
  flex-direction: column;
  background: var(--surface-primary, #fff);
  border: 1px solid var(--border-light, #ece8e1);
  border-radius: var(--radius-lg, 20px);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.phet-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(26,58,42,0.1));
  border-color: var(--color-sage, #5a7d5c);
}

.phet-card-header {
  padding: 20px 20px 12px;
  background: linear-gradient(135deg, rgba(90, 125, 92, 0.06) 0%, rgba(196, 149, 106, 0.04) 100%);
  border-bottom: 1px solid var(--border-light, #ece8e1);
}

.phet-card-topic {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(90, 125, 92, 0.1);
  color: var(--color-sage, #5a7d5c);
  border-radius: var(--radius-full, 9999px);
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.phet-card-title {
  font-family: var(--font-serif, 'Noto Serif SC', serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-deep, #1a3a2a);
  margin-bottom: 4px;
}

.phet-card-subtitle {
  font-size: 0.78rem;
  color: var(--color-amber, #c4956a);
  font-weight: 500;
}

.phet-card-body {
  flex: 1;
  padding: 16px 20px;
}

.phet-card-desc {
  font-size: 0.86rem;
  color: var(--text-secondary, #4a4a4a);
  line-height: 1.6;
  margin-bottom: 14px;
}

.phet-card-knowledge {
  padding: 10px 12px;
  background: var(--surface-tertiary, #f0ebe0);
  border-radius: var(--radius-md, 12px);
  font-size: 0.78rem;
  color: var(--text-secondary, #4a4a4a);
  line-height: 1.55;
}

.phet-card-knowledge-label {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--color-sage, #5a7d5c);
}

.phet-card-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 0 20px 20px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--color-sage, #5a7d5c), var(--color-deep, #1a3a2a));
  color: #fff;
  border: none;
  border-radius: var(--radius-md, 12px);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.phet-card-btn:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(90, 125, 92, 0.3);
}

.phet-card-btn:active {
  transform: scale(0.98);
}

/* ---------- 模拟模态框 ---------- */
.phet-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  animation: phetFadeIn 0.2s ease;
}

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

.phet-modal {
  background: var(--surface-primary, #fff);
  border-radius: var(--radius-lg, 20px);
  width: 100%;
  max-width: 1100px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: phetSlideUp 0.3s ease;
}

@keyframes phetSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.phet-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface-secondary, #faf7f2);
  border-bottom: 1px solid var(--border-light, #ece8e1);
}

.phet-modal-title-wrap {
  flex: 1;
  min-width: 0;
}

.phet-modal-title {
  font-family: var(--font-serif, 'Noto Serif SC', serif);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-deep, #1a3a2a);
  margin-bottom: 2px;
}

.phet-modal-subtitle {
  font-size: 0.78rem;
  color: var(--color-sage, #5a7d5c);
}

.phet-modal-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--surface-tertiary, #f0ebe0);
  color: var(--text-secondary, #4a4a4a);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.phet-modal-close:hover {
  background: var(--color-error, #c0553a);
  color: #fff;
}

.phet-modal-frame {
  flex: 1;
  position: relative;
  background: #000;
  min-height: 500px;
}

.phet-modal-iframe {
  width: 100%;
  height: 100%;
  min-height: 500px;
  max-height: 70vh;
  border: none;
  display: block;
}

/* iframe 加载中：先隐藏，就绪后淡入 */
.phet-modal-iframe--loading {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.phet-modal-iframe:not(.phet-modal-iframe--loading) {
  opacity: 1;
}

/* 加载骨架：覆盖在 iframe 之上，就绪后淡出 */
.phet-modal-skeleton {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: linear-gradient(135deg, #1a2f1d 0%, #243d28 100%);
  color: #d4ddd6;
  transition: opacity 0.3s ease;
}
.phet-modal-skeleton--hidden {
  opacity: 0;
  pointer-events: none;
}

.phet-skeleton-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(196, 149, 106, 0.2);
  border-top-color: #c4956a;
  border-radius: 50%;
  animation: phetSkeletonSpin 0.9s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes phetSkeletonSpin {
  to { transform: rotate(360deg); }
}

.phet-skeleton-text {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.phet-skeleton-hint {
  font-size: 0.78rem;
  color: rgba(212, 221, 214, 0.6);
  letter-spacing: 0.02em;
}

.phet-modal-footer {
  padding: 16px 24px;
  background: var(--surface-secondary, #faf7f2);
  border-top: 1px solid var(--border-light, #ece8e1);
  max-height: 30vh;
  overflow-y: auto;
}

.phet-modal-desc {
  font-size: 0.86rem;
  color: var(--text-secondary, #4a4a4a);
  line-height: 1.6;
  margin-bottom: 10px;
}

.phet-modal-knowledge {
  font-size: 0.82rem;
  color: var(--text-secondary, #4a4a4a);
  line-height: 1.55;
  padding: 10px 12px;
  background: var(--surface-tertiary, #f0ebe0);
  border-radius: var(--radius-md, 12px);
  margin-bottom: 10px;
}

.phet-modal-openlink {
  display: inline-block;
  padding: 6px 12px;
  background: var(--color-amber, #c4956a);
  color: #fff;
  border-radius: var(--radius-sm, 6px);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 10px;
  transition: background 0.15s ease;
}

.phet-modal-openlink:hover {
  background: var(--color-amber-dark, #a87a4f);
}

.phet-modal-fallback {
  padding: 12px 14px;
  margin-bottom: 12px;
  border: 1px solid #f3c98b;
  background: linear-gradient(135deg, #fff7ea 0%, #ffefd6 100%);
  border-radius: var(--radius-md, 12px);
}

.phet-modal-fallback-title {
  font-weight: 700;
  color: #8a5a20;
  font-size: 0.86rem;
  margin-bottom: 4px;
}

.phet-modal-fallback p {
  font-size: 0.78rem;
  color: #6b4a20;
  line-height: 1.5;
  margin: 0 0 8px 0;
}

.phet-modal-fallback-btn {
  display: inline-block;
  padding: 7px 14px;
  background: var(--color-amber, #c4956a);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-sm, 6px);
  font-size: 0.8rem;
  font-weight: 600;
  transition: transform 0.15s ease, background 0.15s ease;
}

.phet-modal-fallback-btn:hover {
  background: var(--color-amber-dark, #a87a4f);
  transform: translateY(-1px);
}

.phet-modal-attribution {
  font-size: 0.72rem;
  color: var(--text-muted, #8a8a8a);
  line-height: 1.5;
}

.phet-modal-attribution a {
  color: var(--color-sage, #5a7d5c);
  text-decoration: none;
}

.phet-modal-attribution a:hover {
  text-decoration: underline;
}

/* ---------- 页脚 ---------- */
.phet-footer {
  text-align: center;
  padding: 24px;
  background: var(--surface-secondary, #faf7f2);
  border-radius: var(--radius-lg, 20px);
  font-size: 0.82rem;
  color: var(--text-secondary, #4a4a4a);
  line-height: 1.7;
}

.phet-license {
  margin-top: 12px;
  font-size: 0.76rem;
  color: var(--text-muted, #8a8a8a);
  line-height: 1.6;
}

.phet-license a {
  color: var(--color-sage, #5a7d5c);
  text-decoration: none;
}

.phet-license a:hover {
  text-decoration: underline;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .phet-grid {
    grid-template-columns: 1fr;
  }
  .phet-modal {
    max-height: 96vh;
    border-radius: var(--radius-md, 12px);
  }
  .phet-modal-header,
  .phet-modal-footer {
    padding: 12px 16px;
  }
  .phet-modal-frame {
    min-height: 400px;
  }
  .phet-modal-iframe {
    min-height: 400px;
    max-height: 55vh;
  }
  .phet-title {
    font-size: 1.4rem;
  }
  .phet-header {
    padding: 28px 16px 24px;
  }
}

@media (max-width: 480px) {
  .phet-grid {
    gap: 12px;
  }
  .phet-card-header,
  .phet-card-body {
    padding: 14px 16px;
  }
  .phet-card-btn {
    width: calc(100% - 32px);
    margin: 0 16px 16px;
  }
}
