/* ==========================================================
   scene.css — 首页场景层 (Home Scene)
   ------------------------------------------------------------
   物理拆分, 不使用 CSS @import. 在 index.html 头部按顺序引入
   (后加载覆盖前加载, 不依赖 !important, 15 CSS):

       1.  base.css                    (基础层: 重置 + 变量 + 纸纹 + scrollbar)
       2.  scene.css                   ← 本文件 (场景层: 海草 + 潜水员 + 标题 + 进场)
       3.  portfolio-layout.css        (作品集骨架)
       4.  portfolio-grid.css          (作品集卡片栅格)
       5.  resume.css                  (简历, 含 experience-tag 八边形化)
       6.  portfolio-preview.css       (预览: Lightbox + PDF 模态框)
       7.  portfolio-x1-sidebar.css    (X1 侧栏: Markdown + modal)
       8.  contact.css                 (联系表单 + 社交)
       9.  life-layout.css             (兴趣卡骨架: 4 张核心卡 + 散落 Polaroid)
      10.  life-modal.css              (通用 modal: 4 主题 + 流体特效 + 响应式)
      11.  life-marathon.css           (Marathon 列表 + 节点 + 响应式) ← 原 lifeCollage.css 一部分
      12.  life-travel.css             (Travel 地图 + 时间轴 + 响应式) ← 原 lifeCollage.css 一部分
      13. life-photography.css        (Photography 骨架位, Backlog #27 待实现)
      14. life-finance.css            (Finance 骨架位, Backlog #27 待实现)
      15. responsive.css              (全局响应兜底)

   完整文件结构与职责归属见 [WORKFLOW.md §4](./WORKFLOW.md).

   包含:
       1. 首页海草 Canvas 容器 (#seaweedCanvas — 固定背景, 远景)
       2. 潜水员 Canvas 容器 (#diverCanvas — 中景)
       3. 电影感大标题 / 副标题 / 品牌名 (.hero-title / .hero-subtitle / .brand-name)
       4. 海草标签 (.seaweed-tag — 顶部小标)
       5. 顶部波光焦散 Canvas 容器 (#causticsCanvas)
       6. 开场动画 @keyframes (fadeBlurReveal / letterSpacingReveal / liquidBreath)
       7. @media (max-width: 768 / 480 / 360) + 横屏下的响应式
       8. 触屏设备下关闭自定义光标 (@media (hover: none))

   注意:
       - 页面底部"向下滚动提示"目前未实现 (.scroll-indicator / .mouse-icon
         / .arrow-down 均不存在). 如需后续添加, 可在本文件中追加.
   ========================================================== */


/* ==========================================================
   1. 海草 Canvas 容器 (远景, z=1)
   ========================================================== */
#seaweedCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
}


/* ==========================================================
   0. 八边形点阵交互背景 (位于 body 渐变背景之上, 海草之下, z=0)
   ------------------------------------------------------------
   独立 Canvas 层, 由 dotmatrix.js 驱动. 每个点为正八边形
   (moveTo + lineTo, 零 arc), 颜色随滚动 lerp 同步深海 4 锚点,
   鼠标靠近时产生排斥偏移 + 纯色亮度提升.
   z-index=0 确保浮于 body 背景之上、低于 #seaweedCanvas (z=1).
   pointer-events:none 不干扰任何上层点击事件.
   ========================================================== */
#dotMatrixCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    /* 透明背景, 让 body 的 --sea-bg 渐变通过 canvas 透出 */
    background: transparent;
}


/* ==========================================================
   2. 潜水员叠加层 Canvas 容器 (中景, z=10)
   ========================================================== */
#diverOverlayCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Backlog #21 修复: 提到 1600000, 高于 X1 侧栏 (1500000),
       让潜水员动画在 X1 打开时仍浮在侧栏之上 */
    z-index: 1600000 !important;
    pointer-events: none !important;
}

/* Backlog #37 修复: 4 个模态 (Travel/Marathon/Photo/Finance) 打开时
   直接 display: none 潜水员, 消除 modal 4% 透明背景透出的"卡在 map 里"
   视觉残留 (Backlog #36 误判的真正根因).
   body.modal-open 是 life-modal.js / life-travel.js / life-marathon.js /
   life-photography.js / life-finance.js 5 个 open 函数统一加的全局状态,
   关闭时统一移除, 单一钩子统一隐藏/显示 4 个模态. */
body.modal-open #diverOverlayCanvas {
    display: none !important;
}


/* ==========================================================
   3. 顶部波光粼粼焦散层 (位于潜水员之上, z=11)
   ========================================================== */
#causticsCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 11 !important;
    pointer-events: none !important;
}


/* ==========================================================
   4. 电影感大标题容器 (固定居中, z=5)
   ========================================================== */
#cinematic-title-container {
    position: fixed;
    top: 20%;
    left: 50%;
    width: 100%;
    max-width: 100vw;
    padding: 0 4vw;
    transform: translate(-50%, -50%);
    text-align: center;
    overflow: hidden;          /* 防止 letter-spacing 动画时撑出横向滚动 */
    pointer-events: none;
    /* Tunnel book layer 3: content paper floats in front of seaweed (1), behind diver (10) */
    z-index: 5;
    animation: fadeBlurReveal 4.5s cubic-bezier(0.25, 1, 0.5, 1) forwards, liquidBreath 4s ease-in-out 4.5s infinite;
}

