/* ── Sheet Modal 专属 CSS 变量 ── */
:root {
  --modal-mask-bg: rgba(117 117 117 / 15%);
  --modal-mask-blur: blur(18px) saturate(125%);
  --modal-sheet-top-gap: clamp(52px, 8vh, 88px);
}

/* ═══════════════════════════════════════
   SHEET MODAL（底部弹出面板）
═══════════════════════════════════════ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-mask-bg);
  backdrop-filter: var(--modal-mask-blur);
  -webkit-backdrop-filter: var(--modal-mask-blur);
  z-index: 9999;
  align-items: flex-end;
  justify-content: center;
  padding: var(--modal-sheet-top-gap) var(--container-pad) 0;
}

.modal.open {
  display: flex;
}

.modal-inner {
  position: relative;
  width: min(760px, 100%);
  max-width: min(760px, 100%);
  max-height: calc(100vh - var(--modal-sheet-top-gap));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg-primary, #fff);
  border: 1px solid rgba(255,255,255,0.4);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -18px 70px rgba(46,35,20,0.24), 0 0 0 1px rgba(255,255,255,0.18);
  animation: modalSheetIn 0.32s cubic-bezier(.2,.82,.2,1);
}

/* 顶部拖拽药丸指示器 */
.modal-inner::before {
  content: '';
  display: block;
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.28);
  margin: 10px auto;
}

.modal-inner img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
}

/* 底部固定操作栏（可选） */
.modal-actions {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  position: sticky;
  bottom: 0;
  background: var(--bg-primary, #fff);
}

.modal-actions .btn {
  flex: 1;
  text-align: center;
  padding: 12px 16px;
}

.modal-close {
  z-index: 10;
  background: rgba(20, 20, 20, 0.52);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--font-size-22);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}

.modal > .modal-close {
  position: fixed;
  top: calc(var(--modal-sheet-top-gap) + 12px);
  right: max(20px, calc((100vw - 760px) / 2 + 14px));
}

.modal-inner > .modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.modal[data-variant="center"] > .modal-close {
  top: 24px;
  right: 24px;
}

