/* =========================================================================
   Wenhan's Home — ui-ux-pro-max design system
   Portfolio Grid · Motion-Driven · Spatial Glass
   Tokens: design-system/wenhan-home/MASTER.md
   ========================================================================= */

:root {
  --canvas: #f8fafc;
  --surface-1: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --hairline: rgba(15, 23, 42, 0.08);
  --hairline-strong: rgba(15, 23, 42, 0.12);

  --ink: #1e293b;
  --ink-muted: rgba(30, 41, 59, 0.72);
  --ink-subtle: rgba(30, 41, 59, 0.55);
  --ink-tertiary: rgba(30, 41, 59, 0.38);

  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-focus: #007aff;
  --accent-glow: rgba(0, 122, 255, 0.12);
  --success: #34c759;

  --bg: var(--canvas);
  --text: var(--ink);
  --text-dim: var(--ink-subtle);
  --text-faint: var(--ink-tertiary);
  --border: var(--hairline);
  --border-strong: var(--hairline-strong);
  --surface: var(--surface-1);
  --surface-strong: var(--surface-2);

  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-fast: 200ms;
  --motion: 300ms;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --pill: 980px;

  --material: saturate(180%) blur(24px);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
  --nav-h: 52px;
  --maxw: 980px;
  --gutter: clamp(20px, 4vw, 32px);

  /* Unified interactive controls — 44px touch targets on mobile */
  --ctrl-size: 44px;
  --ctrl-icon: 20px;
}

[data-theme="dark"] {
  --canvas: #3a3a3c;
  --surface-1: #48484a;
  --surface-2: #545456;
  --surface-3: #636366;
  --hairline: rgba(255, 255, 255, 0.12);
  --hairline-strong: rgba(255, 255, 255, 0.18);
  --ink: #f5f5f7;
  --ink-muted: rgba(245, 245, 247, 0.78);
  --ink-subtle: rgba(245, 245, 247, 0.58);
  --ink-tertiary: rgba(245, 245, 247, 0.38);
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-focus: #0a84ff;
  --accent-glow: rgba(10, 132, 255, 0.18);
  --success: #30d158;
}

[data-theme="light"] {
  --canvas: #f8fafc;
  --surface-1: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --hairline: rgba(15, 23, 42, 0.08);
  --hairline-strong: rgba(15, 23, 42, 0.12);
  --ink: #1e293b;
  --ink-muted: rgba(30, 41, 59, 0.72);
  --ink-subtle: rgba(30, 41, 59, 0.55);
  --ink-tertiary: rgba(30, 41, 59, 0.38);
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-focus: #0d9488;
  --accent-glow: rgba(13, 148, 136, 0.14);
  --success: #34c759;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + env(safe-area-inset-top, 0px) + 16px);
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.47059;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; }

.aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(165deg, #fff8f5 0%, #f0f9ff 45%, #f0fdf4 100%);
  pointer-events: none;
  opacity: 0.5;
}
[data-theme="dark"] .aurora {
  background: #3a3a3c;
  opacity: 0.5;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: left var(--motion) var(--ease-out);
}
.skip-link:focus {
  left: var(--gutter);
  outline: none;
  box-shadow: var(--ring);
}


