/* 《掉线》落地页 V2 · 群青档案
   两套东西不混：系统＝绿、等宽、锐利；人＝米白／暖色、仿宋、手写。 */

@font-face { font-family: "Zhuque Fangsong"; src: url("../fonts/zhuque-sub.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Departure Mono"; src: url("../fonts/departure-mono.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Fraunces"; font-style: italic; font-weight: 300; src: url("../fonts/fraunces-300-italic.woff2") format("woff2"); font-display: swap; }

:root {
  --k0: #03041A;  /* 内页底 */
  --k1: #07075C;  /* 深群青 */
  --k2: #1010E0;  /* 外框 */
  --k3: #4254FF;  /* 格线、编号 */
  --k4: #CDD0FF;  /* 次要字 */
  --green: #3CFF72;
  --lime: #B8FF3C;
  --warm: #FFDCA8;
  --ink: #F5E8CC;
  --grid: rgba(66, 84, 255, .28);
  --frame: 8px;
  --radius: 18px;
  --serif: "Zhuque Fangsong", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --mono: "Departure Mono", ui-monospace, "SFMono-Regular", Menlo, "PingFang SC", "Noto Sans CJK SC", monospace;
  --latin: "Fraunces", Georgia, serif;
  --gutter: 20px;
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--k0); color: var(--ink); }
html:not([data-phase="reading"]) { overflow: hidden; }
body { margin: 0; font-family: var(--serif); line-height: 1.65; }
h1, h2, h3, p, ol, ul, figure { margin: 0; padding: 0; }
ol, ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
img { display: block; max-width: 100%; height: auto; }
:focus-visible { outline: 1px solid var(--warm); outline-offset: 4px; }
@media (prefers-reduced-motion: no-preference) { html[data-phase="reading"] { scroll-behavior: smooth; } }

/* —— 抵达 —— */
#intro { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--k0); }
.sys, .look { grid-area: 1 / 1; }
#intro .sys { width: 168px; text-align: center; color: var(--green); transition: opacity .6s ease; }
#sys-line { font: 13px/1.55 var(--mono); letter-spacing: .04em; white-space: nowrap; }
.meter { height: 2px; margin-top: 15px; background: rgba(60, 255, 114, .15); }
.meter-fill { height: 100%; background: currentColor; transform: scaleX(0); transform-origin: left; }
#intro .sys.timed-out { color: var(--lime); }
.sys.timed-out .meter { background: rgba(184, 255, 60, .18); }
.look { font-size: min(26vw, 22vh, 104px); line-height: 1.2; letter-spacing: .03em; white-space: nowrap; opacity: 0; }
#skip { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: manipulation; }
#skip:focus-visible { outline-offset: -8px; }
[data-phase="look"] .sys, [data-phase="revealing"] .sys { opacity: 0; }
[data-phase="look"] .look { opacity: 1; transition: opacity .3s ease .6s; }
[data-phase="revealing"] .look { opacity: 0; transition: opacity .8s ease; }
[data-phase="revealing"] #intro { background: transparent; }
[data-phase="revealing"] #page { animation: daybreak 2s both; }
@keyframes daybreak { 0%, 40% { opacity: 0; } 100% { opacity: 1; } }

/* —— 群青外框：手机就是穹顶那一圈 —— */
.frame {
  position: fixed; z-index: 20; pointer-events: none;
  top: max(var(--frame), env(safe-area-inset-top)); bottom: max(var(--frame), env(safe-area-inset-bottom));
  left: max(var(--frame), env(safe-area-inset-left)); right: max(var(--frame), env(safe-area-inset-right));
  border-radius: var(--radius);
  box-shadow: 0 0 0 120px var(--k2);
  opacity: 0; transition: opacity 2s ease;
}
[data-phase="revealing"] .frame, [data-phase="reading"] .frame { opacity: 1; }

#page {
  padding: max(var(--frame), env(safe-area-inset-top)) max(var(--frame), env(safe-area-inset-right)) max(var(--frame), env(safe-area-inset-bottom)) max(var(--frame), env(safe-area-inset-left));
}
main { max-width: 1280px; margin: 0 auto; }

