/* 讓漸層、文字與玻璃色彩一起平滑切換；舊瀏覽器仍可直接換色。 */
@property --background { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --background-end { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --text { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --muted { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --accent { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --glass { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --glass-solid { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --button { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --button-hover { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --border { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --inner { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --shadow { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --focus { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --lavender { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --peach { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --mint { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --ring { syntax: "<color>"; inherits: true; initial-value: transparent; }

/* 色彩與玻璃質感：在這裡調整明、暗模式。 */
:root {
  color-scheme: light dark;
  --background: #e8e6f0;
  --background-end: #dcebea;
  --text: #302b40;
  --muted: #61586e;
  --accent: #685587;
  --glass: rgb(255 255 255 / 24%);
  --glass-solid: #f2edf5;
  --button: rgb(255 255 255 / 37%);
  --button-hover: rgb(255 255 255 / 62%);
  --border: rgb(255 255 255 / 74%);
  --inner: rgb(255 255 255 / 54%);
  --shadow: rgb(63 44 92 / 10%);
  --focus: #654480;
  --lavender: #b7a3e5;
  --peach: #edbea9;
  --mint: #91cec3;
  --ring: rgb(255 255 255 / 39%);
  --ease: cubic-bezier(.22, .61, .36, 1);
  transition-property: --background, --background-end, --text, --muted, --accent,
    --glass, --glass-solid, --button, --button-hover, --border, --inner, --shadow,
    --focus, --lavender, --peach, --mint, --ring;
  transition-duration: 300ms;
  transition-timing-function: ease;
}

:root[data-theme="light"] { color-scheme: light; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #1c192c;
  --background-end: #122a2c;
  --text: #f7f3ff;
  --muted: #ccc4dc;
  --accent: #d7c4f7;
  --glass: rgb(34 30 51 / 34%);
  --glass-solid: #292536;
  --button: rgb(255 255 255 / 8%);
  --button-hover: rgb(255 255 255 / 16%);
  --border: rgb(255 255 255 / 21%);
  --inner: rgb(255 255 255 / 10%);
  --shadow: rgb(5 4 17 / 25%);
  --focus: #e0caff;
  --lavender: #63478e;
  --peach: #874a68;
  --mint: #28756c;
  --ring: rgb(255 255 255 / 7%);
}

/* 無 JavaScript 時仍跟隨系統，明亮選擇則優先於系統偏好。 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #1c192c;
    --background-end: #122a2c;
    --text: #f7f3ff;
    --muted: #ccc4dc;
    --accent: #d7c4f7;
    --glass: rgb(34 30 51 / 34%);
    --glass-solid: #292536;
    --button: rgb(255 255 255 / 8%);
    --button-hover: rgb(255 255 255 / 16%);
    --border: rgb(255 255 255 / 21%);
    --inner: rgb(255 255 255 / 10%);
    --shadow: rgb(5 4 17 / 25%);
    --focus: #e0caff;
    --lavender: #63478e;
    --peach: #874a68;
    --mint: #28756c;
    --ring: rgb(255 255 255 / 7%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding: 48px 16px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: linear-gradient(145deg, var(--background), var(--background-end));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC",
    "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.blob {
  position: absolute;
  width: clamp(300px, 48vw, 680px);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(64px);
  opacity: .72;
  animation: drift 28s ease-in-out infinite alternate;
}

.blob--lavender {
  background: var(--lavender);
  left: calc(50% - 520px);
  top: calc(50% - 490px);
}

.blob--peach {
  background: var(--peach);
  width: clamp(280px, 40vw, 560px);
  left: calc(50% + 30px);
  top: calc(50% - 280px);
  animation-duration: 32s;
  animation-delay: -12s;
}

.blob--mint {
  background: var(--mint);
  left: calc(50% - 360px);
  top: calc(50% + 100px);
  animation-duration: 35s;
  animation-delay: -20s;
}

@keyframes drift {
  from { transform: translate3d(-18px, -16px, 0) scale(1); }
  to { transform: translate3d(30px, 28px, 0) scale(1.08); }
}

.page {
  width: 100%;
  max-width: 440px;
  text-align: center;
}

.glass {
  border: 1px solid var(--border);
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: 0 24px 70px var(--shadow), 0 4px 16px var(--shadow),
    inset 0 1px 0 var(--inner);
}

.profile-card {
  padding: 34px 28px 28px;
  border-radius: 36px;
}

/* 獨立一列靠右排列，不覆蓋卡片內容；hidden 保持原生隱藏效果。 */
.theme-switch {
  width: fit-content;
  margin: -12px 0 22px auto;
  padding: 4px;
  border-radius: 999px;
  box-shadow: inset 0 1px 0 var(--inner), 0 4px 16px var(--shadow);
}

.theme-switch:not([hidden]) { display: flex; }

.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-switch button[aria-pressed="true"] {
  color: var(--text);
  background: var(--button-hover);
  border-color: var(--border);
  box-shadow: 0 2px 8px var(--shadow), inset 0 1px 0 var(--inner);
}

.theme-switch button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-switch svg { width: 16px; height: 16px; flex-shrink: 0; }

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: .12em;
}

.eyebrow::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 106px;
  height: 106px;
  margin: 0 auto 22px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: linear-gradient(145deg, var(--ring), var(--glass));
  box-shadow: 0 8px 24px var(--shadow), inset 0 1px 1px var(--inner);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

/* 照片覆蓋在字母上；檔案缺少或損壞時，背景透明，字母仍可見。 */
.avatar::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: url("assets/avatar.jpg") 50% 22% / 170% no-repeat;
}

.avatar-initial {
  margin-top: -5px;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 62px;
  font-style: italic;
  line-height: 1;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 34px);
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}

.handle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.bio {
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.links { margin-top: 30px; }

.section-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 4px 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.6;
}

.section-label::before,
.section-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.link-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.link {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 14px 20px;
  border-radius: 999px;
  color: var(--text);
  background: var(--button);
  text-align: left;
  text-decoration: none;
  box-shadow: 0 5px 16px var(--shadow), inset 0 1px 0 var(--inner);
  /* 色彩由根元素的 300ms 過場統一處理，避免再疊一層延遲。 */
  transition: transform 180ms var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.brand-icon { width: 25px; height: 25px; flex: 0 0 25px; }
.link-copy { min-width: 0; flex: 1; }
.link-title { display: block; font-size: 16px; font-weight: 600; line-height: 1.4; }
.link-caption { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.arrow { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); }

@media (hover: hover) and (pointer: fine) {
  .link:hover {
    transform: translateY(-3px);
    background: var(--button-hover);
    box-shadow: 0 10px 24px var(--shadow), inset 0 1px 0 var(--inner);
  }
}

.link:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 5px;
  transform: translateY(-3px);
  background: var(--button-hover);
}

.link:active { transform: translateY(0) scale(.985); }

/* 精選連結：產品圖放在玻璃底下。圖片為 assets/xiner.jpg，缺圖時自動略過。 */
.link--featured {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.link--featured::before,
.link--featured::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.link--featured::before {
  /* 圖片靠右、寬度 62%，讓左側標題落在玻璃底色上，不和橫幅文字重疊。 */
  background: url("assets/xiner.jpg") 100% 30% / 62% auto no-repeat;
}

/* 只在左側文字區鋪玻璃底色，右側讓圖片清楚露出。 */
.link--featured::after {
  background: linear-gradient(90deg,
    var(--glass-solid) 38%,
    color-mix(in srgb, var(--glass-solid) 50%, transparent) 50%,
    transparent 64%);
}

.link--featured .arrow {
  box-sizing: content-box;
  padding: 6px;
  border-radius: 50%;
  color: var(--text);
  background: color-mix(in srgb, var(--glass-solid) 75%, transparent);
}

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.footer svg { width: 13px; height: 13px; flex-shrink: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 不支援標準 backdrop-filter 的瀏覽器使用更實色的背景。 */
@supports not (backdrop-filter: blur(1px)) {
  .glass, .avatar, .link:hover, .link:focus-visible { background: var(--glass-solid); }
}

@media (prefers-reduced-transparency: reduce) {
  .glass, .avatar, .link:hover, .link:focus-visible { background: var(--glass-solid); }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  :root, .link { transition: none; }
  .link:hover, .link:focus-visible, .link:active { transform: none; }
}

@media (max-width: 380px) {
  .profile-card { padding: 30px 22px 24px; border-radius: 32px; }
  .link-list { gap: 10px; }
  .link { min-height: 72px; padding-inline: 18px; gap: 12px; }
}

@media (max-height: 700px) {
  body { padding-block: 28px; }
}

@media (forced-colors: active) {
  .ambient { display: none; }
  .glass, .avatar { border-color: CanvasText; }
  .link:focus-visible, .theme-switch button:focus-visible { outline-color: Highlight; }
  .theme-switch button[aria-pressed="true"] { border-color: Highlight; }
}

/* 404 頁面 */
.error-card { padding-block: 40px; }
.error-code {
  margin: 0 0 16px;
  color: var(--accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 88px;
  font-style: italic;
  line-height: 1;
}
.error-card h1 { font-size: 24px; letter-spacing: 0; }
.home-link { margin-top: 28px; justify-content: center; min-height: 60px; }
