/* 风间流序留予琪的小屋 · 3D 主页样式
   颜色随天色切换：body[data-sky="day|night"] 由 daytime.js 按场景明暗设置 */
:root {
  --ink: #1f2452;
  --ink-soft: rgba(31, 36, 82, 0.72);
  --glass: rgba(255, 255, 255, 0.74);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-line: rgba(255, 255, 255, 0.95);
  --shadow: 0 18px 50px rgba(40, 46, 120, 0.22);
  --hero-glow: rgba(255, 255, 255, 0.55);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --accent: #ff8fb1;
  color-scheme: light;
}
body[data-sky="night"] {
  --ink: #fff4e6;
  --ink-soft: rgba(255, 244, 230, 0.76);
  --glass: rgba(24, 26, 66, 0.64);
  --glass-strong: rgba(30, 32, 78, 0.86);
  --glass-line: rgba(255, 255, 255, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  --hero-glow: rgba(10, 12, 40, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: linear-gradient(180deg, #8ec5f5 0%, #ffe9d6 60%, #ffd3e0 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.6s;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 3D 画布铺满整屏 */
#scene {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; cursor: grab; z-index: 0; outline: none;
}
body.pointing #scene { cursor: pointer; }
body.dragging #scene { cursor: grabbing; }
/* 顶栏：左边是站标，右边是昼夜切换和管理入口 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) clamp(16px, 3vw, 36px) 0;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  border: 1px solid var(--glass-line); border-radius: 999px; background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: var(--shadow); font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform 0.2s, background 0.6s, border-color 0.6s;
}
.chip-btn:hover { transform: translateY(-2px); }
.chip-btn .sky-icon { font-size: 16px; }

/* 主标题：左侧大字，第二行渐变色 */
.hero {
  position: fixed; z-index: 10; pointer-events: none;
  left: clamp(20px, 5vw, 84px); top: 50%; transform: translateY(-58%);
  max-width: min(38vw, 560px);
  transition: opacity 0.5s, transform 0.6s;
}
.hero h1 {
  margin: 0; font-family: var(--serif); font-weight: 900; line-height: 1.04; letter-spacing: 0.02em;
  font-size: clamp(40px, 5.4vw, 86px);
  filter: drop-shadow(0 4px 18px var(--hero-glow));
}
.hero h1 span { display: block; white-space: nowrap; }
.hero h1 .l2 {
  background: linear-gradient(100deg, #ff5c8a 0%, #ff8a3d 45%, #ffc93c 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-bottom: 0.06em;
}
.lede {
  margin: 18px 0 0; max-width: 24em; font-size: clamp(14px, 1.15vw, 17px); line-height: 1.8;
  color: var(--ink-soft); text-shadow: 0 1px 12px var(--hero-glow);
}
.hint {
  display: inline-flex; margin: 22px 0 0; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.6s;
}
body.touched .hint { opacity: 0; }
body.focused .hero { opacity: 0; transform: translateY(-58%) translateX(-24px); }
.wish {
  position: fixed; z-index: 10; left: clamp(20px, 5vw, 84px); bottom: 26px; margin: 0;
  font-family: var(--serif); font-size: 14px; letter-spacing: 0.2em; color: var(--ink-soft);
  text-shadow: 0 1px 10px var(--hero-glow); pointer-events: none; transition: opacity 0.5s;
}
body.focused .wish { opacity: 0; }
/* 物件上方的浮动标签：位置由 ui.js 每帧计算 */
#pins { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.pin {
  position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center;
  padding: 0; border: 0; background: none; cursor: pointer;
  opacity: 0; visibility: hidden; transition: opacity 0.25s, visibility 0.25s;
  will-change: transform;
}
.pin.on { opacity: 1; visibility: visible; pointer-events: auto; }
.pin-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 7px; white-space: nowrap;
  border-radius: 999px; background: var(--glass-strong); border: 1px solid var(--glass-line);
  box-shadow: 0 8px 22px rgba(30, 30, 80, 0.2); font-size: 13px; font-weight: 700;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  translate: var(--dx, 0px) 0;
  transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1), translate 0.3s, background 0.25s, color 0.25s;
}
.pin-icon {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px;
  background: color-mix(in srgb, var(--accent) 30%, white);
}
.pin-stem { width: 2px; height: calc(16px + var(--lift, 0px)); background: linear-gradient(var(--glass-strong), var(--accent)); transition: height 0.3s; }
.pin-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent); animation: ping 2.2s infinite;
}
.pin.hot { z-index: 1; }
.pin.hot .pin-chip { transform: translateY(-4px) scale(1.08); background: var(--accent); color: #2a1730; }
/* 地方不够时退成只有图标的小圆泡，鼠标指上去再展开文字 */
.pin-label { display: inline-block; max-width: 8em; overflow: hidden; vertical-align: middle; transition: max-width 0.3s; }
.pin.mini:not(.hot) .pin-chip { gap: 0; padding: 6px; }
.pin.mini:not(.hot) .pin-label { max-width: 0; }
#pins.measuring .pin-chip, #pins.measuring .pin-label { transition: none; }
@keyframes ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
  80%, 100% { box-shadow: 0 0 0 12px transparent; }
}

