/*
 * 快捷样式类 - 简化常用排版操作
 * 灵感来源: xaringan, lite.js
 */

/* ============================================
   图片快捷类
   ============================================ */

/* 图片左浮动 */
.img-left {
  float: left;
  width: 33%;
  padding-right: 1rem;
  margin-bottom: 0.5rem;
}

.img-left img {
  width: 100%;
}

/* 图片右浮动 */
.img-right {
  float: right;
  width: 33%;
  padding-left: 1rem;
  margin-bottom: 0.5rem;
}

.img-right img {
  width: 100%;
}

/* 图片居中 */
.img-center {
  display: block;
  margin: 0 auto;
  text-align: center;
}

.img-center img {
  max-width: 100%;
}

/* 图片全宽 */
.img-full {
  width: 100%;
}

.img-full img {
  width: 100%;
}

/* 图片半宽居中 */
.img-half {
  width: 50%;
  margin: 0 auto;
  display: block;
  text-align: center;
}

.img-half img {
  width: 100%;
}

/* 图片尺寸变体 */
.img-25 { width: 25%; }
.img-33 { width: 33%; }
.img-50 { width: 50%; }
.img-66 { width: 66%; }
.img-75 { width: 75%; }

/* ============================================
   xaringan 兼容类 (pull-left/right)
   ============================================ */

.pull-left {
  float: left;
  width: 47%;
}

.pull-right {
  float: right;
  width: 47%;
}

.pull-left + .pull-right {
  clear: none;
}

/* 清除浮动 */
.clearfix::after {
  content: "";
  display: table;
  clear: both;
}

/* ============================================
   概览模式 (Tile View)
   ============================================ */

.tile-view-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(20, 20, 30, 0.98);
  z-index: 9999;
  padding: 2rem;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tile-view-container.active {
  opacity: 1;
  visibility: visible;
}

.tile-view-tile {
  position: relative;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  aspect-ratio: 4 / 3;
}

.tile-view-tile:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.tile-view-tile.current {
  outline: 4px solid #4361ee;
  outline-offset: 3px;
}

.tile-view-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 400%;
  height: 400%;
  transform: scale(0.25);
  transform-origin: top left;
  pointer-events: none;
  overflow: hidden;
}

.tile-view-content .remark-slide-content {
  width: 100%;
  height: 100%;
  padding: 1em 2em;
  box-sizing: border-box;
  font-size: 28px;
}

.tile-view-page {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: bold;
  z-index: 1;
}

/* ============================================
   代码复制按钮样式
   ============================================ */

.copy-button {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 4px 8px;
  font-size: 12px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

pre:hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background: #e0e0e0;
}

.copy-button.copied {
  background: #4caf50;
  color: white;
  border-color: #4caf50;
}

/* ============================================
   快捷文本样式
   ============================================ */

/* 高亮文本 */
.hl {
  background: linear-gradient(transparent 60%, #ffeb3b 60%);
  padding: 0 2px;
}

/* 关键词强调 */
.keyword {
  color: #e91e63;
  font-weight: 600;
}

/* 成功/警告/错误文本 */
.text-success { color: #4caf50; }
.text-warning { color: #ff9800; }
.text-error { color: #f44336; }
.text-info { color: #2196f3; }
.text-muted { color: #9e9e9e; }

/* ============================================
   快捷间距
   ============================================ */

.gap { margin: 1rem 0; }
.gap-sm { margin: 0.5rem 0; }
.gap-lg { margin: 2rem 0; }

/* ============================================
   卡片样式
   ============================================ */

.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  margin: 0.5rem 0;
}

.card-dark {
  background: #2d2d2d;
  color: #fff;
  border-radius: 8px;
  padding: 1rem;
  margin: 0.5rem 0;
}

/* ============================================
   标题自动缩放
   ============================================ */

/* 方案1: 纯 CSS 响应式标题 (推荐) */
/* 使用 class: scale-title */
.remark-slide-content.scale-title h1 {
  font-size: clamp(1.5rem, 5vw, 3rem);
}

/* 更小的标题 */
.remark-slide-content.scale-title-sm h1 {
  font-size: clamp(1.2rem, 4vw, 2.5rem);
}

/* 方案2: 使用 fitty 自动缩放的标题 */
.fit-title {
  display: block;
  white-space: nowrap;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* 整页启用标题缩放: class: fit-text */
.remark-slide-content.fit-text h1 {
  display: block;
  white-space: nowrap;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

/* 方案3: 允许标题换行但保持美观 */
.remark-slide-content.wrap-title h1 {
  white-space: normal;
  word-break: keep-all;
  line-height: 1.2;
  text-wrap: balance; /* 现代浏览器支持 */
}

/* 中文标题按词换行 (不在字符中间断开) */
.word-break-keep h1,
.word-break-keep h2,
h1.word-keep,
h2.word-keep {
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* ============================================
   内容溢出处理
   ============================================ */

/* 可滚动内容区域: class: scroll */
.remark-slide-content.scroll {
  overflow-y: auto;
}

/* 可滚动代码块 */
.scroll-code pre {
  max-height: 400px;
  overflow-y: auto;
}

/* 代码块自适应高度 */
.fit-code pre {
  max-height: 60vh;
  overflow-y: auto;
}

.fit-code pre code {
  font-size: 0.75em;
}

/* 紧凑模式：减小所有间距和字体 */
.remark-slide-content.compact {
  padding: 0.5em 2em;
}

.remark-slide-content.compact h2 {
  margin-top: 0.3em;
  margin-bottom: 0.3em;
}

.remark-slide-content.compact pre {
  margin: 0.3em 0;
  padding: 0.5em;
}

.remark-slide-content.compact p {
  margin: 0.3em 0;
}

.remark-slide-content.compact ul,
.remark-slide-content.compact ol {
  margin: 0.3em 0;
}

/* 超小字体模式 */
.remark-slide-content.tiny {
  font-size: 0.7em;
}

.remark-slide-content.tiny pre code {
  font-size: 0.85em;
}

/* ============================================
   代码块尺寸控制
   ============================================ */

/* 小号代码 */
.code-sm pre code {
  font-size: 0.7em;
  line-height: 1.3;
}

/* 超小号代码 */
.code-xs pre code {
  font-size: 0.6em;
  line-height: 1.2;
}

/* 限制代码块高度 */
.code-h200 pre { max-height: 200px; overflow-y: auto; }
.code-h300 pre { max-height: 300px; overflow-y: auto; }
.code-h400 pre { max-height: 400px; overflow-y: auto; }
