/* ═══════════════════════════════════════════════════════════
   浮層與收尾 —— 導航膠囊、Footer
   ═══════════════════════════════════════════════════════════ */

/* ── 導航膠囊 ──────────────────────────────────────────
   頁面很長，隨時要能回答「我在哪？怎麼回目錄？」
   捲進專案區才出現，離開就收回原路。                      */
.compass {
  position: fixed;
  left: 50%;
  bottom: max(var(--sp-2), env(safe-area-inset-bottom));
  z-index: 50;
  display: flex; align-items: center; gap: 0.6rem;
  height: 44px;
  padding: 0 0.3rem 0 0.8rem;
  border-radius: 999px;
  background: var(--bg-veil);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  /* 亮邊用內陰影而不是 border：上緣比下緣亮一點，像光從上面來 */
  box-shadow: inset 0 1px 0 #ffffff1f, inset 0 0 0 1px #ffffff12,
              0 10px 36px #000000a6;
  font-size: var(--t-small);
  max-width: calc(100vw - 2 * var(--sp-2));
  /* 進來與出去走同一條路徑 */
  transform: translate(-50%, calc(100% + var(--sp-3)));
  opacity: 0;
  transition: transform var(--dur-ui) var(--spring), opacity var(--dur-ui) var(--ease-out);
}
.compass.is-in { transform: translate(-50%, 0); opacity: 1; }

/* 整頁閱讀進度：一個小圓環，跟著捲動填滿。
   原本是貼在膠囊下緣的一條線，但膠囊是圓的 —— 線的兩端會戳出圓角外。 */
.compass__ring {
  width: 18px; height: 18px; flex: none;
  transform: rotate(-90deg);
}
.compass__ring circle {
  fill: none; stroke-width: 2.25;
}
.compass__ring circle:first-child { stroke: #ffffff26; }
.compass__ring circle:last-child {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 44 44;               /* 周長 2π·7 ≈ 44 */
  stroke-dashoffset: calc(44 * (1 - var(--read, 0)));
}

.compass__where {
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
}
.compass__n {
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  margin-right: 0.45em;
}
.compass__to-index {
  border: 0;
  height: 36px;
  background: #ffffff1f;
  color: var(--ink);
  font: inherit;
  font-size: var(--t-label);
  font-weight: 500;
  padding: 0 1rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  transition: background var(--dur-ui) var(--ease-out),
              transform var(--dur-tap) var(--ease-out);
}
.compass__to-index:hover { background: #ffffff33; }
.compass__to-index:active { transform: scale(0.95); }

@media (prefers-reduced-transparency: reduce) {
  .compass { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .compass { transform: translate(-50%, 0); transition: opacity 0.2s ease; }
}

/* ── Footer ───────────────────────────────────────────
   Apple 頁面的收尾：一句置中的大字、一個主要動作、一排次要的，
   然後是一條細線和最小的字。 */
.footer {
  padding-block: var(--sp-7) var(--sp-4);
  display: grid;
  justify-items: center;
  gap: var(--sp-4);
  text-align: center;
}
.footer__say {
  margin: 0;
  max-width: 16em;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.035em;
  text-wrap: balance;
  word-break: keep-all;
  overflow-wrap: anywhere;
  background: linear-gradient(180deg, #ffffff 30%, #a1a1a6 100%);
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
}
.footer__links {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: var(--sp-1);
  list-style: none; margin: 0; padding: 0;
}
/* 第一個聯絡方式是主要動作（實心），其餘是次要（描邊） */
.footer__links a {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.7em 1.35em;
  border-radius: 999px;
  font-size: var(--t-body);
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px #ffffff40;
  transition: background var(--dur-ui) var(--ease-out),
              transform var(--dur-tap) var(--ease-out);
}
.footer__links a:hover { background: #ffffff14; }
.footer__links a:active { transform: scale(0.97); }
.footer__links li:first-child a {
  background: var(--ink);
  color: #000;
  box-shadow: none;
}
.footer__links li:first-child a:hover { background: #fff; }
.footer__links a::after {
  content: "↗";
  font-size: 0.8em;
  opacity: 0.6;
  transition: transform var(--dur-ui) var(--spring), opacity var(--dur-ui) var(--ease-out);
}
.footer__links a:hover::after { transform: translate(0.12em, -0.12em); opacity: 1; }

.footer__fine {
  justify-self: stretch;
  display: flex; justify-content: space-between; gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-5);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--hairline);
  font-size: var(--t-label);
  color: var(--ink-faint);
  text-align: left;
}

/* ── 頂端導覽列 ─────────────────────────────────────────
   Apple 的那條：48px 高、半透明材質、極細的底邊。
   往下捲就讓路（線稿是 sticky 貼著畫面上緣的，不該被一條橫槓壓住），
   往上捲 —— 也就是「想去別的地方」的時候 —— 才回來。 */
.globalnav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 60;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  box-shadow: inset 0 -1px 0 transparent;
  transition: transform var(--dur-ui) var(--ease-out),
              box-shadow var(--dur-ui) var(--ease-out),
              background var(--dur-ui) var(--ease-out);
}
/* 在頁面最上方時完全透明，跟 hero 融在一起；一離開頂端才長出材質和底邊 */
.globalnav:not(.is-scrolled) {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.globalnav.is-scrolled { box-shadow: inset 0 -1px 0 var(--hairline); }
.globalnav.is-away { transform: translateY(-100%); }

.globalnav__inner {
  height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2);
}
.globalnav__brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  font-size: var(--t-small);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
}
.globalnav__brand svg { width: 22px; height: 22px; flex: none; }
.globalnav__brand svg * {
  fill: none; stroke: var(--ink); stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.globalnav__brand .globalnav__dot { stroke: var(--accent); }

.globalnav__links {
  display: flex; gap: var(--sp-3);
  list-style: none; margin: 0; padding: 0;
}
.globalnav__links a {
  font-size: var(--t-label);
  color: color-mix(in srgb, var(--ink) 80%, transparent);
  text-decoration: none;
}
.globalnav__links a:hover { color: var(--ink); }

@media (prefers-reduced-transparency: reduce) {
  .globalnav.is-scrolled { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .globalnav { transition: opacity 0.2s ease; }
  .globalnav.is-away { transform: none; opacity: 0; pointer-events: none; }
}
