/* ==========================================================================
 * sections/crafts.css — 03 / 造物集：左侧手风琴 + 右侧固定展台
 * 依赖：tokens.css, base.css, components/section-header.css, components/tactile.css
 * 联动逻辑见 js/modules/crafts-stage.js
 *
 * 悬停态统一包在 @media (hover: hover) 里且保持原位 —— 媒体查询不改变层叠
 * 优先级，只按源码顺序参与，所以 .craft-card:hover 仍然排在 .craft-card.is-open
 * 之前，展开态照旧覆盖悬停态。
 * ========================================================================== */

/*
  同 hero-section：本元素挂着 .container 类，只能用 padding-top/bottom 上下分写，
  用 padding 简写会把 .container 的左右内边距一起清零。
*/
.works-section {
  padding-top: clamp(5rem, 9vw, 8rem);
  padding-bottom: clamp(5rem, 9vw, 8rem);
}
.works-split-layout {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: clamp(2rem, 4.5vw, 4rem);
  align-items: start;
}

/* ---------- 左侧手风琴列表 ---------- */
.works-accordion {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.craft-card {
  position: relative;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  overflow: hidden;
  transition: border-color 0.35s ease, box-shadow 0.45s ease, transform 0.45s var(--ease-out-expo);
}
.craft-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-sage);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 0.45s var(--ease-out-expo);
}
@media (hover: hover) and (pointer: fine) {
  .craft-card:hover {
    border-color: var(--border-strong);
    transform: translateX(6px);
  }
}
.craft-card.is-open {
  border-color: var(--accent-sage);
  box-shadow: 0 18px 44px rgba(30, 42, 36, 0.08);
}
.craft-card.is-open::before {
  transform: scaleY(1);
}
.craft-header-btn {
  width: 100%;
  background: none;
  border: none;
  padding: 1.5rem 1.75rem;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 1rem;
  align-items: center;
  text-align: left;
  cursor: pointer;
  color: var(--ink-main);
}
.craft-num {
  font-family: var(--font-serif-en);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--accent-sage);
  transition: transform 0.4s var(--ease-out-expo);
}
@media (hover: hover) and (pointer: fine) {
  .craft-card:hover .craft-num {
    transform: translateX(4px);
  }
}
.craft-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.craft-name {
  font-family: var(--font-serif-en);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.2;
  transition: transform 0.45s var(--ease-out-expo);
}
@media (hover: hover) and (pointer: fine) {
  .craft-card:hover .craft-name {
    transform: translateX(6px);
  }
}
.craft-summary {
  font-size: 0.9rem;
  color: var(--ink-body);
}
.craft-arrow {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  transition: transform 0.5s var(--ease-out-expo), background 0.3s ease, color 0.3s ease;
}
.craft-card.is-open .craft-arrow {
  transform: rotate(135deg);
  background: var(--forest-deep);
  color: var(--surface-card);
}

/* 抽屉展开：grid-template-rows 0fr → 1fr，无需测量高度 */
.craft-body-drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.65s var(--ease-out-expo);
}
.craft-card.is-open .craft-body-drawer {
  grid-template-rows: 1fr;
}
.craft-body-inner {
  overflow: hidden;
}
.craft-body-pad {
  padding: 1.25rem 1.75rem 1.75rem calc(48px + 2.75rem);
  border-top: 1px dashed var(--border-subtle);
}
.craft-desc {
  font-size: 0.94rem;
  color: var(--ink-body);
  line-height: 1.85;
  margin-bottom: 1.2rem;
}
.craft-footer-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.craft-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.craft-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.2rem 0.65rem;
  border-radius: 99px;
  background: var(--bg-sage-tint);
  color: var(--forest-deep);
}
.craft-gh-link {
  font-family: var(--font-serif-en);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--accent-terracotta);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-terracotta);
  transition: letter-spacing 0.35s var(--ease-out-expo), opacity 0.3s ease;
}
@media (hover: hover) and (pointer: fine) {
  .craft-gh-link:hover {
    letter-spacing: 0.04em;
    opacity: 0.8;
  }
}