.main-title {
    font-family: 'Cinzel', 'Playfair Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, 'PingFang SC', sans-serif;
    font-size: clamp(1.5rem, 2.8vw, 2.2rem);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: var(--sea-title-color, #0a1f24);
    margin-bottom: 0.8rem;
    font-weight: 300;
    /* Backlog #N: 阴影跟随点阵颜色 — 同 --sea-bg-rgb 形成"色彩半色调"印章感,
       滚动时阴影从 teal 渐变到 near-black, 与点阵 4 锚点同步 */
    text-shadow: 4px 4px 0px rgba(var(--sea-bg-rgb, 0, 168, 150), 0.55) !important;
    animation: letterSpacingReveal 4.5s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

.main-title-en {
    display: block;
    white-space: nowrap;     /* 英文整段保持在一行 */
}

.main-title-cn {
    display: block;
    font-family: 'PingFang SC', 'Microsoft YaHei', -apple-system, sans-serif;
    font-size: 0.6em;        /* 相对英文略小, 体现"中文次要"的层级 */
    font-weight: 400;
    letter-spacing: 0.3em;
    opacity: 0.72;
    text-transform: none;    /* 中文不需要 uppercase */
}


/* ==========================================================
   5. 海草标签 (覆盖在海草上的可点击 label)
   ========================================================== */
.seaweed-label-layer {
    position: fixed;
    inset: 0;
    z-index: 120;
    pointer-events: none;
}

.seaweed-label {
    position: absolute;
    transform: translate(-50%, -50%);
    background: transparent;
    border: none;
    padding: 0.35rem 0.6rem;
    pointer-events: auto;
    appearance: none;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.seaweed-label-text {
    display: block;
    font-family: 'Cinzel', 'Playfair Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, 'PingFang SC', sans-serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3em;
    /* Backlog #N: 米白底上, 海草标签改为深色 */
    color: rgba(10, 31, 36, 0.82);
    text-transform: uppercase;
    transform: scale(1) translateY(0);
    transition: all 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform, text-shadow, color;
}

.seaweed-label:hover .seaweed-label-text {
    color: rgba(10, 31, 36, 1);
    text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.7);
}

.seaweed-label.is-focused .seaweed-label-text {
    transform: scale(1.4) translateY(-30px);
    color: rgba(10, 31, 36, 1);
    text-shadow:
        2px 2px 0 rgba(255, 255, 255, 0.7),
        4px 4px 8px rgba(10, 31, 36, 0.4);
}


/* ==========================================================
   6. 标题分隔线 / 副标题 / 品牌名
   ========================================================== */
.title-divider {
    width: 120px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(10, 31, 36, 0.4), transparent);
    margin: 0 auto 1.25rem;
}

.subtitle {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, 'PingFang SC', sans-serif;
    font-size: 0.95rem;
    letter-spacing: 0.28em;
    color: rgba(10, 31, 36, 0.65);
    font-weight: 300;
    line-height: 1.7;
    width: 100%;
    text-align: center;
}

.branding-name {
    font-family: 'Cinzel', 'Playfair Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, 'PingFang SC', sans-serif;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.45em;
    color: rgba(10, 31, 36, 0.75);
    margin-bottom: 1rem;
    font-weight: 300;
    width: 100%;
    text-align: center;
}


/* ==========================================================
   7. 电影感开场动画 + 标题呼吸 (Keyframes)
   ========================================================== */
@keyframes fadeBlurReveal {
    0% {
        opacity: 0;
        filter: blur(30px);
    }
    40% {
        opacity: 0.4;
        filter: blur(12px);
    }
    100% {
        opacity: 0.85;
        filter: blur(0px);
    }
}

@keyframes letterSpacingReveal {
    0% {
        letter-spacing: 1em;
    }
    100% {
        letter-spacing: 0.18em;
    }
}

@keyframes liquidBreath {
    0%, 100% {
        transform: translate(-50%, -50%) translateY(0px);
        opacity: 0.75;
    }
    50% {
        transform: translate(-50%, -50%) translateY(-6px);
        opacity: 0.88;
    }
}


/* ==========================================================
   8. 触屏设备: 关闭自定义光标 + Canvas 还原默认
   ========================================================== */
@media (hover: none) and (pointer: coarse) {
    #seaweedCanvas, #diverOverlayCanvas { cursor: auto; }

    /* ---- 标题区域 ---- */
    #cinematic-title-container {
        top: 15%;
        padding: 0 6vw;
    }
    .main-title {
        font-size: clamp(1rem, 3.8vw, 1.5rem) !important;
        letter-spacing: 0.2em;
    }
    .branding-name {
        font-size: 0.7rem;
        letter-spacing: 0.3em;
    }
    .subtitle {
        font-size: 0.75rem;
        letter-spacing: 0.15em;
    }
    .title-divider { width: 80px; }
}


