/* Layout: one pinned scene in three acts — centered intro → a stacked card deck you page through with an arrow cursor → a short centered note that fades in where the cards leave. */

/* ===== Base reset ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; overscroll-behavior: none; }
body { margin: 0; }
img, video { max-width: 100%; display: block; }
[hidden] { display: none !important; }

:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: #6b6b6b;
  --chip: #f2f2f2;
  --chip-hover: #e6e6e6;
  --hint: #c2c2c2;                       /* 下滑提示按钮描边（箭头是黑色） */
  --hint-hover: #8a8a8a;
  --r1: #ff3b30; --r2: #ff9500; --r3: #ffcc00; --r4: #34c759; --r5: #007aff; --r6: #af52de;

  /* 与 yien.design 一致：全站 Montserrat */
  --font: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --side: clamp(24px, 8vw, 120px);
  --gutter-l: max(var(--side), env(safe-area-inset-left, 0px));
  --gutter-r: max(var(--side), env(safe-area-inset-right, 0px));
  --maxw: 1200px;

  /* 卡片：固定比例，宽度受屏宽和屏高共同限制 */
  --ratio-n: 1.7778;                     /* 宽 / 高，16:9 */
  /* 宽度跟着屏幕宽 / 高一起变大：不超过屏宽 80%、上下留出至少 210px（大屏按屏高 24%），最大 1400px */
  --card-w: min(80vw, 1400px, calc((100svh - max(210px, 24svh)) * var(--ratio-n)));
  --card-h: calc(var(--card-w) / var(--ratio-n));
  --lift: max(30px, 3svh);               /* 卡片中心比屏幕中心高一点，给下方描述留位置 */
  --radius: 20px;
  --text-w: 720px;                       /* 项目描述和底部介绍文字统一的宽度 */
}

/* 页面文字的选中色：固定浅灰（首屏标题会被脚本覆盖成当前 emoji 的颜色） */
::selection { background: #e2e2e2; color: inherit; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;              /* 兜底：旧版 Safari 不支持 clip */
  overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 4px; border-radius: 8px; }

/* ===== Scene：整段滚动都固定在屏幕上 ===== */
.scene {
  position: relative;
  height: 340svh;               /* 100svh 画面 + 240svh 滚动距离 */
}
.pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
}

/* ----- 第一幕：首屏文字 ----- */
.hero {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  padding-block: 48px;
}
.intro {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(24px, 4svh, 40px);
  text-align: center;
}
.intro h1 {
  margin: 0;
  cursor: default;
  font-weight: 600;
  font-size: clamp(30px, min(4.6vw, 7.5svh), 64px);
  line-height: 1.22;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.emoji {
  display: inline-block;
  width: 1.15em;
  text-align: center;
  cursor: default;
  user-select: none;
}
.intro-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
/* 悬浮时右侧展开图标、按钮变宽；内边距和按钮间距不变 */
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color .2s ease, color .2s ease;
}
.chip-ico {
  flex: none;
  width: 0;
  height: 14px;
  margin-left: 0;
  opacity: 0;
  transition: width .28s cubic-bezier(.2, .8, .2, 1), margin-left .28s cubic-bezier(.2, .8, .2, 1), opacity .2s ease;
  pointer-events: none;
}
.chip.is-hover, .chip:focus-visible { background: var(--chip-hover); color: var(--fg); }
.chip.is-hover .chip-ico, .chip:focus-visible .chip-ico { width: 14px; margin-left: 6px; opacity: 1; transition-delay: 0s, 0s, .06s; }

/* 进入页面时的渐显 */
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.intro > * { animation: rise-in .8s cubic-bezier(.2, .8, .2, 1) both; }
.intro > :nth-child(2) { animation-delay: .18s; }

/* 下滑提示按钮：浅灰描边圆 + 向下箭头 */
.hint {
  position: absolute;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  z-index: 4;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px solid var(--hint);
  border-radius: 50%;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  opacity: 0;
  scale: .6;
  visibility: hidden;
  transition: opacity .3s ease, scale .3s ease, visibility 0s linear .3s, color .2s ease, border-color .2s ease;
}
.hint svg { width: 20px; height: 20px; }
.hint.show {
  opacity: 1;
  scale: 1;
  visibility: visible;
  transition: opacity .4s ease, scale .45s cubic-bezier(.34, 1.56, .64, 1), visibility 0s, color .2s ease, border-color .2s ease;
}
.hint.show svg { animation: nudge 1.8s ease-in-out .6s infinite; }
.hint:hover { border-color: var(--hint-hover); }
.hint.gone { visibility: hidden !important; opacity: 0 !important; transition: none !important; }
.hint.instant { transition: none !important; }
.cursor.snap .cursor-dot { transition: none !important; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: translateY(3px); } }