.modal-close:hover {
  background: rgba(40, 40, 40, 0.72);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

/* ── Sheet 动画 ─────────────────────────────────────────────── */
@keyframes modalSheetIn {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes modalSheetOut {
  to { transform: translateY(110%); }
}

@keyframes modalFadeOut {
  to { opacity: 0; }
}

/* 关闭动画：背景淡出 + 面板下滑 */
.modal.closing {
  pointer-events: none;
  animation: modalFadeOut 0.28s ease forwards;
}

.modal.closing .modal-inner {
  animation: modalSheetOut 0.26s cubic-bezier(.4, 0, .6, 1) forwards;
}

/* ═══════════════════════════════════════
   CENTER 变体（居中弹出）
═══════════════════════════════════════ */
.modal[data-variant="center"] {
  align-items: center;
  padding: 24px;
}

.modal[data-variant="center"] .modal-inner {
  width: min(1000px, 100%);
  max-width: min(1000px, 100%);
  max-height: 85vh;
  border-radius: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.4);
  animation: modalCenterIn 0.28s cubic-bezier(.2,.82,.2,1);
}

.modal[data-variant="center"].closing .modal-inner {
  animation: modalCenterOut 0.26s ease forwards;
}

/* 药丸指示器：center 桌面端不显示 */
.modal[data-variant="center"] .modal-inner::before {
  display: none;
}

/* ═══════════════════════════════════════
   VIDEO MODAL（基于 center 变体）
═══════════════════════════════════════ */
.modal-video .modal-inner {
  max-width: min(900px, 100%);
  overflow: hidden;
  background: rgba(20, 19, 17, 0.94);
  border-color: rgba(255,255,255,0.35);
  box-shadow: 0 30px 90px rgba(46,35,20,0.36), 0 0 0 1px rgba(255,255,255,0.2);
}

.modal-video-wrap {
  background: #000;
}

.modal-video-wrap video {
  width: 100%;
  display: block;
  max-height: 70vh;
  transform: translateZ(0);
}

.modal-video-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.modal-video-copy {
  min-width: 0;
}

.modal-video-info .modal-video-teacher {
  font-size: 14px;
  color: rgba(255,255,255,0.62);
  margin: 0 0 5px;
}

.modal-video-info .modal-video-title {
  font-size: 16px;
  color: #fff;
  margin: 0;
  font-weight: 500;
  line-height: 1.4;
}

.modal-video-transcript-btn {
  flex: 0 0 auto;
  border: 1px solid rgba(201,168,76,0.45);
  background: rgba(201,168,76,0.1);
  color: var(--accent-gold);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.modal-video-transcript-btn:hover {
  border-color: rgba(201,168,76,0.8);
  background: rgba(201,168,76,0.18);
  color: #f5d77b;
}

.modal-video-transcript-btn[hidden] {
  display: none;
}

/* ═══════════════════════════════════════
   TRANSCRIPT MODAL（二层文字版）
═══════════════════════════════════════ */
.modal-transcript {
  z-index: 10020;
}

.modal-transcript > .modal-close {
  z-index: 10030;
  top: calc(var(--modal-sheet-top-gap) + 12px);
  right: max(20px, calc((100vw - 860px) / 2 + 14px));
}

.modal-transcript .modal-inner {
  width: min(860px, 100%);
  max-width: min(860px, 100%);
  background: #151817;
  border-color: rgba(201,168,76,0.26);
  color: #d7d0c4;
}

.modal-transcript .modal-inner::before {
  display: none;
}

.modal-transcript-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px 72px 18px 24px;
  border-bottom: 1px solid rgba(201,168,76,0.2);
  background: rgba(21,24,23,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.modal-transcript-head::before {
  content: '';
  display: block;
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.24);
  margin: 0 auto 14px;
}

.modal-transcript-eyebrow {
  margin: 0 0 6px;
  color: var(--accent-gold);
  font-size: 13px;
  letter-spacing: .12em;
}

.modal-transcript-head h2 {
  margin: 0;
  color: #fff;
  font-family: var(--font-serif);
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 400;
  line-height: 1.35;
}

.modal-transcript-head p:last-child {
  margin: 8px 0 0;
  color: rgba(255,255,255,0.58);
  font-size: 14px;
  line-height: 1.5;
}

.modal-transcript-body {
  padding: 22px 24px 30px;
  color: #bfb7ab;
  font-size: 15px;
  line-height: 1.9;
}

.modal-transcript-body h3 {
  margin: 20px 0 8px;
  color: #f5efe4;
  font-size: 16px;
  line-height: 1.5;
}

.modal-transcript-body p {
  margin: 0 0 13px;
}

.modal-transcript-body .seo-keywords {
  color: var(--accent-gold);
  font-size: 13px;
}

@keyframes modalCenterIn {
  from { opacity: 0; transform: scale(0.93) translateY(14px); }
}
@keyframes modalCenterOut {
  to { opacity: 0; transform: scale(0.93) translateY(14px); }
}

/* ═══════════════════════════════════════
   响应式
═══════════════════════════════════════ */
/* Sheet 变体小屏 */
@media (max-width: 600px) {
  .modal:not([data-variant="center"]) {
    --modal-sheet-top-gap: 48px;
    padding-left: 0;
    padding-right: 0;
  }

  .modal:not([data-variant="center"]) .modal-inner {
    width: 100%;
    max-width: 100% !important;
    max-height: calc(100vh - var(--modal-sheet-top-gap));
    border-left: 0;
    border-right: 0;
    border-radius: 18px 18px 0 0;
  }

  .modal:not([data-variant="center"]) > .modal-close {
    top: calc(var(--modal-sheet-top-gap) + 12px);
    right: 14px;
  }

  .modal-transcript > .modal-close {
    right: 14px;
  }

}

/* Center 变体移动端：全屏展示 */
@media (max-width: 768px) {
  .modal[data-variant="center"] {
    padding: 0;
  }

  .modal[data-variant="center"].open {
    background: #0c0c0c;
  }

  .modal[data-variant="center"] .modal-inner {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    max-height: 100dvh;
    border: none;
  }

  /* 移动端全屏时显示药丸 */
  .modal[data-variant="center"] .modal-inner::before {
    display: block;
  }

  .modal-video.open {
    background: #000;
  }

  .modal-video .modal-inner {
    align-self: stretch;
    background: #000;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .modal-video-wrap video {
    max-height: 100vh;
  }

  .modal-video-info {
    display: none;
  }

  .modal-video.has-transcript .modal-video-info {
    display: flex;
    justify-content: center;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .modal-video.has-transcript .modal-video-copy {
    display: none;
  }

  .modal-video-transcript-btn {
    width: min(220px, 72vw);
  }

}