/* ==========================================================
   9. 768px 以下: Canvas 全屏 + 标题加大占满宽度
   ------------------------------------------------------------
   窄屏/手机下 "HORACE ZENG" / "曾浩荣" 字号显著放大,
   用 vw 单位按视口缩放, 同时把 letter-spacing 收紧
   (英文每字母间已有空格, 视觉宽度主要由字号决定),
   保证单行显示且尽可能占满屏幕宽度, 远大于
   海草上 seaweed-label-text 的 14px 固定字号.
   ========================================================== */
@media (max-width: 768px) {
    /* ---- Canvas 适配 ---- */
    #seaweedCanvas, #diverOverlayCanvas, #causticsCanvas, #dotMatrixCanvas {
        width: 100vw;
        height: 100vh;
    }

    /* 全局：标题容器不要过大，左右内边距收紧 */
    #cinematic-title-container {
        top: 18% !important;
        padding: 0 4vw !important;
    }
    .title-divider { width: 60px; margin-bottom: 0.8rem; }

    /* 标题加大: 占满屏幕宽度, 单行, 明显大于海草标签 (14px) */
    .main-title {
        font-size: clamp(1.6rem, 7vw, 2.6rem) !important;
        letter-spacing: clamp(0.02em, 0.18vw, 0.07em);
        width: 100%;
        gap: 0.35rem;
    }
    .main-title-en {
        letter-spacing: clamp(0.02em, 0.18vw, 0.07em);
        white-space: nowrap;
        max-width: 100%;
    }
    .main-title-cn {
        font-size: 0.5em;
        letter-spacing: clamp(0.1em, 0.9vw, 0.28em);
        white-space: nowrap;
    }

    /* 强制 DIVE / subtitle 缩到一行, 用 vw 按视口缩放 */
    .branding-name {
        font-size: clamp(0.5rem, 3.2vw, 0.78rem);
        letter-spacing: clamp(0.1em, 0.5vw, 0.25em);
        white-space: nowrap;
    }
    .subtitle {
        font-size: clamp(0.5rem, 3vw, 0.8rem);
        letter-spacing: clamp(0.05em, 0.4vw, 0.2em);
        white-space: nowrap;
    }
}


/* ==========================================================
   10. 480px 以下: 标题继续放大占满屏幕宽度, DIVE/subtitle 单行
   ========================================================== */
@media (max-width: 480px) {
    .main-title {
        font-size: clamp(1.8rem, 9vw, 2.4rem) !important;
        letter-spacing: clamp(0.01em, 0.14vw, 0.05em);
        gap: 0.3rem;
    }
    .main-title-en {
        letter-spacing: clamp(0.01em, 0.14vw, 0.05em);
    }
    .main-title-cn {
        font-size: 0.48em;
        letter-spacing: clamp(0.08em, 0.7vw, 0.22em);
    }
    /* 强制单行 + 用 vw 单位按视口缩放, 保证 DIVE INTO ENTHUSIASM / subtitle 不换行 */
    .branding-name {
        font-size: clamp(0.4rem, 2.8vw, 0.55rem);
        letter-spacing: clamp(0.08em, 0.4vw, 0.18em);
        white-space: nowrap;
    }
    .subtitle {
        font-size: clamp(0.42rem, 2.7vw, 0.55rem);
        letter-spacing: clamp(0.05em, 0.3vw, 0.15em);
        white-space: nowrap;
    }
}


/* ==========================================================
   11. 360px 以下 (iPhone SE 1代等超小屏)
   ========================================================== */
@media (max-width: 360px) {
    .main-title {
        font-size: clamp(1.5rem, 10vw, 1.9rem) !important;
        letter-spacing: clamp(0.01em, 0.1vw, 0.04em);
        gap: 0.25rem;
    }
    .main-title-en {
        letter-spacing: clamp(0.01em, 0.1vw, 0.04em);
    }
    .main-title-cn {
        font-size: 0.5em;
        letter-spacing: clamp(0.06em, 0.5vw, 0.18em);
    }
    .branding-name {
        font-size: clamp(0.35rem, 3vw, 0.5rem);
        letter-spacing: 0.08em;
    }
    .subtitle {
        font-size: clamp(0.36rem, 2.9vw, 0.48rem);
        letter-spacing: 0.05em;
    }
}


/* ==========================================================
   12. 横屏模式 (手机横屏, max-width: 900px + landscape)
   ========================================================== */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    #cinematic-title-container { top: 35%; }
    .main-title { font-size: 1rem !important; }
}


/* ==========================================================
   13. (预留) 页面底部"向下滚动"提示
   ------------------------------------------------------------
   当前 index.html 中尚未包含 .scroll-indicator / .mouse-icon
   / .arrow-down 等元素. 如需后续添加, 在此处追加样式即可,
   不会污染主样式表.
   ========================================================== */


/* ==========================================================
   14. iOS 安全区: 标题容器避开灵动岛 / 顶部刘海
   ========================================================== */
@supports (padding: env(safe-area-inset-top)) {
    #cinematic-title-container {
        padding-top: max(0px, env(safe-area-inset-top));
    }
}