/* 鼠标悬停提示 */
#tip {
  position: fixed; left: 0; top: 0; z-index: 30; pointer-events: none;
  padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: rgba(31, 36, 82, 0.9); color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0; transition: opacity 0.15s;
}
#tip.on { opacity: 1; }

/* 底部入口导航 */
.dock {
  position: fixed; z-index: 20; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%); max-width: calc(100vw - 24px);
  padding: 8px; border-radius: 26px; background: var(--glass); border: 1px solid var(--glass-line);
  box-shadow: var(--shadow); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  transition: transform 0.45s cubic-bezier(.2, .8, .2, 1), opacity 0.45s, background 0.6s;
}
.dock ul { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.dock ul::-webkit-scrollbar { display: none; }
.dock li { scroll-snap-align: start; }
.dock-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; padding: 8px 10px 7px;
  border: 0; border-radius: 18px; background: transparent; cursor: pointer; white-space: nowrap;
  font-size: 12px; font-weight: 700; transition: background 0.2s, transform 0.2s;
}
.dock-icon {
  width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; font-size: 19px;
  background: color-mix(in srgb, var(--accent) 34%, white);
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--accent) 60%, transparent);
  transition: transform 0.25s cubic-bezier(.3, 1.6, .5, 1);
}
.dock-btn:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.dock-btn:hover .dock-icon { transform: translateY(-4px) rotate(-6deg); }
.dock-btn[aria-current="true"] { background: var(--accent); color: #2a1730; }
.dock-btn[aria-current="true"] .dock-icon { background: rgba(255, 255, 255, 0.85); }
/* 入口面板：桌面是右侧抽屉 */
.panel {
  position: fixed; z-index: 25; top: 84px; right: clamp(14px, 2.4vw, 32px); bottom: 124px; width: min(400px, calc(100vw - 28px));
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: 28px; background: var(--glass-strong); border: 1px solid var(--glass-line);
  box-shadow: 0 30px 80px rgba(30, 30, 90, 0.3);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  transform: translateX(calc(100% + 40px)); opacity: 0; visibility: hidden;
  transition: transform 0.5s cubic-bezier(.2, .8, .2, 1), opacity 0.35s, visibility 0s 0.5s, background 0.6s;
}
.panel.open { transform: none; opacity: 1; visibility: visible; transition: transform 0.5s cubic-bezier(.2, .8, .2, 1), opacity 0.35s, background 0.6s; }
.panel::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 150px; pointer-events: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 45%, transparent), transparent);
}
.panel-head { position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 24px 22px 8px; }
.panel-icon {
  flex: none; width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center; font-size: 32px;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 45%, transparent);
  transform: rotate(-5deg);
}
.panel-titles { flex: 1; min-width: 0; padding-top: 4px; }
.panel-object { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.panel-title { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 900; line-height: 1.2; }
.icon-btn {
  flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; font-size: 18px; line-height: 1;
  background: rgba(127, 127, 160, 0.16); transition: background 0.2s, transform 0.2s;
}
.icon-btn:hover { background: rgba(127, 127, 160, 0.3); transform: rotate(90deg); }
.panel-body { position: relative; flex: 1; overflow-y: auto; padding: 8px 22px 12px; overscroll-behavior: contain; }
.panel-desc { margin: 6px 0 14px; font-size: 16px; line-height: 1.8; }
.panel-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.panel-meta li {
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
}
.panel-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px;
  border-radius: 16px; border: 0; cursor: pointer; text-decoration: none; font-size: 16px; font-weight: 800;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn-main {
  flex: 1; background: var(--accent); color: #2a1730;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 55%, transparent), inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}
.btn-main:hover { transform: translateY(-2px); box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 65%, transparent), inset 0 -4px 0 rgba(0, 0, 0, 0.12); }
.btn-main:active { transform: translateY(1px); }
.panel-foot {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 18px 16px; border-top: 1px solid rgba(127, 127, 160, 0.18); font-size: 13px; font-weight: 700;
}
.panel-foot .icon-btn:hover { transform: none; }
.panel-count { color: var(--ink-soft); letter-spacing: 0.1em; }

/* 灵感碎片（沿用旧主页的“作品 / 原文 / 感想”结构） */
.excerpt { margin: 4px 0 16px; transition: opacity 0.22s, transform 0.22s; }
.excerpt.is-fading { opacity: 0; transform: translateY(6px); }
.excerpt-count { margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: 0.14em; color: var(--accent); filter: brightness(0.8); }
.excerpt-label { margin: 12px 0 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.2em; color: var(--ink-soft); }
.excerpt-source { margin: 0; font-weight: 700; }
.excerpt-quote { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.6; font-weight: 700; }
.excerpt-thought { margin: 0; line-height: 1.8; color: var(--ink-soft); }
/* 加载画面 */
.loader {
  position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: linear-gradient(180deg, #8ec5f5 0%, #ffe9d6 62%, #ffd3e0 100%); color: #1f2452;
  opacity: 0; visibility: hidden; transition: opacity 0.8s, visibility 0s 0.8s;
}
html.loading .loader { opacity: 1; visibility: visible; transition: none; }
.loader-house { font-size: 64px; animation: hop 1.1s ease-in-out infinite; }
.loader p { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 700; letter-spacing: 0.2em; }
.loader a { font-size: 13px; opacity: 0; animation: show 0.4s 6s forwards; }
/* 跳转过渡：去子站前铺上对方页面的底色（颜色由 index.html 底部脚本按目标设置），界面同时淡出 */
.veil {
  position: fixed; inset: 0; z-index: 60; pointer-events: none;
  background: #f6f4ee; opacity: 0; transition: opacity 0.5s ease-in;
}
html.leaving .veil { opacity: 1; }
html.leaving .hero, html.leaving .dock, html.leaving .panel, html.leaving .topbar,
html.leaving #pins, html.leaving .wish, html.leaving .lite-list { opacity: 0 !important; transition: opacity 0.3s !important; }
@media (prefers-reduced-motion: reduce) { .veil { transition-duration: 0.05s; } }
@keyframes hop { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-14px) rotate(3deg); } }
@keyframes show { to { opacity: 0.8; } }

