/* ==========================================================================
   Lamio · 个人网站
   Liquid-glass shell: ambient light, frosted panels, generous whitespace.
   ========================================================================== */

@view-transition {
  navigation: auto;
}

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */

:root {
  color-scheme: light;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;

  --maxw: 1080px;
  --gutter: clamp(20px, 4vw, 48px);

  --bg: #eef1f6;
  --text: #101419;
  --muted: #5f6675;
  --line: rgba(16, 20, 25, 0.1);
  --focus: #2f5bd7;
  --selection: rgba(120, 150, 255, 0.28);

  --glass-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.26));
  --glass-sheen: rgba(255, 255, 255, 0.34);
  --glass-solid: rgba(255, 255, 255, 0.93);
  --glass-border: rgba(255, 255, 255, 0.75);
  --glass-highlight: rgba(255, 255, 255, 0.9);
  --glass-shadow: 0 26px 60px -28px rgba(23, 32, 54, 0.35), 0 2px 8px rgba(23, 32, 54, 0.05);

  --hover-bg: rgba(255, 255, 255, 0.45);
  --active-bg: rgba(255, 255, 255, 0.72);

  --blob-a: rgba(116, 148, 255, 0.55);
  --blob-b: rgba(255, 178, 138, 0.42);
  --blob-c: rgba(112, 224, 203, 0.34);
}

[data-theme='dark'] {
  color-scheme: dark;

  --bg: #06080d;
  --text: #eef1f7;
  --muted: #9aa3b5;
  --line: rgba(255, 255, 255, 0.12);
  --focus: #a8bcff;
  --selection: rgba(120, 150, 255, 0.35);

  --glass-fill: linear-gradient(135deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035));
  --glass-sheen: rgba(255, 255, 255, 0.12);
  --glass-solid: rgba(18, 22, 31, 0.88);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-highlight: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.8);

  --hover-bg: rgba(255, 255, 255, 0.07);
  --active-bg: rgba(255, 255, 255, 0.12);

  --blob-a: rgba(72, 98, 255, 0.4);
  --blob-b: rgba(255, 128, 96, 0.22);
  --blob-c: rgba(64, 220, 200, 0.22);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  position: relative;
  z-index: 1;
  flex: 1;
}

main:focus {
  outline: none;
}

a {
  color: inherit;
}

::selection {
  background: var(--selection);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

.shell {
  width: min(var(--maxw), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

/* --------------------------------------------------------------------------
   Ambient scene
   -------------------------------------------------------------------------- */

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

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
  opacity: 0.9;
  will-change: transform;
}

.blob-a {
  top: -18vw;
  left: -10vw;
  width: 52vw;
  aspect-ratio: 1;
  background: var(--blob-a);
  animation: drift-a 30s ease-in-out infinite alternate;
}

.blob-b {
  top: -2vh;
  right: -16vw;
  width: 46vw;
  aspect-ratio: 1;
  background: var(--blob-b);
  animation: drift-b 36s ease-in-out infinite alternate;
}

.blob-c {
  bottom: -22vw;
  left: 26vw;
  width: 46vw;
  aspect-ratio: 1;
  background: var(--blob-c);
  animation: drift-c 42s ease-in-out infinite alternate;
}

.grain {
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: overlay;
}

[data-theme='dark'] .grain {
  opacity: 0.06;
}

@keyframes drift-a {
  to {
    transform: translate3d(6vw, 5vh, 0) scale(1.08);
  }
}

@keyframes drift-b {
  to {
    transform: translate3d(-7vw, 8vh, 0) scale(1.12);
  }
}

@keyframes drift-c {
  to {
    transform: translate3d(4vw, -6vh, 0) scale(0.94);
  }
}

/* --------------------------------------------------------------------------
   Glass
   -------------------------------------------------------------------------- */

.glass {
  background: linear-gradient(180deg, var(--glass-sheen), transparent 42%), var(--glass-fill);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), inset 0 1px 0 var(--glass-highlight);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass {
    background: var(--glass-solid);
  }
}

/* --------------------------------------------------------------------------
   Header / navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 18px 0 0;
}

.nav-shell {
  width: min(var(--maxw), 100% - 2 * var(--gutter));
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 20px;
  border-radius: 22px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 0.72rem;
  line-height: 1;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav a {
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  line-height: 1.2;
  text-decoration: none;
  color: var(--muted);
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.nav a:hover {
  color: var(--text);
  background: var(--hover-bg);
}

.nav a[aria-current='page'] {
  color: var(--text);
  background: var(--active-bg);
  box-shadow: inset 0 0 0 1px var(--glass-border);
}

.theme-toggle {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  margin-left: 2px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--hover-bg);
}

.theme-icon {
  position: absolute;
  width: 17px;
  height: 17px;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 160ms ease, transform 160ms ease;
}

[data-theme-mode='system'] .theme-icon-auto,
[data-theme-mode='light'] .theme-icon-light,
[data-theme-mode='dark'] .theme-icon-dark {
  opacity: 1;
  transform: none;
}

/* --------------------------------------------------------------------------
   Home — mostly whitespace, intro copy lands in .home-slot
   -------------------------------------------------------------------------- */

.home {
  position: relative;
  min-height: calc(100svh - 190px);
  display: flex;
  flex-direction: column;
  padding-top: clamp(64px, 12vh, 150px);
  padding-bottom: 96px;
}

.home-title {
  margin: 0;
  font-weight: 400;
  position: relative;
  z-index: 1;
}

.home-name {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(4.5rem, 14vw, 11rem);
  line-height: 0.9;
  letter-spacing: -0.045em;
}

.home-role {
  display: block;
  margin-top: 24px;
  font-size: 0.92rem;
  line-height: 1;
  letter-spacing: 0.32em;
  color: var(--muted);
}

.home-slot {
  position: relative;
  z-index: 1;
  min-height: clamp(160px, 36vh, 360px);
}

.glass-orb {
  position: absolute;
  top: 4vh;
  right: -6vw;
  width: clamp(220px, 34vw, 480px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(
    circle at 32% 28%,
    rgba(255, 255, 255, 0.68),
    rgba(255, 255, 255, 0.1) 46%,
    rgba(255, 255, 255, 0.18) 72%,
    rgba(255, 255, 255, 0.04) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.8), inset 0 -40px 70px rgba(255, 255, 255, 0.14),
    0 40px 90px -40px rgba(16, 24, 40, 0.5);
  -webkit-backdrop-filter: blur(6px) saturate(140%);
  backdrop-filter: blur(6px) saturate(140%);
  pointer-events: none;
}

.glass-orb::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 28% 22%,
    rgba(255, 255, 255, 0.9) 0,
    rgba(255, 255, 255, 0.4) 7%,
    rgba(255, 255, 255, 0) 24%
  );
  filter: blur(2px);
  opacity: 0.9;
}

