/* 首页「上新模板」: slow auto-scroll row of the newest templates. Tokens from base.css; motion pauses on hover/focus,
   stops for prefers-reduced-motion, and becomes a swipeable row on phones. */
/* 模板区 (11-25): 精选 and 上新 are two blocks of one section with the same header (title and count) and the same
   centered 「查看全部 →」 under their cards (精选 → /templates, 上新 → /templates?sort=recent). */
.mk-head { display: flex; align-items: center; gap: 16px; margin: 0 0 18px; }
.mk-foot { display: flex; justify-content: center; margin-top: 28px; }
.mk-foot .mk-all { padding: 11px 22px; font-size: 15px; font-weight: 500; background: rgba(240,246,252,.03); }
.mk-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; min-width: 0; }
.mk-title h3 { display: inline-flex; align-items: center; gap: 10px; margin: 0; font-size: clamp(20px, .7vw + 14px, 24px); font-weight: 700; letter-spacing: -.01em; }
.mk-meta { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.mk-all { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--fg); font-size: 14px; white-space: nowrap;
  transition: border-color .25s var(--ease), background .25s var(--ease); }
.mk-all:hover, .mk-all:focus-visible { border-color: rgba(163,113,247,.6); background: rgba(163,113,247,.08); }
.mk-all .arr { transition: transform .25s var(--ease); }
.mk-all:hover .arr { transform: translateX(3px); }
#featured-templates { margin-top: 4px; }
.home-new { position: relative; margin-top: 56px; margin-bottom: 48px; padding-top: 44px; border-top: 1px solid var(--border-muted); }
.hn-live { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(63,185,80,.55); animation: hn-pulse 2.4s var(--ease) infinite; }
@keyframes hn-pulse { 0% { box-shadow: 0 0 0 0 rgba(63,185,80,.5); } 70% { box-shadow: 0 0 0 8px rgba(63,185,80,0); } 100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); } }

.hn-viewport { position: relative; overflow: hidden; padding: 6px 0 18px; }
.home-new.is-marquee .hn-viewport { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 4%, #000 96%, transparent 100%); }
.hn-track { display: flex; gap: 16px; width: max-content; margin: 0; padding: 0; list-style: none; }
.home-new.is-marquee .hn-track { animation: hn-scroll var(--hn-dur, 60s) linear infinite; }
.home-new.is-marquee .hn-viewport:hover .hn-track, .home-new.is-marquee .hn-viewport:focus-within .hn-track { animation-play-state: paused; }
@keyframes hn-scroll { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(var(--hn-shift, -50%), 0, 0); } }

.hn-card { position: relative; flex: 0 0 auto; width: 272px; border-radius: 14px; border: 1px solid var(--border-muted); background: linear-gradient(180deg, rgba(240,246,252,.03), rgba(240,246,252,.01));
  transition: transform .35s var(--ease), border-color .35s var(--ease), box-shadow .35s var(--ease); }
.hn-card:hover, .hn-card:focus-within { transform: translateY(-4px); border-color: rgba(163,113,247,.45); box-shadow: 0 18px 40px -22px rgba(163,113,247,.55), 0 0 0 1px rgba(121,192,255,.08); }

