/**
 * 功能说明：定义规则动画子站的列表页与详情页视觉系统。
 * 职责边界：只处理静态布局、画布容器和响应式表现，不负责动画状态计算。
 */

:root {
  color-scheme: light;
  --paper: #f7f4ee;
  --paper-deep: #eee8dc;
  --ink: #1d221f;
  --ink-soft: rgba(29, 34, 31, 0.68);
  --ink-muted: rgba(29, 34, 31, 0.46);
  --line: rgba(29, 34, 31, 0.12);
  --surface: #fffdf8;
  --blue: #235789;
  --black: #020100;
  --shadow: 0 22px 56px rgba(31, 28, 23, 0.08);
  --shadow-deep: 0 28px 64px rgba(31, 28, 23, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), transparent 34%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

canvas {
  display: block;
}

.pattern-shell {
  width: min(1180px, calc(100vw - 40px));
  min-height: calc(100vh - 112px);
  margin: 0 auto;
  padding: clamp(36px, 7vw, 92px) 0;
}

.eyebrow,
.work-kicker {
  font-size: 0.78rem;
  line-height: 1.35;
  font-weight: 720;
  color: var(--blue);
}

.catalog-section {
  margin-top: 0;
}

.catalog-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(29, 34, 31, 0.08);
}

.catalog-bar h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.8vw, 2rem);
  line-height: 1.18;
  font-weight: 620;
  letter-spacing: 0;
}

.catalog-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.sort-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(29, 34, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.62);
}

.app-download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid rgba(29, 34, 31, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 680;
  line-height: 1;
  transition:
    border-color 180ms ease,
    color 180ms ease,
    background-color 180ms ease;
}

.app-download-link:hover,
.app-download-link:focus-visible {
  border-color: rgba(29, 34, 31, 0.2);
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  outline: none;
}

.sort-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 680;
  line-height: 1;
  cursor: pointer;
}

.sort-tab:hover,
.sort-tab:focus-visible {
  color: var(--ink);
  outline: none;
}

.sort-tab.is-active {
  background: #27342e;
  color: #fffaf3;
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 360px));
  gap: clamp(16px, 2.5vw, 24px);
  align-items: start;
  justify-content: start;
  margin-top: 22px;
}

.work-card {
  position: relative;
  display: grid;
  gap: 16px;
  min-width: 0;
  overflow: hidden;
  padding: 14px;
  border: 1px solid rgba(29, 34, 31, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(247, 244, 238, 0.84)),
    var(--surface);
  box-shadow: var(--shadow);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.work-card:hover,
.work-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(29, 34, 31, 0.2);
  box-shadow: var(--shadow-deep);
  outline: none;
}

.preview-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(29, 34, 31, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(245, 241, 232, 0.88)),
    #f7f2e8;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 18px 42px rgba(31, 28, 23, 0.08);
}

.preview-frame {
  position: relative;
  aspect-ratio: 16 / 10;
  min-height: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--black);
  box-shadow: 0 14px 34px rgba(2, 1, 0, 0.18);
}

.preview-canvas {
  width: 100%;
  height: 100%;
}

.work-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 2px 4px 4px;
}

.work-title {
  display: block;
  font-size: clamp(1.52rem, 3vw, 2.25rem);
  line-height: 1.1;
  font-weight: 620;
  letter-spacing: 0;
}

.work-desc {
  display: block;
  min-height: 3.4em;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.72;
}

.motion-footer {
  width: min(1180px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 0 0 34px;
}

.motion-footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  align-items: center;
  justify-content: space-between;
  padding-top: 22px;
  border-top: 1px solid rgba(29, 34, 31, 0.1);
}

.motion-home-link,
.motion-records a {
  color: var(--ink-muted);
  font-size: 0.86rem;
  line-height: 1.5;
  transition: color 180ms ease;
}

.motion-home-link {
  font-weight: 680;
  color: rgba(29, 34, 31, 0.62);
}

.motion-home-link:hover,
.motion-home-link:focus-visible,
.motion-records a:hover,
.motion-records a:focus-visible {
  color: var(--ink);
  outline: none;
}

.motion-records {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: flex-end;
}

.police-record {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.police-record img {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.page-work {
  overflow: hidden;
  background: #f9f7f1;
}

.page-work-dark {
  background: var(--black);
}

.page-code {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), transparent 34%),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
}

.code-shell {
  width: min(1120px, calc(100vw - 40px));
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px) 0;
}

.code-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 22px;
  align-items: end;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(29, 34, 31, 0.1);
}

.code-header h1 {
  grid-column: 1 / 2;
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1.12;
  font-weight: 620;
  letter-spacing: 0;
}

.code-back-link {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(29, 34, 31, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink-soft);
  font-size: 0.88rem;
  font-weight: 680;
  line-height: 1;
  transition:
    border-color 180ms ease,
    color 180ms ease,
    background-color 180ms ease;
}

.code-back-link:hover,
.code-back-link:focus-visible {
  border-color: rgba(29, 34, 31, 0.2);
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  outline: none;
}

.source-panel {
  margin-top: 22px;
  overflow: hidden;
  border: 1px solid rgba(29, 34, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
}

.source-panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(29, 34, 31, 0.08);
}

.source-panel-head h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  font-weight: 720;
}

.source-panel-head span {
  color: var(--ink-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.source-code {
  max-height: 78vh;
  margin: 0;
  overflow: auto;
  padding: 18px;
  background: #111310;
  color: #f3efe5;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.68;
  tab-size: 2;
}

.source-code code {
  white-space: pre;
}

.growth-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.growth-canvas,
.patchwork-canvas {
  width: 100vw;
  height: 100vh;
}

.patchwork-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--black);
}

.growth-counter {
  position: fixed;
  left: 50%;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 22px));
  z-index: 3;
  display: inline-flex;
  align-items: baseline;
  min-width: 3ch;
  justify-content: center;
  transform: translateX(-50%);
  color: rgba(2, 1, 0, 0.78);
  font-size: clamp(1rem, 2.2vw, 1.46rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.growth-counter strong {
  min-width: 3ch;
  font-weight: 680;
  letter-spacing: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .pattern-shell {
    width: min(100% - 28px, 560px);
    padding-top: 34px;
  }

  .motion-footer {
    width: min(100% - 28px, 560px);
  }

  .catalog-bar {
    align-items: start;
    flex-direction: column;
  }

  .catalog-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .sort-tabs {
    width: 100%;
  }

  .app-download-link {
    width: 100%;
  }

  .sort-tab {
    flex: 1;
  }

  .work-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .motion-footer-inner {
    align-items: start;
    flex-direction: column;
  }

  .motion-records {
    justify-content: flex-start;
  }

  .code-shell {
    width: min(100% - 28px, 560px);
  }

  .code-header {
    grid-template-columns: 1fr;
  }

  .code-back-link {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
  }

  .source-code {
    max-height: 72vh;
    font-size: 0.76rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .work-card,
  .app-download-link,
  .code-back-link,
  .motion-home-link,
  .motion-records a {
    transition: none;
  }
}