/* 列表模式：不支持 WebGL、加载失败、关闭 JS 或地址带 ?lite 时显示 */
.lite-list { display: none; }
html.lite body { overflow: auto; background: linear-gradient(170deg, #8ec5f5 0%, #ffe9d6 45%, #ffd3e0 100%) fixed; }
html.lite #scene, html.lite #pins, html.lite .dock, html.lite .panel, html.lite .hint, html.lite #tip, html.lite .loader, html.lite #sky-toggle { display: none; }
html.lite .hero { position: static; transform: none; max-width: none; padding: 110px clamp(20px, 5vw, 84px) 0; }
html.lite .wish { position: static; padding: 30px clamp(20px, 5vw, 84px) 40px; }
html.lite .lite-list { display: block; padding: 28px clamp(20px, 5vw, 84px) 0; }
.lite-note { margin: 0 0 18px; color: var(--ink-soft); font-size: 14px; }
.lite-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 0; padding: 0; list-style: none; }
.lite-card {
  display: flex; gap: 14px; align-items: flex-start; height: 100%; padding: 18px; border-radius: 22px; text-decoration: none;
  background: rgba(255, 255, 255, 0.78); border: 1px solid #fff; box-shadow: 0 12px 30px rgba(40, 46, 120, 0.14);
  transition: transform 0.2s;
}
a.lite-card:hover { transform: translateY(-3px); }
.lite-card .ic { flex: none; width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 22px; background: color-mix(in srgb, var(--accent) 34%, white); }
.lite-card b { display: block; font-size: 17px; margin-bottom: 4px; }
.lite-card span { font-size: 13px; line-height: 1.6; color: var(--ink-soft); }
.lite-excerpt { grid-column: 1 / -1; display: block; }
.lite-excerpt .excerpt { margin: 0 0 12px; }
.lite-excerpt .btn { min-height: 42px; font-size: 14px; background: var(--accent); color: #2a1730; }

/* 手机 / 窄屏：面板改成底部卡片，标题移到上方 */
@media (max-width: 760px), (max-height: 520px) and (max-width: 960px) {
  .chip-btn { height: 38px; padding: 0 12px; font-size: 13px; }
  .hero { top: 76px; transform: none; max-width: none; right: 20px; }
  .hero h1 { font-size: clamp(30px, 9.4vw, 44px); }
  .lede { margin-top: 8px; font-size: 13px; line-height: 1.6; }
  .hint { margin-top: 10px; font-size: 12px; padding: 6px 12px; }
  body.focused .hero { opacity: 0; transform: translateY(-12px); }
  .wish { display: none; }
  /* 小屏上标签收小一号，八个入口尽量都露出来 */
  .pin-chip { gap: 4px; padding: 4px 9px 4px 4px; font-size: 12px; }
  .pin-icon { width: 20px; height: 20px; font-size: 11px; }
  .pin.mini:not(.hot) .pin-chip { padding: 4px; }
  .dock { left: 12px; right: 12px; transform: none; max-width: none; padding: 6px; border-radius: 22px; }
  .dock ul { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .dock-btn { min-width: 66px; padding: 6px 6px 5px; font-size: 11px; }
  .dock-icon { width: 34px; height: 34px; font-size: 17px; }
  body.focused .dock { transform: translateY(140%); opacity: 0; pointer-events: none; }
  .panel {
    top: auto; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: auto; max-height: 54vh;
    border-radius: 26px; transform: translateY(calc(100% + 30px));
  }
  .panel-head { padding: 18px 18px 6px; }
  .panel-icon { width: 52px; height: 52px; font-size: 26px; border-radius: 17px; }
  .panel-title { font-size: 23px; }
  .panel-body { padding: 4px 18px 10px; }
  .panel-desc { font-size: 15px; margin-bottom: 12px; }
  .excerpt-quote { font-size: 19px; }
  .panel-foot { padding: 10px 14px 12px; }
  html.lite .hero { padding-top: 90px; }
}
/* 竖着拿的平板：标题放到顶上，小岛在下半屏（和 controls.js 里 tabMQ 同一条件） */
@media (min-width: 761px) and (max-aspect-ratio: 9/10) {
  .hero { top: 104px; transform: none; max-width: min(72vw, 640px); }
  body.focused .hero { opacity: 0; transform: translateY(-12px); }
}
/* 横屏手机：高度太矮，标题缩成左边一列、导航压扁，面板改成从右边滑出 */
@media (max-height: 520px) and (max-width: 960px) and (orientation: landscape) {
  .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  .hero { top: 62px; left: max(20px, env(safe-area-inset-left)); right: auto; max-width: min(36vw, 300px); }
  .hero h1 { font-size: clamp(24px, 4.4vw, 34px); }
  .lede { display: none; }
  .hint { margin-top: 8px; font-size: 11px; padding: 5px 10px; }
  .dock { left: 50%; right: auto; transform: translateX(-50%); max-width: calc(100vw - 24px); padding: 4px; bottom: max(8px, env(safe-area-inset-bottom)); border-radius: 18px; }
  .dock ul { -webkit-mask-image: none; mask-image: none; }
  .dock-btn { min-width: 58px; padding: 4px 4px 3px; font-size: 10px; }
  .dock-icon { width: 26px; height: 26px; font-size: 14px; }
  body.focused .dock { transform: translate(-50%, 140%); }
  .panel {
    top: 10px; bottom: 10px; left: auto; right: max(10px, env(safe-area-inset-right)); width: min(360px, 46vw); max-height: none;
    transform: translateX(calc(100% + 30px));
  }
  .panel-head { padding: 14px 16px 4px; }
  .panel-icon { width: 44px; height: 44px; font-size: 22px; border-radius: 14px; }
  .panel-title { font-size: 20px; }
  .panel-desc { font-size: 14px; line-height: 1.7; margin-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
