/* ============================
   AI风月内置CSS - 抽象表现主义·森系
   容器: <card> 标签
   ============================ */

/* --- 全局容器 --- */
card {
  display: block;
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 24px);
  font-family: "Noto Serif SC", "Source Han Serif CN", Georgia, serif;
  font-size: clamp(14px, 2.5vw, 16px);
  line-height: 1.8;
  color: #3d2e1f;
  background:
    linear-gradient(135deg, rgba(34, 85, 51, 0.03) 0%, rgba(139, 90, 43, 0.05) 100%),
    linear-gradient(to bottom, #faf6f0 0%, #f5ede3 100%);
  border-radius: 12px;
  overflow: hidden;
}

/* 纸质纹理噪点层 */
card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

card > * {
  position: relative;
  z-index: 1;
}

/* --- 环境信息条 (env) --- */
card env {
  display: block;
  padding: 10px clamp(12px, 2vw, 18px);
  margin-bottom: 16px;
  background:
    linear-gradient(90deg, rgba(86, 125, 70, 0.12) 0%, rgba(139, 110, 65, 0.08) 100%);
  border-left: 3px solid #6b8f5e;
  border-radius: 0 8px 8px 0;
  font-size: clamp(12px, 2.2vw, 14px);
  color: #5a7a4a;
  letter-spacing: 0.5px;
}

/* --- 正文区 (text) --- */
card text {
  display: block;
  padding: clamp(16px, 4vw, 28px);
  margin-bottom: 16px;
  background:
    linear-gradient(160deg, rgba(255, 253, 248, 0.9) 0%, rgba(245, 237, 225, 0.95) 100%);
  border-radius: 10px;
  box-shadow:
    0 2px 8px rgba(61, 46, 31, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(139, 110, 65, 0.15);
}

card text p {
  margin: 0 0 1em 0;
  text-indent: 2em;
  text-align: justify;
  word-break: break-word;
}

card text p:last-child {
  margin-bottom: 0;
}

/* 对话文本样式 - 抽象笔触感 */
card text p:has(「) {
  text-indent: 0;
  padding-left: 1em;
  border-left: 2px solid rgba(86, 125, 70, 0.4);
  margin-left: 0.5em;
  font-style: italic;
  color: #2d5a3a;
}

/* --- 行动选项区 (actions) --- */
card actions {
  display: block;
  padding: clamp(12px, 3vw, 20px);
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(107, 143, 94, 0.08) 0%, rgba(180, 156, 120, 0.1) 100%);
  border-radius: 10px;
  border: 1px dashed rgba(107, 143, 94, 0.3);
}

card actions p {
  margin: 0;
  padding: 12px 16px;
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s ease;
  font-size: clamp(13px, 2.3vw, 15px);
  color: #4a6b3d;
  border-bottom: 1px solid rgba(107, 143, 94, 0.12);
}

card actions p:last-child {
  border-bottom: none;
}

card actions p:hover {
  background: rgba(107, 143, 94, 0.12);
  transform: translateX(4px);
  color: #2d5a3a;
}

card actions p:active {
  background: rgba(107, 143, 94, 0.2);
  transform: translateX(2px);
}

/* --- 折叠面板通用 (details/summary) --- */
card details {
  margin-bottom: 10px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(139, 110, 65, 0.15);
  background: rgba(250, 246, 240, 0.7);
  transition: box-shadow 0.3s ease;
}

card details:hover {
  box-shadow: 0 2px 12px rgba(61, 46, 31, 0.08);
}

card details[open] {
  box-shadow: 0 3px 16px rgba(61, 46, 31, 0.1);
}

card details summary {
  padding: clamp(10px, 2.5vw, 14px) clamp(12px, 3vw, 18px);
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  font-size: clamp(13px, 2.4vw, 15px);
  color: #5a4a35;
  background:
    linear-gradient(90deg, rgba(139, 110, 65, 0.06) 0%, rgba(107, 143, 94, 0.06) 100%);
  border-bottom: 1px solid rgba(139, 110, 65, 0.1);
  transition: background 0.2s ease;
  list-style: none;
}

card details summary::-webkit-details-marker {
  display: none;
}

card details summary::before {
  content: "▸";
  margin-right: 8px;
  font-size: 12px;
  color: #6b8f5e;
  transition: transform 0.3s ease;
  display: inline-block;
}

