/* =========================================================
   王振茹设计作品集 — 本地化单页样式
   ========================================================= */

:root {
  --bg: #eef3f0;
  --bg-deep: #e4ebe6;
  --ink: #1a2f2a;
  --ink-soft: #3d524c;
  --accent: #8fd14f;
  --accent-2: #7bb8f0;
  --accent-3: #b8a4f0;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --shadow: 0 12px 40px rgba(26, 47, 42, 0.08);
  --nav-h: 64px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --duration: 0.55s;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(143, 209, 79, 0.18), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(123, 184, 240, 0.16), transparent 50%),
    linear-gradient(180deg, #f3f7f4 0%, var(--bg) 40%, #e8f0ec 100%);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

body.is-portfolio-open {
  overflow: hidden;
}

img {
  max-width: 100%;
  height: auto;
  vertical-align: middle;
  user-select: none;
  -webkit-user-drag: none;
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

ul {
  list-style: none;
}

/* ---------- Sticky Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  background: rgba(243, 247, 244, 0.62);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid rgba(26, 47, 42, 0.06);
  transition: background var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}

.site-header.is-scrolled {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 28px rgba(26, 47, 42, 0.06);
}

.site-nav {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  line-height: 0;
  transition: transform 0.35s var(--ease);
}

.nav-brand img {
  display: block;
  height: 2.35rem;
  width: auto;
}

.nav-brand:hover {
  transform: scale(1.04);
  background: transparent;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-list a {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-soft);
  transition: color 0.3s var(--ease), background 0.3s var(--ease),
    transform 0.35s var(--ease);
}

.nav-list a:hover,
.nav-list a.is-active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  transform: translateY(-1px);
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid rgba(26, 47, 42, 0.08);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.3s var(--ease), opacity 0.3s var(--ease);
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ---------- Home Sections ---------- */
.home-view {
  transition: opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

.home-view.is-hidden {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  inset: 0;
  height: 0;
  overflow: hidden;
}

.home-section {
  position: relative;
  width: 100%;
}

.media-frame {
  width: 100%;
  overflow: hidden;
  background: var(--bg-deep);
}

.media-frame--hero {
  aspect-ratio: 16 / 9;
  min-height: min(100vh, 820px);
}

.media-frame--auto {
  aspect-ratio: auto;
}

.media-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition: transform 0.8s var(--ease);
}

.media-frame--auto img {
  height: auto;
  object-fit: cover;
}

.home-section:hover .media-frame--hero img {
  transform: scale(1.012);
}

/* ---------- Scroll Cue (Scroll Down / Back to Top) ---------- */
.scroll-cue {
  --scroll-cue-ease: cubic-bezier(0.45, 0.05, 0.55, 0.95);
  position: absolute;
  left: 50%;
  z-index: 1100;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  transform: translateX(-50%);
  color: var(--ink-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.scroll-cue--down {
  bottom: 1.35rem;
  animation: scroll-cue-float 3.6s var(--scroll-cue-ease) infinite;
}

.scroll-cue--up {
  bottom: 1.5rem;
}

.scroll-cue__base {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: rgba(26, 47, 42, 0.06);
  border: 1px solid rgba(26, 47, 42, 0.12);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  box-shadow: none;
  transition:
    background 0.45s var(--scroll-cue-ease),
    border-color 0.45s var(--scroll-cue-ease);
}

.scroll-cue__icon {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
  transition: transform 0.45s var(--scroll-cue-ease);
}

.scroll-cue:hover .scroll-cue__base,
.scroll-cue:focus-visible .scroll-cue__base {
  background: rgba(26, 47, 42, 0.15);
  border-color: rgba(26, 47, 42, 0.28);
}

.scroll-cue--down:hover .scroll-cue__icon,
.scroll-cue--down:focus-visible .scroll-cue__icon {
  transform: translateY(3px);
}

.scroll-cue--up:hover .scroll-cue__icon,
.scroll-cue--up:focus-visible .scroll-cue__icon {
  transform: translateY(-3px);
}

.scroll-cue:focus-visible {
  outline: none;
}

.scroll-cue:focus-visible .scroll-cue__base {
  outline: 1px solid rgba(26, 47, 42, 0.35);
  outline-offset: 3px;
}

@keyframes scroll-cue-float {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(4px);
  }
}

.home-section--footer {
  padding-bottom: 0;
}

.home-section--footer .scroll-cue--up {
  bottom: 1.25rem;
}

/* Reveal animation */
[data-reveal] {
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.85s var(--ease), transform 0.85s var(--ease);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Portfolio Entry ---------- */
.portfolio-entry {
  padding-bottom: 0;
}

.portfolio-entry__stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #f2f2f0;
}

.portfolio-entry__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.portfolio-entry__bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.entry-cards {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.entry-card {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  aspect-ratio: 1134 / 1164;
  padding: 0;
  border-radius: 12% / 11%;
  overflow: visible;
  pointer-events: auto;
  background: transparent;
  transform: translate3d(0, 0, 0) scale(1);
  filter: brightness(1);
  transition:
    transform 0.4s var(--ease),
    filter 0.4s var(--ease),
    box-shadow 0.4s var(--ease);
  will-change: transform, filter;
  transform-origin: center center;
}

.entry-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 10px 28px rgba(26, 47, 42, 0.12));
  transition: filter 0.4s var(--ease);
}

/* PC hover：仅精细指针设备启用，避免移动端点击残留 */
@media (hover: hover) and (pointer: fine) {
  .entry-card:hover,
  .entry-card:focus-visible {
    outline: none;
    z-index: 5;
    transform: translate3d(0, -4%, 0) scale(1.06);
    filter: brightness(1.08);
  }

  .entry-card:hover img,
  .entry-card:focus-visible img {
    filter: drop-shadow(0 18px 36px rgba(26, 47, 42, 0.2));
  }

  .entry-card:active {
    transform: translate3d(0, -1%, 0) scale(1.03);
  }
}

/* ---------- Portfolio Detail View ---------- */
.portfolio-view {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(184, 164, 240, 0.2), transparent 50%),
    linear-gradient(180deg, #f5f8f6 0%, #eaf1ed 100%);
  opacity: 0;
  transform: translateY(24px);
  pointer-events: none;
  transition: opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

.portfolio-view:not([hidden]) {
  pointer-events: auto;
}

.portfolio-view.is-open {
  opacity: 1;
  transform: translateY(0);
}

.portfolio-view__bar {
  position: sticky;
  top: var(--nav-h);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  background: rgba(245, 248, 246, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(26, 47, 42, 0.06);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(26, 47, 42, 0.08);
  font-size: 0.88rem;
  font-weight: 600;
  transition: transform 0.35s var(--ease), background 0.35s var(--ease);
  flex-shrink: 0;
}

.back-btn:hover {
  transform: scale(1.04);
  background: #fff;
}

.back-btn__icon {
  font-size: 1rem;
  line-height: 1;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex: 1;
  min-width: 0;
}

.category-tab {
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid transparent;
  transition: transform 0.35s var(--ease), background 0.35s var(--ease),
    color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.category-tab:hover {
  transform: scale(1.04);
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
}

.category-tab.is-active {
  color: var(--ink);
  background: #fff;
  border-color: rgba(26, 47, 42, 0.1);
  box-shadow: 0 6px 18px rgba(26, 47, 42, 0.08);
}

.portfolio-view__content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.35rem 0 3rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.portfolio-panel {
  width: 100%;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.portfolio-panel.is-active {
  opacity: 1;
  transform: translateY(0);
}

.case-block {
  position: relative;
  width: 100%;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.case-block > .scroll-cue {
  z-index: 1100;
}

/* 仅一节时避免上下箭头重叠 */
.case-block:only-child > .scroll-cue--down {
  bottom: 4.35rem;
}

.case-block:only-child > .scroll-cue--up {
  bottom: 1.25rem;
}

.case-block.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.case-block .media-frame {
  width: min(1400px, 100%);
  margin: 0 auto;
  aspect-ratio: auto;
  background: transparent;
}

.case-block img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
}

.portfolio-panel > .case-block:first-child {
  margin-top: 0;
}

body.is-portfolio-open .site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

body.is-portfolio-open .portfolio-view {
  padding-top: var(--nav-h);
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .media-frame--hero {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .entry-card {
    --w: 19% !important;
  }
}

@media (max-width: 768px) {
  :root {
    --nav-h: 58px;
  }

  .nav-toggle {
    display: flex;
  }

  .nav-list {
    position: absolute;
    top: calc(var(--nav-h) - 1px);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding: 0.75rem 1rem 1rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(26, 47, 42, 0.08);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  }

  .nav-list.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .nav-list a {
    width: 100%;
    justify-content: center;
    padding: 0.85rem 1rem;
  }

  /* Section 5：移动端垂直堆叠，高度随内容撑开 */
  .portfolio-entry {
    height: auto;
  }

  .portfolio-entry__stage {
    display: flex;
    flex-direction: column;
    aspect-ratio: auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    background: #f2f2f0;
  }

  /* 5.png 作为顶部 Header，不遮挡卡片 */
  .portfolio-entry__bg {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
  }

  .portfolio-entry__bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
  }

  .entry-cards {
    position: relative;
    inset: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.125rem; /* 18px，落在 16–20px */
    padding: 1.25rem 1.5rem 2rem; /* 左右 px-6 */
    background: #f2f2f0;
    pointer-events: auto;
    height: auto;
  }

  .entry-card {
    position: relative;
    left: auto !important;
    top: auto !important;
    width: 100% !important;
    max-width: none;
    aspect-ratio: 1134 / 1164;
    border-radius: 28px; /* 大圆角，对齐简历页卡片气质 */
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition:
      transform 0.18s var(--ease),
      filter 0.18s var(--ease);
  }

  .entry-card img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* 不拉伸，保持视觉比例 */
    border-radius: inherit;
  }

  .entry-card:last-child {
    grid-column: auto;
    width: 100% !important;
    justify-self: stretch;
  }

  /* 移动端禁用 hover 抬升，仅保留触压反馈 */
  .entry-card:hover,
  .entry-card:focus-visible {
    transform: none;
    filter: none;
    z-index: auto;
  }

  .entry-card:hover img,
  .entry-card:focus-visible img {
    filter: drop-shadow(0 10px 28px rgba(26, 47, 42, 0.12));
  }

  .entry-card:active {
    transform: scale(0.98);
    filter: brightness(0.98);
  }

  .entry-card:active img {
    filter: drop-shadow(0 6px 16px rgba(26, 47, 42, 0.1));
  }

  .portfolio-view__bar {
    top: var(--nav-h);
    flex-direction: column;
    align-items: stretch;
  }

  .category-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.15rem;
  }

  .category-tab {
    flex-shrink: 0;
  }

  .media-frame img,
  .case-block img {
    object-fit: cover;
    width: 100%;
  }

  .case-block img {
    height: auto;
  }
}

@media (max-width: 480px) {
  .site-nav {
    width: calc(100% - 1.25rem);
  }

  .nav-brand img {
    height: 2rem;
  }

  .entry-cards {
    gap: 1rem; /* 16px */
    padding: 1rem 1.5rem 1.75rem; /* 左右保持 px-6 */
  }

  .entry-card {
    border-radius: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
  }

  .entry-card:hover,
  .entry-card:focus-visible,
  .entry-card:active {
    transform: none;
    filter: none;
  }

  .scroll-cue--down {
    animation: none;
  }
}