/* ---------- Site header / Navbar ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top, 0px);
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--nav-h);
  padding: 0 var(--gutter);
}
.nav:not(.liquid-glass) {
  background: color-mix(in srgb, var(--canvas) 72%, transparent);
  border-bottom: 0.5px solid var(--hairline);
  backdrop-filter: var(--material);
  -webkit-backdrop-filter: var(--material);
}
.nav.liquid-glass {
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  border-bottom: 0.5px solid var(--hairline);
}

.nav__brand {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.022em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Top bar: brand + menu button only (links live in drawer) */
.nav__menu {
  flex: none;
  width: var(--ctrl-size);
  height: var(--ctrl-size);
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid;
  place-items: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav__menu:focus-visible { outline: none; box-shadow: var(--ring); }

.nav__menu-icon {
  width: 22px;
  height: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.nav__menu-bar {
  display: block;
  height: 2.25px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.28s var(--ease-out), opacity 0.2s;
  transform-origin: center;
}
.nav.open .nav__menu-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav.open .nav__menu-bar:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav.open .nav__menu-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Drawer — floating glass pills (no chrome sheet behind) */
.nav__drawer {
  position: fixed;
  z-index: 49;
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin: 0;
  padding: 8px;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px) scale(0.98);
  transition:
    opacity 0.28s var(--ease-out),
    transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: visible;
  max-height: calc(100dvh - var(--nav-h) - env(safe-area-inset-top, 0px) - 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  right: var(--gutter);
  top: calc(var(--nav-h) + env(safe-area-inset-top, 0px) + 8px);
  width: min(280px, calc(100vw - var(--gutter) * 2));
}
.site-header.is-nav-open .nav__drawer,
.site-header:has(.nav.open) .nav__drawer {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.nav__drawer a {
  display: flex;
  align-items: center;
  min-height: var(--ctrl-size);
  padding: 12px 18px;
  border-radius: var(--pill);
  text-decoration: none;
  color: var(--ink-subtle);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}
.nav__drawer a:hover { color: var(--ink); }
.nav__drawer a.active {
  color: var(--ink);
  font-weight: 600;
  border-color: color-mix(in srgb, var(--accent) 36%, var(--glass-border));
}

.nav__scrim {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: none;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease-out);
}
.site-header.is-nav-open .nav__scrim,
.site-header:has(.nav.open) .nav__scrim {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 860px) {
  .nav__drawer a { font-size: 17px; }
}

@media (min-width: 861px) {
  .nav__brand { flex: none; margin-right: auto; }
}


/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.section {
  padding: clamp(72px, 12vh, 120px) 0;
  position: relative;
}
.section + .section:not(.theme-panel) {
  border-top: 0.5px solid var(--hairline);
}

/* Themed section layouts */
.section--profile {
  padding: clamp(80px, 14vh, 140px) 0;
}
.section--profile .profile-row {
  align-items: center;
  min-height: min(52vh, 480px);
}

.section--cards .container {
  display: grid;
  gap: clamp(24px, 4vh, 36px);
}
.section--cards .grid {
  margin-top: 8px;
}

.section--spotlight {
  text-align: center;
  padding: clamp(96px, 18vh, 160px) 0;
}
.section--spotlight .container {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.section--spotlight .lead,
.section--spotlight .muted {
  margin-left: auto;
  margin-right: auto;
}
.section--spotlight .linklist {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.section--list .container {
  display: grid;
  gap: 20px;
}
.section--list .linklist {
  margin-top: 4px;
}

.eyebrow {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
  margin-bottom: 12px;
}
.eyebrow .dot { display: none; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.1;
  margin: 0 0 12px;
  letter-spacing: -0.028em;
}
.section h2 {
  font-size: clamp(32px, 5vw, 48px);
  letter-spacing: -0.03em;
}
.section .lead {
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.381;
  color: var(--ink-muted);
  max-width: 56ch;
  margin: 0 0 8px;
  letter-spacing: -0.022em;
}
.muted { color: var(--ink-subtle); }
.danger { color: var(--ink-subtle); font-size: 15px; }

/* ---------- Controls (icons + pills) ---------- */
.ctrl {
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: none;
  text-decoration: none;
  color: var(--ink-subtle);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex: none;
}
.ctrl:not(.glass-interactive) {
  transition: color var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
}
.ctrl:focus-visible { outline: none; box-shadow: var(--ring); }
.ctrl svg { display: block; }

.ctrl--icon {
  width: var(--ctrl-size);
  height: var(--ctrl-size);
  border-radius: 50%;
}
.ctrl--icon svg { width: var(--ctrl-icon); height: var(--ctrl-icon); }

.ctrl--squircle {
  width: var(--ctrl-size);
  height: var(--ctrl-size);
  border-radius: var(--r-md);
}

/* Toolbar hit area — iOS-style on glass nav */
.ctrl--toolbar {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--ink);
}
.ctrl--toolbar:hover { color: var(--ink); }
.ctrl--toolbar:active {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  transform: scale(0.96);
}

.ctrl--glass:hover { color: var(--ink); }

.btns { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--pill);
  min-height: 44px;
  font-size: 17px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn svg { width: 16px; height: 16px; position: relative; z-index: 2; }
.btn-primary {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--glass-border, rgba(255, 255, 255, 0.24)));
  box-shadow:
    var(--glass-rim),
    0 2px 16px color-mix(in srgb, var(--accent) 12%, transparent);
}
.btn-primary:hover { color: var(--accent-hover); }
.btn-ghost {
  color: var(--accent);
  font-weight: 400;
  border-color: color-mix(in srgb, var(--accent) 18%, var(--glass-border, rgba(255, 255, 255, 0.24)));
}
.btn-ghost:hover { color: var(--accent-hover); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .arrow { transition: transform .2s; position: relative; z-index: 2; }
.btn:hover .arrow { transform: translate(2px, -2px); }

@media (max-width: 480px) {
  .btns { flex-direction: column; align-items: stretch; }
  .btns .btn { width: 100%; justify-content: center; }
}

/* ---------- Cards ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  padding: 24px;
  border-radius: var(--r-lg);
  transition: transform var(--motion) var(--ease-out), box-shadow var(--motion) var(--ease-out);
  cursor: pointer;
}
.card:hover { transform: translateY(-2px); }
.card h3 { font-size: 21px; letter-spacing: -0.022em; margin-bottom: 8px; }
.card p { color: var(--ink-muted); font-size: 15px; margin: 0; line-height: 1.47; }

.linklist { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 8px; }
.linklist a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: var(--pill);
  text-decoration: none;
  color: var(--ink);
  font-size: 17px;
  font-weight: 500;
  border-color: color-mix(in srgb, var(--accent) 16%, var(--glass-border, rgba(255, 255, 255, 0.24)));
}
.linklist a .ll-arrow { margin-left: auto; color: var(--ink-tertiary); position: relative; z-index: 2; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: calc(100dvh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(48px, 10vh, 96px) 0;
}
.hero-inner {
  max-width: 640px;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  min-height: min(72vh, 640px);
  text-align: left;
}

.hero-name {
  font-family: var(--font-display);
  font-size: clamp(40px, 8vw, 56px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin: 0;
  color: var(--ink);
}
.hero-tag {
  margin: 10px 0 0;
  font-size: clamp(17px, 2.2vw, 20px);
  color: var(--ink-muted);
  letter-spacing: -0.018em;
}

/* World clock — secondary detail below quote */
.world-clock {
  align-self: stretch;
  margin-top: clamp(20px, 3vh, 28px);
  padding: 16px 20px;
  border-radius: var(--r-xl);
}
.world-clock--compact {
  margin-top: clamp(16px, 2.5vh, 24px);
  padding: 14px 18px;
}
.world-clock__greeting {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-muted);
}
.world-clock__grid {
  display: flex;
  align-items: stretch;
  gap: 16px;
}
.world-clock__divider {
  width: 1px;
  background: var(--hairline);
  flex: none;
}
.world-clock__zone {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.world-clock__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}
.world-clock__time {
  font-family: var(--font-display);
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}
.world-clock--compact .world-clock__time {
  font-size: clamp(22px, 4.5vw, 28px);
}
.world-clock__date {
  font-size: 13px;
  color: var(--ink-subtle);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 400px) {
  .world-clock:not(.world-clock--analog) .world-clock__grid { flex-direction: column; gap: 12px; }
  .world-clock:not(.world-clock--analog) .world-clock__divider { width: 100%; height: 1px; }
}

.hero-quote {
  margin: 0;
  padding: 0;
  border: none;
}
.hero-quote p {
  margin: 0;
  font-size: clamp(20px, 2.8vw, 26px);
  line-height: 1.55;
  letter-spacing: -0.022em;
  color: var(--ink);
  font-weight: 400;
  font-style: normal;
}

.welcome-quote {
  margin: 20px 0 0;
  padding: 0 0 0 16px;
  border: none;
  border-left: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
}
.welcome-quote p {
  margin: 0;
  font-size: clamp(16px, 2vw, 18px);
  line-height: 1.58;
  letter-spacing: -0.016em;
  color: var(--ink-muted);
}
.profile-info .welcome-quote + .btns {
  margin-top: 24px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: clamp(24px, 4vh, 32px);
}
.hero-actions .btn { margin: 0; }
.hero .socials {
  display: flex;
  gap: 10px;
  margin: 0;
}
.hero .socials a.glass-interactive:hover { color: var(--ink); }
.footer-socials a.glass-interactive:hover { color: var(--ink); }

@media (max-width: 480px) {
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero-actions .btn { width: 100%; justify-content: center; }
  .hero-actions .socials { justify-content: center; }
}

/* ---------- Profile ---------- */
.profile-row { display: flex; flex-wrap: wrap; align-items: center; gap: 32px; }
.avatar-ring {
  flex: none;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  padding: 0;
  background: var(--surface-2);
  overflow: hidden;
}
.avatar-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: var(--surface-1);
}
.profile-info { flex: 1; min-width: 260px; }