card details[open] > summary::before {
  transform: rotate(90deg);
}

card details summary:hover {
  background: rgba(107, 143, 94, 0.1);
}

card details > p,
card details > details {
  padding-left: clamp(12px, 3vw, 18px);
  padding-right: clamp(12px, 3vw, 18px);
}

card details > p {
  margin: 8px 0;
  font-size: clamp(12.5px, 2.2vw, 14px);
  color: #4a3d2e;
  line-height: 1.7;
}

card details > p b {
  color: #6b8f5e;
  font-weight: 600;
}

/* --- 嵌套折叠 (记忆区内部) --- */
card details details {
  margin: 6px 0;
  border-color: rgba(107, 143, 94, 0.12);
  background: rgba(255, 253, 248, 0.5);
}

card details details summary {
  padding: 8px 12px;
  min-height: 38px;
  font-size: clamp(12px, 2.1vw, 13.5px);
  font-weight: 500;
  background: rgba(107, 143, 94, 0.04);
}

card details details > p {
  font-size: clamp(11.5px, 2vw, 13px);
  padding-left: 12px;
  padding-right: 12px;
  color: #5a4a35;
  border-left: 2px solid rgba(107, 143, 94, 0.2);
  margin-left: 12px;
}

/* --- 木纹装饰分隔线 --- */
card text + actions::before,
card actions + details::before {
  content: "";
  display: block;
  height: 3px;
  margin: -8px 20% 12px 20%;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(139, 90, 43, 0.3) 0px,
      rgba(139, 90, 43, 0.15) 3px,
      rgba(101, 67, 33, 0.2) 5px,
      rgba(160, 120, 60, 0.1) 8px,
      rgba(139, 90, 43, 0.25) 12px
    );
  border-radius: 2px;
}

/* --- 心声面板特殊样式 --- */
card > details:first-of-type > p {
  font-style: italic;
  color: #7a6b5a;
  position: relative;
  padding-left: 20px;
}

card > details:first-of-type > p::before {
  content: "💭";
  position: absolute;
  left: 0;
  top: 0;
  font-style: normal;
  font-size: 14px;
}

/* --- 滚动条美化 --- */
card details[open] {
  max-height: 60vh;
  overflow-y: auto;
}

card ::-webkit-scrollbar {
  width: 5px;
}

card ::-webkit-scrollbar-track {
  background: rgba(245, 237, 225, 0.5);
  border-radius: 3px;
}

card ::-webkit-scrollbar-thumb {
  background: rgba(107, 143, 94, 0.3);
  border-radius: 3px;
}

card ::-webkit-scrollbar-thumb:hover {
  background: rgba(107, 143, 94, 0.5);
}

/* --- 响应式：移动端 --- */
@media screen and (max-width: 480px) {
  card {
    padding: 10px;
    border-radius: 8px;
  }

  card text {
    padding: 12px;
  }

  card actions p {
    padding: 14px 12px;
    min-height: 48px;
  }

  card details summary {
    min-height: 48px;
    padding: 12px;
  }

  card details details summary {
    min-height: 44px;
  }
}

/* --- 响应式：横屏 --- */
@media screen and (orientation: landscape) and (max-height: 500px) {
  card {
    max-width: 90vw;
    padding: 10px 16px;
  }

  card text {
    padding: 14px 18px;
  }

  card details[open] {
    max-height: 45vh;
  }
}

/* --- 响应式：大屏 --- */
@media screen and (min-width: 1024px) {
  card {
    max-width: 780px;
    padding: 28px 32px;
  }

  card actions p:hover {
    transform: translateX(6px);
    box-shadow: 0 1px 4px rgba(107, 143, 94, 0.15);
  }
}

/* --- 动画：展开 --- */
card details[open] > *:not(summary) {
  animation: fadeSlideIn 0.3s ease forwards;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- 抽象表现主义装饰：自由笔触边角 --- */
card::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 60px;
  height: 60px;
  background:
    radial-gradient(ellipse at 70% 30%, rgba(107, 143, 94, 0.15) 0%, transparent 70%),
    radial-gradient(ellipse at 30% 70%, rgba(139, 90, 43, 0.1) 0%, transparent 60%);
  border-radius: 0 12px 0 0;
  pointer-events: none;
  z-index: 0;
}