.hn-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 13px 13px 0 0; background: #0d1117; }
.hn-media::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(240,246,252,.06) 50%, transparent 80%) 0 0 / 220% 100%; animation: hn-shimmer 1.4s linear infinite; }
.hn-card.is-loaded .hn-media::before { opacity: 0; animation: none; transition: opacity .3s; }
@keyframes hn-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
/* Portrait covers sit on a soft, blurred copy of themselves (same cached image) instead of black bars. */
.hn-card.is-portrait .hn-media::after { content: ""; position: absolute; inset: -24px; background: var(--cover) center / cover no-repeat; filter: blur(22px) saturate(1.15); opacity: 0; transition: opacity .5s var(--ease); }
.hn-card.is-portrait.is-loaded .hn-media::after { opacity: .42; }
.hn-media > img, .hn-media > video, .hn-new, .hn-ratio { z-index: 1; }
.hn-media > .preview-state { display: none !important; }
.hn-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.01); transition: opacity .45s var(--ease), transform .6s var(--ease); }
.hn-card.is-portrait .hn-cover { object-fit: contain; }
.hn-card.is-loaded .hn-cover { opacity: 1; }
.hn-card:hover .hn-cover { transform: scale(1.045); }
.hn-cover-empty { opacity: 1; background: radial-gradient(120% 120% at 20% 10%, rgba(163,113,247,.25), transparent 60%), #0d1117; }
.hn-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s var(--ease); pointer-events: none; }
.hn-card.is-portrait .hn-media video { object-fit: contain; }
.hn-card.is-playing .hn-media video { opacity: 1; }
.hn-new { position: absolute; top: 10px; left: 10px; padding: 3px 8px; border-radius: 999px; font: 700 10px/1.4 var(--mono); letter-spacing: .12em; color: #0b0d12;
  background: var(--grad); box-shadow: 0 4px 16px -6px rgba(247,120,186,.6); overflow: hidden; }
.hn-new::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.55) 50%, transparent 70%) 0 0 / 250% 100%; animation: hn-shine 3.6s var(--ease) infinite; }
@keyframes hn-shine { 0%, 70% { background-position: 150% 0; } 100% { background-position: -100% 0; } }
.hn-ratio { position: absolute; right: 10px; bottom: 10px; padding: 2px 7px; border-radius: 6px; font: 500 11px/1.5 var(--mono); color: rgba(240,246,252,.85); background: rgba(1,4,9,.62); backdrop-filter: blur(6px); }

