/* ============================================================
   0x4ea · Apple-style Bento portfolio
   Pure CSS, system fonts, light/dark via [data-theme]
   ============================================================ */

:root {
  --bg: #fbfbfd;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f5f5f7;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.12);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --accent: #0066cc;
  --accent-soft: rgba(0, 102, 204, 0.1);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.1);
  --nav-bg: rgba(251, 251, 253, 0.72);
  --radius: 24px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg: #08080a;
  --bg-elev: #161618;
  --card: #161618;
  --card-2: #1f1f22;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #86868b;
  --accent: #4aa3ff;
  --accent-soft: rgba(74, 163, 255, 0.16);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 12px 44px rgba(0, 0, 0, 0.6);
  --nav-bg: rgba(8, 8, 10, 0.72);
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

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

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ===== Navigation ===== */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav__inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 56px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav__logo { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.nav__mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, #0066cc, #4aa3ff);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.nav__brand { font-size: 17px; letter-spacing: -0.01em; }
.nav__links { display: flex; gap: 28px; margin-left: auto; font-size: 14px; color: var(--text-2); }
.nav__links a { transition: color 0.2s var(--ease); }
.nav__links a:hover { color: var(--text); }
.nav__actions { display: flex; align-items: center; gap: 8px; margin-left: 8px; }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: transparent;
  color: var(--text); cursor: pointer; display: grid; place-items: center;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
}
.theme-toggle:hover { background: var(--card-2); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* Language toggle — sits next to the theme toggle */
.lang-toggle {
  height: 36px; min-width: 36px; padding: 0 10px; border-radius: 980px;
  border: 1px solid var(--border); background: transparent;
  color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), transform 0.2s var(--ease), border-color 0.2s var(--ease);
}
.lang-toggle:hover { background: var(--card-2); border-color: var(--border-strong); }
.lang-toggle:active { transform: scale(0.94); }
.lang-toggle__globe { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; flex: 0 0 auto; }
.lang-toggle__label { line-height: 1; }

.nav__menu-btn { display: none; width: 36px; height: 36px; border: none; background: transparent; cursor: pointer; flex-direction: column; gap: 5px; align-items: center; justify-content: center; }
.nav__menu-btn span { width: 18px; height: 1.6px; background: var(--text); border-radius: 2px; transition: transform 0.25s var(--ease); }
.nav__mobile { display: none; flex-direction: column; padding: 8px 22px 16px; border-bottom: 1px solid var(--border); background: var(--nav-bg); }
.nav__mobile a { padding: 12px 4px; font-size: 16px; color: var(--text-2); border-bottom: 1px solid var(--border); }
.nav__mobile a:last-child { border-bottom: none; }

