/**
 * 众水不灭 · 雅歌之印
 * 文件名: css/icebreaker.css
 * 作用: 破冰信号箱的长文本自适应排版、响应式降级与移动端单列信笺流引擎
 */

/* ---------------- 基础网格引擎 ---------------- */
.icebreaker-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 🌟 核心：为长文本优化的响应式弹性网格 */
.icebreaker-grid {
  display: grid;
  /* 电脑端保持 2 列对称 (对于较长文本来说 2 列比 3 列阅读体验更好) */
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
}

/* ---------------- 卡片内部排版体系 ---------------- */
.icebreaker-btn {
  /* 🎯 修复：背景色接入主题变量，确保浅色主题变亮、深色主题变暗 */
  background: var(--bg-card, rgba(3, 7, 18, 0.4));
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.1));
  border-radius: 16px;
  /* 将定高改为 min-height，让超长文本自然撑开，绝不溢出！ */
  min-height: 140px;
  padding: 18px 20px;
  cursor: pointer;
  
  /* 默认为纵向排列 (电脑端形态) */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05);
  /* 光学毛玻璃滤镜 */
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* 确保苹果端点击无高亮，整张卡片都是触发区 */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.icebreaker-btn:hover {
  background: var(--bg-card-hover, rgba(3, 7, 18, 0.65));
  border-color: var(--accent-gold, #f59e0b);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--accent-gold-glow, rgba(245, 158, 11, 0.2));
}

.icebreaker-btn:active {
  transform: scale(0.97);
}

.icebreaker-btn__icon {
  font-size: 32px;
  margin-bottom: 10px;
  display: block;
  /* 图标呼吸动画 */
  animation: pulse-icon 3s ease-in-out infinite alternate;
}

@keyframes pulse-icon {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.icebreaker-btn__label {
  font-size: 15.5px;
  font-weight: 800;
  /* 🎯 修复：回归主题变量。配合 text-shadow 消除边缘发虚，极大地增强全主题辨识度 */
  color: var(--text-main, #f8fafc);
  text-shadow: 0 1px 2px var(--shadow-color, rgba(0, 0, 0, 0.1));
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  display: block;
  width: 100%;
}

/* 🌟 核心：长文本优美排版约束 */
.icebreaker-btn__desc {
  font-size: 13px;
  /* 放大行高，增加阅读呼吸感 */
  line-height: 1.6;
  letter-spacing: 0.5px;
  /* 🎯 修复：回归主题副色变量，通过字重保障阅读体验 */
  color: var(--text-sub, #cbd5e1);
  text-shadow: 0 1px 2px var(--shadow-color, rgba(0, 0, 0, 0.05));
  font-weight: 600;
  width: 100%;
  text-align: justify;
  /* 强制单词在行尾自动换行，杜绝撑破卡片 */
  overflow-wrap: break-word;
  word-break: break-word;
}

/* 🌟 核心拦截：移动端 (含 iPhone) 强行降级为单列信笺流，采用 CSS Grid 实现绝美左右排版 */
@media (max-width: 640px) {
  .icebreaker-card {
    padding: 16px;
  }
  .icebreaker-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .icebreaker-btn {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    column-gap: 16px;
    text-align: left;
    align-items: start;
    padding: 16px 14px;
    min-height: auto;
  }
  .icebreaker-btn__icon {
    grid-column: 1;
    grid-row: 1 / 3;
    font-size: 28px;
    margin-bottom: 0;
    margin-top: 2px;
  }
  .icebreaker-btn__label {
    grid-column: 2;
    grid-row: 1;
    text-align: left;
    margin-bottom: 4px;
  }
  .icebreaker-btn__desc {
    grid-column: 2;
    grid-row: 2;
  }
}

/* ---------------- 模态框与历史备忘录 ---------------- */
.icebreaker-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 16px;
}

.icebreaker-modal.active {
  opacity: 1;
  pointer-events: auto;
}

/* 🌟 核心：移动端模态框高度锁定与内部滑动 */
.icebreaker-modal__dialog {
  /* 🎯 修复：大弹窗背景同样接入主题变量，支持浅色主题下变为柔和亮色 */
  background: var(--bg-card, linear-gradient(180deg, rgba(15, 23, 42, 0.95) 0%, rgba(9, 13, 22, 0.95) 100%));
  border: 1px solid var(--border-card);
  border-radius: 24px;
  width: 100%;
  max-width: 560px; /* 略微加宽以容纳长文本 */
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 24px 64px var(--shadow-color, rgba(0, 0, 0, 0.8)), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transform: scale(0.9) translateY(20px);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  
  /* 绝不溢出屏幕，内容过长时开启原生级顺滑惯性滚动 */
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.icebreaker-modal.active .icebreaker-modal__dialog {
  transform: scale(1) translateY(0);
}

.icebreaker-modal--mutual .icebreaker-modal__dialog {
  /* 双向奔赴弹窗：特例，永远保持深紫浪漫渐变 */
  background: linear-gradient(180deg, rgba(88, 28, 135, 0.95) 0%, rgba(15, 23, 42, 0.95) 100%);
  border-color: rgba(217, 70, 239, 0.4);
  box-shadow: 0 24px 64px rgba(192, 38, 211, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

/* 🎯 修复：由于双向奔赴弹窗底色强制为深紫，文本必须强制亮色，防止浅色主题下黑字溶于黑底 */
.icebreaker-modal--mutual .icebreaker-modal__title,
.icebreaker-modal--mutual .icebreaker-letter__quote {
  color: #ffffff !important;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.icebreaker-modal__badge {
  display: inline-block;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-gold, #fde68a);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.icebreaker-modal__title {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-hero, var(--text-main, #fff));
  text-shadow: 0 1px 3px var(--shadow-color, rgba(0,0,0,0.1));
  margin-bottom: 24px;
}

/* 接收到的信笺展现框：为长文本专门扩容 */
.icebreaker-letter {
  background: var(--bg-overlay, rgba(255, 255, 255, 0.03));
  border: 1px dashed var(--accent-gold, rgba(245, 158, 11, 0.3));
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 30px;
  position: relative;
}

.icebreaker-letter__quote {
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text-main, #f8fafc);
  font-style: italic;
  font-weight: 600;
  text-align: left;
}

.icebreaker-modal__actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.icebreaker-btn-primary,
.icebreaker-btn-secondary {
  width: 100%;
  padding: 14px;
  border-radius: 16px;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  outline: none;
}

.icebreaker-btn-primary {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.35);
}

.icebreaker-btn-primary:active {
  transform: scale(0.98);
}

.icebreaker-btn-secondary {
  background: var(--bg-overlay, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.1));
  color: var(--text-sub, #94a3b8);
}

.icebreaker-btn-secondary:active {
  background: var(--bg-card-hover, rgba(255, 255, 255, 0.08));
}

.icebreaker-cooling-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
  padding: 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.icebreaker-cooling-timer {
  font-size: 16px;
  font-weight: 900;
  font-family: ui-monospace, monospace;
  margin-top: 6px;
}

/* ---------------- 顶部横幅动画 ---------------- */
.icebreaker-banner {
  position: fixed;
  top: -80px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card, rgba(15, 23, 42, 0.95));
  border: 1px solid var(--accent-gold, #f59e0b);
  border-radius: 30px;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), 0 0 20px var(--accent-gold-glow, rgba(245, 158, 11, 0.4));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  cursor: pointer;
  transition: top 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  width: 90%;
  max-width: 400px;
}

.icebreaker-banner.show {
  top: max(20px, env(safe-area-inset-top));
}

.icebreaker-banner__icon {
  font-size: 24px;
  animation: float 2s ease-in-out infinite;
}

.icebreaker-banner__text {
  flex: 1;
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icebreaker-banner__arrow {
  font-size: 12px;
  color: var(--accent-gold, #fde68a);
  font-weight: 900;
  background: var(--bg-overlay, rgba(255, 255, 255, 0.1));
  padding: 4px 10px;
  border-radius: 12px;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* ---------------- 历史足迹记录 ---------------- */
.icebreaker-history-wrap {
  border-top: 1px dashed var(--border-card, rgba(255, 255, 255, 0.15));
  padding-top: 24px;
}

.icebreaker-history-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 900;
  color: var(--accent-gold, #f59e0b);
  margin-bottom: 16px;
}

.icebreaker-history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.icebreaker-history-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-sub, #64748b);
  font-size: 12.5px;
  background: var(--bg-overlay, rgba(255, 255, 255, 0.02));
  border-radius: 14px;
}

.icebreaker-history-item {
  background: var(--bg-overlay, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-card, rgba(255, 255, 255, 0.08));
  border-radius: 16px;
  padding: 16px;
  transition: all 0.2s;
}

.icebreaker-history-item:hover {
  background: var(--bg-card-hover, rgba(255, 255, 255, 0.06));
  border-color: var(--accent-gold, rgba(245, 158, 11, 0.3));
}

.icebreaker-history-item__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.icebreaker-history-badge {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
}

.icebreaker-history-date {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

.icebreaker-history-summary {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-main, #f8fafc);
  font-weight: 600;
  text-align: left;
  margin-bottom: 12px;
}

.icebreaker-history-item__footer {
  display: flex;
  justify-content: flex-end;
}

.icebreaker-history-btn {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}

.icebreaker-history-btn:hover {
  background: var(--accent-gold, rgba(245, 158, 11, 0.8));
  color: #fff;
}