/* ----- 第二幕：叠放的卡片 ----- */
.carousel {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.pin.is-live .carousel { pointer-events: auto; }
.track {
  position: absolute;
  inset: 0;
  transform-origin: 50% calc(50% - var(--lift));
  opacity: 0;
  will-change: transform, opacity;
}
.slot {
  position: absolute;
  left: calc(50% - var(--card-w) / 2);
  top: calc(50% - var(--lift) - var(--card-h) / 2);
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--radius);
  overflow: hidden;
  isolation: isolate;
  background: var(--c);
  opacity: 0;
  transition: transform .7s cubic-bezier(.65, 0, .35, 1), opacity .7s cubic-bezier(.65, 0, .35, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 44px -22px rgba(0, 0, 0, .28);
}
/* 内容层：比卡片宽，翻页时比卡片移动得慢（视差）；替换内容时把视频 / 图片 / Lottie 放在这里 */
.card-media {
  position: absolute;
  inset: 0;
  background: var(--c);
  /* 用 clip-path 按卡片圆角裁切内容，Safari 里也能稳定裁出圆角（单靠 overflow: hidden 有时会露出方角） */
  border-radius: inherit;
  clip-path: inset(0 round var(--radius));
}
/* 从第 9 张回到第 1 张时，换位不播放过渡（整组淡出淡入） */
.track.instant .slot, .track.instant .card-media { transition: none; }
.card-media > video,
.card-media > img,
.card-media > iframe,
.card-media > .soon,
.card-media > .lottie {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; object-fit: cover;
}
.card-media > iframe { border: 0; pointer-events: none; background: #fff; }
/* 卡片左上角的标签（比如内容还在做） */
.card-badge { position: absolute; top: clamp(12px, 1.6vw, 20px); left: clamp(12px, 1.6vw, 20px); z-index: 2; padding: 6px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .88); color: #111; font-size: 12px; font-weight: 600; line-height: 1.2; letter-spacing: .01em; pointer-events: none; }
/* 文字卡片：灰色文字 + 打字机光标 */
.soon { display: grid; place-items: center; padding: 0 8%; text-align: center; }
.soon-line { margin: 0; font-size: clamp(16px, 1.7vw, 24px); line-height: 1.4; color: #9a9a9a; letter-spacing: -0.005em; }
.soon-caret { display: inline-block; width: 2px; height: 1.1em; margin-left: 3px; vertical-align: -0.15em; background: currentColor; animation: caret 1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }
.card-num {
  position: absolute;
  top: 50%; left: 50%;
  translate: -50% -50%;
  font-weight: 800;
  font-size: clamp(72px, 14vw, 200px);
  line-height: 1;
  color: var(--ink);
  opacity: .14;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* 卡片下方的项目描述 */
.desc {
  position: absolute;
  left: 50%;
  top: calc(50% - var(--lift) + var(--card-h) / 2 + 18px);
  width: min(var(--card-w), var(--text-w));   /* 和底部介绍文字同宽 */
  translate: -50% 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
  opacity: 0;
}
.desc p { margin: 0; }
.desc-title { font-size: 15px; font-weight: 600; line-height: 1.4; }
.desc-text { font-size: 15px; line-height: 1.45; color: var(--muted); text-wrap: pretty; }   /* 和底部正文同一字号 */
.desc-text a { color: inherit; text-decoration: underline; text-decoration-color: rgba(0, 0, 0, .25); text-underline-offset: 2px; transition: color .2s ease, text-decoration-color .2s ease; }
.desc-text a:hover { color: var(--ink, #111); text-decoration-color: currentColor; }
.pin.in-zone.has-cursor .desc-text a { cursor: pointer; }

/* ----- 自定义鼠标：左半屏左箭头，右半屏右箭头，最后一张时右侧变成“回到开头” ----- */
.cursor {
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  pointer-events: none;
  mix-blend-mode: difference;      /* 圆点颜色 = 下方内容的反色 */
}
.cursor-dot {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 50%;              /* 白色圆和镂空箭头画在里面的 SVG 里 */
  opacity: 0;
  scale: 0;
  /* 消失：缩小 */
  transition: scale .22s cubic-bezier(.5, 0, .75, 0), opacity .22s ease;
}
.dot-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.cursor .i-arrow, .cursor .i-reset { transform-box: fill-box; transform-origin: center; }
.cursor .v-arrow { opacity: 0; }
.cursor .i-arrow { transition: rotate .3s ease, scale .35s cubic-bezier(.3, .9, .3, 1), opacity .25s ease; }
.cursor.left .i-arrow { rotate: 180deg; }

/* 右箭头 ⇄ 刷新图标：箭头一边转一边缩小淡出，刷新的圆弧顺着同一方向“画”出来，最后补上箭头头部 */
.cursor .i-reset { rotate: -140deg; opacity: 0; transition: rotate .5s cubic-bezier(.3, .9, .3, 1), opacity .2s ease; }
.cursor .r-arc { stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .45s cubic-bezier(.4, 0, .2, 1); }
.cursor .r-head { opacity: 0; transition: opacity .15s ease; }
/* 什么时候开始变由脚本控制（等卡片滑到中间、箭头转向朝右之后） */
.cursor.reset .i-arrow { rotate: 140deg; scale: .4; opacity: 0; }
.cursor.reset .i-reset { rotate: 0deg; opacity: 1; }
.cursor.reset .r-arc { stroke-dashoffset: 0; transition-delay: .05s; }
.cursor.reset .r-head { opacity: 1; transition-delay: .38s; }
/* 出现：从小放大，带一点回弹 */
.cursor.on .cursor-dot { opacity: 1; scale: 1; transition: scale .38s cubic-bezier(.34, 1.56, .64, 1), opacity .15s ease; }
.cursor.on.disabled .cursor-dot { opacity: .35; scale: .8; }
.cursor.on.press .cursor-dot { scale: .86; transition-duration: .12s; }
@media (hover: hover) and (pointer: fine) {
  .pin.in-zone.has-cursor, .pin.in-zone.has-cursor * { cursor: none; }
}

/* ----- 第三幕：介绍文字（在卡片离开的位置原地出现） ----- */
.about {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  padding-block: 96px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}
.about-text {
  margin: 0;
  max-width: var(--text-w);         /* 和项目描述同宽 */
  text-align: left;                /* 段落居中放在页面中间，但文字左对齐，行首整齐 */
  hyphens: none;
  font-size: 15px;
  line-height: 1.45;               /* 正文行距收紧一点 */
  color: var(--fg);
  text-wrap: pretty;
}
.nowrap { white-space: nowrap; }
.about-text p { margin: 0; }
.about-text p + p { margin-top: 0.6em; }   /* 段间距 ≈ 原来的行间空隙 */
/* get in touch：悬浮时文字变浅 */
.touch {
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color .2s ease;
}
.touch:hover, .touch:focus-visible { color: var(--muted); }
.foot {
  position: absolute;
  left: 0; right: 0;
  bottom: max(32px, env(safe-area-inset-bottom, 0px));
  font-size: 13px;
  color: var(--muted);
}

/* Footer 彩蛋：悬浮时 © 像纸片一样翻面变成 😎；文字渐渐变成从左向右流动的 6 色彩虹色块 */
.egg { display: inline-flex; align-items: baseline; gap: 0.3em; cursor: default; }
.egg-mark { display: inline-block; width: 1.1em; perspective: 120px; }
.egg-flip {
  display: inline-grid;
  place-items: center;
  width: 100%;
  transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.3, 1.35, .5, 1);
}
.egg-flip > span {
  grid-area: 1 / 1;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.egg-e { transform: rotateY(180deg); font-size: 1em; line-height: 1; }
.egg:hover .egg-flip, .egg:focus-visible .egg-flip { transform: rotateY(180deg); }

/* 彩色层叠在文字上方，悬浮时淡入，同时底下的灰色文字淡出 */
.egg-text { position: relative; transition: color .45s ease; }
.egg-text::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: transparent;
  /* 6 个纯色块（硬边），不做渐变 */
  background-image: linear-gradient(90deg,
    var(--r1) 0 16.667%, var(--r2) 16.667% 33.333%, var(--r3) 33.333% 50%,
    var(--r4) 50% 66.667%, var(--r5) 66.667% 83.333%, var(--r6) 83.333% 100%);
  background-size: 8em 100%;
  background-repeat: repeat-x;
  -webkit-background-clip: text;
  background-clip: text;
  opacity: 0;
  transition: opacity .45s ease;
  animation: rainbow 1.6s linear infinite;
  animation-play-state: paused;
  pointer-events: none;
}
.egg:hover .egg-text, .egg:focus-visible .egg-text { color: transparent; }
.egg:hover .egg-text::after, .egg:focus-visible .egg-text::after { opacity: 1; animation-play-state: running; }
@keyframes rainbow { from { background-position-x: 0; } to { background-position-x: 8em; } }

@media (max-width: 700px) {
  :root {
    --card-w: min(82vw, calc((100svh - 230px) * var(--ratio-n)));
    --lift: 36px;
    --radius: 16px;
  }
  /* 首屏按钮竖向排列 */
  .intro-links { flex-direction: column; align-items: center; gap: 10px; }
  .chip { min-width: 160px; padding: 10px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .slot, .card-media { transition-duration: .01s; }
  .egg-text::after { animation: none !important; }
  .egg-flip { transition-duration: .01s; }
  .intro > *, .hint.show svg { animation: none; }
}

/* ===== 平铺版（.scene.flat）：首屏、卡片、介绍上下排列，正常滚动，没有滚动驱动的过渡 ===== */
.scene.flat { height: auto; }
.scene.flat .pin { position: relative; height: auto; overflow: visible; }
.scene.flat .hero { position: relative; inset: auto; height: 100svh; }
.scene.flat .hint { bottom: auto; top: calc(100svh - 44px - max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px))); }
.scene.flat { --flat-top: 40px; }   /* 卡片区上方的边距 */
.scene.flat .carousel { position: relative; inset: auto; height: auto; display: flow-root; padding-bottom: 64px; pointer-events: auto;
  overflow: hidden; }   /* 两侧移到屏幕外的卡片不撑宽页面（手机上不能横向滚动） */
.scene.flat .slot { top: var(--flat-top); }
.scene.flat .track { transform-origin: 50% calc(var(--flat-top) + var(--card-h) / 2); }
.scene.flat .desc { position: relative; left: auto; top: auto; translate: none; margin: calc(var(--flat-top) + var(--card-h) + 18px) auto 0;
  /* 和下面的介绍文字同宽（文字居中） */
  width: min(var(--text-w), calc(100vw - var(--gutter-l) - var(--gutter-r))); }
.scene.flat .track { opacity: 1; transform: none; }
.scene.flat .desc { opacity: 1; }
/* 第三部分：浅灰色通栏底色，高度跟内容走，上下留适中的间距（底部给 footer 留位置） */
.scene.flat .about { position: relative; inset: auto; min-height: 0; padding-top: clamp(64px, 9svh, 96px); padding-bottom: clamp(112px, 14svh, 144px);
  background: #f4f4f4; opacity: 1; pointer-events: auto; }

/* 首屏标题：手机上按 Yien is / a product designer, / based in / Sydney, Australia. 断行 */
.m-br { display: none; }
.nw { white-space: nowrap; }
@media (max-width: 700px) {
  .m-br { display: inline; }
  .intro h1 { font-size: clamp(26px, 7.6vw, 34px); }
  /* 首屏不占满一屏：标题和按钮下面直接接卡片，不留大片空白；下箭头不需要了 */
  .scene.flat .hero { height: auto; padding-top: max(96px, 18svh); padding-bottom: 24px; }
  .scene.flat .hint { display: none; }
  .scene.flat { --flat-top: 32px; }
  :root { --card-w: calc(100vw - 40px); }
}
/* 横屏手机等矮屏：卡片不再按“整屏放得下卡片+描述”来限制，按屏高留少量边距 */
@media (max-height: 560px) and (orientation: landscape) {
  :root { --card-w: min(78vw, calc((100svh - 56px) * var(--ratio-n))); }
}