/* —— 顶栏 —— */
.bar {
  position: sticky; top: max(var(--frame), env(safe-area-inset-top)); z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; max-width: 1280px; margin: 0 auto; padding: 0 16px 0 var(--gutter);
  background: var(--k0);
}
.mark { font-size: 22px; letter-spacing: .06em; text-decoration: none; }
.pills { display: flex; gap: 6px; }
.pills a {
  display: inline-flex; align-items: center; height: 32px; padding: 0 13px;
  border: 1px solid var(--k3); border-radius: 16px; font-size: 13px; text-decoration: none;
  position: relative;
}
.pills a::after { content: ""; position: absolute; inset: -6px -2px; } /* 触点放大到 44px */

/* —— 开头 —— */
.hero { padding: 76px var(--gutter) clamp(64px, 9vw, 112px); border-bottom: 1px solid var(--k3); }
.hero h1 { font-weight: 400; font-size: clamp(34px, 9.8vw, 64px); line-height: 1.42; letter-spacing: .02em; }
.hero-meta { margin-top: 28px; font-size: 14px; line-height: 1.8; color: var(--k4); }

/* —— 区块标题 —— */
.block { padding-top: 56px; }
#studies { padding-top: 104px; }
.head { display: flex; align-items: baseline; gap: 10px; padding: 0 var(--gutter); }
.head h2 { font-weight: 400; font-size: clamp(48px, 14vw, 72px); line-height: 1; }
.latin { font: italic 300 22px/1 var(--latin); color: var(--k3); }
.sys-tag { margin-left: auto; font: 10px/1 var(--mono); letter-spacing: .06em; color: var(--green); white-space: nowrap; }

/* —— 长卷 —— */
.roll {
  position: relative; height: clamp(200px, 54vw, 440px); margin-top: 32px; overflow: hidden;
  border-top: 1px solid var(--k3); border-bottom: 1px solid var(--k3);
  touch-action: pan-y; cursor: grab; background: var(--k0);
}
.roll-base { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 48% 50%; }
.track { position: relative; overflow: hidden; height: 1px; margin: 22px var(--gutter) 0; background: rgba(66, 84, 255, .4); }
.track::before { content: ""; position: absolute; left: 0; width: var(--wrap-span, 0%); height: 1px; background: var(--ink); }
.thumb { position: absolute; left: 44%; width: 12%; height: 1px; background: var(--ink); }
.caption { margin: 16px var(--gutter) 0; font-size: 15px; }
.hint { margin: 4px var(--gutter) 0; font: 10px/1.6 var(--mono); color: rgba(205, 208, 255, .6); }

/* —— 实验 —— */
.intro { margin: 28px var(--gutter) 0; font-size: 15px; line-height: 1.95; color: var(--k4); }
.studies { display: flex; flex-direction: column; gap: 56px; margin-top: 44px; }
.study {
  position: relative; width: 100%; aspect-ratio: 6 / 5;
  background-image: linear-gradient(to right, var(--grid) 1px, transparent 1px), linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: calc(100% / 6) calc(100% / 5);
  border-bottom: 1px solid var(--grid);
}
.stack { position: absolute; top: 12%; width: 47.5%; aspect-ratio: 3 / 4; }
.study[data-side="l"] .stack { left: 6%; }
.study[data-side="r"] .stack { left: 46.5%; }
.stack img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stack .b2 { transform: translate(-3%, 3%) rotate(-6deg); filter: brightness(.7); }
.stack .b1 { transform: translate(4%, 1%) rotate(4deg); filter: brightness(.82); }
@media (prefers-reduced-motion: no-preference) {
  .stack .back { transition: transform .5s ease; }
  .stack:hover .b2, .stack:focus-visible .b2 { transform: translate(-12%, 4%) rotate(-9deg); }
  .stack:hover .b1, .stack:focus-visible .b1 { transform: translate(12%, 2%) rotate(7deg); }
}
.note { position: absolute; top: 13%; width: 36%; }
.study[data-side="l"] .note { left: 59%; }
.study[data-side="r"] .note { left: 5.5%; }
.sid { font: 11px/1 var(--mono); color: var(--green); }
.note h3 { margin-top: 8px; font-weight: 400; font-size: clamp(44px, 16vw, 72px); line-height: 1.05; }
.what { margin-top: 14px; font-size: 15px; line-height: 1.75; color: var(--k4); }
.what.sys { font: 12px/1.7 var(--mono); color: var(--green); }
.spec { margin-top: 18px; font: 10px/1 var(--mono); color: var(--k3); }