/* ---------- 右侧固定视觉展台（光圈快门裁切转场） ---------- */
.works-stage-sticky {
  position: sticky;
  top: 5.5rem;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  padding: 1.5rem;
  box-shadow: 0 24px 56px rgba(30, 42, 36, 0.08);
}
.stage-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
}
.stage-dots {
  display: flex;
  gap: 6px;
}
.stage-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}
.stage-viewport {
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 250px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--forest-deep);
  position: relative;
}
.stage-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  clip-path: circle(0% at 50% 50%);
  transform: scale(1.12) rotate(1.5deg);
  transition: clip-path 0.75s var(--ease-out-expo), transform 0.85s var(--ease-out-expo), opacity 0.4s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
}
.stage-slide.active {
  opacity: 1;
  clip-path: circle(85% at 50% 50%);
  transform: scale(1) rotate(0deg);
  pointer-events: auto;
}
.stage-slide svg {
  width: 100%;
  height: 100%;
  display: block;
}
@keyframes spinSphere {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.sphere-orbit {
  transform-origin: 180px 120px;
  animation: spinSphere 22s linear infinite;
}
.stage-caption {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.85rem;
  color: var(--ink-body);
}

/* ---------- 角落收录小工具 ---------- */
.minor-crafts-strip {
  margin-top: 2rem;
  background: var(--bg-sand-tint);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.25rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  transition: transform 0.45s var(--ease-out-expo), box-shadow 0.45s ease;
}
@media (hover: hover) and (pointer: fine) {
  .minor-crafts-strip:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 32px rgba(30, 42, 36, 0.06);
  }
}
.minor-crafts-links {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}
.minor-crafts-links a {
  color: var(--ink-main);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.3s ease;
}
@media (hover: hover) and (pointer: fine) {
  .minor-crafts-links a:hover {
    color: var(--accent-terracotta);
  }
}
.minor-crafts-links a strong {
  font-family: var(--font-serif-en);
  font-size: 1.15rem;
  border-bottom: 1px solid var(--ink-main);
  margin-right: 0.35rem;
}

/* ---------- 窄屏：展台提到列表上方并取消吸顶 ---------- */
@media (max-width: 960px) {
  .works-split-layout {
    grid-template-columns: 1fr;
  }
  .works-stage-sticky {
    position: static;
    order: -1;
  }
  .craft-body-pad {
    padding-left: 1.5rem;
  }
}

@media (max-width: 640px) {
  .works-accordion {
    gap: 0.75rem;
  }
  .craft-card {
    border-radius: 15px;
  }
  .craft-header-btn {
    padding: 1.1rem 1.05rem;
    grid-template-columns: 30px 1fr auto;
    gap: 0.7rem;
  }
  .craft-num {
    font-size: 1.15rem;
  }
  .craft-name {
    font-size: 1.2rem;
  }
  .craft-summary {
    font-size: 0.82rem;
    line-height: 1.6;
  }
  .craft-arrow {
    width: 28px;
    height: 28px;
    font-size: 0.78rem;
  }
  .craft-body-pad {
    padding: 1rem 1.05rem 1.25rem 1.05rem;
  }
  .craft-desc {
    font-size: 0.88rem;
  }
  .craft-gh-link {
    font-size: 1rem;
  }
  .works-stage-sticky {
    padding: 1.1rem;
    border-radius: 18px;
  }
  .stage-viewport {
    min-height: 200px;
    border-radius: 12px;
  }
  .stage-slide {
    padding: 1rem;
  }
  .stage-caption {
    font-size: 0.78rem;
    margin-top: 0.85rem;
    padding-top: 0.7rem;
  }
  .minor-crafts-strip {
    margin-top: 1.5rem;
    padding: 1rem 1.05rem;
    border-radius: 14px;
  }
  .minor-crafts-links {
    gap: 0.85rem 1.35rem;
  }
  .minor-crafts-links a {
    font-size: 0.84rem;
  }
  .minor-crafts-links a strong {
    font-size: 1.02rem;
  }
}