[data-theme='dark'] .glass-orb::before {
  opacity: 0.55;
}

[data-theme='dark'] .glass-orb {
  background: radial-gradient(
    circle at 32% 28%,
    rgba(255, 255, 255, 0.2),
    rgba(255, 255, 255, 0.03) 48%,
    rgba(255, 255, 255, 0.06) 74%,
    rgba(255, 255, 255, 0.01) 100%
  );
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.28), inset 0 -40px 70px rgba(255, 255, 255, 0.04),
    0 40px 90px -40px rgba(0, 0, 0, 0.85);
}

/* --------------------------------------------------------------------------
   Inner pages — title, then deliberately empty space
   -------------------------------------------------------------------------- */

.page {
  min-height: calc(100svh - 200px);
  padding-top: clamp(72px, 12vh, 150px);
  padding-bottom: 120px;
}

.page-head {
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}

.page-title {
  margin: 0;
  font-size: clamp(2.2rem, 4.6vw, 3.6rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-body {
  min-height: 46vh;
}

/* --------------------------------------------------------------------------
   Not found
   -------------------------------------------------------------------------- */

.not-found {
  min-height: calc(100svh - 220px);
  display: grid;
  place-items: center;
  padding-block: 80px;
}

.not-found-card {
  width: 100%;
  max-width: 440px;
  padding: clamp(40px, 8vw, 72px);
  border-radius: 28px;
  text-align: center;
}

.not-found-code {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.6rem, 9vw, 5.4rem);
  line-height: 1;
  letter-spacing: -0.04em;
}

.not-found-title {
  margin: 12px 0 28px;
  font-size: 1rem;
  font-weight: 400;
  color: var(--muted);
}

.text-link {
  display: inline-block;
  padding-bottom: 2px;
  font-size: 0.95rem;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color 160ms ease, color 160ms ease;
}

.text-link:hover {
  border-color: currentColor;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  position: relative;
  z-index: 1;
  padding: 28px 0 36px;
  font-size: 0.8rem;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-inner a {
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 160ms ease, border-color 160ms ease;
}

.footer-inner a:hover {
  color: var(--text);
  border-color: var(--line);
}

.footer-sep {
  width: 1px;
  height: 12px;
  background: var(--line);
}

/* --------------------------------------------------------------------------
   Skip link
   -------------------------------------------------------------------------- */

.skip-link {
  position: absolute;
  top: -64px;
  left: 16px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  text-decoration: none;
  transition: top 180ms ease;
}

.skip-link:focus {
  top: 12px;
}

/* --------------------------------------------------------------------------
   Page transitions (cross-document View Transitions, no hash routing)
   -------------------------------------------------------------------------- */

::view-transition-old(root) {
  animation: fade-out 160ms ease both;
}

::view-transition-new(root) {
  animation: fade-in 260ms ease both;
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .site-header {
    padding-top: 10px;
  }

  .nav-shell {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    border-radius: 24px;
  }

  .brand {
    order: 1;
    padding-left: 8px;
  }

  .theme-toggle {
    order: 2;
    margin-left: auto;
  }

  .nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
    gap: 0;
  }

  .nav a {
    padding: 8px 10px;
    font-size: 0.84rem;
  }

  .home {
    min-height: calc(100svh - 210px);
  }

  .glass-orb {
    top: auto;
    bottom: 8vh;
    right: -24vw;
    width: 62vw;
    opacity: 0.7;
  }
}

@media (max-width: 400px) {
  .brand-sub {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Motion preferences
   -------------------------------------------------------------------------- */

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

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
  }
}