/* —— 在吗 —— */
.here { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; min-height: 100svh; margin-top: 40px; padding: 40px var(--gutter); text-align: center; }
.here h2 { font-weight: 400; font-size: 52px; line-height: 1.3; letter-spacing: .04em; }
.here h2:focus { outline: none; }
#answer { position: relative; width: 120px; height: 120px; margin-top: 28px; touch-action: manipulation; }
#answer::after { content: ""; position: absolute; left: 28px; right: 28px; bottom: 22px; height: 1px; background: rgba(245, 232, 204, .47); }
.cue { position: absolute; left: 0; right: 0; bottom: 28px; font-size: 25px; line-height: 1.4; color: rgba(245, 232, 204, .68); }
.ink { position: absolute; inset: 0; display: none; }
.ink svg { width: 100%; height: 100%; }
.ink path { fill: none; stroke: var(--warm); stroke-linecap: round; stroke-linejoin: round; }
#answer.writing .cue, #answer.writing::after { opacity: 0; }
#answer.writing .ink { display: block; }
.writing [data-stroke] { stroke-dasharray: var(--len); animation: write var(--dur) linear var(--delay) both; }
@keyframes write { 0% { opacity: 0; stroke-dashoffset: var(--len); } 1% { opacity: 1; } 100% { opacity: 1; stroke-dashoffset: 0; } }
#answer:disabled { cursor: default; }
#reply { margin-top: 28px; font-size: clamp(16px, 4.6vw, 20px); line-height: 2; }
#reply p { opacity: 0; }
#reply.shown { animation: reply-fade .8s ease 7s forwards; }
@keyframes reply-fade { from { opacity: 1; } to { opacity: 0; } }
#reply.shown p { animation: appear .65s ease-out both; }
#reply.shown p:nth-child(2) { animation-delay: .12s; }
#reply.shown p:nth-child(3) { animation-delay: .24s; }
@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

/* —— 点名册 —— */
.roll-call { width: calc(100% - 2 * var(--gutter)); max-width: 1200px; margin: 0 auto; padding: 28px 0 64px; border-top: 1px solid rgba(66, 84, 255, .4); }
.rc-title { font: 10px/1 var(--mono); letter-spacing: .08em; color: rgba(205, 208, 255, .6); }
.rc { display: flex; flex-direction: column; gap: 18px; margin-top: 22px; }
.rc li { display: flex; align-items: baseline; gap: 8px; }
.role { flex: none; width: 48px; font-size: 12px; color: rgba(205, 208, 255, .7); }
.who { font-size: 18px; }
.latin-name { font-size: 15px; }
.kling { height: 13px; width: auto; opacity: .85; display: inline-block; }
.dots { flex: 1; min-width: 24px; border-bottom: 1px dotted rgba(205, 208, 255, .35); transform: translateY(-4px); }
.ans.human { font-size: 20px; color: var(--warm); }
.ans.machine { font: 13px/1 var(--mono); color: var(--green); }
.colophon { margin-top: 28px; font-size: 12px; color: rgba(205, 208, 255, .6); }

/* —— 桌面：实验两列交错 —— */
@media (min-width: 900px) {
  :root { --gutter: 40px; --frame: 14px; --radius: 24px; }
  .hero { padding-top: 120px; }
  .hero h1 { font-size: clamp(56px, 6vw, 88px); }
  .studies { display: grid; grid-template-columns: 1fr 1fr; column-gap: 0; row-gap: 96px; padding-bottom: 18%; }
  .study:nth-child(even) { transform: translateY(45%); }
}