/* ---------- About / contact ---------- */
.info-card {
  padding: clamp(24px, 4vw, 32px);
  border-radius: var(--r-xl);
}
.kv {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px 16px;
  margin-top: 16px;
}
.kv dt {
  color: var(--ink-tertiary);
  font-size: 13px;
  font-weight: 600;
  padding-top: 2px;
}
.kv dd { margin: 0; font-size: 15px; color: var(--ink-muted); line-height: 1.47; }
.kv dd a { color: var(--accent); text-decoration: none; }
.kv dd a:hover { color: var(--accent-hover); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-subtle);
  margin-bottom: 8px;
}
.input, .textarea {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  border-radius: var(--r-md);
  outline: none;
  transition: box-shadow .2s;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-tertiary); }
.input:focus, .textarea:focus { box-shadow: var(--ring); }
.textarea { resize: vertical; min-height: 120px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 0.5px solid var(--hairline);
  padding: 56px 0 32px;
  margin-top: 24px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 32px;
}
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; gap: 28px; } }
.site-footer h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-tertiary);
  margin: 0 0 12px;
}
.site-footer p, .site-footer a { font-size: 15px; color: var(--ink-subtle); line-height: 1.47; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }
.footer-socials { display: flex; flex-wrap: wrap; gap: 10px; }
.footer-socials a:hover { color: var(--ink); }
.footer-bottom {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 0.5px solid var(--hairline);
  font-size: 13px;
  color: var(--ink-tertiary);
  text-align: center;
}
.footer-bottom a { color: var(--ink-subtle); text-decoration: none; }
.footer-bottom a:hover { color: var(--ink); }

/* Back to top — see glass.css (.to-top.ctrl--glass) */

/* ---------- Reveal ---------- */
@media (prefers-reduced-motion: no-preference) {
  .js .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .7s cubic-bezier(.32, .72, 0, 1), transform .7s cubic-bezier(.32, .72, 0, 1);
  }
  .js .reveal.in,
  .js .hero.is-visible .reveal {
    opacity: 1;
    transform: none;
  }

  /* Hero content reveals on load — not only on scroll */
  .js .hero .reveal {
    transition-delay: calc(var(--reveal-i, 0) * 80ms);
  }
}

/* ---------- 404 ---------- */
.center-screen {
  min-height: calc(100dvh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px var(--gutter);
}
.center-screen .big {
  font-size: clamp(72px, 18vw, 140px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--accent);
}
