/* ============================================================
   OPERA Cloud E-Learning 课程视频库 · 暖纸编辑色系
   强调色: terracotta #A9481F（唯一强调色）
   字体: 衬线栈 · hairline 虚线分隔 · 零值区块动态隐藏
   ============================================================ */

:root {
  --parchment: #F5F0E6;
  --card: #FDFBF5;
  --ink: #2A251D;
  --ink-soft: #6B6252;
  --ink-faint: #9A8F7B;
  --terracotta: #A9481F;
  --terracotta-deep: #8C3A17;
  --hairline: #D9CFBB;
  --shadow: 0 1px 2px rgba(42, 37, 29, .05), 0 8px 24px rgba(42, 37, 29, .07);
  --radius: 10px;
  --serif: Georgia, "Times New Roman", "Songti SC", "Noto Serif SC", "SimSun", serif;
}

* { box-sizing: border-box; }

/* hidden 属性必须战胜类上的 display 声明（.loading/.stats/.grid 等），否则 JS 置 hidden 不生效 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 头部 ---------- */

.site-header {
  padding: 56px 0 36px;
  border-bottom: 1px dashed var(--hairline);
}

.kicker {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--terracotta);
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(28px, 4.5vw, 42px);
  font-weight: 700;
  letter-spacing: .02em;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 26px 0 0;
  padding: 0;
}

.stat {
  min-width: 110px;
  padding: 0 28px 0 0;
  margin-right: 28px;
  border-right: 1px dashed var(--hairline);
}

.stat:last-child { border-right: 0; }

.stat dt {
  font-size: 12px;
  letter-spacing: .14em;
  color: var(--ink-faint);
}

.stat dd {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- 工具栏 ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245, 240, 230, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px dashed var(--hairline);
}

.toolbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 220px;
  min-width: 180px;
  max-width: 360px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-faint);
}

.search:focus-within {
  border-color: var(--terracotta);
  color: var(--terracotta);
}

.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
  min-width: 0;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 5px 14px;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: transparent;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}

.chip:hover { border-color: var(--terracotta); color: var(--terracotta); }

.chip[aria-selected="true"] {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--card);
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--card);
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}

.btn:hover { border-color: var(--terracotta); color: var(--terracotta); }

.btn-primary {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--card);
}

.btn-primary:hover { background: var(--terracotta-deep); color: var(--card); }

.btn-ghost { background: transparent; }

.btn-danger:hover { border-color: #B3261E; color: #B3261E; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  flex: none;
  transition: all .18s ease;
}

.icon-btn:hover { border-color: var(--terracotta); color: var(--terracotta); }

/* ---------- 网格与卡片 ---------- */

main { padding: 28px 0 64px; min-height: 50vh; }

.result-hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--ink-faint);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 2px 4px rgba(42, 37, 29, .06), 0 14px 32px rgba(42, 37, 29, .12);
}

.card-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #EAE2D2;
  border: 0;
  padding: 0;
  cursor: pointer;
  display: block;
  width: 100%;
  overflow: hidden;
}

.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}

.card:hover .card-cover img { transform: scale(1.03); }

.card-cover .cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  font-size: 13px;
  letter-spacing: .2em;
}

.cover-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(42, 37, 29, 0);
  transition: background .25s ease;
}

.cover-play span {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--terracotta);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(.85);
  transition: all .25s ease;
  box-shadow: 0 6px 18px rgba(169, 72, 31, .35);
}

.cover-play svg { margin-left: 3px; }

.card:hover .cover-play { background: rgba(42, 37, 29, .18); }

.card:hover .cover-play span { opacity: 1; transform: scale(1); }

.badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(42, 37, 29, .78);
  color: #FDFBF5;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 18px 14px;
}

.card-cat {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--terracotta);
}

.card-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
}

.card-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px dashed var(--hairline);
  font-size: 12.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.card-play-text {
  color: var(--terracotta);
  letter-spacing: .1em;
  background: none;
  border: 0;
  font-family: var(--serif);
  font-size: 12.5px;
  cursor: pointer;
  padding: 8px 2px 8px 10px;
  margin-right: -10px;
}

/* ---------- 空态 / 加载 ---------- */

.empty {
  text-align: center;
  padding: 80px 0;
}

.empty-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.empty-sub { margin: 0; color: var(--ink-faint); font-size: 14px; }

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 90px 0;
  color: var(--ink-faint);
  font-size: 14px;
}

.loading p { margin: 0; }

.spinner {
  width: 26px;
  height: 26px;
  border: 2px solid var(--hairline);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 页脚 ---------- */

.site-footer {
  border-top: 1px dashed var(--hairline);
  padding: 28px 0 40px;
  color: var(--ink-faint);
  font-size: 13px;
}

.site-footer p { margin: 0 0 4px; }

/* ---------- 弹窗 ---------- */

.modal { position: fixed; inset: 0; z-index: 50; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(42, 37, 29, .55);
  animation: fadeIn .2s ease;
}

.modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 40px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(42, 37, 29, .3);
  animation: popIn .22s ease;
}

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } }

.player-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px dashed var(--hairline);
}

.player-head-text { min-width: 0; }

.player-cat {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: .18em;
  color: var(--terracotta);
}

.player-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.4;
}

.player-stage { background: #1E1A14; }

.player-stage video {
  display: block;
  width: 100%;
  max-height: 62dvh;
  background: #1E1A14;
}

.player-foot {
  padding: 14px 22px 20px;
}

.player-desc {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 14px;
}

.player-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--hairline);
}

.player-pos {
  font-size: 12.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
  .site-header { padding: 32px 0 24px; }
  .wrap { padding: 0 18px; }

  /* 工具栏两行布局：第一行 搜索，第二行 chips 横滚 */
  .toolbar-inner { gap: 8px; padding: 10px 18px; flex-wrap: wrap; }
  .search { flex: 1 1 auto; max-width: none; padding: 7px 12px; }
  .filters {
    order: 3;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -18px;
    padding: 0 18px;
  }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex: none; min-height: 34px; display: inline-flex; align-items: center; }

  .grid { grid-template-columns: 1fr; gap: 16px; }
  .stat { min-width: 88px; padding-right: 16px; margin-right: 16px; }
  .stat dd { font-size: 20px; }

  /* 播放器：移动端全屏，video 占满剩余空间 */
  .player-panel {
    position: fixed;
    inset: 0;
    left: 0;
    top: 0;
    transform: none;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    animation: none;
  }
  .player-head {
    flex: none;
    padding: max(14px, env(safe-area-inset-top)) 16px 10px;
    gap: 10px;
  }
  .player-head h2 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .player-cat { margin-bottom: 2px; }
  .player-stage { flex: 1; display: flex; align-items: center; min-height: 0; background: #1E1A14; }
  .player-stage video { width: 100%; max-height: 100%; object-fit: contain; }
  .player-foot { flex: none; padding: 10px 16px max(14px, env(safe-area-inset-bottom)); }
  .player-desc {
    margin: 0 0 10px;
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .player-nav { padding-top: 10px; }
  .player-nav .btn { min-height: 44px; padding: 8px 18px; }
  .player-pos { font-size: 12px; }

}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .toolbar, .modal, .card-cover { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