/* —— 放大看 —— */
#viewer { position: fixed; inset: 0; z-index: 50; background: #000; color: var(--ink); }
.v-safe { position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  top: env(safe-area-inset-top); right: env(safe-area-inset-right); bottom: env(safe-area-inset-bottom); left: env(safe-area-inset-left); }
.v-stage { position: absolute; top: 56px; bottom: 132px; left: 0; right: 0; overflow: hidden; touch-action: none; }
.v-count { position: absolute; left: 16px; top: 18px; font: 11px/1 var(--mono); color: rgba(205, 208, 255, .75); }
.v-say { position: absolute; left: var(--gutter); right: var(--gutter); bottom: 64px; font-size: 17px; line-height: 1.7; }
.v-spec { position: absolute; left: var(--gutter); bottom: 40px; font: 10px/1 var(--mono); letter-spacing: .06em; color: var(--green); }
.v-hint { position: absolute; right: 16px; bottom: 16px; font: 9px/1 var(--mono); color: rgba(205, 208, 255, .6); }
.v-close, .v-prev, .v-next { position: absolute; display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; }
.v-close { right: 8px; top: 6px; }
.v-prev { right: 104px; bottom: 28px; }
.v-next { right: 56px; bottom: 28px; }
#viewer svg path { fill: none; stroke: var(--k4); stroke-width: 1.2; }
.v-thumbs { position: absolute; left: var(--gutter); bottom: 96px; display: flex; gap: 10px; }
.v-thumbs button { width: 36px; aspect-ratio: 3 / 4; overflow: hidden; border: 1px solid transparent; opacity: .6; }
.v-thumbs button[aria-current="true"] { border-color: var(--ink); opacity: 1; }
.v-thumbs img { width: 100%; height: 100%; object-fit: cover; }
#viewer.series .v-say { bottom: 140px; }
#viewer.series .v-stage { bottom: 180px; }
@media (orientation: portrait) and (max-width: 480px) {
  .v-prev { right: 56px; }
  .v-next { right: 8px; }
  .v-spec { right: 108px; }
}
@media (orientation: portrait) and (max-width: 370px) {
  .v-spec { bottom: 32px; line-height: 1.35; }
}
@media (orientation: landscape) and (max-height: 600px) {
  .v-stage, #viewer.series .v-stage { top: 0; bottom: 0; left: 72px; right: 72px; }
  .v-say, #viewer.series .v-say { left: 24px; right: auto; top: 64px; bottom: auto; writing-mode: vertical-rl; letter-spacing: .12em; }
  .v-spec { left: auto; right: 30px; top: 70px; bottom: auto; writing-mode: vertical-rl; }
  #viewer.series .v-spec { right: 60px; }
  .v-prev { right: auto; left: 14px; bottom: 8px; }
  .v-next { right: 14px; bottom: 8px; }
  .v-hint { display: none; }
  .v-thumbs { left: auto; right: 14px; top: auto; bottom: 64px; flex-direction: column; }
}

/* 拼图查看器 */
.tv { position: absolute; inset: 0; overflow: hidden; }
.tv img { position: absolute; max-width: none; height: auto; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; pointer-events: none; }
.tv .tv-base { image-rendering: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .writing [data-stroke] { opacity: 1; stroke-dashoffset: 0; }
  #reply.shown p { opacity: 1; }
}

.tv img { left: 0; top: 0; }
html.viewing, html.viewing body { overflow: hidden; }
.v-say.sys { font: 13px/1.7 var(--mono); color: var(--green); }
section[id], #top { scroll-margin-top: 84px; }

/* 旧版 WebView 没有 aspect-ratio 时，仍为绝对定位的画幅留出高度。 */
@supports not (aspect-ratio: 1 / 1) {
  .study::before, .stack::before {
    content: ""; display: block; width: 100%;
  }
  .study::before { padding-top: 83.3333%; }
  .stack::before { padding-top: 133.3333%; }
  .v-thumbs button { height: 48px; }
}

@supports not (inset: 0) {
  #intro, #skip, #viewer, .ink, .tv, .roll-base, .stack img { top: 0; right: 0; bottom: 0; left: 0; }
}