.hn-body { display: grid; gap: 8px; padding: 12px 14px 14px; }
.hn-title { overflow: hidden; color: var(--fg); font-size: 15px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.hn-title:hover { color: #fff; }
.hn-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.hn-author { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--muted); font-size: 13px; transition: color .2s; }
.hn-author span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hn-author:hover { color: var(--fg); }
.hn-author .avatar { width: 20px; height: 20px; flex: 0 0 auto; font-size: 10px; }
.hn-time { flex: 0 0 auto; color: var(--subtle); font: 500 12px/1 var(--mono); font-variant-numeric: tabular-nums; }
.hn-zone { display: flex; flex-wrap: wrap; gap: 6px; }
.hn-cat, .hn-area { padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 1.5; color: var(--muted); border: 1px solid var(--border-muted); }
.hn-area { color: #d2a8ff; border-color: rgba(163,113,247,.35); background: rgba(163,113,247,.08); }
.hn-empty { color: var(--muted); }

/* Entrance: cards rise in one after another when the row first comes into view. */
.home-new.has-js:not(.is-in) .hn-card { opacity: 0; transform: translateY(18px) scale(.985); }
.home-new.is-in .hn-card { transition: opacity .7s var(--ease) calc(var(--i, 0) * 70ms), transform .7s var(--ease) calc(var(--i, 0) * 70ms), border-color .35s var(--ease), box-shadow .35s var(--ease); }
.hn-card.is-arrival { animation: hn-arrive 1.1s var(--ease) both; }
@keyframes hn-arrive { 0% { opacity: 0; transform: translateX(-28px) scale(.96); box-shadow: 0 0 0 1px rgba(163,113,247,.0); } 55% { opacity: 1; box-shadow: 0 0 0 2px rgba(163,113,247,.55), 0 18px 44px -18px rgba(163,113,247,.7); } 100% { transform: none; box-shadow: none; } }

@media (max-width: 720px) {
  .home-new { margin-top: 40px; padding-top: 32px; }
  .mk-meta { font-size: 13px; }
  .mk-foot { margin-top: 20px; }
  .mk-foot .mk-all { width: 100%; justify-content: center; padding: 12px 16px; }
  .hn-viewport { overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .hn-viewport::-webkit-scrollbar { display: none; }
  .hn-track { gap: 12px; }
  .hn-card { width: 72vw; max-width: 280px; scroll-snap-align: start; }
}
@media (prefers-reduced-motion: reduce) {
  .hn-viewport { overflow-x: auto; scroll-snap-type: x proximity; }
  .home-new .hn-track { animation: none !important; }
  .home-new .hn-card, .home-new.has-js:not(.is-in) .hn-card { opacity: 1; transform: none; transition: border-color .2s, box-shadow .2s; }
  .hn-card:hover, .hn-card:focus-within { transform: none; }
  .hn-card:hover .hn-cover { transform: none; }
  .hn-live, .hn-new::after, .hn-media::before, .hn-card.is-arrival { animation: none; }
}

/* ---- Homepage refresh (11-25), scoped to the home page: hero line, clients line, spacing, filters, card loading ---- */
.hero .hero-weekly a { text-decoration: none; display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(63,185,80,.35); background: rgba(63,185,80,.07); color: var(--fg); text-decoration: none; transition: border-color .25s var(--ease), background .25s var(--ease); }
.hero-weekly a:hover { border-color: rgba(63,185,80,.65); background: rgba(63,185,80,.12); }
.hero-weekly .arr { color: var(--muted); transition: transform .25s var(--ease); }
.hero-weekly a:hover .arr { transform: translateX(3px); }
.hero-clients { display: flex; align-items: center; justify-content: center; gap: 12px; max-width: 760px; margin: 0 auto; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--border-muted); color: var(--muted); font-size: 14px; text-decoration: none; background: rgba(1,4,9,.5); backdrop-filter: blur(8px); transition: border-color .25s var(--ease), color .25s var(--ease); }
.hero-clients:hover { border-color: rgba(163,113,247,.5); color: var(--fg); }
.hc-mark { display: inline-grid; place-items: center; flex: 0 0 auto; width: 24px; height: 24px; border-radius: 7px; font-size: 11px; font-weight: 700; color: #0b0d12; background: var(--grad); }
.hc-go { flex: 0 0 auto; color: var(--fg); white-space: nowrap; }
.hc-go .arr { margin-left: 4px; display: inline-block; transition: transform .25s var(--ease); }
.hero-clients:hover .hc-go .arr { transform: translateX(3px); }
/* Less empty space between the story sections (about two screens shorter on desktop). */
.section { padding: clamp(72px, 8vw, 116px) 0; }
/* Filters: categories on the left, content type on the right (the grid is 精选; 上新 has its own block). */
@media (min-width: 900px) { #market .mbar .mtools { margin-left: auto; } }
/* Template cards: a soft placeholder behind covers and a thin loading line instead of the 「正在加载预览…」 label. */
.art-grid .vthumb { background: linear-gradient(100deg, #0d1117 30%, #161b22 50%, #0d1117 70%) 0 0 / 220% 100%; animation: hn-shimmer 1.6s linear infinite; }
.art-grid .vthumb[data-preview-state="success"], .art-grid .vthumb:has(img.template-poster) { animation: none; }
.art-grid .vthumb[data-preview-state="loading"] > .preview-state { inset: auto 0 0 0; padding: 0; height: 2px; border-radius: 0; background: linear-gradient(90deg, transparent, #79c0ff, #a371f7, #f778ba, transparent) 0 0 / 200% 100%; animation: hn-loadline 1.2s linear infinite; overflow: hidden; }
.art-grid .vthumb[data-preview-state="loading"] > .preview-state > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@keyframes hn-loadline { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (max-width: 720px) { .hero-clients { flex-wrap: wrap; border-radius: 14px; font-size: 13px; text-align: center; } }
@media (prefers-reduced-motion: reduce) { .art-grid .vthumb, .art-grid .vthumb[data-preview-state="loading"] > .preview-state { animation: none; } }