/* ===== Hero ===== */
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(64px, 12vh, 120px) 22px clamp(48px, 8vh, 88px);
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: #f7f5ec;
  color: #2d2a26;
  transition: background 0.6s var(--ease), color 0.6s var(--ease);
}
[data-theme="dark"] .hero {
  background: #0b1026;
  color: #f5f5f7;
}
.hero__scene {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: grab;
  touch-action: pan-y;            /* 保留竖向滚动，只有横向拖拽才旋转视角 */
}
.hero__canvas:active { cursor: grabbing; }
.hero__inner {
  position: relative;
  z-index: 2;
  max-width: 860px;
  margin: 0 auto;
  /* 让指针事件穿透到 3D 缸（否则容器会挡住右侧的拖拽 / 投喂） */
  pointer-events: none;
}
.hero__inner .btn { pointer-events: auto; }
.eyebrow {
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 18px;
}
.hero__brand-line {
  font-size: clamp(64px, 13vw, 132px);
  font-weight: 700; line-height: 1; letter-spacing: -0.04em;
  color: #1d1d1f;
  margin-bottom: 44px;
  text-shadow: 0 2px 18px rgba(247,245,236,0.8);
  transition: color 0.6s var(--ease), text-shadow 0.6s var(--ease);
}
.hero .btn--ghost { border-color: rgba(0, 0, 0, 0.22); color: #1d1d1f; transition: color 0.6s var(--ease), border-color 0.6s var(--ease), background 0.2s var(--ease); }
.hero .btn--ghost:hover { background: rgba(0, 0, 0, 0.06); }
.hero .hero__stats strong { color: #1d1d1f; transition: color 0.6s var(--ease); }
.hero .hero__stats span { color: rgba(0, 0, 0, 0.56); transition: color 0.6s var(--ease); }
[data-theme="dark"] .hero__brand-line {
  color: #f5f5f7;
  text-shadow: 0 2px 22px rgba(11, 16, 38, 0.9), 0 0 60px rgba(120, 150, 255, 0.25);
}
[data-theme="dark"] .hero .btn--ghost { border-color: rgba(255, 255, 255, 0.32); color: #f5f5f7; }
[data-theme="dark"] .hero .btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }
[data-theme="dark"] .hero .hero__stats strong { color: #f5f5f7; }
[data-theme="dark"] .hero .hero__stats span { color: rgba(255, 255, 255, 0.62); }
.hero__cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 26px; border-radius: 980px; font-size: 15px; font-weight: 500;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), opacity 0.2s var(--ease);
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { opacity: 0.9; }
.btn--ghost { border: 1px solid var(--border-strong); color: var(--text); }
.btn--ghost:hover { background: var(--card-2); }
.btn:active { transform: scale(0.97); }

/* ---- 3D 缸的互动按钮：投喂 / 变色 ---- */
.hero__play {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-top: 20px;
  /* 容器不接管指针，否则会挡住 3D 缸的拖拽与点击投喂 */
  pointer-events: none;
}
.hero__play[hidden] { display: none; }
.play-btn {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 980px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  background: rgba(255, 255, 255, 0.5);
  color: #1d1d1f;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
  cursor: pointer;
  transition: color 0.6s var(--ease), border-color 0.6s var(--ease),
              background 0.2s var(--ease), transform 0.2s var(--ease);
}
.play-btn:hover { background: rgba(0, 0, 0, 0.07); }
.play-btn:active { transform: scale(0.96); }
.play-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.play-btn__ico { font-size: 15px; line-height: 1; }
.play-btn__swatch {
  width: 12px; height: 12px; border-radius: 50%;
  background: #6fd44a;                                    /* 与 PALETTE[0] 同步，JS 会改写 */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  transition: background 0.35s var(--ease);
}
[data-theme="dark"] .hero__play .play-btn {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5f7;
}
[data-theme="dark"] .hero__play .play-btn:hover { background: rgba(255, 255, 255, 0.12); }
[data-theme="dark"] .hero__play .play-btn__swatch { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28); }

.hero__stats {
  list-style: none; display: flex; gap: clamp(24px, 6vw, 64px);
  justify-content: center; margin-top: 56px; flex-wrap: wrap;
}
.hero__stats li { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hero__stats strong { font-size: clamp(28px, 4vw, 38px); font-weight: 700; letter-spacing: -0.02em; }
.hero__stats span { font-size: 14px; color: var(--text-3); }

/* ===== Section ===== */
.section { max-width: 1200px; margin: 0 auto; padding: clamp(48px, 9vh, 96px) 22px; }
.section__head { margin-bottom: 40px; }
.section__title { font-size: clamp(30px, 5vw, 44px); font-weight: 700; letter-spacing: -0.025em; }
.section__lead { font-size: 18px; color: var(--text-2); margin-top: 10px; }

/* ===== Bento Grid ===== */
.bento {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 200px;
  gap: 18px;
}
.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.4s var(--ease);
  will-change: transform;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.card--lg { grid-column: span 2; grid-row: span 2; }
.card--wide { grid-column: span 2; grid-row: span 1; }

.card__art { flex: 1 1 auto; min-height: 0; position: relative; overflow: hidden; }
.card--lg .card__art { flex: 0 0 56%; }
.card--wide .card__art { position: absolute; inset: 0; }
.card--wide .card__body { position: relative; z-index: 2; margin-top: auto;
  background: linear-gradient(90deg, var(--card) 60%, rgba(255,255,255,0) 100%); }
[data-theme="dark"] .card--wide .card__body { background: linear-gradient(90deg, var(--card) 60%, rgba(22,22,24,0) 100%); }

.card__art svg { width: 100%; height: 100%; display: block; }
.card__art img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center; }
.art--hand { background: #0b1220; }
.art--gem { background: linear-gradient(135deg, #eaf4ff, #cfe4fb); }
.art--comic { background: linear-gradient(135deg, #ffe9dc, #ffd2bd); }
.art--dlc { background: #1b1340; }
.art--ai { background: linear-gradient(135deg, #2a2a4a, #3a3a6a); }
.art--quant { background: linear-gradient(135deg, #16302a, #1f4a3c); }
.art--sdk { background: linear-gradient(135deg, #131c33, #22355e); }
.art--facet { background: linear-gradient(135deg, #e3f4ff, #bfe9ff); }
.art--fin { background: linear-gradient(135deg, #2a2f3a, #3a4658); }

.card__body { padding: 22px 24px 24px; display: flex; flex-direction: column; gap: 8px; }
.card--wide .card__body { padding: 30px 32px; max-width: 70%; }
.card__eyebrow { font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.card__title { font-size: clamp(19px, 2.4vw, 24px); font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
.card--lg .card__title { font-size: clamp(24px, 3vw, 32px); }
.card__desc { font-size: 14.5px; color: var(--text-2); line-height: 1.6; margin-top: 2px; }
.card--lg .card__desc { font-size: 15.5px; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.tags li {
  font-size: 12px; color: var(--text-2);
  padding: 4px 11px; border-radius: 980px;
  background: var(--card-2); border: 1px solid var(--border);
}
.link { color: var(--accent); font-size: 15px; font-weight: 500; transition: opacity 0.2s var(--ease); }
.link:hover { opacity: 0.75; }

/* ===== Download ===== */
.download__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 4px; }
.dl-card {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.4s var(--ease);
}
.dl-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.dl-card__icon { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 15px; overflow: hidden; background: var(--card-2); box-shadow: inset 0 0 0 1px var(--border); }
.dl-card__icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dl-card__body { flex: 1 1 auto; min-width: 0; }
.dl-card__title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.dl-card__meta { font-size: 13px; color: var(--text-3); margin-top: 3px; }
.dl-card__btn { flex: 0 0 auto; }
@media (max-width: 640px) {
  .download__grid { grid-template-columns: 1fr; }
  .dl-card { flex-direction: column; align-items: flex-start; gap: 16px; }
  .dl-card__btn { width: 100%; justify-content: center; }
}

/* ===== About ===== */
.about { max-width: 820px; text-align: center; }
.about__inner { display: flex; flex-direction: column; align-items: center; }
.about__title { font-size: clamp(26px, 4.6vw, 40px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.18; margin: 16px 0 26px; max-width: 720px; }
.about__links { display: flex; gap: 26px; margin-top: 4px; }
.about__links .link { font-size: 16px; }
.about__contact { font-size: 16px; font-weight: 500; color: var(--accent); letter-spacing: -0.01em; margin-top: 30px; }
.about__email { font-size: 19px; font-weight: 500; color: var(--text); letter-spacing: -0.01em; margin-top: 6px; user-select: text; }

/* ===== Footer ===== */
.footer { border-top: 1px solid var(--border); margin-top: 40px; }
.footer__inner {
  max-width: 1200px; margin: 0 auto; padding: 28px 22px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-3);
}
.footer__brand { font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.footer__copy { margin-right: auto; }
.footer__link { color: var(--text-2); transition: color 0.2s var(--ease); }
.footer__link:hover { color: var(--accent); }

/* ===== Reveal animation ===== */
.reveal { opacity: 0; transform: translateY(22px); transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
.reveal.is-visible { opacity: 1; transform: none; }
.bento .card.reveal { transform: translateY(28px) scale(0.985); }
.bento .card.reveal.is-visible { transform: none; }

/* ===== Responsive ===== */

/* ---- Hero + 3D 缸：宽屏两栏（文字在左、缸在右），窄屏上下排布 ----
   断点需与 js/hero-terrarium.js 中的 frameSubject() 保持一致 */
@media (min-width: 901px) {
  .hero { padding-left: 0; padding-right: 0; text-align: left; }
  .hero__inner {
    width: 100%;
    max-width: 1200px;              /* 与导航容器对齐 */
    margin: 0 auto;
    padding-left: 22px;
    padding-right: 54%;             /* 右侧留给 3D 缸 */
    text-align: left;
  }
  .hero__cta,
  .hero__play,
  .hero__stats { justify-content: flex-start; }
}
@media (max-width: 900px) {
  .hero {
    min-height: 94vh;
    min-height: 94svh;
    align-items: flex-start;        /* 文字在上，缸在下半部 */
    padding-top: clamp(40px, 7vh, 76px);
  }
}

@media (min-width: 641px) {
  .nav__mobile { display: none !important; }
}
@media (max-width: 900px) {
  .bento { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 190px; }
  .card--lg { grid-column: span 2; grid-row: span 2; }
  .card--wide { grid-column: span 2; }
}
@media (max-width: 640px) {
  .nav__links { display: none; }
  .nav__menu-btn { display: flex; }
  .bento { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .card, .card--lg, .card--wide { grid-column: span 1; grid-row: auto; }
  .card__art { flex: 0 0 150px; }
  .card--wide .card__art { position: relative; inset: auto; flex: 0 0 150px; }
  .card--wide .card__body { position: relative; max-width: 100%;
    background: var(--card); }
  [data-theme="dark"] .card--wide .card__body { background: var(--card); }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .card { transition: none; }
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
